MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / pointAt

Method pointAt

src/ui/tooltips.cpp:140–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140bool TipWindow::pointAt(int arrowAlign, const gfx::Rect& target)
141{
142 m_target = target;
143 m_arrowAlign = arrowAlign;
144
145 remapWindow();
146
147 int x = target.x;
148 int y = target.y;
149 int w = bounds().w;
150 int h = bounds().h;
151
152 int trycount = 0;
153 for (; trycount < 4; ++trycount) {
154 switch (arrowAlign) {
155 case TOP | LEFT:
156 x = m_target.x + m_target.w;
157 y = m_target.y + m_target.h;
158 break;
159 case TOP | RIGHT:
160 x = m_target.x - w;
161 y = m_target.y + m_target.h;
162 break;
163 case BOTTOM | LEFT:
164 x = m_target.x + m_target.w;
165 y = m_target.y - h;
166 break;
167 case BOTTOM | RIGHT:
168 x = m_target.x - w;
169 y = m_target.y - h;
170 break;
171 case TOP:
172 x = m_target.x + m_target.w/2 - w/2;
173 y = m_target.y + m_target.h;
174 break;
175 case BOTTOM:
176 x = m_target.x + m_target.w/2 - w/2;
177 y = m_target.y - h;
178 break;
179 case LEFT:
180 x = m_target.x + m_target.w;
181 y = m_target.y + m_target.h/2 - h/2;
182 break;
183 case RIGHT:
184 x = m_target.x - w;
185 y = m_target.y + m_target.h/2 - h/2;
186 break;
187 }
188
189 x = MID(0, x, ui::display_w()-w);
190 y = MID(0, y, ui::display_h()-h);
191
192 if (m_target.intersects(gfx::Rect(x, y, w, h))) {
193 switch (trycount) {
194 case 0:
195 case 2:
196 // Switch position
197 if (arrowAlign & (TOP | BOTTOM)) arrowAlign ^= TOP | BOTTOM;

Callers 3

openTipWindowMethod · 0.80
show_user_data_popupFunction · 0.80
onTickMethod · 0.80

Calls 3

display_wFunction · 0.85
display_hFunction · 0.85
intersectsMethod · 0.80

Tested by

no test coverage detected