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

Return-To-The-Roots / s25client / 22523669934

28 Feb 2026 03:36PM UTC coverage: 50.338%. First build
22523669934

Pull #1899

github

web-flow
Merge eedc195ef into 8a6c9b6f2
Pull Request #1899: GUI: limit the scaling of ctrlTextButtons

46 of 52 new or added lines in 13 files covered. (88.46%)

23053 of 45796 relevant lines covered (50.34%)

42780.3 hits per line

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

74.67
/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)
1,249✔
21
    : parent_(parent), id_(id), pos_(pos), size_(size), limit_factors_(Extent(0, 0)), active_(false), visible_(true),
22
      scale_(false), isInMouseRelay(false), animations_(this)
1,249✔
23
{}
1,249✔
24

25
Window::~Window()
1,249✔
26
{
27
    RTTR_Assert(!isInMouseRelay);
1,249✔
28
    // Steuerelemente aufräumen
29
    for(Window* ctrl : childIdToWnd_ | boost::adaptors::map_values)
2,336✔
30
        delete ctrl;
1,087✔
31
}
1,249✔
32

33
/**
34
 *  zeichnet das Fenster.
35
 */
36
void Window::Draw()
356✔
37
{
38
    if(visible_)
356✔
39
        Draw_();
349✔
40
}
356✔
41

42
DrawPoint Window::GetPos() const
1,123✔
43
{
44
    return pos_;
1,123✔
45
}
46

47
DrawPoint Window::GetDrawPos() const
1,049✔
48
{
49
    DrawPoint result = pos_;
1,049✔
50
    const Window* temp = this;
1,049✔
51

52
    // Relative Koordinaten in absolute umrechnen
53
    // ( d.h. Koordinaten von allen Eltern zusammenaddieren )
54
    while(temp->parent_)
2,286✔
55
    {
56
        temp = temp->parent_;
1,237✔
57
        result += temp->pos_;
1,237✔
58
    }
59

60
    return result;
1,049✔
61
}
62

63
Extent Window::GetSize() const
5,957✔
64
{
65
    return size_;
5,957✔
66
}
67

68
Extent Window::GetLimitFactors() const
10✔
69
{
70
    return limit_factors_;
10✔
71
}
72

73
void Window::SetLimitFactors(Extent limitFactors)
88✔
74
{
75
    limit_factors_ = limitFactors;
88✔
76
}
88✔
77

78
Rect Window::GetDrawRect() const
660✔
79
{
80
    return Rect(GetDrawPos(), GetSize());
660✔
81
}
82

83
Rect Window::GetBoundaryRect() const
482✔
84
{
85
    // Default to draw rect
86
    return GetDrawRect();
482✔
87
}
88

89
/**
90
 *  Sendet eine Fensternachricht an die Steuerelemente.
91
 *
92
 *  @param[in] msg   Die Nachricht.
93
 *  @param[in] id    Die ID des Quellsteuerelements.
94
 *  @param[in] param Ein nachrichtenspezifischer Parameter.
95
 */
96
bool Window::RelayKeyboardMessage(KeyboardMsgHandler msg, const KeyEvent& ke)
2✔
97
{
98
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Nachrichten erlaubt ist
99
    // (IngameFenster könnten ja z.B. minimiert sein)
100
    if(!IsMessageRelayAllowed())
2✔
101
        return false;
×
102

103
    // Alle Controls durchgehen
104
    // Falls das Fenster dann plötzlich nich mehr aktiv ist (z.b. neues Fenster geöffnet, sofort abbrechen!)
105
    for(Window* wnd : childIdToWnd_ | boost::adaptors::map_values)
14✔
106
    {
107
        if(wnd->visible_ && wnd->active_ && CALL_MEMBER_FN(*wnd, msg)(ke))
12✔
108
            return true;
×
109
    }
110

111
    return false;
2✔
112
}
113

