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

Return-To-The-Roots / s25client / 19726738692

27 Nov 2025 06:00AM UTC coverage: 50.567% (+0.005%) from 50.562%
19726738692

push

github

Flow86
Lock portraits too

22564 of 44622 relevant lines covered (50.57%)

37117.95 hits per line

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

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

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

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

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

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

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

60
    return result;
1,039✔
61
}
62

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

68
Rect Window::GetDrawRect() const
651✔
69
{
70
    return Rect(GetDrawPos(), GetSize());
651✔
71
}
72

73
Rect Window::GetBoundaryRect() const
474✔
74
{
75
    // Default to draw rect
76
    return GetDrawRect();
474✔
77
}
78

79
/**
80
 *  Sendet eine Fensternachricht an die Steuerelemente.
81
 *
82
 *  @param[in] msg   Die Nachricht.
83
 *  @param[in] id    Die ID des Quellsteuerelements.
84
 *  @param[in] param Ein nachrichtenspezifischer Parameter.
85
 */
86
bool Window::RelayKeyboardMessage(KeyboardMsgHandler msg, const KeyEvent& ke)
2✔
87
{
88
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Nachrichten erlaubt ist
89
    // (IngameFenster könnten ja z.B. minimiert sein)
90
    if(!IsMessageRelayAllowed())
2✔
91
        return false;
×
92

93
    // Alle Controls durchgehen
94
    // Falls das Fenster dann plötzlich nich mehr aktiv ist (z.b. neues Fenster geöffnet, sofort abbrechen!)
95
    for(Window* wnd : childIdToWnd_ | boost::adaptors::map_values)
14✔
96
    {
97
        if(wnd->visible_ && wnd->active_ && CALL_MEMBER_FN(*wnd, msg)(ke))
12✔
98
            return true;
×
99
    }
100

101
    return false;
2✔
102
}
103

104
bool Window::RelayMouseMessage(MouseMsgHandler msg, const MouseCoords& mc)
96✔
105
{
106
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Mausnachrichten erlaubt ist
107
    // (IngameFenster könnten ja z.B. minimiert sein)
108
    if(!IsMessageRelayAllowed())
96✔
109
        return false;
×
110

111
    bool processed = false;
96✔
112
    isInMouseRelay = true;
96✔
113

114
    // Alle Controls durchgehen
115
    // Use reverse iterator because the topmost (=last elements) should receive the messages first!
116
    for(Window* wnd : childIdToWnd_ | boost::adaptors::map_values | boost::adaptors::reversed)
426✔
117
    {
118
        if(!lockedAreas_.empty() && IsInLockedRegion(mc.pos, wnd))
330✔
119
            continue;
×
120

121
        if(wnd->visible_ && wnd->active_ && CALL_MEMBER_FN(*wnd, msg)(mc))
330✔
122
            processed = true;
1✔
123
    }
124

125
    for(auto* tofreeArea : tofreeAreas_)
96✔
126
        lockedAreas_.erase(tofreeArea);
×
127
    tofreeAreas_.clear();
96✔
128
    isInMouseRelay = false;
96✔
129

130
    return processed;
96✔
131
}
132

133
/**
134
 *  aktiviert das Fenster.
135
 *
136
 *  @param[in] activate Fenster aktivieren?
137
 */
138
void Window::SetActive(bool activate)
2,329✔
139
{
140
    this->active_ = activate;
2,329✔
141
    ActivateControls(activate);
2,329✔
142
}
2,329✔
143

144
/**
145
 *  aktiviert die Steuerelemente des Fensters.
146
 *
147
 *  @param[in] activate Steuerelemente aktivieren?
148
 */
149
void Window::ActivateControls(bool activate)
2,329✔
150
{
151
    for(auto& it : childIdToWnd_)
3,383✔
152
        it.second->SetActive(activate);
1,054✔
153
}
2,329✔
154

155
/**
156
 *  sperrt eine Region eines Fensters.
157
 *
158
 *  @param[in] window das Fenster, welches die Region sperrt.
159
 *  @param[in] rect   das Rechteck, welches die Region beschreibt.
160
 */
