MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / eventOccured

Method eventOccured

forms/scrollbar.cpp:88–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void ScrollBar::eventOccured(Event *e)
89{
90 Control::eventOccured(e);
91
92 int mousePosition = 0;
93 if (e->type() == EVENT_FORM_INTERACTION)
94 {
95 switch (BarOrientation)
96 {
97 case Orientation::Vertical:
98 // MouseInfo.X/Y is relative to the control that raised it
99 // make it relative to this control instead
100 mousePosition = e->forms().MouseInfo.Y +
101 e->forms().RaisedBy->getLocationOnScreen().y - resolvedLocation.y;
102 break;
103 case Orientation::Horizontal:
104 mousePosition = e->forms().MouseInfo.X +
105 e->forms().RaisedBy->getLocationOnScreen().x - resolvedLocation.x;
106 break;
107 }
108
109 int pos = static_cast<int>(segmentsize * (Value - Minimum));
110 if (e->forms().RaisedBy == shared_from_this() &&
111 e->forms().EventFlag == FormEventType::MouseDown)
112 {
113 if (mousePosition >= pos + grippersize)
114 {
115 scrollNext();
116 }
117 else if (mousePosition <= pos)
118 {
119 scrollPrev();
120 }
121 else
122 {
123 capture = true;
124 }
125 }
126
127 if ((capture || e->forms().RaisedBy == shared_from_this()) &&
128 e->forms().EventFlag == FormEventType::MouseUp)
129 {
130 capture = false;
131 }
132
133 if (e->forms().EventFlag == FormEventType::MouseMove && capture)
134 {
135 this->setValue(static_cast<int>(mousePosition / segmentsize) + Minimum);
136 }
137
138 if (e->forms().EventFlag == FormEventType::MouseMove &&
139 e->forms().RaisedBy == shared_from_this())
140 {
141 if (BarOrientation == Orientation::Vertical)
142 {
143 scrollWheel(e);
144 }
145 }

Callers

nothing calls this directly

Calls 3

setValueMethod · 0.95
typeMethod · 0.80
getLocationOnScreenMethod · 0.80

Tested by

no test coverage detected