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 (Generic 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_widget.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
#include "gx_scroll_wheel.h" |
30 |
|
|
|
31 |
|
|
/**************************************************************************/ |
32 |
|
|
/* */ |
33 |
|
|
/* FUNCTION RELEASE */ |
34 |
|
|
/* */ |
35 |
|
|
/* _gx_generic_scroll_wheel_down_wrap PORTABLE C */ |
36 |
|
|
/* 6.1.7 */ |
37 |
|
|
/* AUTHOR */ |
38 |
|
|
/* */ |
39 |
|
|
/* Ting Zhu, Microsoft Corporation */ |
40 |
|
|
/* */ |
41 |
|
|
/* DESCRIPTION */ |
42 |
|
|
/* */ |
43 |
|
|
/* This function scrolls down the generic scroll wheel. */ |
44 |
|
|
/* */ |
45 |
|
|
/* INPUT */ |
46 |
|
|
/* */ |
47 |
|
|
/* wheel Generic scroll wheel control */ |
48 |
|
|
/* block */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* None */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* _gx_widget_first_visible_client_child_get */ |
57 |
|
|
/* Get the first visible client */ |
58 |
|
|
/* _gx_widget_last_visible_client_child_get */ |
59 |
|
|
/* Get the last visible client */ |
60 |
|
|
/* _gx_widget_detach Detach a widget from its */ |
61 |
|
|
/* parent */ |
62 |
|
|
/* _gx_utility_rectangle_shift Shift a rectangle */ |
63 |
|
|
/* _gx_widget_resize Resize a widget */ |
64 |
|
|
/* _gx_widget_back_attach Attach a widget to its parent */ |
65 |
|
|
/* [gx_generic_scroll_wheel_callback] Callback to create row item */ |
66 |
|
|
/* */ |
67 |
|
|
/* CALLED BY */ |
68 |
|
|
/* */ |
69 |
|
|
/* _gx_generic_scroll_wheel_scroll Generic scroll wheel scroll */ |
70 |
|
|
/* function */ |
71 |
|
|
/* */ |
72 |
|
|
/* RELEASE HISTORY */ |
73 |
|
|
/* */ |
74 |
|
|
/* DATE NAME DESCRIPTION */ |
75 |
|
|
/* */ |
76 |
|
|
/* 06-02-2021 Ting Zhu Initial Version 6.1.7 */ |
77 |
|
|
/* */ |
78 |
|
|
/**************************************************************************/ |
79 |
|
85 |
VOID _gx_generic_scroll_wheel_down_wrap(GX_GENERIC_SCROLL_WHEEL *wheel) |
80 |
|
|
{ |
81 |
|
|
GX_WIDGET *test; |
82 |
|
|
GX_WIDGET *check; |
83 |
|
|
GX_RECTANGLE newpos; |
84 |
|
|
|
85 |
✓✓ |
134 |
while ((wheel -> gx_generic_scroll_wheel_top_index > 0) || |
86 |
✓✓ |
36 |
(wheel -> gx_widget_style & GX_STYLE_WRAP)) |
87 |
|
|
{ |
88 |
|
|
/* Scrolling down, see if my bottom widget can be moved to the top. */ |
89 |
|
110 |
test = _gx_widget_last_visible_client_child_get((GX_WIDGET *)wheel); |
90 |
|
|
|
91 |
✓✓✓✓
|
110 |
if (test && (test -> gx_widget_size.gx_rectangle_top > wheel -> gx_widget_size.gx_rectangle_bottom)) |
92 |
|
|
{ |
93 |
|
|
|
94 |
|
|
/* Bottom widget is below my client area, move it to the top. */ |
95 |
|
50 |
wheel -> gx_generic_scroll_wheel_top_index--; |
96 |
|
|
|
97 |
|
|
/* Wrap index. */ |
98 |
✓✓ |
50 |
if (wheel -> gx_generic_scroll_wheel_top_index < 0) |
99 |
|
|
{ |
100 |
|
9 |
wheel -> gx_generic_scroll_wheel_top_index = wheel -> gx_scroll_wheel_total_rows - 1; |
101 |
|
|
} |
102 |
|
|
|
103 |
|
50 |
check = _gx_widget_first_visible_client_child_get((GX_WIDGET *)wheel); |
104 |
|
|
|
105 |
✓✓ |
50 |
if (check) |
106 |
|
|
{ |
107 |
|
49 |
_gx_widget_detach(test); |
108 |
|
49 |
newpos = test -> gx_widget_size; |
109 |
|
49 |
_gx_utility_rectangle_shift(&newpos, 0, (GX_VALUE)(-(newpos.gx_rectangle_bottom - check -> gx_widget_size.gx_rectangle_top + 1))); |
110 |
|
49 |
_gx_widget_resize(test, &newpos); |
111 |
|
|
|
112 |
|
49 |
wheel -> gx_generic_scroll_wheel_callback(wheel, test, wheel -> gx_generic_scroll_wheel_top_index); |
113 |
|
49 |
_gx_widget_back_attach((GX_WIDGET *)wheel, test); |
114 |
|
|
} |
115 |
|
|
else |
116 |
|
|
{ |
117 |
|
1 |
break; |
118 |
|
|
} |
119 |
|
|
} |
120 |
|
|
else |
121 |
|
|
{ |
122 |
|
|
break; |
123 |
|
|
} |
124 |
|
|
} |
125 |
|
85 |
} |
126 |
|
|
|