161
void Window::LockRegion(Window* window, const Rect& rect)
×
162
{
163
    lockedAreas_[window] = rect;
×
164
    auto it = helpers::find(tofreeAreas_, window);
×
165
    if(it != tofreeAreas_.end())
×
166
        tofreeAreas_.erase(it);
×
167

168
    // Also lock the region for all parents
169
    if(GetParent())
×
170
        GetParent()->LockRegion(this, rect);
×
171
}
×
172

173
/**
174
 *  Gibt eine gesperrte Region wieder frei.
175
 *
176
 *  @param[in] window das Fenster, welches die Region sperrt.
177
 */
178
void Window::FreeRegion(Window* window)
×
179
{
180
    // We need to keep all locked areas otherwise a closed dropdown will enable "click-through" to below control
181
    if(isInMouseRelay)
×
182
        tofreeAreas_.push_back(window);
×
183
    else
184
        lockedAreas_.erase(window);
×
185

186
    // Also free the locked region for all parents
187
    if(GetParent())
×
188
        GetParent()->FreeRegion(this);
×
189
}
×
190

191
void Window::SetPos(const DrawPoint& newPos)
1,317✔
192
{
193
    pos_ = newPos;
1,317✔
194
}
1,317✔
195

196
/// Weiterleitung von Nachrichten von abgeleiteten Klassen erlaubt oder nicht?
197
bool Window::IsMessageRelayAllowed() const
95✔
198
{
199
    return true;
95✔
200
}
201

202
void Window::DeleteCtrl(unsigned id)
2✔
203
{
204
    auto it = childIdToWnd_.find(id);
2✔
205

206
    if(it == childIdToWnd_.end())
2✔
207
        return;
2✔
208

209
    delete it->second;
×
210

211
    childIdToWnd_.erase(it);
×
212
}
213

214
ctrlBuildingIcon* Window::AddBuildingIcon(unsigned id, const DrawPoint& pos, BuildingType type, const Nation nation,
26✔
215
                                          unsigned short size, const std::string& tooltip)
216
{
217
    return AddCtrl(new ctrlBuildingIcon(this, id, ScaleIf(pos), type, nation, ScaleIf(Extent(size, 0)).x, tooltip));
26✔
218
}
219

220
ctrlButton* Window::AddTextButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
80✔
221
                                  const std::string& text, const glFont* font, const std::string& tooltip)
222
{
223
    return AddCtrl(new ctrlTextButton(this, id, ScaleIf(pos), ScaleIf(size), tc, text, font, tooltip));
80✔
224
}
225

226
ctrlButton* Window::AddColorButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
1✔
227
                                   const unsigned fillColor, const std::string& tooltip)
228
{
229
    return AddCtrl(new ctrlColorButton(this, id, ScaleIf(pos), ScaleIf(size), tc, fillColor, tooltip));
1✔
230
}
231

232
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
340✔
233
                                   ITexture* const image, const std::string& tooltip)
234
{
235
    return AddCtrl(new ctrlImageButton(this, id, ScaleIf(pos), ScaleIf(size), tc, image, tooltip));
340✔
236
}
237

238
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
340✔
239
                                   glArchivItem_Bitmap* const image, const std::string& tooltip)
240
{
241
    return AddImageButton(id, pos, size, tc, static_cast<ITexture*>(image), tooltip);
340✔
242
}
243

244
ctrlChat* Window::AddChatCtrl(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
2✔
245
                              const glFont* font)
246
{
247
    return AddCtrl(new ctrlChat(this, id, ScaleIf(pos), ScaleIf(size), tc, font));
2✔
248
}
249

250
ctrlCheck* Window::AddCheckBox(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
45✔
251
                               const std::string& text, const glFont* font, bool readonly)
252
{
253
    return AddCtrl(new ctrlCheck(this, id, ScaleIf(pos), ScaleIf(size), tc, text, font, readonly));
45✔
254
}
255

256
ctrlComboBox* Window::AddComboBox(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
53✔
257
                                  const glFont* font, unsigned short max_list_height, bool readonly)
258
{
259
    return AddCtrl(new ctrlComboBox(this, id, ScaleIf(pos), ScaleIf(size), tc, font, max_list_height, readonly));
53✔
260
}
261

262
ctrlDeepening* Window::AddTextDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
7✔
263
                                        const std::string& text, const glFont* font, unsigned color, FontStyle style)
264
{
265
    return AddCtrl(new ctrlTextDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, text, font, color, style));
