• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 24129294058

08 Apr 2026 09:53AM UTC coverage: 50.381%. First build
24129294058

Pull #1899

github

web-flow
Merge 3282130c1 into e4146df45
Pull Request #1899: GUI: limit the scaling of ctrlTextButtons

78 of 87 new or added lines in 14 files covered. (89.66%)

23093 of 45837 relevant lines covered (50.38%)

42174.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/libs/s25main/Window.cpp
1
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "Window.h"
6
#include "CollisionDetection.h"
7
#include "Loader.h"
8
#include "RescaleWindowProp.h"
9
#include "commonDefines.h"
10
#include "controls/controls.h"
11
#include "driver/MouseCoords.h"
12
#include "drivers/ScreenResizeEvent.h"
13
#include "drivers/VideoDriverWrapper.h"
14
#include "helpers/containerUtils.h"
15
#include "ogl/IRenderer.h"
16
#include <boost/range/adaptor/map.hpp>
17
#include <boost/range/adaptor/reversed.hpp>
18
#include <cstdarg>
19

20
Window::Window(Window* parent, unsigned id, const DrawPoint& pos, const Extent& size, const ScaleLimPercent& scalePercentage)
1,249✔
21
    : parent_(parent), id_(id), pos_(pos), size_(size), scalePercentage_(scalePercentage), active_(false),
22
      visible_(true), scale_(false), limit_(false), isInMouseRelay(false), animations_(this)
1,249✔
23
{
24
    SetScalePercentage(scalePercentage);
1,249✔
25
    if(parent != nullptr && parent->GetScale())
1,249✔
26
    {
27
        scale_ = parent->GetScale();
109✔
28
        limit_ = parent->GetLimit();
109✔
29
        Scale();
109✔
30
    }
31
}
1,249✔
32

33
Window::~Window()
1,249✔
34
{
35
    RTTR_Assert(!isInMouseRelay);
1,249✔
36
    // Steuerelemente aufräumen
37
    for(Window* ctrl : childIdToWnd_ | boost::adaptors::map_values)
2,336✔
38
        delete ctrl;
1,087✔
39
}
1,249✔
40

41
/**
42
 *  zeichnet das Fenster.
43
 */
44
void Window::Draw()
356✔
45
{
46
    if(visible_)
356✔
47
        Draw_();
349✔
48
}
356✔
49

50
DrawPoint Window::GetPos() const
1,123✔
51
{
52
    return pos_;
1,123✔
53
}
54

55
DrawPoint Window::GetDrawPos() const
1,049✔
56
{
57
    DrawPoint result = pos_;
1,049✔
58
    const Window* temp = this;
1,049✔
59

60
    // Relative Koordinaten in absolute umrechnen
61
    // ( d.h. Koordinaten von allen Eltern zusammenaddieren )
62
    while(temp->parent_)
2,286✔
63
    {
64
        temp = temp->parent_;
1,237✔
65
        result += temp->pos_;
1,237✔
66
    }
67

68
    return result;
1,049✔
69
}
70

71
Extent Window::GetSize() const
6,022✔
72
{
73
    return size_;
6,022✔
74
}
75

76
ScaleLimPercent Window::GetScalePercentage() const
10✔
77
{
78
    return scalePercentage_;
10✔
79
}
80

81
void Window::SetScalePercentage(ScaleLimPercent scalePercentage)
1,249✔
82
{
83
    if(scalePercentage.x > 100)
1,249✔
NEW
84
        scalePercentage.x = 100;
×
85

86
    if(scalePercentage.y > 100)
1,249✔
NEW
87
        scalePercentage.y = 100;
×
88

89
    scalePercentage_ = scalePercentage;
1,249✔
90
}
1,249✔
91

92
Rect Window::GetDrawRect() const
660✔
93
{
94
    return Rect(GetDrawPos(), GetSize());
660✔
95
}
96

97
Rect Window::GetBoundaryRect() const
482✔
98
{
99
    // Default to draw rect
100
    return GetDrawRect();
482✔
101
}
102

103
/**
104
 *  Sendet eine Fensternachricht an die Steuerelemente.
105
 *
106
 *  @param[in] msg   Die Nachricht.
107
 *  @param[in] id    Die ID des Quellsteuerelements.
108
 *  @param[in] param Ein nachrichtenspezifischer Parameter.
109
 */
110
bool Window::RelayKeyboardMessage(KeyboardMsgHandler msg, const KeyEvent& ke)
2✔
111
{
112
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Nachrichten erlaubt ist
113
    // (IngameFenster könnten ja z.B. minimiert sein)
114
    if(!IsMessageRelayAllowed())
2✔
115
        return false;
×
116

117
    // Alle Controls durchgehen
118
    // Falls das Fenster dann plötzlich nich mehr aktiv ist (z.b. neues Fenster geöffnet, sofort abbrechen!)
119
    for(Window* wnd : childIdToWnd_ | boost::adaptors::map_values)
14✔
120
    {
121
        if(wnd->visible_ && wnd->active_ && CALL_MEMBER_FN(*wnd, msg)(ke))
12✔
122
            return true;
×
123
    }
124

125
    return false;
2✔
126
}
127

128
bool Window::RelayMouseMessage(MouseMsgHandler msg, const MouseCoords& mc)
113✔
129
{
130
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Mausnachrichten erlaubt ist
131
    // (IngameFenster könnten ja z.B. minimiert sein)
132
    if(!IsMessageRelayAllowed())
113✔
133
        return false;
×
134

135
    bool processed = false;
113✔
136
    isInMouseRelay = true;
113✔
137

138
    // Alle Controls durchgehen
139
    // Use reverse iterator because the topmost (=last elements) should receive the messages first!
140
    for(Window* wnd : childIdToWnd_ | boost::adaptors::map_values | boost::adaptors::reversed)
448✔
141
    {
142
        if(!lockedAreas_.empty() && IsInLockedRegion(mc.pos, wnd))
335✔
143
            continue;
×
144

145
        if(wnd->visible_ && wnd->active_ && CALL_MEMBER_FN(*wnd, msg)(mc))
335✔
146
            processed = true;
1✔
147
    }
148

149
    for(auto* tofreeArea : tofreeAreas_)
113✔
150
        lockedAreas_.erase(tofreeArea);
×
151
    tofreeAreas_.clear();
113✔
152
    isInMouseRelay = false;
113✔
153

154
    return processed;
113✔
155
}
156

157
/**
158
 *  aktiviert das Fenster.
159
 *
160
 *  @param[in] activate Fenster aktivieren?
161
 */
162
void Window::SetActive(bool activate)
2,378✔
163
{
164
    this->active_ = activate;
2,378✔
165
    ActivateControls(activate);
2,378✔
166
}
2,378✔
167

168
/**
169
 *  aktiviert die Steuerelemente des Fensters.
170
 *
171
 *  @param[in] activate Steuerelemente aktivieren?
172
 */
173
void Window::ActivateControls(bool activate)
2,378✔
174
{
175
    for(auto& it : childIdToWnd_)
3,444✔
176
        it.second->SetActive(activate);
1,066✔
177
}
2,378✔
178

179
/**
180
 *  sperrt eine Region eines Fensters.
181
 *
182
 *  @param[in] window das Fenster, welches die Region sperrt.
183
 *  @param[in] rect   das Rechteck, welches die Region beschreibt.
184
 */
185
void Window::LockRegion(Window* window, const Rect& rect)
×
186
{
187
    lockedAreas_[window] = rect;
×
188
    auto it = helpers::find(tofreeAreas_, window);
×
189
    if(it != tofreeAreas_.end())
×
190
        tofreeAreas_.erase(it);
×
191

192
    // Also lock the region for all parents
193
    if(GetParent())
×
194
        GetParent()->LockRegion(this, rect);
×
195
}
×
196

197
/**
198
 *  Gibt eine gesperrte Region wieder frei.
199
 *
200
 *  @param[in] window das Fenster, welches die Region sperrt.
201
 */
202
void Window::FreeRegion(Window* window)
×
203
{
204
    // We need to keep all locked areas otherwise a closed dropdown will enable "click-through" to below control
205
    if(isInMouseRelay)
×
206
        tofreeAreas_.push_back(window);
×
207
    else
208
        lockedAreas_.erase(window);
×
209

210
    // Also free the locked region for all parents
211
    if(GetParent())
×
212
        GetParent()->FreeRegion(this);
×
213
}
×
214

215
void Window::SetPos(const DrawPoint& newPos)
1,342✔
216
{
217
    pos_ = newPos;
1,342✔
218
}
1,342✔
219

220
/// Weiterleitung von Nachrichten von abgeleiteten Klassen erlaubt oder nicht?
221
bool Window::IsMessageRelayAllowed() const
110✔
222
{
223
    return true;
110✔
224
}
225

