2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2016-07-10 03:10:27 +02:00
|
|
|
* Copyright (c) 2010-2016 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-26 17:06:52 +02:00
|
|
|
#ifndef UIANCHORLAYOUT_H
|
|
|
|
#define UIANCHORLAYOUT_H
|
|
|
|
|
|
|
|
#include "uilayout.h"
|
|
|
|
|
2013-02-18 17:16:22 +01:00
|
|
|
class UIAnchor : public stdext::shared_object
|
2011-08-26 17:06:52 +02:00
|
|
|
{
|
|
|
|
public:
|
2011-08-28 18:02:26 +02:00
|
|
|
UIAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge) :
|
2011-08-26 17:06:52 +02:00
|
|
|
m_anchoredEdge(anchoredEdge), m_hookedEdge(hookedEdge), m_hookedWidgetId(hookedWidgetId) { }
|
|
|
|
|
2011-08-28 18:02:26 +02:00
|
|
|
Fw::AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
|
|
|
|
Fw::AnchorEdge getHookedEdge() const { return m_hookedEdge; }
|
2011-08-26 17:06:52 +02:00
|
|
|
|
2013-02-18 17:16:22 +01:00
|
|
|
virtual UIWidgetPtr getHookedWidget(const UIWidgetPtr& widget, const UIWidgetPtr& parentWidget);
|
|
|
|
virtual int getHookedPoint(const UIWidgetPtr& hookedWidget, const UIWidgetPtr& parentWidget);
|
|
|
|
|
|
|
|
protected:
|
2011-08-28 18:02:26 +02:00
|
|
|
Fw::AnchorEdge m_anchoredEdge;
|
|
|
|
Fw::AnchorEdge m_hookedEdge;
|
2011-08-26 17:06:52 +02:00
|
|
|
std::string m_hookedWidgetId;
|
|
|
|
};
|
|
|
|
|
2013-02-18 17:16:22 +01:00
|
|
|
class UIAnchorGroup : public stdext::shared_object
|
2011-08-26 17:06:52 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
UIAnchorGroup() : m_updated(true) { }
|
|
|
|
|
2013-02-18 17:16:22 +01:00
|
|
|
void addAnchor(const UIAnchorPtr& anchor);
|
2012-06-17 17:21:46 +02:00
|
|
|
const UIAnchorList& getAnchors() { return m_anchors; }
|
|
|
|
bool isUpdated() { return m_updated; }
|
2011-08-26 17:06:52 +02:00
|
|
|
void setUpdated(bool updated) { m_updated = updated; }
|
|
|
|
|
|
|
|
private:
|
2011-08-28 18:31:01 +02:00
|
|
|
UIAnchorList m_anchors;
|
2011-08-26 17:06:52 +02:00
|
|
|
bool m_updated;
|
|
|
|
};
|
|
|
|
|
2012-06-22 05:14:13 +02:00
|
|
|
// @bindclass
|
2011-08-26 17:06:52 +02:00
|
|
|
class UIAnchorLayout : public UILayout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UIAnchorLayout(UIWidgetPtr parentWidget) : UILayout(parentWidget) { }
|
|
|
|
|
2011-08-28 18:02:26 +02:00
|
|
|
void addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
|
|
|
|
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge);
|
2011-08-26 17:06:52 +02:00
|
|
|
void removeAnchors(const UIWidgetPtr& anchoredWidget);
|
2012-03-28 16:10:21 +02:00
|
|
|
bool hasAnchors(const UIWidgetPtr& anchoredWidget);
|
2011-08-26 17:06:52 +02:00
|
|
|
void centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
|
|
|
void fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
|
|
|
|
|
|
|
void addWidget(const UIWidgetPtr& widget);
|
|
|
|
void removeWidget(const UIWidgetPtr& widget);
|
|
|
|
|
2012-07-29 05:34:40 +02:00
|
|
|
bool isUIAnchorLayout() { return true; }
|
2011-08-26 17:06:52 +02:00
|
|
|
|
2012-01-08 23:32:55 +01:00
|
|
|
protected:
|
2013-02-18 17:16:22 +01:00
|
|
|
virtual bool internalUpdate();
|
|
|
|
virtual bool updateWidget(const UIWidgetPtr& widget, const UIAnchorGroupPtr& anchorGroup, UIWidgetPtr first = nullptr);
|
|
|
|
std::unordered_map<UIWidgetPtr, UIAnchorGroupPtr> m_anchorsGroups;
|
2011-08-26 17:06:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|