Cleanup widgets
This commit is contained in:
parent
9e7704a446
commit
bce1dbacc2
30 changed files with 705 additions and 654 deletions
|
|
@ -7,6 +7,9 @@
|
|||
namespace tp {
|
||||
|
||||
class ButtonWidget : public Widget {
|
||||
public:
|
||||
// enum State { NONE, ANTICIPATION, ACTIVATED, CONFIRMED };
|
||||
|
||||
public:
|
||||
ButtonWidget();
|
||||
ButtonWidget(const std::string& label, const tp::RectF& aArea);
|
||||
|
|
@ -20,6 +23,7 @@ namespace tp {
|
|||
|
||||
public:
|
||||
LabelWidget mLabel;
|
||||
// State mStat = NONE;
|
||||
|
||||
RGBA pressedColor;
|
||||
RGBA hoveredColor;
|
||||
|
|
|
|||
|
|
@ -44,5 +44,8 @@ namespace tp {
|
|||
bool mCollapsed = true;
|
||||
bool mLocked = false;
|
||||
bool mAdjustHeight = true;
|
||||
|
||||
public:
|
||||
bool mBorders = true;
|
||||
};
|
||||
}
|
||||
18
Widgets/public/FloatingLayoutWidget.hpp
Normal file
18
Widgets/public/FloatingLayoutWidget.hpp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include "FloatingWidget.hpp"
|
||||
|
||||
namespace tp {
|
||||
class FloatingLayoutWidget : public Widget {
|
||||
public:
|
||||
FloatingLayoutWidget();
|
||||
|
||||
void eventProcess(const Events& events) override;
|
||||
|
||||
[[nodiscard]] bool handlesEvent() const;
|
||||
|
||||
private:
|
||||
void updateActiveWindow(const tp::Events& events);
|
||||
|
||||
private:
|
||||
bool mIsPassThrough = false;
|
||||
};
|
||||
}
|
||||
|
|
@ -11,6 +11,9 @@ namespace tp {
|
|||
void eventDraw(Canvas& canvas) override;
|
||||
void eventUpdateConfiguration(WidgetManager& wm) override;
|
||||
|
||||
[[nodiscard]] bool isFloating() const;
|
||||
void stopFloating();
|
||||
|
||||
private:
|
||||
void checkFloating(const Events& events);
|
||||
void checkResizing(const Events& events);
|
||||
|
|
@ -26,5 +29,8 @@ namespace tp {
|
|||
bool mResizing = false;
|
||||
|
||||
Vec2F mActionStartRelativePos = {};
|
||||
|
||||
public:
|
||||
bool mResizable = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,25 +1,51 @@
|
|||
#include "FloatingWidget.hpp"
|
||||
#include "WidgetBase.hpp"
|
||||
|
||||
namespace tp {
|
||||
class DockSpaceWidget : public Widget {
|
||||
class GridLayoutWidget : public Widget {
|
||||
public:
|
||||
enum Side { LEFT, TOP, RIGHT, BOTTOM };
|
||||
enum Side { LEFT, TOP, RIGHT, BOTTOM, NONE };
|
||||
|
||||
private:
|
||||
struct ResizeHandle {
|
||||
RectF area{ 0, 0, 0, 0 };
|
||||
halnf start{ 0 };
|
||||
halnf end{ 0 };
|
||||
bool active = false;
|
||||
bool hover = false;
|
||||
};
|
||||
|
||||
struct SideWidgetData {
|
||||
Widget* widget = nullptr;
|
||||
bool hidden = false;
|
||||
halnf absoluteSize = 200;
|
||||
alni order = -1;
|
||||
|
||||
Side side = { TOP };
|
||||
|
||||
RectF area = {};
|
||||
RectF headerArea = {};
|
||||
RectF previewHandleArea = {};
|
||||
|
||||
ResizeHandle resizeHandle;
|
||||
};
|
||||
|
||||
public:
|
||||
DockSpaceWidget();
|
||||
GridLayoutWidget();
|
||||
|
||||
void eventProcess(const Events& events) override;
|
||||
void eventDraw(Canvas& canvas) override;
|
||||
void eventDrawOver(Canvas& canvas) override;
|
||||
|
||||
void addSideWidget(Widget* widget, Side side);
|
||||
void removeSideWidget(Side side);
|
||||
|
||||
void toggleHiddenState(DockSpaceWidget::Side side);
|
||||
void toggleHiddenState(Side side);
|
||||
|
||||
void setCenterWidget(Widget* widget);
|
||||
|
||||
Side getPreviewSide();
|
||||
|
||||
private:
|
||||
void updateActiveWindow(const tp::Events& events);
|
||||
void calculateSideAreas();
|
||||
void calculateResizeHandles();
|
||||
void handleResizeEvents(const Events& events);
|
||||
|
|
@ -27,43 +53,36 @@ namespace tp {
|
|||
|
||||
void calculateHeaderAreas();
|
||||
|
||||
|
||||
bool isSideVisible(Side side);
|
||||
bool isSideExists(Side side);
|
||||
ualni getVisibleSidesSize();
|
||||
void handlePreview(const Events& events);
|
||||
|
||||
private:
|
||||
// todo : make better grouping into structs
|
||||
RectF mPreviewArea = {};
|
||||
Side mPreviewSide = NONE;
|
||||
int resizeType[2] = { 0, 0 };
|
||||
|
||||
Widget* mSideWidgets[4] { nullptr, nullptr, nullptr, nullptr };
|
||||
public:
|
||||
SideWidgetData mSideWidgets[4];
|
||||
|
||||
private:
|
||||
Widget* mCenterWidget = nullptr;
|
||||
|
||||
alni mSideSplitOrder[4] = { -1, -1, -1, -1 };
|
||||
halnf mSideAbsoluteSize[4] { 200, 100, 200, 100 };
|
||||
bool mSideHidden[4] { true, false, false, false };
|
||||
halnf mSideSizePadding = 50.f;
|
||||
|
||||
// Geometry cache
|
||||
struct ResizeHandle {
|
||||
RectF area{ 0, 0, 0, 0 };
|
||||
Side side{ TOP };
|
||||
halnf start{ 0 };
|
||||
halnf end{ 0 };
|
||||
bool active = false;
|
||||
bool hover = false;
|
||||
};
|
||||
|
||||
Buffer<ResizeHandle> mResizeHandles;
|
||||
RectF mSideAreas[4];
|
||||
RectF mSideHeaderAreas[4];
|
||||
RectF mCenterArea {};
|
||||
|
||||
// View Parameters
|
||||
// Parameters
|
||||
halnf mSideSizePadding = 150.f;
|
||||
halnf mPadding = 4;
|
||||
halnf mHeaderSize = 27;
|
||||
halnf mRounding = 10;
|
||||
Vec2F mPreviewHandleSize = { 50, 50 };
|
||||
|
||||
RGBA mResizeHandleColorHovered = RGBA(0.3, 0.3, 0.3, 1);
|
||||
RGBA mResizeHandleColorActive = RGBA(0.6, 0.6, 0.6, 1);
|
||||
RGBA mBackgroundColor = RGBA(0, 0, 0, 1);
|
||||
RGBA mPreviewColor = RGBA(0.6, 0.6, 0.6, 1);
|
||||
|
||||
public:
|
||||
bool mPreview = false;
|
||||
};
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ namespace tp {
|
|||
RGBA handleColor;
|
||||
halnf handleSize = 0;
|
||||
halnf rounding = 0;
|
||||
halnf borderSize = 2;
|
||||
};
|
||||
|
||||
class NamedSliderWidget : public Widget {
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "LabelWidget.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
//TODO : clean up this mess
|
||||
// takes the whole parent area
|
||||
class SplitView : public Widget {
|
||||
public:
|
||||
SplitView();
|
||||
|
||||
void eventProcess(const Events& events) override;
|
||||
void eventDraw(Canvas& canvas) override;
|
||||
|
||||
[[nodiscard]] bool getFirstEnabled() const;
|
||||
[[nodiscard]] bool getSecondEnabled() const;
|
||||
|
||||
RectF getFirst() const;
|
||||
RectF getFirstHeader() const;
|
||||
RectF getSecondHeader() const;
|
||||
RectF getSecond() const ;
|
||||
RectF getHandle() const;
|
||||
|
||||
public:
|
||||
void eventUpdateConfiguration(WidgetManager& wm) override;
|
||||
|
||||
public:
|
||||
halnf mFactor = 0.7f;
|
||||
bool mResizeInProcess = false;
|
||||
bool mIsHover = false;
|
||||
|
||||
RGBA mHandleColor;
|
||||
RGBA mHoveredColor;
|
||||
RGBA mResizingColor;
|
||||
halnf mMinSize = 0;
|
||||
halnf mHandleSize = 0;
|
||||
|
||||
// Headers
|
||||
halnf mHeaderSize = 0;
|
||||
bool mHeaders = false;
|
||||
enum CollapsedSize { NONE, LEFT, RIGHT } mCollapsedSide = NONE;
|
||||
|
||||
LabelWidget mLeftLabel;
|
||||
LabelWidget mRightLabel;
|
||||
};
|
||||
}
|
||||
|
|
@ -20,7 +20,13 @@ namespace tp {
|
|||
void updateConfigWrapper(WidgetManager& wm);
|
||||
|
||||
virtual void eventProcess(const Events& events);
|
||||
|
||||
// draws before child widgets
|
||||
virtual void eventDraw(Canvas& canvas);
|
||||
|
||||
// draws overlay after child widgets
|
||||
virtual void eventDrawOver(Canvas& canvas);
|
||||
|
||||
virtual void eventUpdateConfiguration(WidgetManager& wm);
|
||||
|
||||
virtual void eventVisible(const Events& events);
|
||||
|
|
@ -52,6 +58,7 @@ namespace tp {
|
|||
|
||||
public:
|
||||
RectF mArea;
|
||||
RectF mVisibleArea;
|
||||
|
||||
List<Widget*> mChildWidgets;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "Animations.hpp"
|
||||
#include "ButtonWidget.hpp"
|
||||
#include "LabelWidget.hpp"
|
||||
#include "ScrollableWidget.hpp"
|
||||
#include "SplitViewWidget.hpp"
|
||||
#include "TextInputWidget.hpp"
|
||||
#include "SliderWidget.hpp"
|
||||
#include "CollapsableMenu.hpp"
|
||||
#include "FloatingWidget.hpp"
|
||||
#include "Animations.hpp"
|
||||
#include "DockspaceWidget.hpp"
|
||||
#include "FloatingLayoutWidget.hpp"
|
||||
#include "GridLayoutWidget.hpp"
|
||||
#include "WorkspaceWidget.hpp"
|
||||
|
|
|
|||
19
Widgets/public/WorkspaceWidget.hpp
Normal file
19
Widgets/public/WorkspaceWidget.hpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widgets.hpp"
|
||||
|
||||
namespace tp {
|
||||
class WorkspaceWidget : public Widget {
|
||||
public:
|
||||
WorkspaceWidget();
|
||||
|
||||
void eventProcess(const Events& events) override;
|
||||
|
||||
protected:
|
||||
GridLayoutWidget mDockSpace;
|
||||
FloatingLayoutWidget mFloatingLayer;
|
||||
|
||||
// Parameters
|
||||
Vec2F mDefaultFloatSize = { 200, 200 };
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue