This commit is contained in:
Eduardo Bart
2011-04-17 16:14:24 -03:00
93 changed files with 862 additions and 824 deletions

View File

@@ -25,19 +25,20 @@
#ifndef UI_H
#define UI_H
#include "prerequisites.h"
#include <prerequisites.h>
#include <ui/uiconstants.h>
#include "uiconstants.h"
#include "uielement.h"
#include "uicontainer.h"
#include "uipanel.h"
#include "uibutton.h"
#include "uilabel.h"
#include "uiskins.h"
#include "uiwindow.h"
#include "uitextedit.h"
#include "uiloader.h"
#include "uilinedecoration.h"
#include "uicheckbox.h"
#include <ui/uiskins.h>
#include <ui/uiloader.h>
#include <ui/uielement.h>
#include <ui/uielementskin.h>
#include <ui/uicontainer.h>
#include <ui/uibutton.h>
#include <ui/uilabel.h>
#include <ui/uiwindow.h>
#include <ui/uitextedit.h>
#include <ui/uicheckbox.h>
#endif // UI_H

View File

@@ -22,8 +22,9 @@
*/
#include "uibutton.h"
#include "core/dispatcher.h"
#include <prerequisites.h>
#include <core/dispatcher.h>
#include <ui/uibutton.h>
void UIButton::onInputEvent(const InputEvent& event)
{

View File

@@ -25,9 +25,9 @@
#ifndef UIBUTTON_H
#define UIBUTTON_H
#include "prerequisites.h"
#include "uielement.h"
#include "graphics/borderedimage.h"
#include <prerequisites.h>
#include <ui/uielement.h>
#include <graphics/borderedimage.h>
class UIButton : public UIElement
{

View File

@@ -22,9 +22,10 @@
*/
#include "uibuttonskin.h"
#include "uibutton.h"
#include "graphics/fonts.h"
#include <prerequisites.h>
#include <graphics/fonts.h>
#include <ui/uibuttonskin.h>
#include <ui/uibutton.h>
void UIButtonSkin::load(const YAML::Node& node)
{

View File

@@ -25,9 +25,9 @@
#ifndef UIBUTTONSKIN_H
#define UIBUTTONSKIN_H
#include "prerequisites.h"
#include "uiconstants.h"
#include "uielementskin.h"
#include <prerequisites.h>
#include <ui/uiconstants.h>
#include <ui/uielementskin.h>
class Font;

View File

@@ -1,4 +1,29 @@
#include "uicheckbox.h"
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* 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.
*/
#include <prerequisites.h>
#include <ui/uicheckbox.h>
UICheckBox::UICheckBox(UI::EElementType type): UIElement(type)
{

View File

@@ -1,9 +1,33 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* 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.
*/
#ifndef UICHECKBOX_H
#define UICHECKBOX_H
#include <prerequisites.h>
#include <ui/uielement.h>
class UICheckBox : public UIElement
{

View File

@@ -1,2 +1,27 @@
#include "uicheckboxskin.h"
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* 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.
*/
#include <prerequisites.h>
#include <ui/uicheckboxskin.h>

View File

@@ -1,6 +1,32 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* 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.
*/
#ifndef UICHECKBOXSKIN_H
#define UICHECKBOXSKIN_H
#include <prerequisites.h>
class UICheckBoxSkin
{
};

View File

@@ -22,13 +22,9 @@
*/
#include "uicontainer.h"
#include "core/resources.h"
#include "uibutton.h"
#include "uipanel.h"
#include "uilabel.h"
#include "uitextedit.h"
#include "uiwindow.h"
#include <prerequisites.h>
#include <core/resources.h>
#include <ui/uicontainer.h>
UIContainerPtr rootContainer(new UIContainer);

View File

@@ -25,8 +25,8 @@
#ifndef UICONTAINER_H
#define UICONTAINER_H
#include "prerequisites.h"
#include "uielement.h"
#include <prerequisites.h>
#include <ui/uielement.h>
class UIContainer : public UIElement
{

View File

@@ -22,16 +22,17 @@
*/
#include "uielement.h"
#include "uiskins.h"
#include "uielementskin.h"
#include "graphics/graphics.h"
#include <prerequisites.h>
#include <core/dispatcher.h>
#include <graphics/graphics.h>
#include <ui/uielement.h>
#include <ui/uiskins.h>
#include <ui/uielementskin.h>
#include <ui/uicontainer.h>
UIElement::UIElement(UI::EElementType type) :
UILayout(),
m_type(type),
m_skin(NULL),
m_visible(true),
m_enabled(true),
m_focused(false)
@@ -49,7 +50,7 @@ void UIElement::destroy()
assert(asUIElement().use_count() == 4);
}
void UIElement::setSkin(UIElementSkin* skin)
void UIElement::setSkin(const UIElementSkinPtr& skin)
{
m_skin = skin;
if(skin)

View File

@@ -25,10 +25,11 @@
#ifndef UIELEMENT_H
#define UIELEMENT_H
#include "prerequisites.h"
#include "core/input.h"
#include "uiconstants.h"
#include "uilayout.h"
#include <prerequisites.h>
#include <core/input.h>
#include <ui/uiconstants.h>
#include <ui/uilayout.h>
#include <ui/uielementskin.h>
class UIElementSkin;
@@ -60,8 +61,8 @@ public:
void moveTo(Point pos);
void setSkin(UIElementSkin *skin);
UIElementSkin *getSkin() { return m_skin; }
void setSkin(const UIElementSkinPtr& skin);
const UIElementSkinPtr& getSkin() const { return m_skin; }
void setParent(UIContainerPtr parent) { m_parent = parent; }
UIContainerPtr getParent() const { return m_parent.lock(); }
@@ -89,7 +90,7 @@ public:
private:
UI::EElementType m_type;
UIContainerWeakPtr m_parent;
UIElementSkin *m_skin;
UIElementSkinPtr m_skin;
std::string m_id;
bool m_visible;
bool m_enabled;

View File

@@ -22,11 +22,12 @@
*/
#include "uielementskin.h"
#include "uielement.h"
#include "graphics/borderedimage.h"
#include "graphics/textures.h"
#include "uiskins.h"
#include <prerequisites.h>
#include <ui/uiskins.h>
#include <ui/uielement.h>
#include <ui/uielementskin.h>
#include <graphics/borderedimage.h>
#include <graphics/textures.h>
void UIElementSkin::load(const YAML::Node& node)
{

View File

@@ -25,9 +25,9 @@
#ifndef UIELEMENTSKIN_H
#define UIELEMENTSKIN_H
#include "prerequisites.h"
#include "uiconstants.h"
#include "graphics/image.h"
#include <prerequisites.h>
#include <graphics/image.h>
#include <ui/uiconstants.h>
class UIElement;
@@ -58,4 +58,6 @@ private:
ImagePtr m_defaultImage;
};
typedef boost::shared_ptr<UIElementSkin> UIElementSkinPtr;
#endif // UIELEMENTSKIN_H

View File

@@ -22,4 +22,5 @@
*/
#include "uilabel.h"
#include <prerequisites.h>
#include <ui/uilabel.h>

View File

@@ -25,9 +25,9 @@
#ifndef UILABEL_H
#define UILABEL_H
#include "prerequisites.h"
#include "uielement.h"
#include "graphics/font.h"
#include <prerequisites.h>
#include <ui/uielement.h>
#include <graphics/font.h>
class UILabel : public UIElement
{

View File

@@ -22,9 +22,10 @@
*/
#include "uilabelskin.h"
#include "uilabel.h"
#include "graphics/fonts.h"
#include <prerequisites.h>
#include <graphics/fonts.h>
#include <ui/uilabelskin.h>
#include <ui/uilabel.h>
void UILabelSkin::load(const YAML::Node& node)
{

View File

@@ -25,9 +25,9 @@
#ifndef UILABELSKIN_H
#define UILABELSKIN_H
#include "prerequisites.h"
#include "uielementskin.h"
#include "graphics/font.h"
#include <prerequisites.h>
#include <graphics/font.h>
#include <ui/uielementskin.h>
class UILabelSkin : public UIElementSkin
{

View File

@@ -22,8 +22,9 @@
*/
#include "uilayout.h"
#include "uielement.h"
#include <prerequisites.h>
#include <ui/uielement.h>
#include <ui/uilayout.h>
int AnchorLine::getPos() const
{

View File

@@ -25,8 +25,8 @@
#ifndef UILAYOUT_H
#define UILAYOUT_H
#include "prerequisites.h"
#include "uiconstants.h"
#include <prerequisites.h>
#include <ui/uiconstants.h>
enum EAnchorType {
ANCHOR_LEFT = 0,

View File

@@ -22,9 +22,10 @@
*/
#include "uiloader.h"
#include "core/resources.h"
#include "ui.h"
#include <prerequisites.h>
#include <core/resources.h>
#include <ui/ui.h>
#include <ui/uiloader.h>
UIElementPtr UILoader::createElementFromId(const std::string& id)
{
@@ -39,7 +40,7 @@ UIElementPtr UILoader::createElementFromId(const std::string& id)
std::string elementId = split[1];
if(elementType == "panel") {
element = UIElementPtr(new UIPanel);
element = UIElementPtr(new UIContainer(UI::Panel));
} else if(elementType == "button") {
element = UIElementPtr(new UIButton);
} else if(elementType == "label") {
@@ -49,7 +50,7 @@ UIElementPtr UILoader::createElementFromId(const std::string& id)
} else if(elementType == "textEdit") {
element = UIElementPtr(new UITextEdit);
} else if(elementType == "lineDecoration") {
element = UIElementPtr(new UILineDecoration);
element = UIElementPtr(new UIElement(UI::LineDecoration));
} else if(elementType == "checkBox") {
element = UIElementPtr(new UICheckBox);
}

View File

@@ -25,9 +25,9 @@
#ifndef UILOADER_H
#define UILOADER_H
#include "prerequisites.h"
#include "uiconstants.h"
#include "uicontainer.h"
#include <prerequisites.h>
#include <ui/uiconstants.h>
#include <ui/uicontainer.h>
namespace UILoader
{

View File

@@ -22,15 +22,15 @@
*/
#include "uiskins.h"
#include "core/resources.h"
#include "graphics/textures.h"
#include "uielementskin.h"
#include "uibuttonskin.h"
#include "uiwindowskin.h"
#include "uitexteditskin.h"
#include "uilabelskin.h"
#include "uilinedecorationskin.h"
#include <prerequisites.h>
#include <core/resources.h>
#include <graphics/textures.h>
#include <ui/uiskins.h>
#include <ui/uielementskin.h>
#include <ui/uibuttonskin.h>
#include <ui/uiwindowskin.h>
#include <ui/uitexteditskin.h>
#include <ui/uilabelskin.h>
UISkins g_uiSkins;
@@ -58,7 +58,7 @@ void UISkins::load(const std::string& skinsFile)
std::string name;
it.first() >> name;
UIElementSkin *skin = new UIButtonSkin(name);
UIElementSkinPtr skin = UIElementSkinPtr(new UIButtonSkin(name));
skin->load(it.second());
m_elementSkins.push_back(skin);
}
@@ -70,7 +70,7 @@ void UISkins::load(const std::string& skinsFile)
std::string name;
it.first() >> name;
UIElementSkin *skin = new UIElementSkin(name, UI::Panel);
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::Panel));
skin->load(it.second());
m_elementSkins.push_back(skin);
}
@@ -82,7 +82,7 @@ void UISkins::load(const std::string& skinsFile)
std::string name;
it.first() >> name;
UIElementSkin *skin = new UIWindowSkin(name);
UIElementSkinPtr skin = UIElementSkinPtr(new UIWindowSkin(name));
skin->load(it.second());
m_elementSkins.push_back(skin);
}
@@ -94,7 +94,7 @@ void UISkins::load(const std::string& skinsFile)
std::string name;
it.first() >> name;
UIElementSkin *skin = new UILabelSkin(name);
UIElementSkinPtr skin = UIElementSkinPtr(new UILabelSkin(name));
skin->load(it.second());
m_elementSkins.push_back(skin);
}
@@ -107,7 +107,7 @@ void UISkins::load(const std::string& skinsFile)
std::string name;
it.first() >> name;
UIElementSkin *skin = new UITextEditSkin(name);
UIElementSkinPtr skin = UIElementSkinPtr(new UITextEditSkin(name));
skin->load(it.second());
m_elementSkins.push_back(skin);
}
@@ -120,7 +120,7 @@ void UISkins::load(const std::string& skinsFile)
std::string name;
it.first() >> name;
UIElementSkin *skin = new UILineDecorationSkin(name);
UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::LineDecoration));
skin->load(it.second());
m_elementSkins.push_back(skin);
}
@@ -132,20 +132,17 @@ void UISkins::load(const std::string& skinsFile)
void UISkins::terminate()
{
for(auto it = m_elementSkins.begin(); it != m_elementSkins.end(); ++it)
delete (*it);
m_elementSkins.clear();
}
UIElementSkin* UISkins::getElementSkin(UI::EElementType elementType, const std::string& name)
UIElementSkinPtr UISkins::getElementSkin(UI::EElementType elementType, const std::string& name)
{
for(auto it = m_elementSkins.begin(); it != m_elementSkins.end(); ++it) {
UIElementSkin *skin = (*it);
if(elementType == skin->getElementType() && name == skin->getName()) {
const UIElementSkinPtr& skin = (*it);
if(elementType == skin->getElementType() && name == skin->getName())
return skin;
}
}
logWarning("Element skin '%s' not found", name.c_str());
return NULL;
return UIElementSkinPtr();
}

View File

@@ -25,11 +25,9 @@
#ifndef UISKIN_H
#define UISKIN_H
#include "prerequisites.h"
#include "uicontainer.h"
#include "graphics/texture.h"
class UIElementSkin;
#include <prerequisites.h>
#include <graphics/texture.h>
#include <ui/uielementskin.h>
class UISkins
{
@@ -39,13 +37,13 @@ public:
void load(const std::string& skinsFile);
void terminate();
UIElementSkin *getElementSkin(UI::EElementType elementType, const std::string& name = "default");
UIElementSkinPtr getElementSkin(UI::EElementType elementType, const std::string& name = "default");
TexturePtr getDefaultTexture() { return m_defaultTexture; }
private:
TexturePtr m_defaultTexture;
std::vector<UIElementSkin *> m_elementSkins;
std::vector<UIElementSkinPtr> m_elementSkins;
};
extern UISkins g_uiSkins;

View File

@@ -22,10 +22,11 @@
*/
#include "uitextedit.h"
#include "uitexteditskin.h"
#include "graphics/fonts.h"
#include "uicontainer.h"
#include <prerequisites.h>
#include <graphics/fonts.h>
#include <ui/uitextedit.h>
#include <ui/uitexteditskin.h>
#include <ui/uicontainer.h>
UITextEdit::UITextEdit() :
UIElement(UI::TextEdit)
@@ -61,7 +62,7 @@ void UITextEdit::onInputEvent(const InputEvent& event)
void UITextEdit::onLayoutRectChange(const Rect& rect)
{
UITextEditSkin *skin = static_cast<UITextEditSkin*>(getSkin());
UITextEditSkin *skin = static_cast<UITextEditSkin*>(getSkin().get());
Rect textRect = rect;
int margin = skin->getTextMargin();
textRect.setLeft(textRect.left()+margin);

View File

@@ -25,9 +25,9 @@
#ifndef UITEXTEDIT_H
#define UITEXTEDIT_H
#include "prerequisites.h"
#include "uielement.h"
#include "graphics/textarea.h"
#include <prerequisites.h>
#include <graphics/textarea.h>
#include <ui/uielement.h>
class Font;

View File

@@ -22,9 +22,10 @@
*/
#include "uitexteditskin.h"
#include "uitextedit.h"
#include "graphics/fonts.h"
#include <prerequisites.h>
#include <graphics/fonts.h>
#include <ui/uitexteditskin.h>
#include <ui/uitextedit.h>
void UITextEditSkin::load(const YAML::Node& node)
{

View File

@@ -25,9 +25,8 @@
#ifndef UITEXTEDITSKIN_H
#define UITEXTEDITSKIN_H
#include "prerequisites.h"
#include "uiconstants.h"
#include "uielementskin.h"
#include <prerequisites.h>
#include <ui/uielementskin.h>
class Font;

View File

@@ -22,14 +22,15 @@
*/
#include "uiwindow.h"
#include "uiwindowskin.h"
#include <prerequisites.h>
#include <ui/uiwindow.h>
#include <ui/uiwindowskin.h>
void UIWindow::onInputEvent(const InputEvent& event)
{
UIContainer::onInputEvent(event);
if(event.type == EV_MOUSE_LDOWN) {
UIWindowSkin *skin = static_cast<UIWindowSkin*>(getSkin());
UIWindowSkin *skin = static_cast<UIWindowSkin*>(getSkin().get());
Rect headRect = getRect();
headRect.setHeight(skin->getHeadHeight());
if(headRect.contains(event.mousePos)) {

View File

@@ -25,8 +25,8 @@
#ifndef UIWINDOW_H
#define UIWINDOW_H
#include "prerequisites.h"
#include "uicontainer.h"
#include <prerequisites.h>
#include <ui/uicontainer.h>
class UIWindow : public UIContainer
{

View File

@@ -21,9 +21,10 @@
* THE SOFTWARE.
*/
#include "uiwindowskin.h"
#include "uiwindow.h"
#include "graphics/fonts.h"
#include <prerequisites.h>
#include <graphics/fonts.h>
#include <ui/uiwindowskin.h>
#include <ui/uiwindow.h>
void UIWindowSkin::load(const YAML::Node& node)
{

View File

@@ -24,10 +24,9 @@
#ifndef UIWINDOWSKIN_H
#define UIWINDOWSKIN_H
#include "prerequisites.h"
#include "uiconstants.h"
#include "uielementskin.h"
#include "graphics/font.h"
#include <prerequisites.h>
#include <graphics/font.h>
#include <ui/uielementskin.h>
class UIWindowSkin : public UIElementSkin
{