7✔
266
}
267

268
ctrlDeepening* Window::AddColorDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
269
                                         unsigned fillColor)
270
{
271
    return AddCtrl(new ctrlColorDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, fillColor));
×
272
}
273

274
ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
275
                                         ITexture* image)
276
{
277
    return AddCtrl(new ctrlImageDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, image));
×
278
}
279

280
ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
×
281
                                         glArchivItem_Bitmap* image)
282
{
283
    return AddImageDeepening(id, pos, size, tc, static_cast<ITexture*>(image));
×
284
}
285

286
ctrlEdit* Window::AddEdit(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
4✔
287
                          unsigned short maxlength, bool password, bool disabled, bool notify)
288
{
289
    return AddCtrl(
4✔
290
      new ctrlEdit(this, id, ScaleIf(pos), ScaleIf(size), tc, font, maxlength, password, disabled, notify));
8✔
291
}
292

293
ctrlGroup* Window::AddGroup(unsigned id)
95✔
294
{
295
    return AddCtrl(new ctrlGroup(this, id));
95✔
296
}
297

298
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, ITexture* image, const std::string& tooltip)
51✔
299
{
300
    return AddCtrl(new ctrlImage(this, id, ScaleIf(pos), image, tooltip));
51✔
301
}
302

303
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, glArchivItem_Bitmap* image, const std::string& tooltip)
51✔
304
{
305
    return AddImage(id, pos, static_cast<ITexture*>(image), tooltip);
51✔
306
}
307

308
ctrlList* Window::AddList(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font)
55✔
309
{
310
    return AddCtrl(new ctrlList(this, id, ScaleIf(pos), ScaleIf(size), tc, font));
55✔
311
}
312

313
ctrlMultiline* Window::AddMultiline(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
13✔
314
                                    const glFont* font, FontStyle format)
315
{
316
    return AddCtrl(new ctrlMultiline(this, id, ScaleIf(pos), ScaleIf(size), tc, font, format));
13✔
317
}
318

319
/**
320
 *  fügt ein OptionenGruppe hinzu.
321
 *
322
 *  @param[in] id          ID des Steuerelements
323
 *  @param[in] select_type Typ der Auswahl
324
 *
325
 *  @return Instanz das Steuerelement.
326
 */
327
ctrlOptionGroup* Window::AddOptionGroup(unsigned id, GroupSelectType select_type)
4✔
328
{
329
    return AddCtrl(new ctrlOptionGroup(this, id, select_type));
4✔
330
}
331

332
/**
333
 *  fügt ein MultiSelectGruppe hinzu.
334
 *
335
 *  @param[in] id          ID des Steuerelements
336
 *  @param[in] select_type Typ der Auswahl
337
 *
338
 *  @return Instanz das Steuerelement.
339
 */
340
ctrlMultiSelectGroup* Window::AddMultiSelectGroup(unsigned id, GroupSelectType select_type)
×
341
{
342
    return AddCtrl(new ctrlMultiSelectGroup(this, id, select_type));
×
343
}
344

345
ctrlPercent* Window::AddPercent(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
3✔
346
                                unsigned text_color, const glFont* font, const unsigned short* percentage)
347
{
348
    return AddCtrl(new ctrlPercent(this, id, ScaleIf(pos), ScaleIf(size), tc, text_color, font, percentage));
3✔
349
}
350

351
ctrlProgress* Window::AddProgress(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
7✔
352
                                  unsigned short button_minus, unsigned short button_plus, unsigned short maximum,
353
                                  const std::string& tooltip, const Extent& padding, unsigned force_color,
354
                                  const std::string& button_minus_tooltip, const std::string& button_plus_tooltip)
355
{
356
    return AddCtrl(new ctrlProgress(this, id, ScaleIf(pos), ScaleIf(size), tc, button_minus, button_plus, maximum,
21✔
357
                                    padding, force_color, tooltip, button_minus_tooltip, button_plus_tooltip));
21✔
358
}
359

360
ctrlScrollBar* Window::AddScrollBar(unsigned id, const DrawPoint& pos, const Extent& size, unsigned short button_height,
74✔
361
                                    TextureColor tc, unsigned short page_size)
362
{
363
    button_height = ScaleIf(Extent(0, button_height)).y;
74✔
364

365
    return AddCtrl(new ctrlScrollBar(this, id, ScaleIf(pos), ScaleIf(size), button_height, tc, page_size));
74✔
366
}
367

368
ctrlTab* Window::AddTabCtrl(unsigned id, const DrawPoint& pos, unsigned short width)
3✔
369
{
370
    return AddCtrl(new ctrlTab(this, id, ScaleIf(pos), ScaleIf(Extent(width, 0)).x));
3✔
371
}
372

373
/**
374
 *  fügt eine Tabelle hinzu.
375
 *  ... sollte eine Menge von const char*, int und SortType sein
376
 */
377
ctrlTable* Window::AddTable(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
×
378
                            std::vector<TableColumn> columns)
379
{
380
    return AddCtrl(new ctrlTable(this, id, ScaleIf(pos), ScaleIf(size), tc, font, std::move(columns)));
×
381
}
382

383
ctrlTimer* Window::AddTimer(unsigned id, std::chrono::milliseconds timeout)
5✔
384
{
385
    return AddCtrl(new ctrlTimer(this, id, timeout));
5✔
386
}
387

388
/**
389
 *  fügt ein TextCtrl hinzu.
390
 *
391
 *  @param[in] x      X-Koordinate des Steuerelements
392
 *  @param[in] y      Y-Koordinate des Steuerelements
393
 *  @param[in] text   Text
394
 *  @param[in] color  Textfarbe
395
 *  @param[in] format Formatierung des Textes
396
 *                      @p FontStyle::LEFT    - Text links ( standard )
397
 *                      @p FontStyle::CENTER  - Text mittig
398
 *                      @p FontStyle::RIGHT   - Text rechts
399
 *                      @p FontStyle::TOP     - Text oben ( standard )
400
 *                      @p FontStyle::VCENTER - Text vertikal zentriert
401
 *                      @p FontStyle::BOTTOM  - Text unten
402
 *  @param[in] font   Schriftart
403
 */
404
ctrlText* Window::AddText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color, FontStyle format,
157✔
405
                          const glFont* font)
406
{
407
    return AddCtrl(new ctrlText(this, id, ScaleIf(pos), text, color, format, font));
157✔
408
}
409

410
ctrlMapSelection* Window::AddMapSelection(unsigned id, const DrawPoint& pos, const Extent& size,
×
411
                                          const SelectionMapInputData& inputData)
412
{
413
    return AddCtrl(new ctrlMapSelection(this, id, ScaleIf(pos), ScaleIf(size), inputData));
×
414
}
415

416
TextFormatSetter Window::AddFormattedText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color,
×
417
                                          FontStyle format, const glFont* font)
418
{
419
    return AddText(id, pos, text, color, format, font);
×
420
}
421

422
ctrlVarDeepening* Window::AddVarDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
1✔
423
                                          const std::string& formatstr, const glFont* font, unsigned color,
424
                                          unsigned parameters, ...)
425
{
426
    va_list liste;
427
    va_start(liste, parameters);
1✔
428

429
    auto* ctrl =
430
      new ctrlVarDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, formatstr, font, color, parameters, liste);
1✔
431

432
    va_end(liste);
1✔
433

434
    return AddCtrl(ctrl);
2✔
435
}
436

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

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

463
    va_end(liste);
×
464

465
    return AddCtrl(ctrl);
×
466
}
467

468
ctrlPreviewMinimap* Window::AddPreviewMinimap(const unsigned id, const DrawPoint& pos, const Extent& size,
×
469
                                              libsiedler2::ArchivItem_Map* const map)
470
{
471
    return AddCtrl(new ctrlPreviewMinimap(this, id, ScaleIf(pos), ScaleIf(size), map));
×
472
}
473

474
void Window::Draw3D(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
36✔
475
                    unsigned contentColor)
476
{
477
    const Extent rectSize = rect.getSize();
36✔
478
    if(rectSize.x < 4 || rectSize.y < 4)
36✔
479
        return;
×
480
    Draw3DBorder(rect, tc, elevated);
36✔
481
    // Move content inside border
482
    Rect contentRect(rect.getOrigin() + Position(2, 2), rectSize - Extent(4, 4));
36✔
483
    Draw3DContent(contentRect, tc, elevated, highlighted, illuminated, contentColor);
36✔
484
}
485