226
void Window::DeleteCtrl(unsigned id)
2✔
227
{
228
    auto it = childIdToWnd_.find(id);
2✔
229

230
    if(it == childIdToWnd_.end())
2✔
231
        return;
2✔
232

233
    delete it->second;
×
234

235
    childIdToWnd_.erase(it);
×
236
}
237

238
ctrlBuildingIcon* Window::AddBuildingIcon(unsigned id, const DrawPoint& pos, BuildingType type, const Nation nation,
26✔
239
                                          unsigned short size, const std::string& tooltip)
240
{
241
    return AddCtrl(new ctrlBuildingIcon(this, id, pos, type, nation, Extent(size, 0).x, tooltip));
26✔
242
}
243

244
ctrlButton* Window::AddTextButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
86✔
245
                                  const std::string& text, const glFont* font, const std::string& tooltip)
246
{
247
    return AddCtrl(new ctrlTextButton(this, id, pos, size, tc, text, font, tooltip, ScaleLimPercent(30, 50)));
86✔
248
}
249

250
ctrlButton* Window::AddColorButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
1✔
251
                                   const unsigned fillColor, const std::string& tooltip)
252
{
253
    return AddCtrl(new ctrlColorButton(this, id, pos, size, tc, fillColor, tooltip));
1✔
254
}
255

256
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
351✔
257
                                   ITexture* const image, const std::string& tooltip)
258
{
259
    return AddCtrl(new ctrlImageButton(this, id, pos, size, tc, image, tooltip));
351✔
260
}
261

262
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
351✔
263
                                   glArchivItem_Bitmap* const image, const std::string& tooltip)
264
{
265
    return AddImageButton(id, pos, size, tc, static_cast<ITexture*>(image), tooltip);
351✔
266
}
267

268
ctrlChat* Window::AddChatCtrl(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
2✔
269
                              const glFont* font)
270
{
271
    return AddCtrl(new ctrlChat(this, id, pos, size, tc, font));
2✔
272
}
273

274
ctrlCheck* Window::AddCheckBox(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
49✔
275
                               const std::string& text, const glFont* font, bool readonly)
276
{
277
    return AddCtrl(new ctrlCheck(this, id, pos, size, tc, text, font, readonly));
49✔
278
}
279

280
ctrlComboBox* Window::AddComboBox(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
55✔
281
                                  const glFont* font, unsigned short max_list_height, bool readonly)
282
{
283
    return AddCtrl(new ctrlComboBox(this, id, pos, size, tc, font, max_list_height, readonly));
55✔
284
}
285

286
ctrlDeepening* Window::AddTextDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
9✔
287
                                        const std::string& text, const glFont* font, unsigned color, FontStyle style)
288
{
289
    return AddCtrl(new ctrlTextDeepening(this, id, pos, size, tc, text, font, color, style));
9✔
290
}
291

292
ctrlDeepening* Window::AddColorDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
293
                                         unsigned fillColor)
294
{
NEW
295
    return AddCtrl(new ctrlColorDeepening(this, id, pos, size, tc, fillColor));
×
296
}
297

298
ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
299
                                         ITexture* image)
300
{
NEW
301
    return AddCtrl(new ctrlImageDeepening(this, id, pos, size, tc, image));
×
302
}
303

304
ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
305
                                         glArchivItem_Bitmap* image)
306
{
307
    return AddImageDeepening(id, pos, size, tc, static_cast<ITexture*>(image));
×
308
}
309

310
ctrlEdit* Window::AddEdit(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
6✔
311
                          unsigned short maxlength, bool password, bool disabled, bool notify)
312
{
313
    return AddCtrl(
6✔
314
      new ctrlEdit(this, id, pos, size, tc, font, maxlength, password, disabled, notify));
12✔
315
}
316

317
ctrlGroup* Window::AddGroup(unsigned id)
101✔
318
{
319
    return AddCtrl(new ctrlGroup(this, id));
101✔
320
}
321

322
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, ITexture* image, const std::string& tooltip)
54✔
323
{
324
    return AddCtrl(new ctrlImage(this, id, pos, image, tooltip));
54✔
325
}
326

327
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, glArchivItem_Bitmap* image, const std::string& tooltip)
54✔
328
{
329
    return AddImage(id, pos, static_cast<ITexture*>(image), tooltip);
54✔
330
}
331

332
ctrlList* Window::AddList(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font)
57✔
333
{
334
    return AddCtrl(new ctrlList(this, id, pos, size, tc, font));
57✔
335
}
336

337
ctrlMultiline* Window::AddMultiline(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
13✔
338
                                    const glFont* font, FontStyle format)
339
{
340
    return AddCtrl(new ctrlMultiline(this, id, pos, size, tc, font, format));
13✔
341
}
342

343
/**
344
 *  fügt ein OptionenGruppe hinzu.
345
 *
346
 *  @param[in] id          ID des Steuerelements
347
 *  @param[in] select_type Typ der Auswahl
348
 *
349
 *  @return Instanz das Steuerelement.
350
 */
351
ctrlOptionGroup* Window::AddOptionGroup(unsigned id, GroupSelectType select_type)
4✔
352
{
353
    return AddCtrl(new ctrlOptionGroup(this, id, select_type));
4✔
354
}
355

356
/**
357
 *  fügt ein MultiSelectGruppe hinzu.
358
 *
359
 *  @param[in] id          ID des Steuerelements
360
 *  @param[in] select_type Typ der Auswahl
361
 *
362
 *  @return Instanz das Steuerelement.
363
 */
364
ctrlMultiSelectGroup* Window::AddMultiSelectGroup(unsigned id, GroupSelectType select_type)
×
365
{
366
    return AddCtrl(new ctrlMultiSelectGroup(this, id, select_type));
×
367
}
368

369
ctrlPercent* Window::AddPercent(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
3✔
370
                                unsigned text_color, const glFont* font, const unsigned short* percentage)
371
{
372
    return AddCtrl(new ctrlPercent(this, id, pos, size, tc, text_color, font, percentage));
3✔
373
}
374

375
ctrlProgress* Window::AddProgress(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
7✔
376
                                  unsigned short button_minus, unsigned short button_plus, unsigned short maximum,
377
                                  const std::string& tooltip, const Extent& padding, unsigned force_color,
378
                                  const std::string& button_minus_tooltip, const std::string& button_plus_tooltip)
379
{
380
    return AddCtrl(new ctrlProgress(this, id, pos, size, tc, button_minus, button_plus, maximum,
7✔
381
                                    padding, force_color, tooltip, button_minus_tooltip, button_plus_tooltip));
14✔
382
}
383

384
ctrlScrollBar* Window::AddScrollBar(unsigned id, const DrawPoint& pos, const Extent& size, unsigned short button_height,
76✔
385
                                    TextureColor tc, unsigned short page_size)
386
{
387
    button_height = Extent(0, button_height).y;
76✔
388

389
    return AddCtrl(new ctrlScrollBar(this, id, pos, size, button_height, tc, page_size));
76✔
390
}
391

392
ctrlTab* Window::AddTabCtrl(unsigned id, const DrawPoint& pos, unsigned short width)
3✔
393
{
394
    return AddCtrl(new ctrlTab(this, id, pos, Extent(width, 0).x));
3✔
395
}
396

397
/**
398
 *  fügt eine Tabelle hinzu.
399
 *  ... sollte eine Menge von const char*, int und SortType sein
400
 */
401
ctrlTable* Window::AddTable(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
×
402
                            std::vector<TableColumn> columns)
403
{
NEW
404
    return AddCtrl(new ctrlTable(this, id, pos, size, tc, font, std::move(columns)));
×
405
}
406

407
ctrlTimer* Window::AddTimer(unsigned id, std::chrono::milliseconds timeout)
5✔
408
{
409
    return AddCtrl(new ctrlTimer(this, id, timeout));
5✔
410
}
411

412
/**
413
 *  fügt ein TextCtrl hinzu.
414
 *
415
 *  @param[in] x      X-Koordinate des Steuerelements
416
 *  @param[in] y      Y-Koordinate des Steuerelements
417
 *  @param[in] text   Text
418
 *  @param[in] color  Textfarbe
419
 *  @param[in] format Formatierung des Textes
420
 *                      @p FontStyle::LEFT    - Text links ( standard )
421
 *                      @p FontStyle::CENTER  - Text mittig
422
 *                      @p FontStyle::RIGHT   - Text rechts
423
 *                      @p FontStyle::TOP     - Text oben ( standard )
424
 *                      @p FontStyle::VCENTER - Text vertikal zentriert
425
 *                      @p FontStyle::BOTTOM  - Text unten
426
 *  @param[in] font   Schriftart
427
 */
