commit
8f27ff60ac
@ -0,0 +1,21 @@
|
|||||||
|
Window
|
||||||
|
id: messageBoxWindow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
height: 80
|
||||||
|
width: 120
|
||||||
|
|
||||||
|
Label
|
||||||
|
id: messageBoxLabel
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.top: parent.top
|
||||||
|
margin.top: 27
|
||||||
|
margin.bottom : 27
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: messageBoxRightButton
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
margin.right: 10
|
||||||
|
margin.bottom: 10
|
||||||
|
width: 64
|
||||||
|
visible: true
|
@ -0,0 +1,5 @@
|
|||||||
|
TextList < UIWidget
|
||||||
|
size: 200 200
|
||||||
|
border-image:
|
||||||
|
source: /core_ui/images/panel_flat.png
|
||||||
|
border: 4
|
@ -0,0 +1,30 @@
|
|||||||
|
UI = { }
|
||||||
|
UI.root = getRootWidget()
|
||||||
|
|
||||||
|
function UI.loadAndDisplayLocked(otuiFile)
|
||||||
|
local widget = loadUI(otuiFile, UI.root)
|
||||||
|
UI.root:lockChild(widget)
|
||||||
|
return widget
|
||||||
|
end
|
||||||
|
|
||||||
|
function UI.loadAndDisplay(otuiFile)
|
||||||
|
local widget = loadUI(otuiFile, UI.root)
|
||||||
|
return widget
|
||||||
|
end
|
||||||
|
|
||||||
|
function UI.display(widget)
|
||||||
|
UI.root:addChild(widget)
|
||||||
|
end
|
||||||
|
|
||||||
|
function UI.displayLocked(widget)
|
||||||
|
UI.root:addChild(widget)
|
||||||
|
UI.root:lockChild(widget)
|
||||||
|
end
|
||||||
|
|
||||||
|
importStyles('styles/buttons.otui')
|
||||||
|
importStyles('styles/labels.otui')
|
||||||
|
importStyles('styles/panels.otui')
|
||||||
|
importStyles('styles/separators.otui')
|
||||||
|
importStyles('styles/lineedits.otui')
|
||||||
|
importStyles('styles/windows.otui')
|
||||||
|
importStyles('styles/listboxes.otui')
|
@ -0,0 +1,34 @@
|
|||||||
|
MainWindow
|
||||||
|
id: charactersWindow
|
||||||
|
title: Charlist
|
||||||
|
size: 200 250
|
||||||
|
|
||||||
|
TextList
|
||||||
|
id: charactersList
|
||||||
|
anchors.fill: parent
|
||||||
|
margin.top: 30
|
||||||
|
margin.bottom: 50
|
||||||
|
margin.left: 16
|
||||||
|
margin.right: 16
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: buttonOk
|
||||||
|
text: Ok
|
||||||
|
width: 64
|
||||||
|
anchors.right: next.left
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
margin.bottom: 16
|
||||||
|
margin.right: 16
|
||||||
|
|
||||||
|
Button
|
||||||
|
id: buttonCancel
|
||||||
|
text: Cancel
|
||||||
|
width: 64
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
margin.bottom: 16
|
||||||
|
margin.right: 16
|
||||||
|
onClick: |
|
||||||
|
function(self)
|
||||||
|
self:getParent():destroy()
|
||||||
|
end
|
@ -0,0 +1 @@
|
|||||||
|
--UI.loadAndDisplayLocked('/mainmenu/ui/charlist.otui')
|
@ -0,0 +1,10 @@
|
|||||||
|
Module
|
||||||
|
name: playground
|
||||||
|
autoLoad: true
|
||||||
|
dependencies:
|
||||||
|
- core
|
||||||
|
|
||||||
|
onLoad: |
|
||||||
|
require 'playground'
|
||||||
|
return true
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
#ifndef FRAMEWORK_UI_CONST_H
|
|
||||||
#define FRAMEWORK_UI_CONST_H
|
|
||||||
|
|
||||||
// namespace ui {
|
|
||||||
|
|
||||||
namespace UI {
|
|
||||||
|
|
||||||
enum FocusReason {
|
|
||||||
MouseFocusReason = 0,
|
|
||||||
TabFocusReason,
|
|
||||||
ActiveFocusReason,
|
|
||||||
OtherFocusReason
|
|
||||||
};
|
|
||||||
|
|
||||||
enum MouseButton {
|
|
||||||
MouseNoButton = 0,
|
|
||||||
MouseLeftButton,
|
|
||||||
MouseRightButton,
|
|
||||||
MouseMidButton
|
|
||||||
};
|
|
||||||
|
|
||||||
enum MouseWheelDirection {
|
|
||||||
MouseNoWheel = 0,
|
|
||||||
MouseWheelUp,
|
|
||||||
MouseWheelDown
|
|
||||||
};
|
|
||||||
|
|
||||||
enum KeyboardModifier {
|
|
||||||
KeyboardNoModifier = 0,
|
|
||||||
KeyboardCtrlModifier = 1,
|
|
||||||
KeyboardAltModifier = 2,
|
|
||||||
KeyboardShiftModifier = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
#include "uianchor.h"
|
|
||||||
#include "uiwidget.h"
|
|
||||||
|
|
||||||
UIAnchor::UIAnchor(AnchorEdge anchoredEdge, const std::string& hookedWidgetId, AnchorEdge hookedEdge) :
|
|
||||||
m_anchoredEdge(anchoredEdge), m_hookedWidgetId(hookedWidgetId), m_hookedEdge(hookedEdge) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int UIAnchor::getHookedPoint() const {
|
|
||||||
UIWidgetPtr hookedWidget = getHookedWidget();
|
|
||||||
|
|
||||||
if(hookedWidget) {
|
|
||||||
switch(m_hookedEdge) {
|
|
||||||
case AnchorLeft:
|
|
||||||
return hookedWidget->getRect().left();
|
|
||||||
case AnchorRight:
|
|
||||||
return hookedWidget->getRect().right();
|
|
||||||
case AnchorTop:
|
|
||||||
return hookedWidget->getRect().top();
|
|
||||||
case AnchorBottom:
|
|
||||||
return hookedWidget->getRect().bottom();
|
|
||||||
case AnchorHorizontalCenter:
|
|
||||||
return hookedWidget->getRect().horizontalCenter();
|
|
||||||
case AnchorVerticalCenter:
|
|
||||||
return hookedWidget->getRect().verticalCenter();
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return INVALID_POINT;
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#ifndef UIANCHOR_H
|
|
||||||
#define UIANCHOR_H
|
|
||||||
|
|
||||||
#include "declarations.h"
|
|
||||||
|
|
||||||
class UIAnchor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
INVALID_POINT = -999999
|
|
||||||
};
|
|
||||||
|
|
||||||
UIAnchor(AnchorEdge anchoredEdge, const std::string& hookedWidgetId, AnchorEdge hookedEdge);
|
|
||||||
|
|
||||||
AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
|
|
||||||
UIWidgetPtr getHookedWidget() const { return m_hookedWidget.lock(); }
|
|
||||||
std::string getHookedWidgetId() const { return m_hookedWidgetId; }
|
|
||||||
int getHookedPoint() const;
|
|
||||||
|
|
||||||
void setHookedWidget(const UIWidgetPtr hookedWidget) { m_hookedWidget = hookedWidget; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
AnchorEdge m_anchoredEdge;
|
|
||||||
UIWidgetWeakPtr m_hookedWidget;
|
|
||||||
std::string m_hookedWidgetId;
|
|
||||||
AnchorEdge m_hookedEdge;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -0,0 +1,190 @@
|
|||||||
|
#include "uianchorlayout.h"
|
||||||
|
#include "uiwidget.h"
|
||||||
|
|
||||||
|
void UIAnchorGroup::addAnchor(const UIAnchor& anchor)
|
||||||
|
{
|
||||||
|
// duplicated anchors must be replaced
|
||||||
|
for(UIAnchor& other : m_anchors) {
|
||||||
|
if(other.getAnchoredEdge() == anchor.getAnchoredEdge()) {
|
||||||
|
other = anchor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_anchors.push_back(anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::addAnchor(const UIWidgetPtr& anchoredWidget, AnchorEdge anchoredEdge,
|
||||||
|
const std::string& hookedWidgetId, AnchorEdge hookedEdge)
|
||||||
|
{
|
||||||
|
if(!anchoredWidget)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert(anchoredWidget != getParentWidget());
|
||||||
|
|
||||||
|
UIAnchor anchor(anchoredEdge, hookedWidgetId, hookedEdge);
|
||||||
|
UIAnchorGroup& anchorGroup = m_anchorsGroups[anchoredWidget];
|
||||||
|
anchorGroup.addAnchor(anchor);
|
||||||
|
|
||||||
|
// layout must be updated because a new anchor got in
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::removeAnchors(const UIWidgetPtr& anchoredWidget)
|
||||||
|
{
|
||||||
|
m_anchorsGroups.erase(anchoredWidget);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
|
||||||
|
{
|
||||||
|
addAnchor(anchoredWidget, AnchorHorizontalCenter, hookedWidgetId, AnchorHorizontalCenter);
|
||||||
|
addAnchor(anchoredWidget, AnchorVerticalCenter, hookedWidgetId, AnchorVerticalCenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
|
||||||
|
{
|
||||||
|
addAnchor(anchoredWidget, AnchorLeft, hookedWidgetId, AnchorLeft);
|
||||||
|
addAnchor(anchoredWidget, AnchorRight, hookedWidgetId, AnchorRight);
|
||||||
|
addAnchor(anchoredWidget, AnchorTop, hookedWidgetId, AnchorTop);
|
||||||
|
addAnchor(anchoredWidget, AnchorBottom, hookedWidgetId, AnchorBottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::update()
|
||||||
|
{
|
||||||
|
// reset all anchors groups update state
|
||||||
|
for(auto& it : m_anchorsGroups) {
|
||||||
|
UIAnchorGroup& anchorGroup = it.second;
|
||||||
|
anchorGroup.setUpdated(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update all anchors
|
||||||
|
for(auto& it : m_anchorsGroups) {
|
||||||
|
const UIWidgetPtr& widget = it.first;
|
||||||
|
UIAnchorGroup& anchorGroup = it.second;
|
||||||
|
if(!anchorGroup.isUpdated())
|
||||||
|
updateWidget(widget, anchorGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::addWidget(const UIWidgetPtr& widget)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::removeWidget(const UIWidgetPtr& widget)
|
||||||
|
{
|
||||||
|
removeAnchors(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup)
|
||||||
|
{
|
||||||
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
|
Rect newRect = widget->getRect();
|
||||||
|
bool verticalMoved = false;
|
||||||
|
bool horizontalMoved = false;
|
||||||
|
|
||||||
|
// calculates new rect based on anchors
|
||||||
|
for(const UIAnchor& anchor : anchorGroup.getAnchors()) {
|
||||||
|
// skip invalid anchors
|
||||||
|
if(anchor.getHookedEdge() == AnchorNone)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// determine hooked widget
|
||||||
|
UIWidgetPtr hookedWidget;
|
||||||
|
if(parentWidget) {
|
||||||
|
if(anchor.getHookedWidgetId() == "parent")
|
||||||
|
hookedWidget = parentWidget;
|
||||||
|
else if(anchor.getHookedWidgetId() == "next")
|
||||||
|
hookedWidget = parentWidget->getChildAfter(widget);
|
||||||
|
else if(anchor.getHookedWidgetId() == "prev")
|
||||||
|
hookedWidget = parentWidget->getChildBefore(widget);
|
||||||
|
else
|
||||||
|
hookedWidget = parentWidget->getChildById(anchor.getHookedWidgetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip invalid anchors
|
||||||
|
if(!hookedWidget)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(hookedWidget != getParentWidget()) {
|
||||||
|
// update this hooked widget anchors
|
||||||
|
auto it = m_anchorsGroups.find(hookedWidget);
|
||||||
|
if(it != m_anchorsGroups.end()) {
|
||||||
|
UIAnchorGroup& hookedAnchorGroup = it->second;
|
||||||
|
if(!hookedAnchorGroup.isUpdated())
|
||||||
|
updateWidget(hookedWidget, hookedAnchorGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine hooked widget edge point
|
||||||
|
int point = 0;
|
||||||
|
switch(anchor.getHookedEdge()) {
|
||||||
|
case AnchorLeft:
|
||||||
|
point = hookedWidget->getRect().left();
|
||||||
|
break;
|
||||||
|
case AnchorRight:
|
||||||
|
point = hookedWidget->getRect().right();
|
||||||
|
break;
|
||||||
|
case AnchorTop:
|
||||||
|
point = hookedWidget->getRect().top();
|
||||||
|
break;
|
||||||
|
case AnchorBottom:
|
||||||
|
point = hookedWidget->getRect().bottom();
|
||||||
|
break;
|
||||||
|
case AnchorHorizontalCenter:
|
||||||
|
point = hookedWidget->getRect().horizontalCenter();
|
||||||
|
break;
|
||||||
|
case AnchorVerticalCenter:
|
||||||
|
point = hookedWidget->getRect().verticalCenter();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// must never happens
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(anchor.getAnchoredEdge()) {
|
||||||
|
case AnchorHorizontalCenter:
|
||||||
|
newRect.moveHorizontalCenter(point + widget->getMarginLeft() - widget->getMarginRight());
|
||||||
|
horizontalMoved = true;
|
||||||
|
break;
|
||||||
|
case AnchorLeft:
|
||||||
|
if(!horizontalMoved) {
|
||||||
|
newRect.moveLeft(point + widget->getMarginLeft());
|
||||||
|
horizontalMoved = true;
|
||||||
|
} else
|
||||||
|
newRect.setLeft(point + widget->getMarginLeft());
|
||||||
|
break;
|
||||||
|
case AnchorRight:
|
||||||
|
if(!horizontalMoved) {
|
||||||
|
newRect.moveRight(point - widget->getMarginRight());
|
||||||
|
horizontalMoved = true;
|
||||||
|
} else
|
||||||
|
newRect.setRight(point - widget->getMarginRight());
|
||||||
|
break;
|
||||||
|
case AnchorVerticalCenter:
|
||||||
|
newRect.moveVerticalCenter(point + widget->getMarginTop() - widget->getMarginBottom());
|
||||||
|
verticalMoved = true;
|
||||||
|
break;
|
||||||
|
case AnchorTop:
|
||||||
|
if(!verticalMoved) {
|
||||||
|
newRect.moveTop(point + widget->getMarginTop());
|
||||||
|
verticalMoved = true;
|
||||||
|
} else
|
||||||
|
newRect.setTop(point + widget->getMarginTop());
|
||||||
|
break;
|
||||||
|
case AnchorBottom:
|
||||||
|
if(!verticalMoved) {
|
||||||
|
newRect.moveBottom(point - widget->getMarginBottom());
|
||||||
|
verticalMoved = true;
|
||||||
|
} else
|
||||||
|
newRect.setBottom(point - widget->getMarginBottom());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
widget->setRect(newRect);
|
||||||
|
anchorGroup.setUpdated(true);
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
#ifndef UIANCHORLAYOUT_H
|
||||||
|
#define UIANCHORLAYOUT_H
|
||||||
|
|
||||||
|
#include "uilayout.h"
|
||||||
|
|
||||||
|
class UIAnchor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UIAnchor(AnchorEdge anchoredEdge, const std::string& hookedWidgetId, AnchorEdge hookedEdge) :
|
||||||
|
m_anchoredEdge(anchoredEdge), m_hookedEdge(hookedEdge), m_hookedWidgetId(hookedWidgetId) { }
|
||||||
|
|
||||||
|
AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
|
||||||
|
std::string getHookedWidgetId() const { return m_hookedWidgetId; }
|
||||||
|
AnchorEdge getHookedEdge() const { return m_hookedEdge; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
AnchorEdge m_anchoredEdge;
|
||||||
|
AnchorEdge m_hookedEdge;
|
||||||
|
std::string m_hookedWidgetId;
|
||||||
|
};
|
||||||
|
|
||||||
|
class UIAnchorGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UIAnchorGroup() : m_updated(true) { }
|
||||||
|
|
||||||
|
void addAnchor(const UIAnchor& anchor);
|
||||||
|
const std::vector<UIAnchor>& getAnchors() const { return m_anchors; }
|
||||||
|
bool isUpdated() const { return m_updated; }
|
||||||
|
void setUpdated(bool updated) { m_updated = updated; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<UIAnchor> m_anchors;
|
||||||
|
bool m_updated;
|
||||||
|
};
|
||||||
|
|
||||||
|
class UIAnchorLayout : public UILayout
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UIAnchorLayout(UIWidgetPtr parentWidget) : UILayout(parentWidget) { }
|
||||||
|
|
||||||
|
void addAnchor(const UIWidgetPtr& anchoredWidget, AnchorEdge anchoredEdge,
|
||||||
|
const std::string& hookedWidgetId, AnchorEdge hookedEdge);
|
||||||
|
void removeAnchors(const UIWidgetPtr& anchoredWidget);
|
||||||
|
void centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||||
|
void fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||||
|
|
||||||
|
void update();
|
||||||
|
void addWidget(const UIWidgetPtr& widget);
|
||||||
|
void removeWidget(const UIWidgetPtr& widget);
|
||||||
|
|
||||||
|
UIAnchorLayoutPtr asUIAnchorLayout() { return std::static_pointer_cast<UIAnchorLayout>(shared_from_this()); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anchorGroup);
|
||||||
|
std::map<UIWidgetPtr, UIAnchorGroup> m_anchorsGroups;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1 @@
|
|||||||
|
#include "uilayout.h"
|
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef UILAYOUT_H
|
||||||
|
#define UILAYOUT_H
|
||||||
|
|
||||||
|
#include "declarations.h"
|
||||||
|
#include <framework/luascript/luaobject.h>
|
||||||
|
|
||||||
|
class UILayout : public LuaObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UILayout(UIWidgetPtr parentWidget) : m_parentWidget(parentWidget) { }
|
||||||
|
|
||||||
|
virtual void update() = 0;
|
||||||
|
virtual void addWidget(const UIWidgetPtr& widget) = 0;
|
||||||
|
virtual void removeWidget(const UIWidgetPtr& widget) = 0;
|
||||||
|
|
||||||
|
UIWidgetPtr getParentWidget() { return m_parentWidget.lock(); }
|
||||||
|
|
||||||
|
virtual UIAnchorLayoutPtr asUIAnchorLayout() { return nullptr; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UIWidgetWeakPtr m_parentWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,32 +0,0 @@
|
|||||||
#include "uilist.h"
|
|
||||||
|
|
||||||
UIList::UIList()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIList::onStyleApply(const OTMLNodePtr& styleNode)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIList::render()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UIList::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UIList::onMousePress(const Point& mousePos, UI::MouseButton button)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UIList::onMouseMove(const Point& mousePos, const Point& mouseMoved)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
#ifndef UILIST_H
|
|
||||||
#define UILIST_H
|
|
||||||
|
|
||||||
#include "uiwidget.h"
|
|
||||||
|
|
||||||
class UIList : public UIWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
UIList();
|
|
||||||
|
|
||||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
|
||||||
virtual void render();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers);
|
|
||||||
virtual bool onMousePress(const Point& mousePos, UI::MouseButton button);
|
|
||||||
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::list<std::string> m_items;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -0,0 +1,37 @@
|
|||||||
|
#include "uiverticallayout.h"
|
||||||
|
#include "uiwidget.h"
|
||||||
|
|
||||||
|
UIVerticalLayout::UIVerticalLayout(UIWidgetPtr parentWidget)
|
||||||
|
: UILayout(parentWidget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIVerticalLayout::update()
|
||||||
|
{
|
||||||
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
|
UIWidgetList widgets = parentWidget->getChildren();
|
||||||
|
Point pos = parentWidget->getPosition();
|
||||||
|
for(const UIWidgetPtr& widget : widgets) {
|
||||||
|
Size size = widget->getSize();
|
||||||
|
pos.y += widget->getMarginTop();
|
||||||
|
if(widget->isSizeFixed()) {
|
||||||
|
pos.x = parentWidget->getX() + (parentWidget->getWidth() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2;
|
||||||
|
pos.x = std::max(pos.x, parentWidget->getX());
|
||||||
|
} else {
|
||||||
|
size.setWidth(parentWidget->getWidth() - (widget->getMarginLeft() + widget->getMarginRight()));
|
||||||
|
pos.x = std::max(pos.x, parentWidget->getX() + (parentWidget->getWidth() - size.width())/2);
|
||||||
|
}
|
||||||
|
widget->setRect(Rect(pos, size));
|
||||||
|
pos.y += widget->getHeight() + widget->getMarginBottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIVerticalLayout::addWidget(const UIWidgetPtr& widget)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIVerticalLayout::removeWidget(const UIWidgetPtr& widget)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef UIVERTICALLAYOUT_H
|
||||||
|
#define UIVERTICALLAYOUT_H
|
||||||
|
|
||||||
|
#include "uilayout.h"
|
||||||
|
|
||||||
|
class UIVerticalLayout : public UILayout
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UIVerticalLayout(UIWidgetPtr parentWidget);
|
||||||
|
|
||||||
|
virtual void update();
|
||||||
|
virtual void addWidget(const UIWidgetPtr& widget);
|
||||||
|
virtual void removeWidget(const UIWidgetPtr& widget);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue