1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026 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 |
|
|
// Some portions generated by Copilot (Claude Sonnet 4.6). |
12 |
|
|
|
13 |
|
|
|
14 |
|
|
/**************************************************************************/ |
15 |
|
|
/**************************************************************************/ |
16 |
|
|
/** */ |
17 |
|
|
/** GUIX Component */ |
18 |
|
|
/** */ |
19 |
|
|
/** Progress Bar Management (Radial Progress Bar) */ |
20 |
|
|
/** */ |
21 |
|
|
/**************************************************************************/ |
22 |
|
|
|
23 |
|
|
#define GX_SOURCE_CODE |
24 |
|
|
|
25 |
|
|
/* Include necessary system files. */ |
26 |
|
|
|
27 |
|
|
#include "gx_api.h" |
28 |
|
|
#include "gx_context.h" |
29 |
|
|
#include "gx_widget.h" |
30 |
|
|
#include "gx_canvas.h" |
31 |
|
|
#include "gx_utility.h" |
32 |
|
|
#include "gx_radial_progress_bar.h" |
33 |
|
|
#include "gx_system.h" |
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_radial_progress_bar_background_draw PORTABLE C */ |
40 |
|
|
/* 6.1.8 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This service draws a radial progress bar background. */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* progress_bar Radial Progress Bar control */ |
52 |
|
|
/* block */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* None */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* _gx_widget_background_draw */ |
61 |
|
|
/* _gx_context_brush_get */ |
62 |
|
|
/* _gx_context_line_color_set */ |
63 |
|
|
/* _gx_context_brush_width_set */ |
64 |
|
|
/* _gx_canvas_circle_draw */ |
65 |
|
|
/* _gx_canvas_arc_draw */ |
66 |
|
|
/* */ |
67 |
|
|
/* CALLED BY */ |
68 |
|
|
/* */ |
69 |
|
|
/* Application Code */ |
70 |
|
|
/* GUIX Internal Code */ |
71 |
|
|
/* */ |
72 |
|
|
/**************************************************************************/ |
73 |
|
6180 |
VOID _gx_radial_progress_bar_background_draw(GX_RADIAL_PROGRESS_BAR *progress_bar) |
74 |
|
|
{ |
75 |
|
|
GX_RADIAL_PROGRESS_BAR_INFO *info; |
76 |
|
|
GX_VALUE xcenter; |
77 |
|
|
GX_VALUE ycenter; |
78 |
|
|
GX_BRUSH *brush; |
79 |
|
|
GX_RECTANGLE *size; |
80 |
|
|
|
81 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
82 |
|
|
GX_UBYTE brush_alpha; |
83 |
|
|
GX_RECTANGLE dirty; |
84 |
|
|
GX_PIXELMAP map; |
85 |
|
|
VOID *canvas_memory; |
86 |
|
|
INT canvas_size; |
87 |
|
|
GX_DISPLAY *display; |
88 |
|
|
GX_CANVAS *canvas; |
89 |
|
6180 |
GX_VALUE old_xpos = 0; |
90 |
|
6180 |
GX_VALUE old_ypos = 0; |
91 |
|
|
UINT status; |
92 |
|
|
#endif |
93 |
|
|
|
94 |
|
6180 |
_gx_context_brush_get(&brush); |
95 |
|
|
|
96 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
97 |
|
6180 |
brush_alpha = brush -> gx_brush_alpha; |
98 |
✓✓ |
6180 |
if (brush_alpha == 0) |
99 |
|
|
{ |
100 |
|
1 |
return; |
101 |
|
|
} |
102 |
|
|
|
103 |
✓✓ |
6179 |
if (brush_alpha != GX_ALPHA_VALUE_OPAQUE) |
104 |
|
|
{ |
105 |
|
535 |
size = &progress_bar -> gx_widget_size; |
106 |
|
535 |
map.gx_pixelmap_width = (GX_VALUE)(size -> gx_rectangle_right - size -> gx_rectangle_left + 1); |
107 |
|
535 |
map.gx_pixelmap_height = (GX_VALUE)(size -> gx_rectangle_bottom - size -> gx_rectangle_top + 1); |
108 |
|
|
|
109 |
|
535 |
display = _gx_system_current_draw_context -> gx_draw_context_display; |
110 |
|
|
|
111 |
✓✓✓✓
|
535 |
if ((progress_bar -> gx_radial_progress_bar_canvas.gx_canvas_id != GX_CANVAS_ID) && |
112 |
|
|
_gx_system_memory_allocator) |
113 |
|
|
{ |
114 |
|
|
|
115 |
|
|
/* Pixelmap width and height is GX_VALUE type, overflow cannot occur. */ |
116 |
|
266 |
canvas_size = display -> gx_display_driver_row_pitch_get((USHORT)map.gx_pixelmap_width); |
117 |
|
266 |
canvas_size *= map.gx_pixelmap_height; |
118 |
|
|
|
119 |
|
266 |
canvas_memory = _gx_system_memory_allocator((ULONG)canvas_size); |
120 |
|
|
|
121 |
✓✓ |
266 |
if (canvas_memory) |
122 |
|
|
{ |
123 |
|
265 |
_gx_canvas_create(&progress_bar -> gx_radial_progress_bar_canvas, "progress_bar_canvas", |
124 |
|
265 |
display, GX_CANVAS_SIMPLE, (UINT)map.gx_pixelmap_width, |
125 |
|
265 |
(UINT)map.gx_pixelmap_height, (GX_COLOR *)canvas_memory, (ULONG)canvas_size); |
126 |
|
|
} |
127 |
|
|
} |
128 |
|
|
|
129 |
✓✓ |
535 |
if (progress_bar -> gx_radial_progress_bar_canvas.gx_canvas_id == GX_CANVAS_ID) |
130 |
|
|
{ |
131 |
|
|
/* Remove resize notify temporary. */ |
132 |
|
533 |
progress_bar -> gx_widget_status &= ~GX_STATUS_RESIZE_NOTIFY; |
133 |
|
|
|
134 |
|
533 |
old_xpos = size -> gx_rectangle_left; |
135 |
|
533 |
old_ypos = size -> gx_rectangle_top; |
136 |
|
|
|
137 |
✓✓✓✓
|
533 |
if (old_xpos || old_ypos) |
138 |
|
|
{ |
139 |
|
531 |
_gx_widget_shift((GX_WIDGET *)progress_bar, (GX_VALUE)(-old_xpos), (GX_VALUE)(-old_ypos), GX_FALSE); |
140 |
|
|
} |
141 |
|
|
|
142 |
|
533 |
canvas = _gx_system_current_draw_context -> gx_draw_context_canvas; |
143 |
|
533 |
dirty = canvas -> gx_canvas_dirty_area; |
144 |
|
533 |
_gx_utility_rectangle_shift(&dirty, (GX_VALUE)(-old_xpos), (GX_VALUE)(-old_ypos)); |
145 |
|
533 |
_gx_utility_rectangle_overlap_detect(&dirty, &progress_bar -> gx_widget_size, &dirty); |
146 |
|
|
|
147 |
|
533 |
status = _gx_canvas_drawing_initiate(&progress_bar -> gx_radial_progress_bar_canvas, GX_NULL, &dirty); |
148 |
|
|
|
149 |
✗✓✗✗
|
533 |
if (status == GX_SUCCESS || status == GX_NO_VIEWS) |
150 |
|
|
{ |
151 |
✓✓ |
533 |
if (progress_bar -> gx_widget_status & GX_STATUS_TRANSPARENT) |
152 |
|
|
{ |
153 |
|
522 |
xcenter = canvas -> gx_canvas_display_offset_x; |
154 |
|
522 |
ycenter = canvas -> gx_canvas_display_offset_y; |
155 |
|
522 |
_gx_canvas_offset_set(canvas, (GX_VALUE)(-old_xpos), (GX_VALUE)(-old_ypos)); |
156 |
|
522 |
display -> gx_display_driver_canvas_copy(canvas, &progress_bar -> gx_radial_progress_bar_canvas); |
157 |
|
522 |
_gx_canvas_offset_set(canvas, xcenter, ycenter); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
533 |
_gx_context_brush_get(&brush); |
161 |
|
|
} |
162 |
|
|
} |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
#endif |
166 |
|
|
|
167 |
|
|
/* Draw progress bar background. */ |
168 |
|
6179 |
_gx_widget_background_draw((GX_WIDGET *)progress_bar); |
169 |
|
|
|
170 |
|
|
/* Draw circular track. */ |
171 |
|
6179 |
info = &progress_bar -> gx_radial_progress_bar_info; |
172 |
|
|
|
173 |
|
6179 |
size = &progress_bar -> gx_widget_size; |
174 |
|
|
|
175 |
|
6179 |
xcenter = (GX_VALUE)(size -> gx_rectangle_right + size -> gx_rectangle_left); |
176 |
|
6179 |
xcenter >>= 1; |
177 |
|
|
|
178 |
|
6179 |
ycenter = (GX_VALUE)(size -> gx_rectangle_bottom + size -> gx_rectangle_top); |
179 |
|
6179 |
ycenter >>= 1; |
180 |
|
|
|
181 |
|
6179 |
brush -> gx_brush_style &= (ULONG)(~GX_BRUSH_SOLID_FILL); |
182 |
|
|
|
183 |
✓✓ |
6179 |
if (progress_bar -> gx_widget_style & GX_STYLE_RADIAL_PROGRESS_ALIAS) |
184 |
|
|
{ |
185 |
|
5701 |
brush -> gx_brush_style |= GX_BRUSH_ALIAS; |
186 |
|
|
} |
187 |
|
|
|
188 |
✓✓ |
6179 |
if (progress_bar -> gx_widget_style & GX_STYLE_RADIAL_PROGRESS_ROUND) |
189 |
|
|
{ |
190 |
|
5702 |
brush -> gx_brush_style |= GX_BRUSH_ROUND; |
191 |
|
|
} |
192 |
|
|
|
193 |
✓✓ |
6179 |
if (!(progress_bar -> gx_widget_style & GX_STYLE_RADIAL_PROGRESS_NO_BACKTRACK)) |
194 |
|
|
{ |
195 |
|
4068 |
_gx_context_line_color_set(info -> gx_radial_progress_bar_info_normal_brush_color); |
196 |
|
4068 |
_gx_context_brush_width_set((UINT)(info -> gx_radial_progress_bar_info_normal_brush_width)); |
197 |
|
|
|
198 |
|
4068 |
_gx_canvas_circle_draw(xcenter, ycenter, (UINT)(info -> gx_radial_progress_bar_info_radius)); |
199 |
|
|
} |
200 |
|
|
|
201 |
✓✓ |
6179 |
if (info -> gx_radial_progress_bar_info_current_val != 0) |
202 |
|
|
{ |
203 |
|
6147 |
_gx_context_line_color_set(info -> gx_radial_progress_bar_info_selected_brush_color); |
204 |
|
6147 |
brush -> gx_brush_width = info -> gx_radial_progress_bar_info_selected_brush_width; |
205 |
|
|
|
206 |
✓✓ |
6147 |
if (info -> gx_radial_progress_bar_info_current_val > 0) |
207 |
|
|
{ |
208 |
|
782 |
_gx_canvas_arc_draw(xcenter, ycenter, |
209 |
|
782 |
(UINT)(info -> gx_radial_progress_bar_info_radius), |
210 |
|
782 |
info -> gx_radial_progress_bar_info_anchor_val, |
211 |
|
782 |
info -> gx_radial_progress_bar_info_current_val + info -> gx_radial_progress_bar_info_anchor_val); |
212 |
|
|
} |
213 |
|
|
else |
214 |
|
|
{ |
215 |
|
5365 |
_gx_canvas_arc_draw(xcenter, ycenter, |
216 |
|
5365 |
(UINT)(info -> gx_radial_progress_bar_info_radius), |
217 |
|
5365 |
info -> gx_radial_progress_bar_info_current_val + info -> gx_radial_progress_bar_info_anchor_val, |
218 |
|
5365 |
info -> gx_radial_progress_bar_info_anchor_val); |
219 |
|
|
} |
220 |
|
|
} |
221 |
|
|
|
222 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
223 |
✓✓ |
6179 |
if ((brush_alpha != GX_ALPHA_VALUE_OPAQUE) && |
224 |
✓✓ |
535 |
(progress_bar -> gx_radial_progress_bar_canvas.gx_canvas_id == GX_CANVAS_ID)) |
225 |
|
|
{ |
226 |
✓✓✓✓
|
533 |
if (old_xpos || old_ypos) |
227 |
|
|
{ |
228 |
|
531 |
_gx_widget_shift((GX_WIDGET *)progress_bar, old_xpos, old_ypos, GX_FALSE); |
229 |
|
|
} |
230 |
|
|
|
231 |
✗✓✗✗
|
533 |
if (status == GX_SUCCESS || status == GX_NO_VIEWS) |
232 |
|
|
{ |
233 |
|
533 |
_gx_canvas_pixelmap_get(&map); |
234 |
|
533 |
_gx_canvas_drawing_complete(&progress_bar -> gx_radial_progress_bar_canvas, GX_FALSE); |
235 |
|
533 |
_gx_canvas_pixelmap_blend(old_xpos, old_ypos, &map, brush_alpha); |
236 |
|
|
} |
237 |
|
|
|
238 |
|
|
/* Added resize notification back. */ |
239 |
|
533 |
progress_bar -> gx_widget_status |= GX_STATUS_RESIZE_NOTIFY; |
240 |
|
|
} |
241 |
|
|
#endif |
242 |
|
|
} |
243 |
|
|
|