428
ctrlText* Window::AddText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color, FontStyle format,
166✔
429
                          const glFont* font)
430
{
431
    return AddCtrl(new ctrlText(this, id, pos, text, color, format, font));
166✔
432
}
433

434
ctrlMapSelection* Window::AddMapSelection(unsigned id, const DrawPoint& pos, const Extent& size,
×
435
                                          const SelectionMapInputData& inputData)
436
{
NEW
437
    return AddCtrl(new ctrlMapSelection(this, id, pos, size, inputData));
×
438
}
439

440
TextFormatSetter Window::AddFormattedText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color,
×
441
                                          FontStyle format, const glFont* font)
442
{
443
    return AddText(id, pos, text, color, format, font);
×
444
}
445

446
ctrlVarDeepening* Window::AddVarDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
1✔
447
                                          const std::string& formatstr, const glFont* font, unsigned color,
448
                                          unsigned parameters, ...)
449
{
450
    va_list liste;
451
    va_start(liste, parameters);
1✔
452

453
    auto* ctrl =
454
      new ctrlVarDeepening(this, id, pos, size, tc, formatstr, font, color, parameters, liste);
1✔
455

456
    va_end(liste);
1✔
457

458
    return AddCtrl(ctrl);
2✔
459
}
460

461
/**
462
 *  fügt ein variables TextCtrl hinzu.
463
 *
464
 *  @param[in] x          X-Koordinate des Steuerelements
465
 *  @param[in] y          Y-Koordinate des Steuerelements
466
 *  @param[in] formatstr  Der Formatstring des Steuerelements
467
 *  @param[in] color      Textfarbe
468
 *  @param[in] format     Formatierung des Textes
469
 *                          @p FontStyle::LEFT    - Text links ( standard )
470
 *                          @p FontStyle::CENTER  - Text mittig
471
 *                          @p FontStyle::RIGHT   - Text rechts
472
 *                          @p FontStyle::TOP     - Text oben ( standard )
473
 *                          @p FontStyle::VCENTER - Text vertikal zentriert
474
 *                          @p FontStyle::BOTTOM  - Text unten
475
 *  @param[in] font       Schriftart
476
 *  @param[in] parameters Anzahl der nachfolgenden Parameter
477
 *  @param[in] ...        die variablen Parameter
478
 */
479
ctrlVarText* Window::AddVarText(unsigned id, const DrawPoint& pos, const std::string& formatstr, unsigned color,
×
480
                                FontStyle format, const glFont* font, unsigned parameters, ...)
481
{
482
    va_list liste;
483
    va_start(liste, parameters);
×
484

NEW
485
    auto* ctrl = new ctrlVarText(this, id, pos, formatstr, color, format, font, parameters, liste);
×
486

487
    va_end(liste);
×
488

489
    return AddCtrl(ctrl);
×
490
}
491

492
ctrlPreviewMinimap* Window::AddPreviewMinimap(const unsigned id, const DrawPoint& pos, const Extent& size,
×
493
                                              libsiedler2::ArchivItem_Map* const map)
494
{
NEW
495
    return AddCtrl(new ctrlPreviewMinimap(this, id, pos, size, map));
×
496
}
497

498
void Window::Draw3D(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
36✔
499
                    unsigned contentColor)
500
{
501
    const Extent rectSize = rect.getSize();
36✔
502
    if(rectSize.x < 4 || rectSize.y < 4)
36✔
503
        return;
×
504
    Draw3DBorder(rect, tc, elevated);
36✔
505
    // Move content inside border
506
    Rect contentRect(rect.getOrigin() + Position(2, 2), rectSize - Extent(4, 4));
36✔
507
    Draw3DContent(contentRect, tc, elevated, highlighted, illuminated, contentColor);
36✔
508
}
509

510
void Window::Draw3DBorder(const Rect& rect, TextureColor tc, bool elevated)
36✔
511
{
512
    if(tc == TextureColor::Invisible)
36✔
513
        return;
×
514
    glArchivItem_Bitmap* borderImg = LOADER.GetImageN("io", 12 + rttr::enum_cast(tc));
72✔
515
    VIDEODRIVER.GetRenderer()->Draw3DBorder(rect, elevated, *borderImg);
36✔
516
}
517

518
void Window::Draw3DContent(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
68✔
519
                           unsigned contentColor)
