GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_block_move.c Lines: 23 23 100.0 %
Date: 2026-03-06 19:21:09 Branches: 10 10 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Widget Management (Widget)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_widget.h"
30
#include "gx_canvas.h"
31
#include "gx_utility.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_widget_block_move                               PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This service move a rectangular block of pixels.                    */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    widget                                Pointer to widget             */
50
/*    block                                 Rectangle to move             */
51
/*    x_shift                               Number of pixels to shift on  */
52
/*                                            the x-axis                  */
53
/*    y_shift                               Number of pixels to shift on  */
54
/*                                            the y-axis                  */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_system_dirty_partial_add          Add area to the dirty list    */
63
/*    _gx_widget_canvas_get                 Find canvas associated with   */
64
/*                                            the specified widget        */
65
/*    _gx_canvas_drawing_initiate           Start canvas draw             */
66
/*    _gx_canvas_block_move                 Canvas-level block move call  */
67
/*    _gx_canvas_drawing_complete           Finish canvas draw            */
68
/*                                                                        */
69
/*  CALLED BY                                                             */
70
/*                                                                        */
71
/*    Application Code                                                    */
72
/*    GUIX Internal Code                                                  */
73
/*                                                                        */
74
/**************************************************************************/
75
3813
UINT _gx_widget_block_move(GX_WIDGET *widget, GX_RECTANGLE *block, INT x_shift, INT y_shift)
76
{
77
GX_CANVAS   *canvas;
78
UINT         status;
79
GX_RECTANGLE dirty;
80
GX_VALUE     width;
81
GX_VALUE     height;
82
83
3813
    if (widget -> gx_widget_status & GX_STATUS_TRANSPARENT)
84
    {
85
        /* cannot do block move if transparent widget */
86
323
        _gx_system_dirty_partial_add(widget, block);
87
323
        return GX_SUCCESS;
88
    }
89
90
3490
    _gx_widget_canvas_get(widget, &canvas);
91
92
3490
    if (!canvas)
93
    {
94
1
        return GX_INVALID_CANVAS;
95
    }
96
97
3489
    GX_ENTER_CRITICAL
98
99
3489
    _gx_widget_width_get(widget, &width);
100
3489
    _gx_widget_height_get(widget, &height);
101
102

3489
    if ((GX_ABS(x_shift) >= width) || (GX_ABS(y_shift) >= height))
103
    {
104
        /* Shift is too large, just invalidate the widget. */
105
752
        _gx_system_dirty_partial_add(widget, block);
106
    }
107
    else
108
    {
109
2737
        _gx_canvas_drawing_initiate(canvas, widget, block);
110
2737
        status = _gx_canvas_block_move(block, (GX_VALUE)x_shift, (GX_VALUE)y_shift, &dirty);
111
112
2737
        if (status == GX_SUCCESS)
113
        {
114
            /* re-draw the portion that could not be moved */
115
2669
            _gx_canvas_drawing_initiate(canvas, widget, &dirty);
116
2669
            widget->gx_widget_draw_function(widget);
117
2669
            _gx_canvas_drawing_complete(canvas, GX_FALSE);
118
2669
            _gx_canvas_drawing_complete(canvas, GX_TRUE);
119
        }
120
        else
121
        {
122
            /* block move was not successful, just invalidate the widget client */
123
68
            _gx_system_dirty_partial_add(widget, block);
124
68
            _gx_canvas_drawing_complete(canvas, GX_FALSE);
125
        }
126
    }
127
128
3489
    GX_EXIT_CRITICAL
129
3489
    return(GX_SUCCESS);
130
}
131