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

Return-To-The-Roots / s25client / 9374022113

04 Jun 2024 08:49PM UTC coverage: 50.392% (-0.008%) from 50.4%
9374022113

Pull #1671

github

web-flow
Merge e7217890a into fad2022f6
Pull Request #1671: Add `indexOf_if` and refactor `helpers::` related functions

70 of 86 new or added lines in 15 files covered. (81.4%)

12 existing lines in 4 files now uncovered.

22007 of 43672 relevant lines covered (50.39%)

32612.07 hits per line

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

74.41
/libs/s25main/Window.cpp
1
// Copyright (C) 2005 - 2024 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,172✔
21
    : parent_(parent), id_(id), pos_(pos), size_(size), active_(false), visible_(true), scale_(false),
22
      isInMouseRelay(false), animations_(this)
1,172✔
23
{}
1,172✔
24

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

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

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

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

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

60
    return result;
937✔
61
}
62

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

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

73
Rect Window::GetBoundaryRect() const
18✔
74
{
75
    // Default to draw rect
76
    return GetDrawRect();
18✔
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)
94✔
105
{
106
    // Abgeleitete Klassen fragen, ob das Weiterleiten von Mausnachrichten erlaubt ist
107
    // (IngameFenster könnten ja z.B. minimiert sein)
108
    if(!IsMessageRelayAllowed())
94✔
109
        return false;
×
110

111
    bool processed = false;
94✔
112
    isInMouseRelay = true;
94✔
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)
417✔
117
    {
118
        if(!lockedAreas_.empty() && IsInLockedRegion(mc.GetPos(), wnd))
323✔
119
            continue;
×
120

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

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

130
    return processed;
94✔
131
}
132

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

144
/**
145
 *  aktiviert die Steuerelemente des Fensters.
146
 *
147
 *  @param[in] activate Steuerelemente aktivieren?
148
 */
149
void Window::ActivateControls(bool activate)
2,293✔
150
{
151
    for(auto& it : childIdToWnd_)
3,337✔
152
        it.second->SetActive(activate);
1,044✔
153
}
2,293✔
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;
×
NEW
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
93✔
198
{
199
    return true;
93✔
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,
333✔
233
                                   ITexture* const image, const std::string& tooltip)
234
{
235
    return AddCtrl(new ctrlImageButton(this, id, ScaleIf(pos), ScaleIf(size), tc, image, tooltip));
333✔
236
}
237

238
ctrlButton* Window::AddImageButton(unsigned id, const DrawPoint& pos, const Extent& size, const TextureColor tc,
333✔
239
                                   glArchivItem_Bitmap* const image, const std::string& tooltip)
240
{
241
    return AddImageButton(id, pos, size, tc, static_cast<ITexture*>(image), tooltip);
333✔
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,
43✔
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));
43✔
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
ctrlEdit* Window::AddEdit(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
4✔
275
                          unsigned short maxlength, bool password, bool disabled, bool notify)
276
{
277
    return AddCtrl(
4✔
278
      new ctrlEdit(this, id, ScaleIf(pos), ScaleIf(size), tc, font, maxlength, password, disabled, notify));
8✔
279
}
280

281
ctrlGroup* Window::AddGroup(unsigned id)
93✔
282
{
283
    return AddCtrl(new ctrlGroup(this, id));
93✔
284
}
285

286
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, ITexture* image, const std::string& tooltip)
50✔
287
{
288
    return AddCtrl(new ctrlImage(this, id, ScaleIf(pos), image, tooltip));
50✔
289
}
290

291
ctrlImage* Window::AddImage(unsigned id, const DrawPoint& pos, glArchivItem_Bitmap* image, const std::string& tooltip)
50✔
292
{
293
    return AddImage(id, pos, static_cast<ITexture*>(image), tooltip);
50✔
294
}
295

296
ctrlList* Window::AddList(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font)
55✔
297
{
298
    return AddCtrl(new ctrlList(this, id, ScaleIf(pos), ScaleIf(size), tc, font));
55✔
299
}
300

301
ctrlMultiline* Window::AddMultiline(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
13✔
302
                                    const glFont* font, FontStyle format)
303
{
304
    return AddCtrl(new ctrlMultiline(this, id, ScaleIf(pos), ScaleIf(size), tc, font, format));
13✔
305
}
306

307
/**
308
 *  fügt ein OptionenGruppe hinzu.
309
 *
310
 *  @param[in] id          ID des Steuerelements
311
 *  @param[in] select_type Typ der Auswahl
312
 *
313
 *  @return Instanz das Steuerelement.
314
 */
315
ctrlOptionGroup* Window::AddOptionGroup(unsigned id, GroupSelectType select_type)
4✔
316
{
317
    return AddCtrl(new ctrlOptionGroup(this, id, select_type));
4✔
318
}
319

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

333
ctrlPercent* Window::AddPercent(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
3✔
334
                                unsigned text_color, const glFont* font, const unsigned short* percentage)
335
{
336
    return AddCtrl(new ctrlPercent(this, id, ScaleIf(pos), ScaleIf(size), tc, text_color, font, percentage));
3✔
337
}
338

339
ctrlProgress* Window::AddProgress(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
7✔
340
                                  unsigned short button_minus, unsigned short button_plus, unsigned short maximum,
341
                                  const std::string& tooltip, const Extent& padding, unsigned force_color,
342
                                  const std::string& button_minus_tooltip, const std::string& button_plus_tooltip)
343
{
344
    return AddCtrl(new ctrlProgress(this, id, ScaleIf(pos), ScaleIf(size), tc, button_minus, button_plus, maximum,
21✔
345
                                    padding, force_color, tooltip, button_minus_tooltip, button_plus_tooltip));
21✔
346
}
347

348
ctrlScrollBar* Window::AddScrollBar(unsigned id, const DrawPoint& pos, const Extent& size, unsigned short button_height,
74✔
349
                                    TextureColor tc, unsigned short page_size)
350
{
351
    button_height = ScaleIf(Extent(0, button_height)).y;
74✔
352

353
    return AddCtrl(new ctrlScrollBar(this, id, ScaleIf(pos), ScaleIf(size), button_height, tc, page_size));
74✔
354
}
355

356
ctrlTab* Window::AddTabCtrl(unsigned id, const DrawPoint& pos, unsigned short width)
3✔
357
{
358
    return AddCtrl(new ctrlTab(this, id, ScaleIf(pos), ScaleIf(Extent(width, 0)).x));
3✔
359
}
360

361
/**
362
 *  fügt eine Tabelle hinzu.
363
 *  ... sollte eine Menge von const char*, int und SortType sein
364
 */
365
ctrlTable* Window::AddTable(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
×
366
                            std::vector<TableColumn> columns)
367
{
368
    return AddCtrl(new ctrlTable(this, id, ScaleIf(pos), ScaleIf(size), tc, font, std::move(columns)));
×
369
}
370

371
ctrlTimer* Window::AddTimer(unsigned id, std::chrono::milliseconds timeout)
5✔
372
{
373
    return AddCtrl(new ctrlTimer(this, id, timeout));
5✔
374
}
375

376
/**
377
 *  fügt ein TextCtrl hinzu.
378
 *
379
 *  @param[in] x      X-Koordinate des Steuerelements
380
 *  @param[in] y      Y-Koordinate des Steuerelements
381
 *  @param[in] text   Text
382
 *  @param[in] color  Textfarbe
383
 *  @param[in] format Formatierung des Textes
384
 *                      @p FontStyle::LEFT    - Text links ( standard )
385
 *                      @p FontStyle::CENTER  - Text mittig
386
 *                      @p FontStyle::RIGHT   - Text rechts
387
 *                      @p FontStyle::TOP     - Text oben ( standard )
388
 *                      @p FontStyle::VCENTER - Text vertikal zentriert
389
 *                      @p FontStyle::BOTTOM  - Text unten
390
 *  @param[in] font   Schriftart
391
 */