520
{
521
    if(tc == TextureColor::Invisible)
68✔
522
        return;
×
523
    glArchivItem_Bitmap* contentImg = LOADER.GetImageN("io", rttr::enum_cast(tc) * 2 + (highlighted ? 0 : 1));
136✔
524
    VIDEODRIVER.GetRenderer()->Draw3DContent(rect, elevated, *contentImg, illuminated, contentColor);
68✔
525
}
526

527
void Window::DrawRectangle(const Rect& rect, unsigned color)
266✔
528
{
529
    VIDEODRIVER.GetRenderer()->DrawRect(rect, color);
266✔
530
}
266✔
531

532
void Window::DrawLine(DrawPoint pt1, DrawPoint pt2, unsigned short width, unsigned color)
×
533
{
534
    VIDEODRIVER.GetRenderer()->DrawLine(pt1, pt2, width, color);
×
535
}
×
536

537
void Window::Msg_PaintBefore()
305✔
538
{
539
    animations_.update(VIDEODRIVER.GetTickCount());
305✔
540
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
479✔
541
        control->Msg_PaintBefore();
174✔
542
}
305✔
543

544
void Window::Msg_PaintAfter()
351✔
545
{
546
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
544✔
547
        control->Msg_PaintAfter();
193✔
548
}
351✔
549

550
void Window::Draw_()
157✔
551
{
552
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
340✔
553
        control->Draw();
183✔
554
}
157✔
555

556
void Window::Msg_ScreenResize(const ScreenResizeEvent& sr)
18✔
557
{
558
    // If the window elements don't get scaled there is nothing to do
559
    if(!scale_)
18✔
560
        return;
×
561
    ScaleWindowProp rescale(sr.oldSize, sr.newSize);
18✔
562
    for(Window* ctrl : childIdToWnd_ | boost::adaptors::map_values)
28✔
563
    {
564
        if(!ctrl)
10✔
565
            continue;
×
566
        // Save new size (could otherwise be changed(?) in Msg_ScreenResize)
567
        ScaleLimPercent limits(100, 100);
10✔
568
        if(limit_)
10✔
569
            limits = ctrl->GetScalePercentage();
10✔
570
        Extent newSize = rescale(ctrl->GetSize(), limits);
10✔
571
        ctrl->SetPos(rescale(ctrl->GetPos()));
10✔
572
        ctrl->Msg_ScreenResize(sr);
10✔
573
        ctrl->Resize(newSize);
10✔
574
    }
575
    animations_.onRescale(sr);
18✔
576
}
577

578
template<class T_Pt>
579
T_Pt Window::Scale(const T_Pt& pt, const ScaleLimPercent& scalePercentage)
80✔
580
{
581
    return ScaleWindowProp::scale(pt, VIDEODRIVER.GetRenderSize(), scalePercentage);
80✔
582
}
583

584
void Window::Scale()
109✔
585
{
586
    pos_ = ScaleWindowProp::scale(pos_, VIDEODRIVER.GetRenderSize());
109✔
587
    size_ = ScaleWindowProp::scale(size_, VIDEODRIVER.GetRenderSize(), limit_ ? scalePercentage_ : ScaleLimPercent(100, 100));
109✔
588
}
109✔
589

590
template<class T_Pt>
591
T_Pt Window::ScaleIf(const T_Pt& pt) const
877✔
592
{
593
    return scale_ ? Scale(pt) : pt;
1,754✔
594
}
595

596
// Inlining removes those. so add it here
597
template DrawPoint Window::ScaleIf(const DrawPoint&) const;
598
template Extent Window::ScaleIf(const Extent&) const;
599

600
bool Window::IsInLockedRegion(const Position& pos, const Window* exception) const
×
601
{
602
    for(const auto& lockEntry : lockedAreas_)
×
603
    {
604
        // Ignore exception
605
        if(lockEntry.first == exception)
×
606
            continue;
×
607
        if(IsPointInRect(pos, lockEntry.second))
×
608
            return true;
×
609
    }
610
    return false;
×
611
}
612

613
bool Window::IsMouseOver() const
138✔
614
{
615
    return IsMouseOver(VIDEODRIVER.GetMousePos());
138✔
616
}
617

618
bool Window::IsMouseOver(const MouseCoords& mousePos) const
465✔
619
{
620
    return IsPointInRect(mousePos.pos, GetBoundaryRect());
465✔
621
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc