commit 50e62f2dd97690912880fdf6549097f9a16cbd23
parent 4e63344dad5f1c81d6cb8a1323e258b733bb1c04
Author: falkTX <falktx@falktx.com>
Date: Mon, 6 May 2024 00:21:29 +0200
Ensure all TopLevelWidgets start with correct size; Cleanup
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
4 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/dgl/Base.hpp b/dgl/Base.hpp
@@ -73,7 +73,7 @@ enum Key {
kKeySpace = 0x00000020U, ///< Space
// Unicode Private Use Area
- kKeyF1 = 0x0000E000U, ///< F1
+ kKeyF1 = 0xE000U, ///< F1
kKeyF2, ///< F2
kKeyF3, ///< F3
kKeyF4, ///< F4
@@ -85,7 +85,7 @@ enum Key {
kKeyF10, ///< F10
kKeyF11, ///< F11
kKeyF12, ///< F12
- kKeyPageUp = 0xE031, ///< Page Up
+ kKeyPageUp = 0xE031U, ///< Page Up
kKeyPageDown, ///< Page Down
kKeyEnd, ///< End
kKeyHome, ///< Home
@@ -100,7 +100,7 @@ enum Key {
kKeyNumLock, ///< Num Lock
kKeyScrollLock, ///< Scroll Lock
kKeyCapsLock, ///< Caps Lock
- kKeyShiftL = 0xE051U, ///< Left Shift,
+ kKeyShiftL = 0xE051U, ///< Left Shift
kKeyShiftR, ///< Right Shift
kKeyControlL, ///< Left Control
kKeyControlR, ///< Right Control
diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp
@@ -227,7 +227,7 @@ uint Window::getWidth() const noexcept
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0);
const double width = puglGetFrame(pData->view).width;
- DISTRHO_SAFE_ASSERT_RETURN(width >= 0.0, 0);
+ DISTRHO_SAFE_ASSERT_RETURN(width > 0.0, 0);
return static_cast<uint>(width + 0.5);
}
@@ -236,7 +236,7 @@ uint Window::getHeight() const noexcept
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, 0);
const double height = puglGetFrame(pData->view).height;
- DISTRHO_SAFE_ASSERT_RETURN(height >= 0.0, 0);
+ DISTRHO_SAFE_ASSERT_RETURN(height > 0.0, 0);
return static_cast<uint>(height + 0.5);
}
@@ -245,8 +245,8 @@ Size<uint> Window::getSize() const noexcept
DISTRHO_SAFE_ASSERT_RETURN(pData->view != nullptr, Size<uint>());
const PuglRect rect = puglGetFrame(pData->view);
- DISTRHO_SAFE_ASSERT_RETURN(rect.width >= 0.0, Size<uint>());
- DISTRHO_SAFE_ASSERT_RETURN(rect.height >= 0.0, Size<uint>());
+ DISTRHO_SAFE_ASSERT_RETURN(rect.width > 0.0, Size<uint>());
+ DISTRHO_SAFE_ASSERT_RETURN(rect.height > 0.0, Size<uint>());
return Size<uint>(static_cast<uint>(rect.width + 0.5),
static_cast<uint>(rect.height + 0.5));
}
@@ -315,6 +315,16 @@ void Window::setSize(uint width, uint height)
else if (pData->view != nullptr)
{
puglSetSizeAndDefault(pData->view, width, height);
+
+ // there are no resize events for closed windows, so short-circuit the top-level widgets here
+ if (pData->isClosed)
+ {
+ for (std::list<TopLevelWidget*>::iterator it = pData->topLevelWidgets.begin(),
+ end = pData->topLevelWidgets.end(); it != end; ++it)
+ {
+ ((Widget*)*it)->setSize(width, height);
+ }
+ }
}
}
diff --git a/dgl/src/WindowPrivateData.cpp b/dgl/src/WindowPrivateData.cpp
@@ -604,7 +604,7 @@ void Window::PrivateData::onPuglConfigure(const double width, const double heigh
#ifndef DPF_TEST_WINDOW_CPP
FOR_EACH_TOP_LEVEL_WIDGET(it)
{
- TopLevelWidget* const widget(*it);
+ TopLevelWidget* const widget = *it;
/* Some special care here, we call Widget::setSize instead of the TopLevelWidget one.
* This is because we want TopLevelWidget::setSize to handle both window and widget size,
diff --git a/distrho/extra/Sleep.hpp b/distrho/extra/Sleep.hpp
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -29,7 +29,9 @@
# include <unistd.h>
#endif
-// -----------------------------------------------------------------------
+START_NAMESPACE_DISTRHO
+
+// -----------------------------------------------------------------------------------------------------------
// d_*sleep
/*
@@ -66,6 +68,8 @@ void d_msleep(const uint msecs) noexcept
} DISTRHO_SAFE_EXCEPTION("d_msleep");
}
-// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------
+
+END_NAMESPACE_DISTRHO
#endif // DISTRHO_SLEEP_HPP_INCLUDED