114
bool Window::RelayMouseMessage(MouseMsgHandler msg, const MouseCoords& mc)
107✔
115
{
116
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Mausnachrichten erlaubt ist
117
    // (IngameFenster könnten ja z.B. minimiert sein)
118
    if(!IsMessageRelayAllowed())
107✔
119
        return false;
×
120

121
    bool processed = false;
107✔
122
    isInMouseRelay = true;
107✔
123

124
    // Alle Controls durchgehen
125
    // Use reverse iterator because the topmost (=last elements) should receive the messages first!
126
    for(Window* wnd : childIdToWnd_ | boost::adaptors::map_values | boost::adaptors::reversed)
436✔
127
    {
128
        if(!lockedAreas_.empty() && IsInLockedRegion(mc.pos, wnd))
329✔
129
            continue;
×
130

131
        if(wnd->visible_ && wnd->active_ && CALL_MEMBER_FN(*wnd, msg)(mc))
329✔
132
            processed = true;
1✔
133
    }
134

135
    for(auto* tofreeArea : tofreeAreas_)
107✔
136
        lockedAreas_.erase(tofreeArea);
×
137
    tofreeAreas_.clear();
107✔
138
    isInMouseRelay = false;
107✔
139

140
    return processed;
107✔
141
}
142

143
/**
144
 *  aktiviert das Fenster.
145
 *
146
 *  @param[in] activate Fenster aktivieren?
147
 */
148
void Window::SetActive(bool activate)
2,378✔
149
{
150
    this->active_ = activate;
2,378✔
151
    ActivateControls(activate);
2,378✔
152
}
2,378✔
153

154
/**
155
 *  aktiviert die Steuerelemente des Fensters.
156
 *
157
 *  @param[in] activate Steuerelemente aktivieren?
158
 */
159
void Window::ActivateControls(bool activate)
2,378✔
160
{
161
    for(auto& it : childIdToWnd_)
3,444✔
162
        it.second->SetActive(activate);
1,066✔
163
}
2,378✔
164

165
/**
166
 *  sperrt eine Region eines Fensters.
167
 *
168
 *  @param[in] window das Fenster, welches die Region sperrt.
169
 *  @param[in] rect   das Rechteck, welches die Region beschreibt.
170
 */
171
void Window::LockRegion(Window* window, const Rect& rect)
×
172
{
173
    lockedAreas_[window] = rect;
×
174
    auto it = helpers::find(tofreeAreas_, window);
×
175
    if(it != tofreeAreas_.end())
×
176
        tofreeAreas_.erase(it);
×
177

178
    // Also lock the region for all parents
179
    if(GetParent())
×
180
        GetParent()->LockRegion(this, rect);
×
181
}
×
182

183
/**
184
 *  Gibt eine gesperrte Region wieder frei.
185
 *
186
 *  @param[in] window das Fenster, welches die Region sperrt.
187
 */
188
void Window::FreeRegion(Window* window)
×
189
{
190
    // We need to keep all locked areas otherwise a closed dropdown will enable "click-through" to below control
191
    if(isInMouseRelay)
×
192
        tofreeAreas_.push_back(window);
×
193
    else
194
        lockedAreas_.erase(window);
×
195

196
    // Also free the locked region for all parents
197
    if(GetParent())
×
198
        GetParent()->FreeRegion(this);
×
199
}
×
200

201
void Window::SetPos(const DrawPoint& newPos)
1,342✔
202
{
203
    pos_ = newPos;
1,342✔
204
}
1,342✔
205

206
/// Weiterleitung von Nachrichten von abgeleiteten Klassen erlaubt oder nicht?
207
bool Window::IsMessageRelayAllowed() const
104✔
208
{
209
    return true;
104✔
210
}
211

212
void Window::DeleteCtrl(unsigned id)
2✔
213
{
214
    auto it = childIdToWnd_.find(id);
2✔
215

216
    if(it == childIdToWnd_.end())
2✔
217
        return;
2✔
218

219
    delete it->second;
×
220

221
    childIdToWnd_.erase(it);
×
222
}
223

224
ctrlBuildingIcon* Window::AddBuildingIcon(unsigned id, const DrawPoint& pos, BuildingType type, const Nation nation,
26✔
225
                                          unsigned short size, const std::string& tooltip)
226
{
227
    return AddCtrl(new ctrlBuildingIcon(this, id, ScaleIf(pos), type, nation, ScaleIf(Extent(size, 0)).x, tooltip));
26✔
228
}
229

230
ctrlButton* Window::AddTextButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
86✔
231
                                  const std::string& text, const glFont* font, const std::string& tooltip)
232
{
233
    return AddCtrl(new ctrlTextButton(this, id, pos, size, tc, text, font, tooltip, Extent(7, 5)));
86✔
234
}
235

236
ctrlButton* Window::AddColorButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
1✔
237
                                   const unsigned fillColor, const std::string& tooltip)
238
{
239
    return AddCtrl(new ctrlColorButton(this, id, ScaleIf(pos), ScaleIf(size), tc, fillColor, tooltip));
1✔
240
}
241

242
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
351✔
243
                                   ITexture* const image, const std::string& tooltip)
244
{
245
    return AddCtrl(new ctrlImageButton(this, id, ScaleIf(pos), ScaleIf(size), tc, image, tooltip));
351✔
246
}
247

248
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
351✔
249
                                   glArchivItem_Bitmap* const image, const std::string& tooltip)
250
{
251
    return AddImageButton(id, pos, size, tc, static_cast<ITexture*>(image), tooltip);
351✔
252
}
253

254
ctrlChat* Window::AddChatCtrl(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
2✔
255
                              const glFont* font)
256
{
257
    return AddCtrl(new ctrlChat(this, id, ScaleIf(pos), ScaleIf(size), tc, font));
2✔
258
}
259

260
ctrlCheck* Window::AddCheckBox(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
49✔
261
                               const std::string& text, const glFont* font, bool readonly)
262
{
263
    return AddCtrl(new ctrlCheck(this, id, ScaleIf(pos), ScaleIf(size), tc, text, font, readonly));
49✔
264
}
265

266
ctrlComboBox* Window::AddComboBox(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
55✔
267
                                  const glFont* font, unsigned short max_list_height, bool readonly)
268
{
269
    return AddCtrl(new ctrlComboBox(this, id, ScaleIf(pos), ScaleIf(size), tc, font, max_list_height, readonly));
55✔
270
}
271

272
ctrlDeepening* Window::AddTextDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
9✔
273
                                        const std::string& text, const glFont* font, unsigned color, FontStyle style)
274
{
275
    return AddCtrl(new ctrlTextDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, text, font, color, style));
9✔
276
}
277

NEW
278
ctrlDeepening* Window::AddColorDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
279
                                         unsigned fillColor)
280
{
281
    return AddCtrl(new ctrlColorDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, fillColor));
×
282
}
283

NEW
284
ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
285
                                         ITexture* image)
286
{
287
    return AddCtrl(new ctrlImageDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, image));
×
288
}
289

NEW
290
ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
291
                                         glArchivItem_Bitmap* image)
292
{
293
    return AddImageDeepening(id, pos, size, tc, static_cast<ITexture*>(image));
×
294
}
295

296
ctrlEdit* Window::AddEdit(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
6✔
297
                          unsigned short maxlength, bool password, bool disabled, bool notify)
298
{
299
    return AddCtrl(
6✔
300
      new ctrlEdit(this, id, ScaleIf(pos), ScaleIf(size), tc, font, maxlength, password, disabled, notify));
12✔
301
}
302

303
ctrlGroup* Window::AddGroup(unsigned id)
101✔
304
{
305
    return AddCtrl(new ctrlGroup(this, id));
101✔
306
}
307

308
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, ITexture* image, const std::string& tooltip)
54✔
309
{
310
    return AddCtrl(new ctrlImage(this, id, ScaleIf(pos), image, tooltip));
54✔
311
}
312

313
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, glArchivItem_Bitmap* image, const std::string& tooltip)
54✔
314
{
315
    return AddImage(id, pos, static_cast<ITexture*>(image), tooltip);
54✔
316
}
317

318
ctrlList* Window::AddList(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font)
57✔
319
{
320
    return AddCtrl(new ctrlList(this, id, ScaleIf(pos), ScaleIf(size), tc, font));
57✔
321
}
322

323
ctrlMultiline* Window::AddMultiline(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
13✔
324
                                    const glFont* font, FontStyle format)
325
{
326
    return AddCtrl(new ctrlMultiline(this, id, ScaleIf(pos), ScaleIf(size), tc, font, format));
13✔
327
}
328

329
/**
330
 *  fügt ein OptionenGruppe hinzu.
331
 *
332
 *  @param[in] id          ID des Steuerelements
333
 *  @param[in] select_type Typ der Auswahl
334
 *
335
 *  @return Instanz das Steuerelement.
336
 */
337
ctrlOptionGroup* Window::AddOptionGroup(unsigned id, GroupSelectType select_type)
4✔
338
{
339
    return AddCtrl(new ctrlOptionGroup(this, id, select_type));
4✔
340
}
341

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

355
ctrlPercent* Window::AddPercent(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
3✔
356
                                unsigned text_color, const glFont* font, const unsigned short* percentage)
357
{
358
    return AddCtrl(new ctrlPercent(this, id, ScaleIf(pos), ScaleIf(size), tc, text_color, font, percentage));
3✔
359
}
360

361
ctrlProgress* Window::AddProgress(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
7✔
362
                                  unsigned short button_minus, unsigned short button_plus, unsigned short maximum,
363
                                  const std::string& tooltip, const Extent& padding, unsigned force_color,
364
                                  const std::string& button_minus_tooltip, const std::string& button_plus_tooltip)
365
{
366
    return AddCtrl(new ctrlProgress(this, id, ScaleIf(pos), ScaleIf(size), tc, button_minus, button_plus, maximum,
21✔
367
                                    padding, force_color, tooltip, button_minus_tooltip, button_plus_tooltip));
21✔
368
}
369

370
ctrlScrollBar* Window::AddScrollBar(unsigned id, const DrawPoint& pos, const Extent& size, unsigned short button_height,
76✔
371
                                    TextureColor tc, unsigned short page_size)
372
{
373
    button_height = ScaleIf(Extent(0, button_height)).y;
76✔
374

375
    return AddCtrl(new ctrlScrollBar(this, id, ScaleIf(pos), ScaleIf(size), button_height, tc, page_size));
76✔
376
}
377

378
ctrlTab* Window::AddTabCtrl(unsigned id, const DrawPoint& pos, unsigned short width)
3✔
379
{
380
    return AddCtrl(new ctrlTab(this, id, ScaleIf(pos), ScaleIf(Extent(width, 0)).x));
3✔
381
}
382

383
/**
384
 *  fügt eine Tabelle hinzu.
385
 *  ... sollte eine Menge von const char*, int und SortType sein
386
 */
NEW
387
ctrlTable* Window::AddTable(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
×
388
                            std::vector<TableColumn> columns)
389
{
390
    return AddCtrl(new ctrlTable(this, id, ScaleIf(pos), ScaleIf(size), tc, font, std::move(columns)));
×
391
}
392

393
ctrlTimer* Window::AddTimer(unsigned id, std::chrono::milliseconds timeout)
5✔
394
{
395
    return AddCtrl(new ctrlTimer(this, id, timeout));
5✔
396
}
397

398
/**
399
 *  fügt ein TextCtrl hinzu.
400
 *
401
 *  @param[in] x      X-Koordinate des Steuerelements
402
 *  @param[in] y      Y-Koordinate des Steuerelements
403
 *  @param[in] text   Text
404
 *  @param[in] color  Textfarbe
405
 *  @param[in] format Formatierung des Textes
406
 *                      @p FontStyle::LEFT    - Text links ( standard )
407
 *                      @p FontStyle::CENTER  - Text mittig
408
 *                      @p FontStyle::RIGHT   - Text rechts
409
 *                      @p FontStyle::TOP     - Text oben ( standard )
410
 *                      @p FontStyle::VCENTER - Text vertikal zentriert
411
 *                      @p FontStyle::BOTTOM  - Text unten
412
 *  @param[in] font   Schriftart
413
 */
414
ctrlText* Window::AddText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color, FontStyle format,
166✔
415
                          const glFont* font)
416
{
417
    return AddCtrl(new ctrlText(this, id, ScaleIf(pos), text, color, format, font));
166✔
418
}
419

420
ctrlMapSelection* Window::AddMapSelection(unsigned id, const DrawPoint& pos, const Extent& size,
×
421
                                          const SelectionMapInputData& inputData)
422
{
423
    return AddCtrl(new ctrlMapSelection(this, id, ScaleIf(pos), ScaleIf(size), inputData));
×
424
}
425

426
TextFormatSetter Window::AddFormattedText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color,
×
427
                                          FontStyle format, const glFont* font)
428
{
429
    return AddText(id, pos, text, color, format, font);
×
430
}
431

432
ctrlVarDeepening* Window::AddVarDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
1✔
433
                                          const std::string& formatstr, const glFont* font, unsigned color,
434
                                          unsigned parameters, ...)
435
{
436
    va_list liste;
437
    va_start(liste, parameters);
1✔
438

439
    auto* ctrl =
440
      new ctrlVarDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, formatstr, font, color, parameters, liste);
1✔
441

442
    va_end(liste);
1✔
443

444
    return AddCtrl(ctrl);
2✔
445
}
446

447
/**
448
 *  fügt ein variables TextCtrl hinzu.
449
 *
450
 *  @param[in] x          X-Koordinate des Steuerelements
451
 *  @param[in] y          Y-Koordinate des Steuerelements
452
 *  @param[in] formatstr  Der Formatstring des Steuerelements
453
 *  @param[in] color      Textfarbe
454
 *  @param[in] format     Formatierung des Textes
455
 *                          @p FontStyle::LEFT    - Text links ( standard )
456
 *                          @p FontStyle::CENTER  - Text mittig
457
 *                          @p FontStyle::RIGHT   - Text rechts
458
 *                          @p FontStyle::TOP     - Text oben ( standard )
459
 *                          @p FontStyle::VCENTER - Text vertikal zentriert
460
 *                          @p FontStyle::BOTTOM  - Text unten
461
 *  @param[in] font       Schriftart
462
 *  @param[in] parameters Anzahl der nachfolgenden Parameter
463
 *  @param[in] ...        die variablen Parameter
464
 */
465
ctrlVarText* Window::AddVarText(unsigned id, const DrawPoint& pos, const std::string& formatstr, unsigned color,
×
466
                                FontStyle format, const glFont* font, unsigned parameters, ...)
467
{
468
    va_list liste;
469
    va_start(liste, parameters);
×
470

471
    auto* ctrl = new ctrlVarText(this, id, ScaleIf(pos), formatstr, color, format, font, parameters, liste);
×
472

473
    va_end(liste);
×
474

475
    return AddCtrl(ctrl);
×
476
}
477

478
ctrlPreviewMinimap* Window::AddPreviewMinimap(const unsigned id, const DrawPoint& pos, const Extent& size,
×
479
                                              libsiedler2::ArchivItem_Map* const map)
480
{
481
    return AddCtrl(new ctrlPreviewMinimap(this, id, ScaleIf(pos), ScaleIf(size), map));
×
482
}
483

484
void Window::Draw3D(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
36✔
485
                    unsigned contentColor)
486
{
487
    const Extent rectSize = rect.getSize();
36✔
488
    if(rectSize.x < 4 || rectSize.y < 4)
36✔
489
        return;
×
490
    Draw3DBorder(rect, tc, elevated);
36✔
491
    // Move content inside border
492
    Rect contentRect(rect.getOrigin() + Position(2, 2), rectSize - Extent(4, 4));
36✔
493
    Draw3DContent(contentRect, tc, elevated, highlighted, illuminated, contentColor);
36✔
494
}
495

496
void Window::Draw3DBorder(const Rect& rect, TextureColor tc, bool elevated)
36✔
497
{
498
    if(tc == TextureColor::Invisible)
36✔
499
        return;
×
500
    glArchivItem_Bitmap* borderImg = LOADER.GetImageN("io", 12 + rttr::enum_cast(tc));
72✔
501
    VIDEODRIVER.GetRenderer()->Draw3DBorder(rect, elevated, *borderImg);
36✔
502
}
503

504
void Window::Draw3DContent(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
68✔
505
                           unsigned contentColor)
506
{
507
    if(tc == TextureColor::Invisible)
68✔
508
        return;
×
509
    glArchivItem_Bitmap* contentImg = LOADER.GetImageN("io", rttr::enum_cast(tc) * 2 + (highlighted ? 0 : 1));
136✔
510
    VIDEODRIVER.GetRenderer()->Draw3DContent(rect, elevated, *contentImg, illuminated, contentColor);
68✔
511
}
512

513
void Window::DrawRectangle(const Rect& rect, unsigned color)
266✔
514
{
515
    VIDEODRIVER.GetRenderer()->DrawRect(rect, color);
266✔
516
}
266✔
517

518
void Window::DrawLine(DrawPoint pt1, DrawPoint pt2, unsigned short width, unsigned color)
×
519
{
520
    VIDEODRIVER.GetRenderer()->DrawLine(pt1, pt2, width, color);
×
521
}
×
522

523
void Window::Msg_PaintBefore()
305✔
524
{
525
    animations_.update(VIDEODRIVER.GetTickCount());
305✔
526
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
479✔
527
        control->Msg_PaintBefore();
174✔
528
}
305✔
529

530
void Window::Msg_PaintAfter()
351✔
531
{
532
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
544✔
533
        control->Msg_PaintAfter();
193✔
534
}
351✔
535

536
void Window::Draw_()
157✔
537
{
538
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
340✔
539
        control->Draw();
183✔
540
}
157✔
541

542
void Window::Msg_ScreenResize(const ScreenResizeEvent& sr)
18✔
543
{
544
    // If the window elements don't get scaled there is nothing to do
545
    if(!scale_)
18✔
546
        return;
×
547
    RescaleWindowProp rescale(sr.oldSize, sr.newSize);
18✔
548
    for(Window* ctrl : childIdToWnd_ | boost::adaptors::map_values)
28✔
549
    {
550
        if(!ctrl)
10✔
551
            continue;
×
552
        // Save new size (could otherwise be changed(?) in Msg_ScreenResize)
553
        Extent newSize = rescale(ctrl->GetSize(), ctrl->GetLimitFactors());
10✔
554
        ctrl->SetPos(rescale(ctrl->GetPos(), Extent(0, 0)));
10✔
555
        ctrl->Msg_ScreenResize(sr);
10✔
556
        ctrl->Resize(newSize);
10✔
557
    }
558
    animations_.onRescale(sr);
18✔
559
}
560

561
template<class T_Pt>
562
T_Pt Window::Scale(const T_Pt& pt, const Extent& limfactors)
152✔
563
{
564
    return ScaleWindowPropUp::scale(pt, VIDEODRIVER.GetRenderSize(), limfactors);
152✔
565
}
566

567
void Window::ScaleByFactor()
86✔
568
{
569
    if(scale_)
86✔
570
    {
571
        pos_ = ScaleWindowPropUp::scale(pos_, VIDEODRIVER.GetRenderSize(), Extent(0, 0));
12✔
572
        size_ = ScaleWindowPropUp::scale(size_, VIDEODRIVER.GetRenderSize(), limit_factors_);
12✔
573
    }
574
}
86✔
575

576
template<class T_Pt>
577
T_Pt Window::ScaleIf(const T_Pt& pt) const
2,491✔
578
{
579
    return scale_ ? Scale(pt, Extent(0, 0)) : pt;
4,982✔
580
}
581

582
// Inlining removes those. so add it here
583
template DrawPoint Window::ScaleIf(const DrawPoint&) const;
584
template Extent Window::ScaleIf(const Extent&) const;
585

NEW
586
bool Window::IsInLockedRegion(const Position& pos, const Window* exception) const
×
587
{
588
    for(const auto& lockEntry : lockedAreas_)
×
589
    {
590
        // Ignore exception
591
        if(lockEntry.first == exception)
×
592
            continue;
×
593
        if(IsPointInRect(pos, lockEntry.second))
×
594
            return true;
×
595
    }
596
    return false;
×
597
}
598

599
bool Window::IsMouseOver() const
138✔
600
{
601
    return IsMouseOver(VIDEODRIVER.GetMousePos());
138✔
602
}
603

604
bool Window::IsMouseOver(const MouseCoords& mousePos) const
465✔
605
{
606
    return IsPointInRect(mousePos.pos, GetBoundaryRect());
465✔
607
}
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