1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** GUIX Component */ 16 /** */ 17 /** Progress Bar Management (Radial Progress Bar) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_radial_progress_bar.h" 28 #include "gx_widget.h" 29 #include "gx_utility.h" 30 #include "gx_system.h" 31 #include "gx_canvas.h" 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_radial_prpgress_bar_resize PORTABLE C */ 38 /* 6.1.7 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function updates the center and radius of radial progress bar */ 46 /* according to size. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* radial_progress Radial progess bar control */ 51 /* block */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* status Completion status */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _gx_system_dirty_mark Mark the widget dirty */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Application Code */ 64 /* */ 65 /* RELEASE HISTORY */ 66 /* */ 67 /* DATE NAME DESCRIPTION */ 68 /* */ 69 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 70 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 71 /* resulting in version 6.1 */ 72 /* 06-02-2021 Ting Zhu Modified comment(s), */ 73 /* fixed compile error when */ 74 /* GX_BRUSH_ALPHA_SUPPORT is */ 75 /* not defined, */ 76 /* resulting in version 6.1.7 */ 77 /* */ 78 /**************************************************************************/ 79 _gx_radial_progress_bar_resize(GX_RADIAL_PROGRESS_BAR * radial_progress)80UINT _gx_radial_progress_bar_resize(GX_RADIAL_PROGRESS_BAR *radial_progress) 81 { 82 GX_RADIAL_PROGRESS_BAR_INFO *info; 83 GX_VALUE new_xcenter; 84 GX_VALUE new_ycenter; 85 GX_VALUE new_radius; 86 INT width; 87 #if defined(GX_BRUSH_ALPHA_SUPPORT) 88 INT height; 89 #endif 90 GX_RECTANGLE *size; 91 92 info = &radial_progress -> gx_radial_progress_bar_info; 93 width = info -> gx_radial_progress_bar_info_selected_brush_width; 94 95 if (width < info -> gx_radial_progress_bar_info_normal_brush_width) 96 { 97 width = info -> gx_radial_progress_bar_info_normal_brush_width; 98 } 99 100 width = (GX_VALUE)((width + 1) >> 1); 101 102 size = &radial_progress -> gx_widget_size; 103 104 new_xcenter = (GX_VALUE)((size -> gx_rectangle_left + size -> gx_rectangle_right) >> 1); 105 new_ycenter = (GX_VALUE)((size -> gx_rectangle_top + size -> gx_rectangle_bottom) >> 1); 106 new_radius = (GX_VALUE)(new_xcenter - size -> gx_rectangle_left); 107 new_radius = (GX_VALUE)(new_radius - width); 108 109 info -> gx_radial_progress_bar_info_xcenter = new_xcenter; 110 info -> gx_radial_progress_bar_info_ycenter = new_ycenter; 111 112 if (new_radius > 0) 113 { 114 info -> gx_radial_progress_bar_info_radius = new_radius; 115 } 116 117 #if defined(GX_BRUSH_ALPHA_SUPPORT) 118 width = size -> gx_rectangle_right - size -> gx_rectangle_left + 1; 119 height = size -> gx_rectangle_bottom - size -> gx_rectangle_top + 1; 120 121 if (radial_progress -> gx_radial_progress_bar_canvas.gx_canvas_memory && 122 (width != radial_progress -> gx_radial_progress_bar_canvas.gx_canvas_x_resolution || 123 height != radial_progress -> gx_radial_progress_bar_canvas.gx_canvas_y_resolution) && 124 _gx_system_memory_free) 125 { 126 _gx_system_memory_free((VOID *)radial_progress -> gx_radial_progress_bar_canvas.gx_canvas_memory); 127 _gx_canvas_delete(&radial_progress -> gx_radial_progress_bar_canvas); 128 } 129 #endif 130 131 if (radial_progress -> gx_widget_status & GX_STATUS_VISIBLE) 132 { 133 _gx_system_dirty_mark((GX_WIDGET *)radial_progress); 134 } 135 136 return GX_SUCCESS; 137 } 138 139