mirror of
https://github.com/edubart/otclient.git
synced 2025-11-07 13:56:22 +01:00
rework ui related scripting stuff
This commit is contained in:
@@ -2,48 +2,60 @@
|
||||
#define UIANCHORLAYOUT_H
|
||||
|
||||
#include <global.h>
|
||||
#include <ui/uiconstants.h>
|
||||
#include <ui/uilayout.h>
|
||||
#include <ui/uielement.h>
|
||||
|
||||
class UIElement;
|
||||
typedef boost::shared_ptr<UIElement> UIElementPtr;
|
||||
typedef boost::weak_ptr<UIElement> UIElementWeakPtr;
|
||||
|
||||
enum AnchorPoint {
|
||||
AnchorNone = 0,
|
||||
AnchorTop,
|
||||
AnchorBottom,
|
||||
AnchorLeft,
|
||||
AnchorRight,
|
||||
AnchorVerticalCenter,
|
||||
AnchorHorizontalCenter,
|
||||
};
|
||||
|
||||
class AnchorLine
|
||||
{
|
||||
public:
|
||||
AnchorLine(const std::string& elementId, UI::AnchorPoint edge) : m_elementId(elementId), m_edge(edge) { }
|
||||
AnchorLine(const std::string& elementId, AnchorPoint edge) : m_elementId(elementId), m_edge(edge) { }
|
||||
AnchorLine(const AnchorLine& other) : m_elementId(other.m_elementId), m_edge(other.m_edge) { }
|
||||
UI::AnchorPoint getEdge() const { return m_edge; }
|
||||
AnchorPoint getEdge() const { return m_edge; }
|
||||
const std::string& getElementId() const { return m_elementId; }
|
||||
|
||||
private:
|
||||
std::string m_elementId;
|
||||
UI::AnchorPoint m_edge;
|
||||
AnchorPoint m_edge;
|
||||
};
|
||||
|
||||
class Anchor
|
||||
{
|
||||
public:
|
||||
Anchor(const UIElementPtr& anchoredElement, UI::AnchorPoint anchoredEdge, const AnchorLine& anchorLine)
|
||||
Anchor(const UIElementPtr& anchoredElement, AnchorPoint anchoredEdge, const AnchorLine& anchorLine)
|
||||
: m_anchoredElement(anchoredElement), m_anchoredEdge(anchoredEdge), m_anchorLine(anchorLine) { }
|
||||
UIElementPtr getAnchorLineElement() const ;
|
||||
UIElementPtr getAnchoredElement() const { return m_anchoredElement.lock(); }
|
||||
UI::AnchorPoint getAnchoredEdge() const { return m_anchoredEdge; }
|
||||
AnchorPoint getAnchoredEdge() const { return m_anchoredEdge; }
|
||||
int getAnchorLinePoint() const;
|
||||
|
||||
private:
|
||||
UIElementWeakPtr m_anchoredElement;
|
||||
UI::AnchorPoint m_anchoredEdge;
|
||||
AnchorPoint m_anchoredEdge;
|
||||
AnchorLine m_anchorLine;
|
||||
};
|
||||
|
||||
class UIAnchorLayout : public UILayout
|
||||
{
|
||||
public:
|
||||
bool addAnchor(const UIElementPtr& anchoredElement, UI::AnchorPoint anchoredEdge, const AnchorLine& anchorLine);
|
||||
bool addAnchor(const UIElementPtr& anchoredElement, AnchorPoint anchoredEdge, const AnchorLine& anchorLine);
|
||||
void recalculateElementLayout(const UIElementPtr& element);
|
||||
void recalculateChildrenLayout(const UIElementPtr& parent);
|
||||
|
||||
bool hasElementInAnchorTree(const UIElementPtr& element, const UIElementPtr& treeAnchor);
|
||||
static UI::AnchorPoint parseAnchorPoint(const std::string& anchorPointStr);
|
||||
static AnchorPoint parseAnchorPoint(const std::string& anchorPointStr);
|
||||
|
||||
private:
|
||||
std::vector<Anchor> m_anchors;
|
||||
|
||||
Reference in New Issue
Block a user