Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
ButtonComponent.c
Go to the documentation of this file.
1// More complex button handling 6 states:
2// Default, hovered, focused, hovered+focused, clicked, disabled.
3// Used for more complex buttons types requiring hovering over a button
4
6{
7 [Attribute("1 1 1 0.05", UIWidgets.ColorPicker, "")]
9
10 [Attribute("1 1 1 0.25", UIWidgets.ColorPicker, "")]
12
13 [Attribute("1 1 1 1", UIWidgets.ColorPicker, "")]
15
16 [Attribute("0 0 0 1", UIWidgets.ColorPicker, "")]
18
19 [Attribute(SCR_SoundEvent.SOUND_FE_BUTTON_HOVER, UIWidgets.EditBox, "")]
20 protected string m_sSoundHovered;
21
22 protected bool m_bIsHovered = false;
23
24 //------------------------------------------------------------------------------------------------
25 override void HandlerDeattached(Widget w)
26 {
27 super.HandlerDeattached(w);
32 }
33
34 //------------------------------------------------------------------------------------------------
44
45 //------------------------------------------------------------------------------------------------
46 override bool OnFocus(Widget w, int x, int y)
47 {
48 m_bIsFocused = true;
50
51 Color buttonColor;
52 Color childColor;
53 if (m_bIsHovered)
54 {
55 buttonColor = m_ColorButtonHoveredFocused;
56 childColor = m_ColorChildHoveredFocused;
57 }
58 else
59 {
60 buttonColor = m_ColorButtonFocused;
61 childColor = m_ColorChildFocused;
62 }
63
64 AnimateWidget.Color(w, buttonColor, m_fAnimationLength);
67
68 return false;
69 }
70
71 //------------------------------------------------------------------------------------------------
72 override bool OnFocusLost(Widget w, int x, int y)
73 {
74 m_bIsFocused = false;
75
76 Color buttonColor;
77 Color childColor;
78 if (m_bIsHovered)
79 {
80 buttonColor = m_ColorButtonHovered;
81 childColor = m_ColorChildHovered;
82 }
83 else
84 {
85 buttonColor = m_ColorButtonDefault;
86 childColor = m_ColorChildDefault;
87 }
88
89 AnimateWidget.Color(w, buttonColor, m_fAnimationLength);
92
93 return false;
94 }
95
96 //------------------------------------------------------------------------------------------------
97 override bool OnMouseEnter(Widget w, int x, int y)
98 {
99 m_bIsHovered = true;
101
102 Color buttonColor;
103 Color childColor;
104 if (m_bIsFocused)
105 {
106 buttonColor = m_ColorButtonHoveredFocused;
107 childColor = m_ColorChildHoveredFocused;
108 }
109 else
110 {
111 buttonColor = m_ColorButtonHovered;
112 childColor = m_ColorChildHovered;
113 }
114
115 AnimateWidget.Color(w, buttonColor, m_fAnimationLength);
118
119 return false;
120 }
121
122 //------------------------------------------------------------------------------------------------
123 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
124 {
125 m_bIsHovered = false;
126
127 Color buttonColor;
128 Color childColor;
129 if (m_bIsFocused)
130 {
131 buttonColor = m_ColorButtonFocused;
132 childColor = m_ColorChildFocused;
133 }
134 else
135 {
136 buttonColor = m_ColorButtonDefault;
137 childColor = m_ColorChildDefault;
138 }
139
140 AnimateWidget.Color(w, buttonColor, m_fAnimationLength);
143
144 return false;
145 }
146};
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
override void HandlerDeattached(Widget w)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnFocus(Widget w, int x, int y)
ref Color m_ColorChildHovered
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
ref Color m_ColorChildHoveredFocused
override bool OnMouseEnter(Widget w, int x, int y)
ref Color m_ColorButtonHovered
ref Color m_ColorButtonHoveredFocused
Definition Color.c:13
SCR_FieldOfViewSettings Attribute