Improved access to the inner widgets from CSS.

Minor fix in docs Makefile.
Minor fix in keyboard shortcuts.
This commit is contained in:
Martín Lucas Golini
2020-04-06 03:07:56 -03:00
parent 75d940da8f
commit 887d2f331d
24 changed files with 217 additions and 95 deletions

View File

@@ -250,6 +250,8 @@ class EE_API MapEditor {
void onMapLoad();
void updateScroll();
bool addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget );
};
}} // namespace EE::Maps

View File

@@ -0,0 +1,27 @@
#ifndef EE_UI_KEYBOARDSHORTCUT_HPP
#define EE_UI_KEYBOARDSHORTCUT_HPP
#include <eepp/config.hpp>
#include <list>
namespace EE { namespace UI {
class UIWidget;
class KeyboardShortcut {
public:
KeyboardShortcut() : KeyCode( 0 ), Mod( 0 ), Widget( NULL ) {}
KeyboardShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget ) :
KeyCode( KeyCode ), Mod( Mod ), Widget( Widget ) {}
Uint32 KeyCode;
Uint32 Mod;
UIWidget* Widget;
};
typedef std::list<KeyboardShortcut> KeyboardShortcuts;
}} // namespace EE::UI
#endif // EE_UI_KEYBOARDSHORTCUT_HPP

View File

@@ -24,9 +24,9 @@ class EE_API UICheckBox : public UITextView {
void setChecked( const bool& checked );
UINode* getCheckedButton() const;
UIWidget* getCheckedButton() const;
UINode* getInactiveButton() const;
UIWidget* getInactiveButton() const;
Int32 getTextSeparation() const;
@@ -38,8 +38,8 @@ class EE_API UICheckBox : public UITextView {
const Uint32& propertyIndex = 0 );
protected:
UINode* mActiveButton;
UINode* mInactiveButton;
UIWidget* mActiveButton;
UIWidget* mInactiveButton;
bool mChecked;
Uint32 mLastTick;
Int32 mTextSeparation;

View File

@@ -14,9 +14,11 @@ class EE_API UIDropDownList : public UITextInput {
bool PopUpToMainControl = false;
};
static UIDropDownList* NewWithTag( const std::string& tag );
static UIDropDownList* New();
UIDropDownList();
UIDropDownList( const std::string& tag = "dropdownlist" );
virtual ~UIDropDownList();
@@ -64,9 +66,13 @@ class EE_API UIDropDownList : public UITextInput {
virtual void hide();
Uint32 onMouseUp( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseOver( const Vector2i& position, const Uint32& flags );
Uint32 onMouseClick( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseLeave( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseClick( const Vector2i& position, const Uint32& flags );
virtual void onItemClicked( const Event* Event );
@@ -74,7 +80,7 @@ class EE_API UIDropDownList : public UITextInput {
virtual void onControlClear( const Event* Event );
Uint32 onKeyDown( const KeyEvent& Event );
virtual Uint32 onKeyDown( const KeyEvent& Event );
virtual void onSizeChange();

View File

@@ -24,9 +24,9 @@ class EE_API UIRadioButton : public UITextView {
void setActive( const bool& active );
UINode* getActiveButton() const;
UIWidget* getActiveButton() const;
UINode* getInactiveButton() const;
UIWidget* getInactiveButton() const;
Int32 getTextSeparation() const;
@@ -38,8 +38,8 @@ class EE_API UIRadioButton : public UITextView {
const Uint32& propertyIndex = 0 );
protected:
UINode* mActiveButton;
UINode* mInactiveButton;
UIWidget* mActiveButton;
UIWidget* mInactiveButton;
bool mActive;
Uint32 mLastTick;
Int32 mTextSeparation;

View File

@@ -4,6 +4,7 @@
#include <eepp/scene/scenenode.hpp>
#include <eepp/system/translator.hpp>
#include <eepp/ui/css/stylesheet.hpp>
#include <eepp/ui/keyboardshortcut.hpp>
namespace EE { namespace Graphics {
class Font;
@@ -73,6 +74,10 @@ class EE_API UISceneNode : public SceneNode {
void invalidateStyleSheet();
bool addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget );
bool removeShortcut( const Uint32& KeyCode, const Uint32& Mod );
protected:
friend class EE::UI::UIWindow;
UIWidget* mRoot;
@@ -85,6 +90,7 @@ class EE_API UISceneNode : public SceneNode {
bool mCSSInvalid;
UIThemeManager* mUIThemeManager;
std::vector<Font*> mFontFaces;
KeyboardShortcuts mKbShortcuts;
virtual void resizeControl( EE::Window::Window* win );
@@ -113,6 +119,12 @@ class EE_API UISceneNode : public SceneNode {
void loadFontFaces( const CSS::StyleSheetStyleVector& styles );
UIWidget* loadNode( pugi::xml_node node, Node* parent );
virtual Uint32 onKeyDown( const KeyEvent& Event );
void checkShortcuts( const Uint32& KeyCode, const Uint32& Mod );
KeyboardShortcuts::iterator existsShortcut( const Uint32& KeyCode, const Uint32& Mod );
};
}} // namespace EE::UI

View File

@@ -74,8 +74,8 @@ class EE_API UIScrollBar : public UIWidget {
protected:
ScrollBarType mScrollBarType;
UISlider* mSlider;
UINode* mBtnUp;
UINode* mBtnDown;
UIWidget* mBtnUp;
UIWidget* mBtnDown;
virtual void onSizeChange();

View File

@@ -41,9 +41,9 @@ class EE_API UISlider : public UIWidget {
bool isVertical() const;
UINode* getBackSlider() const;
UIWidget* getBackSlider() const;
UINode* getSliderButton() const;
UIWidget* getSliderButton() const;
void adjustChilds();
@@ -76,7 +76,7 @@ class EE_API UISlider : public UIWidget {
UIOrientation mOrientation;
bool mAllowHalfSliderOut;
bool mExpandBackground;
UINode* mBackSlider;
UIWidget* mBackSlider;
UIWidget* mSlider;
Float mMinValue;
Float mMaxValue;

View File

@@ -115,6 +115,8 @@ class EE_API UITextInput : public UITextView {
virtual Uint32 onMouseDoubleClick( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseOver( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseLeave( const Vector2i& position, const Uint32& flags );
virtual Uint32 onFocus();

View File

@@ -1,6 +1,7 @@
#ifndef EE_UICUIWINDOW_HPP
#define EE_UICUIWINDOW_HPP
#include <eepp/ui/keyboardshortcut.hpp>
#include <eepp/ui/uipushbutton.hpp>
#include <eepp/ui/uitextview.hpp>
#include <eepp/ui/uiwidget.hpp>
@@ -110,7 +111,7 @@ class EE_API UIWindow : public UIWidget {
UITextView* getTitleTextBox() const;
bool addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIPushButton* Button );
bool addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget );
bool removeShortcut( const Uint32& KeyCode, const Uint32& Mod );
@@ -160,20 +161,6 @@ class EE_API UIWindow : public UIWidget {
std::string getWindowFlagsString();
protected:
class KeyboardShortcut {
public:
KeyboardShortcut() : KeyCode( 0 ), Mod( 0 ), Button( NULL ) {}
KeyboardShortcut( const Uint32& KeyCode, const Uint32& Mod, UIPushButton* Button ) :
KeyCode( KeyCode ), Mod( Mod ), Button( Button ) {}
Uint32 KeyCode;
Uint32 Mod;
UIPushButton* Button;
};
typedef std::list<KeyboardShortcut> KeyboardShortcuts;
enum UI_RESIZE_TYPE {
RESIZE_NONE,
RESIZE_LEFT,
@@ -188,15 +175,15 @@ class EE_API UIWindow : public UIWidget {
FrameBuffer* mFrameBuffer;
StyleConfig mStyleConfig;
UINode* mWindowDecoration;
UINode* mBorderLeft;
UINode* mBorderRight;
UINode* mBorderBottom;
UIWidget* mWindowDecoration;
UIWidget* mBorderLeft;
UIWidget* mBorderRight;
UIWidget* mBorderBottom;
UIWidget* mContainer;
UINode* mButtonClose;
UINode* mButtonMinimize;
UINode* mButtonMaximize;
UIWidget* mButtonClose;
UIWidget* mButtonMinimize;
UIWidget* mButtonMaximize;
UITextView* mTitle;
UIWidget* mModalCtrl;
@@ -213,7 +200,7 @@ class EE_API UIWindow : public UIWidget {
virtual void onAlphaChange();
virtual void onChildCountChange( Node * child, const bool& removed );
virtual void onChildCountChange( Node* child, const bool& removed );
virtual void onPositionChange();