mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
Improved access to the inner widgets from CSS.
Minor fix in docs Makefile. Minor fix in keyboard shortcuts.
This commit is contained in:
@@ -8,7 +8,7 @@ clean:
|
||||
|
||||
doxygen:
|
||||
cd ../../ && doxygen Doxyfile
|
||||
sh fix_md_files.sh
|
||||
bash fix_md_files.sh
|
||||
|
||||
doxyrest: doxygen
|
||||
doxyrest -c doxyrest-config.lua
|
||||
|
||||
@@ -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
|
||||
|
||||
27
include/eepp/ui/keyboardshortcut.hpp
Normal file
27
include/eepp/ui/keyboardshortcut.hpp
Normal 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
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
../../bin/assets/layouts/test.xml
|
||||
../../bin/assets/layouts/test_widgets.xml
|
||||
../../bin/assets/ui/uitheme.css
|
||||
../../docs/articles/cssspecification.md
|
||||
../../docs/articles/uiintroduction.md
|
||||
../../external_projects.lua
|
||||
../../include/eepp/audio/alresource.hpp
|
||||
@@ -310,6 +311,7 @@
|
||||
../../include/eepp/ui/css/stylesheetstyle.hpp
|
||||
../../include/eepp/ui/css/stylesheetvariable.hpp
|
||||
../../include/eepp/ui/css/transitiondefinition.hpp
|
||||
../../include/eepp/ui/keyboardshortcut.hpp
|
||||
../../include/eepp/ui/marginmove/scale.hpp
|
||||
../../include/eepp/ui/tools/textureatlaseditor.hpp
|
||||
../../include/eepp/ui/tools/uicolorpicker.hpp
|
||||
|
||||
@@ -8,3 +8,5 @@
|
||||
../../include/eepp/ui/css
|
||||
../../src/eepp/ui/css
|
||||
../../src/thirdparty/mbedtls/include
|
||||
../../include/eepp/ui
|
||||
../../docs/articles
|
||||
|
||||
@@ -72,17 +72,13 @@ MapEditor::MapEditor( UIWindow* AttatchTo, const MapEditorCloseCb& callback ) :
|
||||
return;
|
||||
}
|
||||
|
||||
if ( NULL == mUIWindow ) {
|
||||
mUIContainer = SceneManager::instance()->getUISceneNode();
|
||||
} else {
|
||||
mUIContainer = mUIWindow->getContainer();
|
||||
}
|
||||
|
||||
if ( NULL != mUIWindow ) {
|
||||
mUIContainer = mUIWindow->getContainer();
|
||||
mUIWindow->setTitle( "Map Editor" );
|
||||
mUIWindow->addEventListener( Event::OnWindowClose,
|
||||
cb::Make1( this, &MapEditor::windowClose ) );
|
||||
} else {
|
||||
mUIContainer = SceneManager::instance()->getUISceneNode();
|
||||
mUIContainer->addEventListener( Event::OnClose,
|
||||
cb::Make1( this, &MapEditor::windowClose ) );
|
||||
}
|
||||
@@ -100,6 +96,14 @@ void MapEditor::createME() {
|
||||
createUIMap();
|
||||
}
|
||||
|
||||
bool MapEditor::addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget ) {
|
||||
if ( NULL != mUIWindow ) {
|
||||
return mUIWindow->addShortcut( KeyCode, Mod, Widget );
|
||||
} else {
|
||||
return mUIContainer->asType<UISceneNode>()->addShortcut( KeyCode, Mod, Widget );
|
||||
}
|
||||
}
|
||||
|
||||
void MapEditor::createWinMenu() {
|
||||
UIWinMenu* WinMenu = UIWinMenu::New();
|
||||
WinMenu->setParent( mUIContainer );
|
||||
@@ -141,18 +145,16 @@ void MapEditor::createWinMenu() {
|
||||
mChkShowBlocked = PU3->getItem( PU3->addCheckBox( "Show Blocked" ) )->asType<UIMenuCheckBox>();
|
||||
|
||||
PU3->addSeparator();
|
||||
mUIWindow->addShortcut(
|
||||
KEY_KP_PLUS, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Zoom In", mTheme->getIconByName( "zoom-in" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
mUIWindow->addShortcut(
|
||||
KEY_KP_MINUS, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Zoom Out", mTheme->getIconByName( "zoom-out" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
mUIWindow->addShortcut(
|
||||
KEY_KP0, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Normal Size", mTheme->getIconByName( "zoom-original" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
|
||||
addShortcut( KEY_KP_PLUS, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Zoom In", mTheme->getIconByName( "zoom-in" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
addShortcut( KEY_KP_MINUS, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Zoom Out", mTheme->getIconByName( "zoom-out" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
addShortcut( KEY_KP0, KEYMOD_CTRL,
|
||||
PU3->getItem( PU3->add( "Normal Size", mTheme->getIconByName( "zoom-original" ) ) )
|
||||
->asType<UIPushButton>() );
|
||||
PU3->addSeparator();
|
||||
|
||||
PU3->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::viewMenuClick ) );
|
||||
@@ -739,7 +741,7 @@ void MapEditor::onAddObject( Uint32 Type, Polygon2f poly ) {
|
||||
void MapEditor::onLightTypeChange( const Event* Event ) {
|
||||
if ( NULL != mUIMap->getSelectedLight() ) {
|
||||
mUIMap->getSelectedLight()->setType( mLightTypeChk->isChecked() ? MapLightType::Isometric
|
||||
: MapLightType::Normal );
|
||||
: MapLightType::Normal );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -920,7 +922,7 @@ void MapEditor::chkClickAnimated( const Event* Event ) {
|
||||
updateFlags();
|
||||
|
||||
if ( mChkAnim->isChecked() && ( mGOTypeList->getText() == "TextureRegion" ||
|
||||
mGOTypeList->getText() == "TextureRegionEx" ) ) {
|
||||
mGOTypeList->getText() == "TextureRegionEx" ) ) {
|
||||
mGOTypeList->getListBox()->setSelected( "Sprite" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ UICheckBox* UICheckBox::New() {
|
||||
}
|
||||
|
||||
UICheckBox::UICheckBox() : UITextView( "checkbox" ), mChecked( false ), mTextSeparation( 4 ) {
|
||||
mActiveButton = UINode::New();
|
||||
mActiveButton = UIWidget::NewWithTag( "checkbox::active" );
|
||||
mActiveButton->setVisible( false );
|
||||
mActiveButton->setEnabled( true );
|
||||
mActiveButton->setParent( this );
|
||||
mActiveButton->setPosition( 0, 0 );
|
||||
mActiveButton->setSize( 16, 16 );
|
||||
|
||||
mInactiveButton = UINode::New();
|
||||
mInactiveButton = UIWidget::NewWithTag( "checkbox::inactive" );
|
||||
mInactiveButton->setVisible( true );
|
||||
mInactiveButton->setEnabled( true );
|
||||
mInactiveButton->setParent( this );
|
||||
@@ -192,11 +192,11 @@ void UICheckBox::alignFix() {
|
||||
mAlignOffset = PixelDensity::pxToDp( mRealAlignOffset );
|
||||
}
|
||||
|
||||
UINode* UICheckBox::getCheckedButton() const {
|
||||
UIWidget* UICheckBox::getCheckedButton() const {
|
||||
return mActiveButton;
|
||||
}
|
||||
|
||||
UINode* UICheckBox::getInactiveButton() const {
|
||||
UIWidget* UICheckBox::getInactiveButton() const {
|
||||
return mInactiveButton;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ void UIComboBox::setTheme( UITheme* Theme ) {
|
||||
UIWidget::setTheme( Theme );
|
||||
|
||||
if ( NULL == mDropDownList ) {
|
||||
mDropDownList = UIDropDownList::New();
|
||||
mDropDownList = UIDropDownList::NewWithTag( "combobox::dropdownlist" );
|
||||
mDropDownList->setParent( this );
|
||||
mDropDownList->setFriendControl( this );
|
||||
mDropDownList->setVisible( true );
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
UIDropDownList* UIDropDownList::NewWithTag( const std::string& tag ) {
|
||||
return eeNew( UIDropDownList, ( tag ) );
|
||||
}
|
||||
|
||||
UIDropDownList* UIDropDownList::New() {
|
||||
return eeNew( UIDropDownList, () );
|
||||
}
|
||||
|
||||
UIDropDownList::UIDropDownList() :
|
||||
UITextInput( "dropdownlist" ), mListBox( NULL ), mFriendCtrl( NULL ) {
|
||||
UIDropDownList::UIDropDownList( const std::string& tag ) :
|
||||
UITextInput( tag ), mListBox( NULL ), mFriendCtrl( NULL ) {
|
||||
clipEnable();
|
||||
setFlags( UI_AUTO_SIZE | UI_AUTO_PADDING );
|
||||
unsetFlags( UI_TEXT_SELECTION_ENABLED );
|
||||
@@ -23,7 +27,7 @@ UIDropDownList::UIDropDownList() :
|
||||
|
||||
applyDefaultTheme();
|
||||
|
||||
mListBox = UIListBox::NewWithTag( "dropdownlist::listbox" );
|
||||
mListBox = UIListBox::NewWithTag( mTag + "::listbox" );
|
||||
mListBox->setSize( getSize().getWidth(),
|
||||
mStyleConfig.MaxNumVisibleItems * getSize().getHeight() );
|
||||
mListBox->setEnabled( false );
|
||||
@@ -268,6 +272,22 @@ void UIDropDownList::hide() {
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UIDropDownList::onMouseOver( const Vector2i& position, const Uint32& flags ) {
|
||||
if ( getParent()->isType( UI_TYPE_COMBOBOX ) ) {
|
||||
return UITextInput::onMouseOver( position, flags );
|
||||
} else {
|
||||
return UITextView::onMouseOver( position, flags );
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UIDropDownList::onMouseLeave( const Vector2i& position, const Uint32& flags ) {
|
||||
if ( getParent()->isType( UI_TYPE_COMBOBOX ) ) {
|
||||
return UITextInput::onMouseLeave( position, flags );
|
||||
} else {
|
||||
return UITextView::onMouseLeave( position, flags );
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UIDropDownList::onKeyDown( const KeyEvent& Event ) {
|
||||
mListBox->onKeyDown( Event );
|
||||
|
||||
|
||||
@@ -259,11 +259,11 @@ void UIRadioButton::alignFix() {
|
||||
mAlignOffset = PixelDensity::pxToDp( mRealAlignOffset );
|
||||
}
|
||||
|
||||
UINode* UIRadioButton::getActiveButton() const {
|
||||
UIWidget* UIRadioButton::getActiveButton() const {
|
||||
return mActiveButton;
|
||||
}
|
||||
|
||||
UINode* UIRadioButton::getInactiveButton() const {
|
||||
UIWidget* UIRadioButton::getInactiveButton() const {
|
||||
return mInactiveButton;
|
||||
}
|
||||
|
||||
|
||||
@@ -442,4 +442,53 @@ void UISceneNode::loadFontFaces( const StyleSheetStyleVector& styles ) {
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UISceneNode::onKeyDown( const KeyEvent& Event ) {
|
||||
checkShortcuts( Event.getKeyCode(), Event.getMod() );
|
||||
|
||||
return SceneNode::onKeyDown( Event );
|
||||
}
|
||||
|
||||
void UISceneNode::checkShortcuts( const Uint32& KeyCode, const Uint32& Mod ) {
|
||||
if ( NULL == getEventDispatcher() )
|
||||
return;
|
||||
|
||||
for ( auto& kb : mKbShortcuts ) {
|
||||
if ( KeyCode == kb.KeyCode && ( Mod & kb.Mod ) ) {
|
||||
getEventDispatcher()->sendMouseUp( kb.Widget, Vector2i( -1, -1 ), EE_BUTTON_LMASK );
|
||||
getEventDispatcher()->sendMouseClick( kb.Widget, Vector2i( -1, -1 ), EE_BUTTON_LMASK );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardShortcuts::iterator UISceneNode::existsShortcut( const Uint32& KeyCode, const Uint32& Mod ) {
|
||||
for ( KeyboardShortcuts::iterator it = mKbShortcuts.begin(); it != mKbShortcuts.end(); ++it ) {
|
||||
if ( ( *it ).KeyCode == KeyCode && ( *it ).Mod == Mod )
|
||||
return it;
|
||||
}
|
||||
|
||||
return mKbShortcuts.end();
|
||||
}
|
||||
|
||||
bool UISceneNode::addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget ) {
|
||||
if ( inParentTreeOf( Widget ) && mKbShortcuts.end() == existsShortcut( KeyCode, Mod ) ) {
|
||||
mKbShortcuts.push_back( KeyboardShortcut( KeyCode, Mod, Widget ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UISceneNode::removeShortcut( const Uint32& KeyCode, const Uint32& Mod ) {
|
||||
KeyboardShortcuts::iterator it = existsShortcut( KeyCode, Mod );
|
||||
|
||||
if ( mKbShortcuts.end() != it ) {
|
||||
mKbShortcuts.erase( it );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -28,8 +28,13 @@ UIScrollBar::UIScrollBar( const UIOrientation& orientation ) :
|
||||
|
||||
setLayoutSizeRules( LayoutSizeRule::Fixed, LayoutSizeRule::Fixed );
|
||||
|
||||
mBtnDown = UINode::New();
|
||||
mBtnUp = UINode::New();
|
||||
if ( orientation == UIOrientation::Vertical ) {
|
||||
mBtnDown = UIWidget::NewWithTag( "scrollbar::btndown" );
|
||||
mBtnUp = UIWidget::NewWithTag( "scrollbar::btnup" );
|
||||
} else {
|
||||
mBtnDown = UIWidget::NewWithTag( "scrollbar::btnleft" );
|
||||
mBtnUp = UIWidget::NewWithTag( "scrollbar::btnright" );
|
||||
}
|
||||
mBtnUp->setParent( this );
|
||||
mBtnUp->setSize( 16, 16 );
|
||||
mBtnDown->setParent( this );
|
||||
@@ -43,6 +48,8 @@ UIScrollBar::UIScrollBar( const UIOrientation& orientation ) :
|
||||
mSlider->setParent( this );
|
||||
mSlider->setAllowHalfSliderOut( false );
|
||||
mSlider->setExpandBackground( false );
|
||||
mSlider->getSliderButton()->setElementTag( "scrollbar::button" );
|
||||
mSlider->getBackSlider()->setElementTag( "scrollbar::back" );
|
||||
|
||||
adjustChilds();
|
||||
|
||||
@@ -69,6 +76,8 @@ void UIScrollBar::setTheme( UITheme* Theme ) {
|
||||
mSlider->getSliderButton()->setThemeSkin( Theme, "hscrollbar_button" );
|
||||
mBtnUp->setThemeSkin( Theme, "hscrollbar_btnup" );
|
||||
mBtnDown->setThemeSkin( Theme, "hscrollbar_btndown" );
|
||||
mBtnDown->setElementTag( "scrollbar::btnleft" );
|
||||
mBtnUp->setElementTag( "scrollbar::btnright" );
|
||||
} else {
|
||||
UINode::setThemeSkin( Theme, "vscrollbar" );
|
||||
mSlider->setThemeSkin( Theme, "vscrollbar_slider" );
|
||||
@@ -76,6 +85,8 @@ void UIScrollBar::setTheme( UITheme* Theme ) {
|
||||
mSlider->getSliderButton()->setThemeSkin( Theme, "vscrollbar_button" );
|
||||
mBtnUp->setThemeSkin( Theme, "vscrollbar_btnup" );
|
||||
mBtnDown->setThemeSkin( Theme, "vscrollbar_btndown" );
|
||||
mBtnDown->setElementTag( "scrollbar::btndown" );
|
||||
mBtnUp->setElementTag( "scrollbar::btnup" );
|
||||
}
|
||||
|
||||
UISkin* tSkin = mBtnUp->getSkin();
|
||||
|
||||
@@ -443,11 +443,11 @@ void UISlider::setPageStep( const Float& pageStep ) {
|
||||
}
|
||||
}
|
||||
|
||||
UINode* UISlider::getBackSlider() const {
|
||||
UIWidget* UISlider::getBackSlider() const {
|
||||
return mBackSlider;
|
||||
}
|
||||
|
||||
UINode* UISlider::getSliderButton() const {
|
||||
UIWidget* UISlider::getSliderButton() const {
|
||||
return mSlider;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ UITextEdit::UITextEdit() :
|
||||
setFlags( UI_AUTO_PADDING | UI_TEXT_SELECTION_ENABLED );
|
||||
clipEnable();
|
||||
|
||||
mTextInput = UITextInput::New();
|
||||
mTextInput = UITextInput::NewWithTag( mTag + "::input" );
|
||||
mTextInput->setLayoutSizeRules( LayoutSizeRule::Fixed, LayoutSizeRule::Fixed );
|
||||
mTextInput->setParent( this );
|
||||
mTextInput->setFlags( UI_TEXT_SELECTION_ENABLED | UI_VALIGN_TOP );
|
||||
|
||||
@@ -57,10 +57,6 @@ bool UITextInput::isType( const Uint32& type ) const {
|
||||
}
|
||||
|
||||
void UITextInput::scheduledUpdate( const Time& time ) {
|
||||
if ( isMouseOverMeOrChilds() && NULL != mSceneNode ) {
|
||||
mSceneNode->setCursor( Cursor::IBeam );
|
||||
}
|
||||
|
||||
updateWaitingCursor( time );
|
||||
}
|
||||
|
||||
@@ -355,8 +351,15 @@ Uint32 UITextInput::onMouseDoubleClick( const Vector2i& Pos, const Uint32& Flags
|
||||
return 1;
|
||||
}
|
||||
|
||||
Uint32 UITextInput::onMouseOver(const Vector2i& position, const Uint32& flags) {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->setCursor( Cursor::IBeam );
|
||||
|
||||
return UITextView::onMouseOver( position, flags );
|
||||
}
|
||||
|
||||
Uint32 UITextInput::onMouseLeave( const Vector2i& Pos, const Uint32& Flags ) {
|
||||
UIWidget::onMouseLeave( Pos, Flags );
|
||||
UITextView::onMouseLeave( Pos, Flags );
|
||||
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->setCursor( Cursor::Arrow );
|
||||
|
||||
@@ -143,7 +143,7 @@ void UIWindow::updateWinFlags() {
|
||||
|
||||
if ( !( mStyleConfig.WinFlags & UI_WIN_NO_DECORATION ) ) {
|
||||
if ( NULL == mWindowDecoration ) {
|
||||
mWindowDecoration = UINode::New();
|
||||
mWindowDecoration = UIWidget::NewWithTag( "window::decoration" );
|
||||
mWindowDecoration->writeNodeFlag( NODE_FLAG_OWNED_BY_NODE, 1 );
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ void UIWindow::updateWinFlags() {
|
||||
mWindowDecoration->setEnabled( false );
|
||||
|
||||
if ( NULL == mBorderLeft ) {
|
||||
mBorderLeft = UINode::New();
|
||||
mBorderLeft = UIWidget::NewWithTag( "window::border::left" );
|
||||
mBorderLeft->writeNodeFlag( NODE_FLAG_OWNED_BY_NODE, 1 );
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void UIWindow::updateWinFlags() {
|
||||
mBorderLeft->setVisible( true );
|
||||
|
||||
if ( NULL == mBorderRight ) {
|
||||
mBorderRight = UINode::New();
|
||||
mBorderRight = UIWidget::NewWithTag( "window::border::right" );
|
||||
mBorderRight->writeNodeFlag( NODE_FLAG_OWNED_BY_NODE, 1 );
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ void UIWindow::updateWinFlags() {
|
||||
mBorderRight->setVisible( true );
|
||||
|
||||
if ( NULL == mBorderBottom ) {
|
||||
mBorderBottom = UINode::New();
|
||||
mBorderBottom = UIWidget::NewWithTag( "window::border::bottom" );
|
||||
mBorderBottom->writeNodeFlag( NODE_FLAG_OWNED_BY_NODE, 1 );
|
||||
}
|
||||
|
||||
@@ -1298,18 +1298,15 @@ void UIWindow::checkShortcuts( const Uint32& KeyCode, const Uint32& Mod ) {
|
||||
if ( NULL == getEventDispatcher() )
|
||||
return;
|
||||
|
||||
for ( KeyboardShortcuts::iterator it = mKbShortcuts.begin(); it != mKbShortcuts.end(); ++it ) {
|
||||
KeyboardShortcut kb = ( *it );
|
||||
|
||||
for ( auto& kb : mKbShortcuts ) {
|
||||
if ( KeyCode == kb.KeyCode && ( Mod & kb.Mod ) ) {
|
||||
getEventDispatcher()->sendMouseUp( kb.Button, Vector2i( 0, 0 ), EE_BUTTON_LMASK );
|
||||
getEventDispatcher()->sendMouseClick( kb.Button, Vector2i( 0, 0 ), EE_BUTTON_LMASK );
|
||||
getEventDispatcher()->sendMouseUp( kb.Widget, Vector2i( -1, -1 ), EE_BUTTON_LMASK );
|
||||
getEventDispatcher()->sendMouseClick( kb.Widget, Vector2i( -1, -1 ), EE_BUTTON_LMASK );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UIWindow::KeyboardShortcuts::iterator UIWindow::existsShortcut( const Uint32& KeyCode,
|
||||
const Uint32& Mod ) {
|
||||
KeyboardShortcuts::iterator UIWindow::existsShortcut( const Uint32& KeyCode, const Uint32& Mod ) {
|
||||
for ( KeyboardShortcuts::iterator it = mKbShortcuts.begin(); it != mKbShortcuts.end(); ++it ) {
|
||||
if ( ( *it ).KeyCode == KeyCode && ( *it ).Mod == Mod )
|
||||
return it;
|
||||
@@ -1318,9 +1315,9 @@ UIWindow::KeyboardShortcuts::iterator UIWindow::existsShortcut( const Uint32& Ke
|
||||
return mKbShortcuts.end();
|
||||
}
|
||||
|
||||
bool UIWindow::addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIPushButton* Button ) {
|
||||
if ( inParentTreeOf( Button ) && mKbShortcuts.end() == existsShortcut( KeyCode, Mod ) ) {
|
||||
mKbShortcuts.push_back( KeyboardShortcut( KeyCode, Mod, Button ) );
|
||||
bool UIWindow::addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget* Widget ) {
|
||||
if ( inParentTreeOf( Widget ) && mKbShortcuts.end() == existsShortcut( KeyCode, Mod ) ) {
|
||||
mKbShortcuts.push_back( KeyboardShortcut( KeyCode, Mod, Widget ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user