reorganize sources

This commit is contained in:
Eduardo Bart
2011-08-15 11:06:15 -03:00
parent 4e03b15b27
commit d8cc37afdb
113 changed files with 621 additions and 3437 deletions

50
src/framework/ui/const.h Normal file
View File

@@ -0,0 +1,50 @@
#ifndef FRAMEWORK_UI_CONST_H
#define FRAMEWORK_UI_CONST_H
// namespace ui {
enum UIWidgetType {
UITypeWidget = 0,
UITypeLabel,
UITypeButton,
UITypeLineEdit,
UITypeWindow,
UITypeList
};
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
};
enum ButtonState {
ButtonUp = 0,
ButtonDown,
ButtonHover
};
// }
#endif

View File

@@ -0,0 +1,29 @@
#ifndef FRAMEWORK_UI_DECLARATIONS_H
#define FRAMEWORK_UI_DECLARATIONS_H
#include <framework/global.h>
#include "const.h"
class UIManager;
class UILayout;
class UIAnchorLayout;
class UIStyle;
class UIWidget;
class UILabel;
class UIButton;
class UILineEdit;
class UIWindow;
typedef std::shared_ptr<UIWidget> UIWidgetPtr;
typedef std::weak_ptr<UIWidget> UIWidgetWeakPtr;
typedef std::deque<UIWidgetPtr> UIWidgetList;
typedef std::shared_ptr<UILayout> UILayoutPtr;
typedef std::shared_ptr<UIAnchorLayout> UIAnchorLayoutPtr;
typedef std::shared_ptr<UIStyle> UIStylePtr;
typedef std::shared_ptr<UILabel> UILabelPtr;
typedef std::shared_ptr<UIButton> UIButtonPtr;
typedef std::shared_ptr<UILineEdit> UILineEditPtr;
typedef std::shared_ptr<UIWindow> UIWindowPtr;
#endif

View File

