summaryrefslogtreecommitdiff
path: root/dgl/src/Window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dgl/src/Window.cpp')
-rw-r--r--dgl/src/Window.cpp47
1 files changed, 43 insertions, 4 deletions
diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp
index 8396a954..610196fd 100644
--- a/dgl/src/Window.cpp
+++ b/dgl/src/Window.cpp
@@ -83,6 +83,7 @@ struct Window::PrivateData {
fUsingEmbed(false),
fWidth(1),
fHeight(1),
+ fScaling(1.0),
fTitle(nullptr),
fWidgets(),
fModal(),
@@ -113,6 +114,7 @@ struct Window::PrivateData {
fUsingEmbed(false),
fWidth(1),
fHeight(1),
+ fScaling(1.0),
fTitle(nullptr),
fWidgets(),
fModal(parent.pData),
@@ -155,6 +157,7 @@ struct Window::PrivateData {
fUsingEmbed(parentId != 0),
fWidth(1),
fHeight(1),
+ fScaling(1.0),
fTitle(nullptr),
fWidgets(),
fModal(),
@@ -689,6 +692,20 @@ struct Window::PrivateData {
// -------------------------------------------------------------------
+ double getScaling() const noexcept
+ {
+ return fScaling;
+ }
+
+ void setScaling(double scaling) noexcept
+ {
+ DISTRHO_SAFE_ASSERT_RETURN(scaling > 0.0,);
+
+ fScaling = scaling;
+ }
+
+ // -------------------------------------------------------------------
+
void addWidget(Widget* const widget)
{
fWidgets.push_back(widget);
@@ -740,7 +757,7 @@ struct Window::PrivateData {
FOR_EACH_WIDGET(it)
{
Widget* const widget(*it);
- widget->pData->display(fWidth, fHeight, false);
+ widget->pData->display(fWidth, fHeight, fScaling, false);
}
fSelf->onDisplayAfter();
@@ -800,7 +817,7 @@ struct Window::PrivateData {
return 1;
}
- void onPuglMouse(const int button, const bool press, const int x, const int y)
+ void onPuglMouse(const int button, const bool press, int x, int y)
{
DBGp("PUGL: onMouse : %i %i %i %i\n", button, press, x, y);
@@ -810,6 +827,9 @@ struct Window::PrivateData {
if (fModal.childFocus != nullptr)
return fModal.childFocus->focus();
+ x /= fScaling;
+ y /= fScaling;
+
Widget::MouseEvent ev;
ev.button = button;
ev.press = press;
@@ -827,13 +847,16 @@ struct Window::PrivateData {
}
}
- void onPuglMotion(const int x, const int y)
+ void onPuglMotion(int x, int y)
{
DBGp("PUGL: onMotion : %i %i\n", x, y);
if (fModal.childFocus != nullptr)
return;
+ x /= fScaling;
+ y /= fScaling;
+
Widget::MotionEvent ev;
ev.mod = static_cast<Modifier>(puglGetModifiers(fView));
ev.time = puglGetEventTimestamp(fView);
@@ -849,13 +872,18 @@ struct Window::PrivateData {
}
}
- void onPuglScroll(const int x, const int y, const float dx, const float dy)
+ void onPuglScroll(int x, int y, float dx, float dy)
{
DBGp("PUGL: onScroll : %i %i %f %f\n", x, y, dx, dy);
if (fModal.childFocus != nullptr)
return;
+ x /= fScaling;
+ y /= fScaling;
+ dx /= fScaling;
+ dy /= fScaling;
+
Widget::ScrollEvent ev;
ev.delta = Point<float>(dx, dy);
ev.mod = static_cast<Modifier>(puglGetModifiers(fView));
@@ -1004,6 +1032,7 @@ struct Window::PrivateData {
bool fUsingEmbed;
uint fWidth;
uint fHeight;
+ double fScaling;
char* fTitle;
std::list<Widget*> fWidgets;
@@ -1290,6 +1319,16 @@ void Window::setTransientWinId(uintptr_t winId)
pData->setTransientWinId(winId);
}
+double Window::getScaling() const noexcept
+{
+ return pData->getScaling();
+}
+
+void Window::setScaling(double scaling) noexcept
+{
+ pData->setScaling(scaling);
+}
+
Application& Window::getApp() const noexcept
{
return pData->fApp;