Allow any window to be bounds-checked (#4802)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-09-24 15:32:43 +02:00
committed by GitHub
parent 37009e8e6b
commit 783c7530f3
9 changed files with 122 additions and 88 deletions
+2 -17
View File
@@ -1,6 +1,7 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "util/WidgetHelpers.hpp"
#include "widgets/BaseWidget.hpp"
#include <pajlada/signals/signalholder.hpp>
@@ -36,17 +37,6 @@ public:
DisableLayoutSave = 128,
};
enum class BoundsChecker {
// Don't attempt to do any "stay in screen" stuff, just move me!
Off,
// Attempt to keep the window within bounds of the screen the cursor is on
CursorPosition,
// Attempt to keep the window within bounds of the screen the desired position is on
DesiredPosition,
};
enum ActionOnFocusLoss { Nothing, Delete, Close, Hide };
explicit BaseWindow(FlagsEnum<Flags> flags_ = None,
@@ -65,7 +55,7 @@ public:
void setActionOnFocusLoss(ActionOnFocusLoss value);
ActionOnFocusLoss getActionOnFocusLoss() const;
void moveTo(QPoint point, BoundsChecker boundsChecker);
void moveTo(QPoint point, widgets::BoundsChecking mode);
float scale() const override;
float qtFontScale() const;
@@ -110,11 +100,6 @@ protected:
private:
void init();
/**
*
**/
void moveWithinScreen(QPoint point, QPoint origin);
void calcButtonsSizes();
void drawCustomWindowFrame(QPainter &painter);
void onFocusLost();