1 #pragma once 2 #include "NanoVG.hpp" 3 #include <vector> 4 class ColorPalette; 5 6 class FloatingWindow : public NanoWidget { 7 public: 8 FloatingWindow(Widget *group, ColorPalette &palette); 9 10 void setMoveLimits(DGL::Point<int> origin, DGL::Size<uint> size); 11 void repositionWithinLimits(); 12 void moveAlong(Widget *w); 13 void setAllVisible(bool visible); 14 15 protected: 16 void onNanoDisplay() override; 17 void onPositionChanged(const PositionChangedEvent &ev) override; 18 bool onMouse(const MouseEvent &ev) override; 19 bool onMotion(const MotionEvent &ev) override; 20 21 private: 22 DGL::Point<int> restrictWithinLimits(DGL::Point<int> pos); 23 24 private: 25 ColorPalette &fPalette; 26 std::vector<Widget *> fMoveAlong; 27 bool fIsDragging = false; 28 DGL::Point<int> fDragMouseOrigin; 29 DGL::Point<int> fDragStartingWindowPos; 30 DGL::Point<int> fLimitOrigin; 31 DGL::Size<uint> fLimitSize; 32 }; 33