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 |
|
|
/** Scroll Wheel Management (Scroll Wheel) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_scroll_wheel.h" |
28 |
|
|
#include "gx_system.h" |
29 |
|
|
|
30 |
|
|
/**************************************************************************/ |
31 |
|
|
/* */ |
32 |
|
|
/* FUNCTION RELEASE */ |
33 |
|
|
/* */ |
34 |
|
|
/* _gx_scroll_wheel_selected_set PORTABLE C */ |
35 |
|
|
/* 6.1.7 */ |
36 |
|
|
/* AUTHOR */ |
37 |
|
|
/* */ |
38 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
39 |
|
|
/* */ |
40 |
|
|
/* DESCRIPTION */ |
41 |
|
|
/* */ |
42 |
|
|
/* This function sets the current selected row index for scroll wheel */ |
43 |
|
|
/* widget. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* wheel Scroll wheel control block */ |
48 |
|
|
/* row Selected row to be set */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* status Completion status */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* None */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLED BY */ |
59 |
|
|
/* */ |
60 |
|
|
/* Application Code */ |
61 |
|
|
/* GUIX Internal Code */ |
62 |
|
|
/* */ |
63 |
|
|
/* RELEASE HISTORY */ |
64 |
|
|
/* */ |
65 |
|
|
/* DATE NAME DESCRIPTION */ |
66 |
|
|
/* */ |
67 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
68 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
69 |
|
|
/* resulting in version 6.1 */ |
70 |
|
|
/* 06-02-2021 Ting Zhu Modified comment(s), */ |
71 |
|
|
/* improved logic, */ |
72 |
|
|
/* resulting in version 6.1.7 */ |
73 |
|
|
/* */ |
74 |
|
|
/**************************************************************************/ |
75 |
|
502 |
UINT _gx_scroll_wheel_selected_set(GX_SCROLL_WHEEL *wheel, INT row) |
76 |
|
|
{ |
77 |
|
|
INT dist; |
78 |
|
|
|
79 |
✓✓✓✓
|
502 |
if ((row < 0) || (wheel -> gx_scroll_wheel_total_rows == 0)) |
80 |
|
|
{ |
81 |
|
18 |
row = 0; |
82 |
|
|
} |
83 |
✓✓ |
484 |
else if (row > wheel -> gx_scroll_wheel_total_rows - 1) |
84 |
|
|
{ |
85 |
|
5 |
row = wheel -> gx_scroll_wheel_total_rows - 1; |
86 |
|
|
} |
87 |
|
|
|
88 |
✓✓ |
502 |
if (wheel -> gx_scroll_wheel_selected_row == row) |
89 |
|
|
{ |
90 |
|
179 |
return GX_SUCCESS; |
91 |
|
|
} |
92 |
|
|
|
93 |
✓✓ |
323 |
if (wheel -> gx_widget_status & GX_STATUS_VISIBLE) |
94 |
|
|
{ |
95 |
✓✓ |
27 |
if (wheel -> gx_scroll_wheel_wrap_style_check(wheel)) |
96 |
|
|
{ |
97 |
|
9 |
if (GX_ABS(wheel -> gx_scroll_wheel_selected_row - row) < |
98 |
✓✓ |
9 |
GX_ABS(wheel -> gx_scroll_wheel_selected_row + wheel -> gx_scroll_wheel_total_rows - row)) |
99 |
|
|
{ |
100 |
|
6 |
dist = wheel -> gx_scroll_wheel_selected_row - row; |
101 |
|
|
} |
102 |
|
|
else |
103 |
|
|
{ |
104 |
|
3 |
dist = wheel -> gx_scroll_wheel_selected_row + wheel -> gx_scroll_wheel_total_rows - row; |
105 |
|
|
} |
106 |
|
|
} |
107 |
|
|
else |
108 |
|
|
{ |
109 |
|
18 |
dist = wheel -> gx_scroll_wheel_selected_row - row; |
110 |
|
|
} |
111 |
|
|
|
112 |
|
27 |
wheel -> gx_scroll_wheel_animation_steps = 10; |
113 |
|
27 |
wheel -> gx_scroll_wheel_animation_speed = (GX_VALUE)(dist * wheel -> gx_scroll_wheel_row_height) / 10; |
114 |
|
27 |
wheel -> gx_scroll_wheel_shift_error = (GX_BYTE)(dist * wheel -> gx_scroll_wheel_row_height) % 10; |
115 |
|
27 |
_gx_system_timer_start((GX_WIDGET *)wheel, GX_ANIMATION_TIMER, 2, 2); |
116 |
|
|
} |
117 |
|
|
else |
118 |
|
|
{ |
119 |
|
296 |
wheel -> gx_scroll_wheel_selected_row = row; |
120 |
|
|
} |
121 |
|
|
|
122 |
|
323 |
return GX_SUCCESS; |
123 |
|
|
} |
124 |
|
|
|