392
ctrlText* Window::AddText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color, FontStyle format,
152✔
393
                          const glFont* font)
394
{
395
    return AddCtrl(new ctrlText(this, id, ScaleIf(pos), text, color, format, font));
152✔
396
}
397

398
ctrlMapSelection* Window::AddMapSelection(unsigned id, const DrawPoint& pos, const Extent& size,
×
399
                                          const SelectionMapInputData& inputData)
400
{
401
    return AddCtrl(new ctrlMapSelection(this, id, ScaleIf(pos), ScaleIf(size), inputData));
×
402
}
403

404
TextFormatSetter Window::AddFormattedText(unsigned id, const DrawPoint& pos, const std::string& text, unsigned color,
×
405
                                          FontStyle format, const glFont* font)
406
{
407
    return AddText(id, pos, text, color, format, font);
×
408
}
409

410
ctrlVarDeepening* Window::AddVarDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
1✔
411
                                          const std::string& formatstr, const glFont* font, unsigned color,
412
                                          unsigned parameters, ...)
413
{
414
    va_list liste;
415
    va_start(liste, parameters);
1✔
416

417
    auto* ctrl =
418
      new ctrlVarDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, formatstr, font, color, parameters, liste);
1✔
419

420
    va_end(liste);
1✔
421

422
    return AddCtrl(ctrl);
2✔
423
}
424

425
/**
426
 *  fügt ein variables TextCtrl hinzu.
427
 *
428
 *  @param[in] x          X-Koordinate des Steuerelements
429
 *  @param[in] y          Y-Koordinate des Steuerelements
430
 *  @param[in] formatstr  Der Formatstring des Steuerelements
431
 *  @param[in] color      Textfarbe
432
 *  @param[in] format     Formatierung des Textes
433
 *                          @p FontStyle::LEFT    - Text links ( standard )
434
 *                          @p FontStyle::CENTER  - Text mittig
435
 *                          @p FontStyle::RIGHT   - Text rechts
436
 *                          @p FontStyle::TOP     - Text oben ( standard )
437
 *                          @p FontStyle::VCENTER - Text vertikal zentriert
438
 *                          @p FontStyle::BOTTOM  - Text unten
439
 *  @param[in] font       Schriftart
440
 *  @param[in] parameters Anzahl der nachfolgenden Parameter
441
 *  @param[in] ...        die variablen Parameter
442
 */
443
ctrlVarText* Window::AddVarText(unsigned id, const DrawPoint& pos, const std::string& formatstr, unsigned color,
×
444
                                FontStyle format, const glFont* font, unsigned parameters, ...)
445
{
446
    va_list liste;
447
    va_start(liste, parameters);
×
448

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

451
    va_end(liste);
×
452

453
    return AddCtrl(ctrl);
×
454
}
455

456
ctrlPreviewMinimap* Window::AddPreviewMinimap(const unsigned id, const DrawPoint& pos, const Extent& size,
×
457
                                              libsiedler2::ArchivItem_Map* const map)
458
{
459
    return AddCtrl(new ctrlPreviewMinimap(this, id, ScaleIf(pos), ScaleIf(size), map));
×
460
}
461

462
void Window::Draw3D(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
31✔
463
                    unsigned contentColor)
464
{
465
    const Extent rectSize = rect.getSize();
31✔
466
    if(rectSize.x < 4 || rectSize.y < 4)
31✔
467
        return;
×
468
    Draw3DBorder(rect, tc, elevated);
31✔
469
    // Move content inside border
470
    Rect contentRect(rect.getOrigin() + Position(2, 2), rectSize - Extent(4, 4));
31✔
471
    Draw3DContent(contentRect, tc, elevated, highlighted, illuminated, contentColor);
31✔
472
}
473