486
void Window::Draw3DBorder(const Rect& rect, TextureColor tc, bool elevated)
36✔
487
{
488
    if(tc == TextureColor::Invisible)
36✔
489
        return;
×
490
    glArchivItem_Bitmap* borderImg = LOADER.GetImageN("io", 12 + rttr::enum_cast(tc));
72✔
491
    VIDEODRIVER.GetRenderer()->Draw3DBorder(rect, elevated, *borderImg);
36✔
492
}
493

494
void Window::Draw3DContent(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
68✔
495
                           unsigned contentColor)
496
{
497
    if(tc == TextureColor::Invisible)
68✔
498
        return;
×
499
    glArchivItem_Bitmap* contentImg = LOADER.GetImageN("io", rttr::enum_cast(tc) * 2 + (highlighted ? 0 : 1));
136✔
500
    VIDEODRIVER.GetRenderer()->Draw3DContent(rect, elevated, *contentImg, illuminated, contentColor);
68✔
501
}
502

503
void Window::DrawRectangle(const Rect& rect, unsigned color)
266✔
504
{
505
    VIDEODRIVER.GetRenderer()->DrawRect(rect, color);
266✔
506
}
266✔
507

508
void Window::DrawLine(DrawPoint pt1, DrawPoint pt2, unsigned short width, unsigned color)
×
509
{
510
    VIDEODRIVER.GetRenderer()->DrawLine(pt1, pt2, width, color);
×
511
}
×
512

513
void Window::Msg_PaintBefore()
303✔
514
{
515
    animations_.update(VIDEODRIVER.GetTickCount());
303✔
516
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
476✔
517
        control->Msg_PaintBefore();
173✔
518
}
303✔
519

520
void Window::Msg_PaintAfter()
349✔
521
{
522
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
541✔
523
        control->Msg_PaintAfter();
192✔
524
}
349✔
525

526
void Window::Draw_()
156✔
527
{
528
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
338✔
529
        control->Draw();
182✔
530
}
156✔
531

532
void Window::Msg_ScreenResize(const ScreenResizeEvent& sr)
18✔
533
{
534
    // If the window elements don't get scaled there is nothing to do
535
    if(!scale_)
18✔
536
        return;
×
537
    RescaleWindowProp rescale(sr.oldSize, sr.newSize);
18✔
538
    for(Window* ctrl : childIdToWnd_ | boost::adaptors::map_values)
28✔
539
    {
540
        if(!ctrl)
10✔
541
            continue;
×
542
        // Save new size (could otherwise be changed(?) in Msg_ScreenResize)
543
        Extent newSize = rescale(ctrl->GetSize());
10✔
544
        ctrl->SetPos(rescale(ctrl->GetPos()));
10✔
545
        ctrl->Msg_ScreenResize(sr);
10✔
546
        ctrl->Resize(newSize);
10✔
547
    }
548
    animations_.onRescale(sr);
18✔
549
}
550

551
template<class T_Pt>
552
T_Pt Window::Scale(const T_Pt& pt)
175✔
553
{
554
    return ScaleWindowPropUp::scale(pt, VIDEODRIVER.GetRenderSize());
175✔
555
}
556

557
template<class T_Pt>
558
T_Pt Window::ScaleIf(const T_Pt& pt) const
2,575✔
559
{
560
    return scale_ ? Scale(pt) : pt;
2,575✔
561
}
562

563
// Inlining removes those. so add it here
564
template DrawPoint Window::ScaleIf(const DrawPoint&) const;
565
template Extent Window::ScaleIf(const Extent&) const;
566

567
bool Window::IsInLockedRegion(const Position& pos, const Window* exception) const
×
568
{
569
    for(const auto& lockEntry : lockedAreas_)
×
570
    {
571
        // Ignore exception
572
        if(lockEntry.first == exception)
×
573
            continue;
×
574
        if(IsPointInRect(pos, lockEntry.second))
×
575
            return true;
×
576
    }
577
    return false;
×
578
}
579

580
bool Window::IsMouseOver() const
138✔
581
{
582
    return IsMouseOver(VIDEODRIVER.GetMousePos());
138✔
583
}
584

585
bool Window::IsMouseOver(const MouseCoords& mousePos) const
457✔
586
{
587
    return IsPointInRect(mousePos.pos, GetBoundaryRect());
457✔
588
}
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