1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   Slider Management (Slider)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_system.h"
28 #include "gx_display.h"
29 #include "gx_context.h"
30 #include "gx_widget.h"
31 #include "gx_utility.h"
32 #include "gx_slider.h"
33 
34 
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _gx_slider_value_set                                PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Kenneth Maxwell, Microsoft Corporation                              */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This service sets the slider value.                                 */
49 /*                                                                        */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    slider                                Slider widget control block   */
54 /*    info                                  Pointer to slider info        */
55 /*    new_value                             New slider value              */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    status                                Completion status             */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*    _gx_slider_needle_position_get        Get the slider needle         */
64 /*                                            position                    */
65 /*    _gx_utility_rectangle_combine         Combine the first and second  */
66 /*                                            rectangle into the first    */
67 /*                                            rectangle                   */
68 /*    _gx_system_dirty_partial_add          Mark the partial area of this */
69 /*                                            widget as dirty             */
70 /*    _gx_widget_event_generate             Generate an event and send it */
71 /*                                            to the parent widget        */
72 /*                                                                        */
73 /*  CALLED BY                                                             */
74 /*                                                                        */
75 /*    Application Code                                                    */
76 /*    GUIX Internal Code                                                  */
77 /*                                                                        */
78 /*  RELEASE HISTORY                                                       */
79 /*                                                                        */
80 /*    DATE              NAME                      DESCRIPTION             */
81 /*                                                                        */
82 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
83 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
84 /*                                            resulting in version 6.1    */
85 /*                                                                        */
86 /**************************************************************************/
_gx_slider_value_set(GX_SLIDER * slider,GX_SLIDER_INFO * info,INT new_value)87 UINT _gx_slider_value_set(GX_SLIDER *slider, GX_SLIDER_INFO *info, INT new_value)
88 {
89 GX_RECTANGLE oldpos;
90 GX_RECTANGLE newpos;
91 
92     if (new_value != info -> gx_slider_info_current_val)
93     {
94         /* get the old need position */
95         _gx_slider_needle_position_get(slider, info, &oldpos);
96 
97         /* assign slider value */
98         info -> gx_slider_info_current_val = new_value;
99 
100         /* get the new needle position */
101 
102         _gx_slider_needle_position_get(slider, info, &newpos);
103 
104         /* combine old and new needle positions */
105         _gx_utility_rectangle_combine(&newpos, &oldpos);
106 
107         if (slider -> gx_widget_type == GX_TYPE_PIXELMAP_SLIDER)
108         {
109             newpos.gx_rectangle_left = slider -> gx_widget_size.gx_rectangle_left;
110             newpos.gx_rectangle_right = slider -> gx_widget_size.gx_rectangle_right;
111         }
112 
113         /* mark as dirty so that I get redrawn */
114         _gx_system_dirty_partial_add((GX_WIDGET *)slider, &newpos);
115 
116         /* notify my parent of my new value */
117         _gx_widget_event_generate((GX_WIDGET *)slider, GX_EVENT_SLIDER_VALUE, new_value);
118     }
119     return(GX_SUCCESS);
120 }
121 
122