474
void Window::Draw3DBorder(const Rect& rect, TextureColor tc, bool elevated)
31✔
475
{
476
    if(tc == TextureColor::Invisible)
31✔
477
        return;
×
478
    glArchivItem_Bitmap* borderImg = LOADER.GetImageN("io", 12 + rttr::enum_cast(tc));
62✔
479
    VIDEODRIVER.GetRenderer()->Draw3DBorder(rect, elevated, *borderImg);
31✔
480
}
481

482
void Window::Draw3DContent(const Rect& rect, TextureColor tc, bool elevated, bool highlighted, bool illuminated,
59✔
483
                           unsigned contentColor)
484
{
485
    if(tc == TextureColor::Invisible)
59✔
486
        return;
×
487
    glArchivItem_Bitmap* contentImg = LOADER.GetImageN("io", rttr::enum_cast(tc) * 2 + (highlighted ? 0 : 1));
118✔
488
    VIDEODRIVER.GetRenderer()->Draw3DContent(rect, elevated, *contentImg, illuminated, contentColor);
59✔
489
}
490

491
void Window::DrawRectangle(const Rect& rect, unsigned color)
10✔
492
{
493
    VIDEODRIVER.GetRenderer()->DrawRect(rect, color);
10✔
494
}
10✔
495

496
void Window::DrawLine(DrawPoint pt1, DrawPoint pt2, unsigned short width, unsigned color)
×
497
{
498
    VIDEODRIVER.GetRenderer()->DrawLine(pt1, pt2, width, color);
×
499
}
×
500

501
void Window::Msg_PaintBefore()
300✔
502
{
503
    animations_.update(VIDEODRIVER.GetTickCount());
300✔
504
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
471✔
505
        control->Msg_PaintBefore();
171✔
506
}
300✔
507

508
void Window::Msg_PaintAfter()
346✔
509
{
510
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
536✔
511
        control->Msg_PaintAfter();
190✔
512
}
346✔
513

514
void Window::Draw_()
90✔
515
{
516
    for(Window* control : childIdToWnd_ | boost::adaptors::map_values)
264✔
517
        control->Draw();
174✔
518
}
90✔
519

520
void Window::Msg_ScreenResize(const ScreenResizeEvent& sr)
18✔
521
{
522
    // If the window elements don't get scaled there is nothing to do
523
    if(!scale_)
18✔
524
        return;
×
525
    RescaleWindowProp rescale(sr.oldSize, sr.newSize);
18✔
526
    for(Window* ctrl : childIdToWnd_ | boost::adaptors::map_values)
28✔
527
    {
528
        if(!ctrl)
10✔
529
            continue;
×
530
        // Save new size (could otherwise be changed(?) in Msg_ScreenResize)
531
        Extent newSize = rescale(ctrl->GetSize());
10✔
532
        ctrl->SetPos(rescale(ctrl->GetPos()));
10✔
533
        ctrl->Msg_ScreenResize(sr);
10✔
534
        ctrl->Resize(newSize);
10✔
535
    }
536
    animations_.onRescale(sr);
18✔
537
}
538

539
template<class T_Pt>
540
T_Pt Window::Scale(const T_Pt& pt)
171✔
541
{
542
    return ScaleWindowPropUp::scale(pt, VIDEODRIVER.GetRenderSize());
171✔
543
}
544

545
template<class T_Pt>
546
T_Pt Window::ScaleIf(const T_Pt& pt) const
2,551✔
547
{
548
    return scale_ ? Scale(pt) : pt;
2,551✔
549
}
550

551
// Inlining removes those. so add it here
552
template DrawPoint Window::ScaleIf(const DrawPoint&) const;
553
template Extent Window::ScaleIf(const Extent&) const;
554

555
bool Window::IsInLockedRegion(const Position& pos, const Window* exception) const
×
556
{
557
    for(const auto& lockEntry : lockedAreas_)
×
558
    {
559
        // Ignore exception
560
        if(lockEntry.first == exception)
×
561
            continue;
×
562
        if(IsPointInRect(pos, lockEntry.second))
×
563
            return true;
×
564
    }
565
    return false;
×
566
}
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