@@ -1,7 +1,7 @@
#ifndef UIANCHOR_H
#define UIANCHOR_H
#include "uideclarations.h"
#include "declarations.h"
struct AnchorLine {
AnchorLine(std::string widgetId, AnchorPoint edge) : widgetId(widgetId), edge(edge) { }

View File

@@ -1,8 +1,8 @@
#include "uibutton.h"
#include <graphics/borderimage.h>
#include <graphics/font.h>
#include <otml/otmlnode.h>
#include <luascript/luainterface.h>
#include <framework/graphics/borderimage.h>
#include <framework/graphics/font.h>
#include <framework/otml/otmlnode.h>
#include <framework/luascript/luainterface.h>
UIButton::UIButton(): UIWidget(UITypeButton)
{
@@ -37,7 +37,7 @@ void UIButton::loadStyleFromOTML(const OTMLNodePtr& styleNode)
if(OTMLNodePtr node = styleNode->get("state.down"))
loadStateStyle(m_statesStyle[ButtonDown], node);
m_text = styleNode->readAt("text", aux::empty_string);
m_text = styleNode->readAt("text", fw::empty_string);
if(OTMLNodePtr node = styleNode->get("onClick")) {
g_lua.loadFunction(node->read<std::string>(), "@" + node->source() + "[" + node->tag() + "]");

View File

@@ -1,70 +0,0 @@
#ifndef UIDECLARATIONS_H
#define UIDECLARATIONS_H
#include <global.h>
class UIManager;
class UILayout;
class UIAnchorLayout;
class UIStyle;
class UIWidget;
class UILabel;
class UIButton;
class UILineEdit;
class UIWindow;
typedef std::shared_ptr<UIWidget> UIWidgetPtr;
typedef std::weak_ptr<UIWidget> UIWidgetWeakPtr;
typedef std::deque<UIWidgetPtr> UIWidgetList;
typedef std::shared_ptr<UILayout> UILayoutPtr;
typedef std::shared_ptr<UIAnchorLayout> UIAnchorLayoutPtr;
typedef std::shared_ptr<UIStyle> UIStylePtr;
typedef std::shared_ptr<UILabel> UILabelPtr;
typedef std::shared_ptr<UIButton> UIButtonPtr;
typedef std::shared_ptr<UILineEdit> UILineEditPtr;
typedef std::shared_ptr<UIWindow> UIWindowPtr;
enum UIWidgetType {
UITypeWidget = 0,
UITypeLabel,
UITypeButton,
UITypeLineEdit,
UITypeWindow,
UITypeList
};
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
};
enum ButtonState {
ButtonUp = 0,
ButtonDown,
ButtonHover
};
#endif

View File

@@ -1,8 +1,8 @@
#ifndef UIEVENT_H
#define UIEVENT_H
#include <core/inputevent.h>
#include "uideclarations.h"
#include <framework/platform/platformevent.h>
#include "declarations.h"
class UIEvent
{

View File

@@ -1,6 +1,6 @@
#include "uilabel.h"
#include <graphics/font.h>
#include <otml/otmlnode.h>
#include <framework/graphics/font.h>
#include <framework/otml/otmlnode.h>
UILabel::UILabel() : UIWidget(UITypeLabel)
{
@@ -21,7 +21,7 @@ void UILabel::loadStyleFromOTML(const OTMLNodePtr& styleNode)
m_text = styleNode->readAt("text", m_text);
if(styleNode->hasChild("align"))
m_align = parseAlignment(styleNode->readAt<std::string>("align"));
m_align = fw::translateAlignment(styleNode->readAt<std::string>("align"));
// auto resize if no size supplied
if(!m_text.empty() && !getGeometry().isValid())

View File

@@ -1,7 +1,7 @@
#ifndef UILAYOUT_H
#define UILAYOUT_H
#include "uideclarations.h"
#include "declarations.h"
class UILayout
{

View File

@@ -1,8 +1,8 @@
#include "uilineedit.h"
#include <graphics/font.h>
#include <graphics/graphics.h>
#include <core/platform.h>
#include <otml/otmlnode.h>
#include <framework/graphics/font.h>
#include <framework/graphics/graphics.h>
#include <framework/platform/platform.h>
#include <framework/otml/otmlnode.h>
UILineEdit::UILineEdit() : UIWidget(UITypeLabel)
{

View File

@@ -0,0 +1,32 @@
#include "uilist.h"
UIList::UIList() : UIWidget(UITypeList)
{
}
void UIList::loadStyleFromOTML(const OTMLNodePtr& styleNode)
{
}
void UIList::render()
{
}
void UIList::onKeyPress(UIKeyEvent& event)
{
}
void UIList::onMousePress(UIMouseEvent& event)
{
}
void UIList::onMouseMove(UIMouseEvent& event)
{
}

23
src/framework/ui/uilist.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef UILIST_H
#define UILIST_H
#include "uiwidget.h"
class UIList : public UIWidget
{
public:
UIList();
virtual void loadStyleFromOTML(const OTMLNodePtr& styleNode);
virtual void render();
protected:
virtual void onKeyPress(UIKeyEvent& event);
virtual void onMousePress(UIMouseEvent& event);
virtual void onMouseMove(UIMouseEvent& event);
private:
std::list<std::string> m_items;
};
#endif

View File

@@ -2,8 +2,8 @@
#include "ui.h"
#include "uianchorlayout.h"
#include <otml/otml.h>
#include <graphics/graphics.h>
#include <framework/otml/otml.h>
#include <framework/graphics/graphics.h>
UIManager g_ui;
@@ -136,7 +136,7 @@ OTMLNodePtr UIManager::getStyle(const std::string& styleName)
auto it = m_styles.find(styleName);
if(it == m_styles.end())
throw std::logic_error(aux::make_string("style '", styleName, "' is not a defined style"));
throw std::logic_error(fw::mkstr("style '", styleName, "' is not a defined style"));
return m_styles[styleName];
}

View File

@@ -1,9 +1,9 @@
#ifndef UIMANAGER_H
#define UIMANAGER_H
#include "uideclarations.h"
#include <core/inputevent.h>
#include <otml/otmldeclarations.h>
#include "declarations.h"
#include <framework/platform/platformevent.h>
#include <framework/otml/declarations.h>
class UIManager
{

View File

@@ -3,12 +3,12 @@
#include "uilayout.h"
#include "uianchorlayout.h"
#include <core/eventdispatcher.h>
#include <graphics/image.h>
#include <graphics/borderimage.h>
#include <graphics/fontmanager.h>
#include <otml/otmlnode.h>
#include <graphics/graphics.h>
#include <framework/core/eventdispatcher.h>
#include <framework/graphics/image.h>
#include <framework/graphics/borderimage.h>
#include <framework/graphics/fontmanager.h>
#include <framework/otml/otmlnode.h>
#include <framework/graphics/graphics.h>
UIWidget::UIWidget(UIWidgetType type)
{
@@ -26,7 +26,7 @@ UIWidget::UIWidget(UIWidgetType type)
// generate an unique id, this is need because anchored layouts find widgets by id
static unsigned long id = 1;
m_id = aux::make_string("widget", id++);
m_id = fw::mkstr("widget", id++);
}
UIWidget::~UIWidget()
@@ -172,7 +172,7 @@ void UIWidget::loadStyleFromOTML(const OTMLNodePtr& styleNode)
} else if(what == "centerIn") {
centerIn(node->value());
} else {
AnchorPoint myEdge = parseAnchorPoint(what);
AnchorPoint myEdge = fw::translateAnchorPoint(what);
std::string anchorDescription = node->value();
std::vector<std::string> split;
@@ -181,7 +181,7 @@ void UIWidget::loadStyleFromOTML(const OTMLNodePtr& styleNode)
throw OTMLException(node, "invalid anchor description");
std::string target = split[0];
AnchorPoint targetEdge = parseAnchorPoint(split[1]);
AnchorPoint targetEdge = fw::translateAnchorPoint(split[1]);
if(myEdge == AnchorNone)
throw OTMLException(node, "invalid anchor edge");

View File

@@ -1,11 +1,11 @@
#ifndef UIWIDGET_H
#define UIWIDGET_H
#include "uideclarations.h"
#include "declarations.h"
#include "uievent.h"
#include <luascript/luaobject.h>
#include <graphics/graphicsdeclarations.h>
#include <otml/otmldeclarations.h>
#include <framework/luascript/luaobject.h>
#include <framework/graphics/declarations.h>
#include <framework/otml/declarations.h>
class UIWidget : public LuaObject
{

View File

@@ -1,7 +1,7 @@
#include "uiwindow.h"
#include <graphics/borderimage.h>
#include <graphics/font.h>
#include <otml/otml.h>
#include <framework/graphics/borderimage.h>
#include <framework/graphics/font.h>
#include <framework/otml/otml.h>
UIWindow::UIWindow(): UIWidget(UITypeWindow)
{
@@ -25,7 +25,7 @@ void UIWindow::loadStyleFromOTML(const OTMLNodePtr& styleNode)
m_headImage = BorderImage::loadFromOTML(node);
m_headHeight = headNode->readAt("height", m_headImage->getDefaultSize().height());
m_headMargin = headNode->readAt("margin", 0);
m_titleAlign = parseAlignment(headNode->readAt("text align", std::string("center")));
m_titleAlign = fw::translateAlignment(headNode->readAt("text align", std::string("center")));
} else {
m_headHeight = 0;
m_headMargin = 0;
@@ -37,7 +37,7 @@ void UIWindow::loadStyleFromOTML(const OTMLNodePtr& styleNode)
m_bodyImage = BorderImage::loadFromOTML(node);
}
m_title = styleNode->readAt("title", aux::empty_string);
m_title = styleNode->readAt("title", fw::empty_string);
}
void UIWindow::render()