mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
More CSS specification clean up and improvements.
UIPushButton refactorization. Fixed crash on tooltip close. And several minor changes to adapt the CSS specification changes into the widgets.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
/* Global rules */
|
||||
* {
|
||||
color: var(--font-color);
|
||||
color: #E6E6E6FF;
|
||||
shadow-color: #32323296;
|
||||
selected-color: #000;
|
||||
selection-back-color: #969696FF;
|
||||
@@ -31,7 +31,7 @@ TabWidget::TabContainer {
|
||||
ProgressBar {
|
||||
display-percent: true;
|
||||
vertical-expand: true;
|
||||
movement-speed: 32 0;
|
||||
movement-speed: 32dp 0dp;
|
||||
padding: 2dp;
|
||||
}
|
||||
|
||||
@@ -46,10 +46,27 @@ WinMenu::button {
|
||||
|
||||
Menu,
|
||||
PopUpMenu {
|
||||
color: var(--font-color);
|
||||
color: #E6E6E6FF;
|
||||
min-width: 100dp;
|
||||
min-icon-space: 24dp;
|
||||
min-margin-right: 8dp;
|
||||
min-icon-size: 16dp 16dp;
|
||||
}
|
||||
|
||||
Menu::Item,
|
||||
Menu::CheckBox,
|
||||
Menu::Separator,
|
||||
Menu::SubMenu {
|
||||
padding-left: 4dp;
|
||||
}
|
||||
|
||||
Menu::Item::text,
|
||||
Menu::CheckBox::text,
|
||||
Menu::Separator::text,
|
||||
Menu::SubMenu::text {
|
||||
padding-right: 4dp;
|
||||
}
|
||||
|
||||
Menu::SubMenu::arrow {
|
||||
margin-right: 1dp;
|
||||
}
|
||||
|
||||
Menu:hover,
|
||||
@@ -78,10 +95,15 @@ Window {
|
||||
}
|
||||
|
||||
Window::title {
|
||||
color: var(--font-color);
|
||||
color: #E6E6E6FF;
|
||||
font-style: shadow;
|
||||
}
|
||||
|
||||
Tab::text {
|
||||
padding-left: 4dp;
|
||||
padding-right: 4dp;
|
||||
}
|
||||
|
||||
Tooltip {
|
||||
padding: 8dp;
|
||||
color: #020203;
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
<!-- <Loader layout_width="350dp" layout_height="350dp" layout_gravity="center" fill-color="#999" padding="44dp" outline-thickness="8dp" /> -->
|
||||
|
||||
<PushButton layout_width="wrap_content" layout_height="wrap_content" text="testing padding" layout_gravity="bottom|right" gravity="center" padding="8dp" layout_to_top_of="tmp" />
|
||||
<PushButton id="pbut" text="OK!" font-size="16dp" icon="ok" layout_gravity="left|bottom" gravity="center" layout_width="300dp" layout_height="wrap_content" margin-bottom="8dp" padding="8dp" layout_to_top_of="tm" />
|
||||
<PushButton id="pbut" text="OK!" font-size="16dp" icon="ok" layout_gravity="left|bottom"
|
||||
gravity="center" layout_width="wrap_content" layout_height="wrap_content"
|
||||
margin-bottom="8dp" padding="8dp" layout_to_top_of="tm" />
|
||||
|
||||
<Slider id="slider" orientation="horizontal" half-slider="true" layout_width="200dp" layout_height="wrap_content" layout_to_bottom_of="el1" />
|
||||
|
||||
@@ -101,13 +103,13 @@
|
||||
<Widget layout_width="match_parent" layout_height="match_parent" />
|
||||
</hbox>
|
||||
</ViewPager>
|
||||
<Tab name="Padding Test" owns="test_1" />
|
||||
<Tab name="Tabs Test" owns="test_2" />
|
||||
<Tab name="Cascade Test" owns="test_3" />
|
||||
<Tab name="Hover Test" owns="test_4" />
|
||||
<Tab name="Scroll Test" owns="test_5" />
|
||||
<Tab name="Grid Test" owns="test_6" />
|
||||
<Tab name="View Pager Test" owns="test_7" />
|
||||
<Tab name="MinMax Size Test" owns="test_8" />
|
||||
<Tab text="Padding Test" owns="test_1" />
|
||||
<Tab text="Tabs Test" owns="test_2" />
|
||||
<Tab text="Cascade Test" owns="test_3" />
|
||||
<Tab text="Hover Test" owns="test_4" />
|
||||
<Tab text="Scroll Test" owns="test_5" />
|
||||
<Tab text="Grid Test" owns="test_6" />
|
||||
<Tab text="View Pager Test" owns="test_7" />
|
||||
<Tab text="MinMax Size Test" owns="test_8" />
|
||||
</TabWidget>
|
||||
</vbox>
|
||||
|
||||
@@ -45,13 +45,13 @@
|
||||
|
||||
<PushButton layout_width="wrap_content" layout_height="wrap_content" text="testing padding" layout_gravity="bottom|right" gravity="center" padding="8dp" layout_to_top_of="tmp" />
|
||||
<PushButton text="OK!" font-size="16dp" icon="ok" layout_gravity="left|bottom" gravity="center" layout_width="wrap_content" layout_height="wrap_content" margin-bottom="8dp" padding="8dp" layout_to_top_of="tm" />
|
||||
|
||||
|
||||
<Slider id="slider" orientation="horizontal" half-slider="true" layout_width="200dp" layout_height="wrap_content" padding="32dp" background="#555" layout_to_bottom_of="el1" />
|
||||
|
||||
|
||||
<ScrollBar id="scrollbar" orientation="horizontal" layout_width="200dp" layout_height="wrap_content" padding="8dp" background="#12345666" layout_to_bottom_of="slider" />
|
||||
|
||||
<SpinBox id="spinbox" layout_width="200dp" layout_height="wrap_content" padding="8dp" background="#54345666" layout_to_bottom_of="scrollbar" />
|
||||
|
||||
|
||||
<TextEdit layout_width="200dp" layout_height="50dp" layout_gravity="bottom|center_horizontal" padding="16dp" margin-bottom="140dp" />
|
||||
</RelativeLayout>
|
||||
</vbox>
|
||||
@@ -59,9 +59,9 @@
|
||||
<hbox id="test_2" layout_width="match_parent" layout_height="match_parent">
|
||||
<TextView layout_width="match_parent" layout_height="match_parent" text="Hello World!" gravity="center" background="#333" font-size="24dp" border-radius="128" />
|
||||
</hbox>
|
||||
|
||||
<Tab name="Padding Test" owns="test_1" />
|
||||
<Tab name="Tabs Test" owns="test_2" />
|
||||
|
||||
<Tab text="Padding Test" owns="test_1" />
|
||||
<Tab text="Tabs Test" owns="test_2" />
|
||||
</TabWidget>
|
||||
</vbox>
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ TabWidget::TabContainer {
|
||||
ProgressBar {
|
||||
display-percent: true;
|
||||
vertical-expand: true;
|
||||
movement-speed: 32 0;
|
||||
movement-speed: 32dp 0dp;
|
||||
padding: 2dp;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,25 @@ Menu,
|
||||
PopUpMenu {
|
||||
color: #E6E6E6FF;
|
||||
min-width: 100dp;
|
||||
min-icon-space: 24dp;
|
||||
min-margin-right: 8dp;
|
||||
min-icon-size: 16dp 16dp;
|
||||
}
|
||||
|
||||
Menu::Item,
|
||||
Menu::CheckBox,
|
||||
Menu::Separator,
|
||||
Menu::SubMenu {
|
||||
padding-left: 4dp;
|
||||
}
|
||||
|
||||
Menu::Item::text,
|
||||
Menu::CheckBox::text,
|
||||
Menu::Separator::text,
|
||||
Menu::SubMenu::text {
|
||||
padding-right: 4dp;
|
||||
}
|
||||
|
||||
Menu::SubMenu::arrow {
|
||||
margin-right: 1dp;
|
||||
}
|
||||
|
||||
Menu:hover,
|
||||
@@ -70,6 +87,11 @@ Window::title {
|
||||
font-style: shadow;
|
||||
}
|
||||
|
||||
Tab::text {
|
||||
padding-left: 4dp;
|
||||
padding-right: 4dp;
|
||||
}
|
||||
|
||||
Tooltip {
|
||||
padding: 8dp;
|
||||
color: #020203;
|
||||
|
||||
@@ -1049,22 +1049,37 @@ Read [min-height](https://developer.mozilla.org/en-US/docs/Web/CSS/min-height) d
|
||||
|
||||
### min-icon-size
|
||||
|
||||
---
|
||||
Sets the minimum size of the icon inside a push button (or any widget that extends from it, for
|
||||
example a menu item or a tab). It's usually required for the EE::UI::UIMenu (Menu) sice the icon
|
||||
box must have a size if the menu contains items with icons and others without, otherwise the menu
|
||||
items will be misaligned.
|
||||
|
||||
### min-icon-space
|
||||
|
||||
---
|
||||
|
||||
### min-margin-right
|
||||
* Applicatable to: EE::UI::UIPushButton (PushButton), EE::UI::UIMenuItem (Menu::item),
|
||||
EE::UI::UITab (Tab), EE::UI::UISelectButton (SelectButton), EE::UI::UIMenuCheckBox (Menu::checkbox),
|
||||
EE::UI::UIMenuSubMenu (Menu::SubMenu)
|
||||
* Value Type: vector2-length
|
||||
* Default value: _No value_
|
||||
|
||||
---
|
||||
|
||||
### min-tab-width
|
||||
|
||||
Sets the minimum width that a tab can have inside a EE::UI::UITabWidget (TabWidget).
|
||||
|
||||
* Applicable to: EE::UI::UITabWidget (TabWidget)
|
||||
* Value Type: length
|
||||
* Default value: `32dp`
|
||||
|
||||
---
|
||||
|
||||
### min-value
|
||||
|
||||
Sets the minimum value that a range element will hold.
|
||||
|
||||
* Applicable to: EE::UI::UISlider (Slider), EE::UI::UIScrollBar (ScrollBar), EE::UI::UISpinBox (SpinBox)
|
||||
* Value Type: float
|
||||
* Default value: `0`
|
||||
|
||||
---
|
||||
|
||||
### min-width
|
||||
@@ -1075,13 +1090,22 @@ Read [min-width](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) doc
|
||||
|
||||
### movement-speed
|
||||
|
||||
---
|
||||
Sets the movement speed in displaced length per second of the progress bar filler.
|
||||
|
||||
### name
|
||||
* Applicable to: EE::UI::UIProgressBar (ProgressBar)
|
||||
* Value Type: vector2-length
|
||||
* Default value: `0dp 0dp`
|
||||
|
||||
---
|
||||
|
||||
### only-numbers
|
||||
### numeric
|
||||
|
||||
Sets the text input as a numeric input, this means that only numbers will be accepted and
|
||||
if [allow-float](#allow-float) also is enabled it will allow numeric float numbers.
|
||||
|
||||
* Applicable to: EE::UI::UITextInput (TextInput)
|
||||
* Value Type: boolean
|
||||
* Default value: `false`
|
||||
|
||||
---
|
||||
|
||||
@@ -1093,14 +1117,38 @@ Read [opacity](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) documen
|
||||
|
||||
### orientation
|
||||
|
||||
Sets the orientation to any element that allows vertical and horizontal orientation.
|
||||
|
||||
* Applicable to: EE::UI::UILinearLayout (LinearLayout), EE::UI::UISlider (Slider), EE::UI::UIScrollBar
|
||||
(ScrollBar), EE::UI::UIViewPager (ViewPager)
|
||||
* Value Type: string-list
|
||||
* Value List:
|
||||
* `horizontal`
|
||||
* `vertical`
|
||||
* Default value: `vertical` for LinearLayout, Slider and ScrollBar, `horizontal` for ViewPager
|
||||
|
||||
---
|
||||
|
||||
### outline-thickness
|
||||
|
||||
Sets the outline thickness of the loader spinner.
|
||||
|
||||
* Applicable to: EE::UI::UILoader (Loader)
|
||||
* Value Type: length
|
||||
* Default value: `8dp`
|
||||
|
||||
---
|
||||
|
||||
### owns
|
||||
|
||||
Indicates the element ID that the Tab element owns. The ownership indicates that the element ID
|
||||
is going to be shown when the Tab element is selected, and will be closed if the Tab is closed.
|
||||
The owned element will be automatically resized to the tab widget container size.
|
||||
|
||||
* Applicable to: EE::UI::UITab (Tab)
|
||||
* Value Type: string (element ID)
|
||||
* Default value: _No value_
|
||||
|
||||
---
|
||||
|
||||
### padding-bottom
|
||||
|
||||
@@ -76,8 +76,6 @@ enum class PropertyId : Uint32 {
|
||||
TextAlign = String::hash( "text-align" ),
|
||||
Icon = String::hash( "icon" ),
|
||||
MinIconSize = String::hash( "min-icon-size" ),
|
||||
IconHorizontalMargin = String::hash( "icon-horizontal-margin" ),
|
||||
IconAutoMargin = String::hash( "icon-auto-margin" ),
|
||||
Src = String::hash( "src" ),
|
||||
ScaleType = String::hash( "scale-type" ),
|
||||
Tint = String::hash( "tint" ),
|
||||
@@ -118,8 +116,6 @@ enum class PropertyId : Uint32 {
|
||||
MinHeight = String::hash( "min-height" ),
|
||||
MaxWidth = String::hash( "max-width" ),
|
||||
MaxHeight = String::hash( "max-height" ),
|
||||
MinMarginRight = String::hash( "min-margin-right" ),
|
||||
MinIconSpace = String::hash( "min-icon-space" ),
|
||||
TotalSteps = String::hash( "total-steps" ),
|
||||
VerticalExpand = String::hash( "vertical-expand" ),
|
||||
DisplayPercent = String::hash( "display-percent" ),
|
||||
@@ -132,12 +128,11 @@ enum class PropertyId : Uint32 {
|
||||
BackgroundExpand = String::hash( "background-expand" ),
|
||||
ScrollBarMode = String::hash( "scrollbar-mode" ),
|
||||
HalfSlider = String::hash( "half-slider" ),
|
||||
Name = String::hash( "name" ),
|
||||
Owns = String::hash( "owns" ),
|
||||
AllowEditing = String::hash( "allow-editing" ),
|
||||
MaxLength = String::hash( "max-length" ),
|
||||
FreeEditing = String::hash( "free-editing" ),
|
||||
OnlyNumbers = String::hash( "only-numbers" ),
|
||||
Numeric = String::hash( "numeric" ),
|
||||
AllowFloat = String::hash( "allow-float" ),
|
||||
TouchDrag = String::hash( "touch-drag" ),
|
||||
TouchDragDeceleration = String::hash( "touch-drag-deceleration" ),
|
||||
|
||||
@@ -6,20 +6,12 @@
|
||||
#include <eepp/ui/uimenuitem.hpp>
|
||||
#include <eepp/ui/uimenuseparator.hpp>
|
||||
#include <eepp/ui/uimenusubmenu.hpp>
|
||||
#include <eepp/ui/uinode.hpp>
|
||||
#include <eepp/ui/uiwidget.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class EE_API UIMenu : public UIWidget {
|
||||
public:
|
||||
class StyleConfig {
|
||||
public:
|
||||
Rectf Padding = Rectf( 0, 0, 0, 0 );
|
||||
Uint32 MinWidth = 0;
|
||||
Uint32 MinSpaceForIcons = 0;
|
||||
Uint32 MinRightMargin = 0;
|
||||
};
|
||||
|
||||
static UIMenu* New();
|
||||
|
||||
static void fixMenuPos( Vector2f& position, UIMenu* Menu, UIMenu* parent = NULL,
|
||||
@@ -35,7 +27,7 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
Uint32 add( const String& Text, Drawable* Icon = NULL );
|
||||
|
||||
Uint32 add( UINode* Control );
|
||||
Uint32 add( UIWidget* widget );
|
||||
|
||||
Uint32 addSeparator();
|
||||
|
||||
@@ -43,23 +35,23 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
Uint32 addSubMenu( const String& Text, Drawable* Icon = NULL, UIMenu* SubMenu = NULL );
|
||||
|
||||
UINode* getItem( const Uint32& Index );
|
||||
UIWidget* getItem( const Uint32& Index );
|
||||
|
||||
UINode* getItem( const String& Text );
|
||||
UIWidget* getItem( const String& Text );
|
||||
|
||||
Uint32 getItemIndex( UINode* Item );
|
||||
Uint32 getItemIndex( UIWidget* Item );
|
||||
|
||||
Uint32 getCount() const;
|
||||
|
||||
void remove( const Uint32& Index );
|
||||
|
||||
void remove( UINode* Ctrl );
|
||||
void remove( UIWidget* Ctrl );
|
||||
|
||||
void removeAll();
|
||||
|
||||
void insert( const String& Text, Drawable* Icon, const Uint32& Index );
|
||||
|
||||
void insert( UINode* Control, const Uint32& Index );
|
||||
void insert( UIWidget* Control, const Uint32& Index );
|
||||
|
||||
virtual void setTheme( UITheme* Theme );
|
||||
|
||||
@@ -67,12 +59,6 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
virtual bool hide();
|
||||
|
||||
Uint32 getMinRightMargin() const;
|
||||
|
||||
void setMinRightMargin( const Uint32& minRightMargin );
|
||||
|
||||
const StyleConfig& getStyleConfig() const;
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
@@ -85,21 +71,25 @@ class EE_API UIMenu : public UIWidget {
|
||||
/** The owner node is the node who triggers the visibility of the menu */
|
||||
void setOwnerNode( UINode* ownerNode );
|
||||
|
||||
void setIconMinimumSize( const Sizei& minIconSize );
|
||||
|
||||
const Sizei& getIconMinimumSize() const;
|
||||
|
||||
protected:
|
||||
friend class UIMenuItem;
|
||||
friend class UIMenuCheckBox;
|
||||
friend class UIMenuSubMenu;
|
||||
|
||||
std::deque<UINode*> mItems;
|
||||
StyleConfig mStyleConfig;
|
||||
std::deque<UIWidget*> mItems;
|
||||
Uint32 mMaxWidth;
|
||||
Uint32 mNextPosY;
|
||||
Uint32 mBiggestIcon;
|
||||
UINode* mItemSelected;
|
||||
Int32 mBiggestIcon;
|
||||
UIWidget* mItemSelected;
|
||||
Uint32 mItemSelectedIndex;
|
||||
bool mClickHide;
|
||||
Uint32 mLastTickMove;
|
||||
UINode* mOwnerNode;
|
||||
Sizei mIconMinSize;
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
@@ -107,11 +97,11 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
void setControlSize( UINode* Control, const Uint32& position );
|
||||
void setWidgetSize( UIWidget* widget );
|
||||
|
||||
void resizeControls();
|
||||
void widgetsResize();
|
||||
|
||||
void rePosControls();
|
||||
void widgetsSetPos();
|
||||
|
||||
void resizeMe();
|
||||
|
||||
@@ -123,11 +113,13 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
void onThemeLoaded();
|
||||
|
||||
bool checkControlSize( UINode* Control, const bool& Resize = true );
|
||||
virtual void onPaddingChange();
|
||||
|
||||
bool widgetCheckSize( UIWidget* widget, const bool& Resize = true );
|
||||
|
||||
bool isSubMenu( Node* Ctrl );
|
||||
|
||||
void setItemSelected( UINode* Item );
|
||||
void setItemSelected( UIWidget* Item );
|
||||
|
||||
virtual Uint32 onKeyDown( const KeyEvent& Event );
|
||||
|
||||
@@ -135,9 +127,7 @@ class EE_API UIMenu : public UIWidget {
|
||||
|
||||
void nextSel();
|
||||
|
||||
void trySelect( UINode* Ctrl, bool Up );
|
||||
|
||||
void setMinSpaceForIcons( const Uint32& minSpaceForIcons );
|
||||
void trySelect( UIWidget* Ctrl, bool Up );
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -37,7 +37,7 @@ class EE_API UIMenuSubMenu : public UIMenuItem {
|
||||
|
||||
protected:
|
||||
UIMenu* mSubMenu;
|
||||
UINode* mArrow;
|
||||
UIWidget* mArrow;
|
||||
Time mMaxTime;
|
||||
Uint32 mCbId;
|
||||
Uint32 mCbId2;
|
||||
@@ -53,6 +53,8 @@ class EE_API UIMenuSubMenu : public UIMenuItem {
|
||||
|
||||
virtual void onAlphaChange();
|
||||
|
||||
virtual UIWidget* getExtraInnerWidget();
|
||||
|
||||
void onSubMenuFocusLoss( const Event* Event );
|
||||
|
||||
void onHideByClick( const Event* Event );
|
||||
|
||||
@@ -192,7 +192,7 @@ class EE_API UINode : public Node {
|
||||
|
||||
virtual void popState( const Uint32& State, bool emitEvent = true );
|
||||
|
||||
Sizef getSkinSize() const;
|
||||
Sizef getSkinSize( const Uint32& state = UIState::StateFlagNormal ) const;
|
||||
|
||||
void applyDefaultTheme();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class EE_API UIProgressBar : public UIWidget {
|
||||
public:
|
||||
bool DisplayPercent = false;
|
||||
bool VerticalExpand = true;
|
||||
Vector2f MovementSpeed = Vector2f( 64.f, 0 );
|
||||
Vector2f MovementSpeed = Vector2f( 0.f, 0 );
|
||||
};
|
||||
|
||||
static UIProgressBar* New();
|
||||
|
||||
@@ -9,13 +9,6 @@ namespace EE { namespace UI {
|
||||
|
||||
class EE_API UIPushButton : public UIWidget {
|
||||
public:
|
||||
class StyleConfig {
|
||||
public:
|
||||
Int32 IconHorizontalMargin = 4;
|
||||
bool IconAutoMargin = true;
|
||||
Sizei IconMinSize;
|
||||
};
|
||||
|
||||
static UIPushButton* New();
|
||||
|
||||
UIPushButton();
|
||||
@@ -36,17 +29,11 @@ class EE_API UIPushButton : public UIWidget {
|
||||
|
||||
virtual const String& getText();
|
||||
|
||||
void setIconHorizontalMargin( Int32 margin );
|
||||
|
||||
const Int32& getIconHorizontalMargin() const;
|
||||
|
||||
UITextView* getTextBox() const;
|
||||
|
||||
const StyleConfig& getStyleConfig() const;
|
||||
|
||||
void setIconMinimumSize( const Sizei& minIconSize );
|
||||
|
||||
void setStyleConfig( const StyleConfig& styleConfig );
|
||||
const Sizei& getIconMinimumSize() const;
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
@@ -54,9 +41,9 @@ class EE_API UIPushButton : public UIWidget {
|
||||
const Uint32& propertyIndex = 0 );
|
||||
|
||||
protected:
|
||||
StyleConfig mStyleConfig;
|
||||
UIImage* mIcon;
|
||||
UITextView* mTextBox;
|
||||
Sizei mIconMinSize;
|
||||
|
||||
explicit UIPushButton( const std::string& tag );
|
||||
|
||||
@@ -78,7 +65,7 @@ class EE_API UIPushButton : public UIWidget {
|
||||
|
||||
virtual Uint32 onKeyUp( const KeyEvent& Event );
|
||||
|
||||
void autoIconHorizontalMargin();
|
||||
virtual UIWidget* getExtraInnerWidget();
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -207,6 +207,8 @@ class EE_API UIWidget : public UINode {
|
||||
|
||||
const std::string& getMinWidthEq() const;
|
||||
|
||||
void setMinSizeEq( const std::string& minWidthEq, const std::string& minHeightEq );
|
||||
|
||||
void setMinWidthEq( const std::string& minWidthEq );
|
||||
|
||||
const std::string& getMinHeightEq() const;
|
||||
@@ -215,6 +217,8 @@ class EE_API UIWidget : public UINode {
|
||||
|
||||
const std::string& getMaxWidthEq() const;
|
||||
|
||||
void setMaxSizeEq( const std::string& maxWidthEq, const std::string& maxHeightEq );
|
||||
|
||||
void setMaxWidthEq( const std::string& maxWidthEq );
|
||||
|
||||
const std::string& getMaxHeightEq() const;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.11.1, 2020-03-25T03:19:26. -->
|
||||
<!-- Written by QtCreator 4.11.1, 2020-04-04T02:40:31. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -1455,7 +1455,7 @@
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-MapEditor-debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="QString" key="RunConfiguration.Arguments">-x assets/layouts/test.xml -c assets/layouts/test.css -u</value>
|
||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
|
||||
|
||||
@@ -300,7 +300,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
mGOTypeList = UIDropDownList::New();
|
||||
mGOTypeList->setFontStyle( Text::Shadow )
|
||||
->setParent( mTextureRegionCont )
|
||||
->setSize( Width - 26, 0 )
|
||||
->setSize( Width - 30, 0 )
|
||||
->setPosition( TAB_CONT_X_DIST, Txt->getPosition().y + Txt->getSize().getHeight() + 4 );
|
||||
|
||||
mGOTypeList->addEventListener( Event::OnItemSelected,
|
||||
|
||||
@@ -261,9 +261,6 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
.setType( PropertyType::NumberLength )
|
||||
.setRelativeTarget( PropertyRelativeTarget::ContainingBlockHeight );
|
||||
|
||||
registerProperty( "min-margin-right", "" ).setType( PropertyType::NumberLength );
|
||||
registerProperty( "min-icon-space", "" ).setType( PropertyType::NumberLength );
|
||||
|
||||
registerProperty( "total-steps", "" ).setType( PropertyType::NumberInt );
|
||||
registerProperty( "vertical-expand", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "display-percent", "" ).setType( PropertyType::Bool );
|
||||
@@ -276,12 +273,11 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
registerProperty( "background-expand", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "scrollbar-mode", "" );
|
||||
registerProperty( "half-slider", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "name", "" ).setType( PropertyType::String );
|
||||
registerProperty( "owns", "" ).setType( PropertyType::String );
|
||||
registerProperty( "allow-editing", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "max-length", "" ).setType( PropertyType::NumberInt );
|
||||
registerProperty( "free-editing", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "only-numbers", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "numeric", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "allow-float", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "touch-drag", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "touch-drag-deceleration", "" ).setType( PropertyType::NumberFloat );
|
||||
|
||||
@@ -77,8 +77,8 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow* attachTo, const TGEditorCloseC
|
||||
<GridLayout columnMode="size" rowMode="size" columnWidth="64dp" row-height="64dp" layout_width="match_parent" layout_height="wrap_content" id="gridlayout" />
|
||||
</ScrollView>
|
||||
<ListBox id="TextureRegionList" layout_width="match_parent" layout_height="144dp" touchDrag="true" />
|
||||
<Tab name="List" owns="TextureRegionList" />
|
||||
<Tab name="Grid" owns="GridView" />
|
||||
<Tab text="List" owns="TextureRegionList" />
|
||||
<Tab text="Grid" owns="GridView" />
|
||||
</TabWidget>
|
||||
<TextView text="Current TextureRegion:" font-style="shadow" margin-top="16dp" margin-bottom="16dp" />
|
||||
<LinearLayout orientation="horizontal" layout_width="match_parent" layout_height="wrap_content">
|
||||
|
||||
@@ -82,7 +82,7 @@ void UIDropDownList::onAutoSize() {
|
||||
if ( mLayoutHeightRule == LayoutSizeRule::WrapContent ) {
|
||||
setInternalPixelsHeight( PixelDensity::dpToPxI( getSkinSize().getHeight() ) +
|
||||
mRealPadding.Top + mRealPadding.Bottom );
|
||||
} else if ( ( mFlags & UI_AUTO_SIZE || 0 == getSize().getHeight() ) &&
|
||||
} else if ( ( ( mFlags & UI_AUTO_SIZE ) || 0 == getSize().getHeight() ) &&
|
||||
0 != getSkinSize().getHeight() ) {
|
||||
setInternalHeight( getSkinSize().getHeight() );
|
||||
}
|
||||
|
||||
@@ -55,12 +55,15 @@ void UIMenu::onThemeLoaded() {
|
||||
onSizeChange();
|
||||
}
|
||||
|
||||
void UIMenu::onPaddingChange() {
|
||||
widgetsSetPos();
|
||||
}
|
||||
|
||||
UIMenuItem* UIMenu::createMenuItem( const String& Text, Drawable* Icon ) {
|
||||
UIMenuItem* tCtrl = UIMenuItem::New();
|
||||
tCtrl->setHorizontalAlign( UI_HALIGN_LEFT );
|
||||
tCtrl->setParent( this );
|
||||
tCtrl->setIconMinimumSize(
|
||||
Sizei( mStyleConfig.MinSpaceForIcons, mStyleConfig.MinSpaceForIcons ) );
|
||||
tCtrl->setIconMinimumSize( mIconMinSize );
|
||||
tCtrl->setIcon( Icon );
|
||||
tCtrl->setText( Text );
|
||||
|
||||
@@ -75,8 +78,7 @@ UIMenuCheckBox* UIMenu::createMenuCheckBox( const String& Text, const bool& Acti
|
||||
UIMenuCheckBox* tCtrl = UIMenuCheckBox::New();
|
||||
tCtrl->setHorizontalAlign( UI_HALIGN_LEFT );
|
||||
tCtrl->setParent( this );
|
||||
tCtrl->setIconMinimumSize(
|
||||
Sizei( mStyleConfig.MinSpaceForIcons, mStyleConfig.MinSpaceForIcons ) );
|
||||
tCtrl->setIconMinimumSize( mIconMinSize );
|
||||
tCtrl->setText( Text );
|
||||
|
||||
if ( Active )
|
||||
@@ -93,8 +95,7 @@ UIMenuSubMenu* UIMenu::createSubMenu( const String& Text, Drawable* Icon, UIMenu
|
||||
UIMenuSubMenu* tCtrl = UIMenuSubMenu::New();
|
||||
tCtrl->setHorizontalAlign( UI_HALIGN_LEFT );
|
||||
tCtrl->setParent( this );
|
||||
tCtrl->setIconMinimumSize(
|
||||
Sizei( mStyleConfig.MinSpaceForIcons, mStyleConfig.MinSpaceForIcons ) );
|
||||
tCtrl->setIconMinimumSize( mIconMinSize );
|
||||
tCtrl->setIcon( Icon );
|
||||
tCtrl->setText( Text );
|
||||
tCtrl->setSubMenu( SubMenu );
|
||||
@@ -106,47 +107,27 @@ Uint32 UIMenu::addSubMenu( const String& Text, Drawable* Icon, UIMenu* SubMenu )
|
||||
return add( createSubMenu( Text, Icon, SubMenu ) );
|
||||
}
|
||||
|
||||
bool UIMenu::checkControlSize( UINode* Control, const bool& Resize ) {
|
||||
if ( Control->isType( UI_TYPE_MENUITEM ) ) {
|
||||
UIMenuItem* tItem = Control->asType<UIMenuItem>();
|
||||
bool UIMenu::widgetCheckSize( UIWidget* widget, const bool& Resize ) {
|
||||
if ( widget->isType( UI_TYPE_MENUITEM ) ) {
|
||||
UIMenuItem* tItem = widget->asType<UIMenuItem>();
|
||||
|
||||
if ( NULL != tItem->getIcon() &&
|
||||
tItem->getIconHorizontalMargin() + tItem->getIcon()->getSize().getWidth() >
|
||||
(Int32)mBiggestIcon ) {
|
||||
mBiggestIcon =
|
||||
tItem->getIconHorizontalMargin() + tItem->getIcon()->getSize().getWidth();
|
||||
if ( NULL != tItem->getIcon() && tItem->getIcon()->getLayoutMargin().Left +
|
||||
tItem->getIcon()->getLayoutMargin().Right +
|
||||
tItem->getIcon()->getSize().getWidth() >
|
||||
(Int32)mBiggestIcon ) {
|
||||
mBiggestIcon = tItem->getIcon()->getLayoutMargin().Left +
|
||||
tItem->getIcon()->getLayoutMargin().Right +
|
||||
tItem->getIcon()->getSize().getWidth();
|
||||
}
|
||||
|
||||
if ( mFlags & UI_AUTO_SIZE ) {
|
||||
if ( Control->isType( UI_TYPE_MENUSUBMENU ) ) {
|
||||
Int32 textWidth = tItem->getTextBox()->getTextWidth();
|
||||
if ( widget->getPixelsSize().getWidth() > (Int32)mMaxWidth ) {
|
||||
mMaxWidth = widget->getPixelsSize().getWidth();
|
||||
|
||||
UIMenuSubMenu* tMenu = tItem->asType<UIMenuSubMenu>();
|
||||
if ( Resize ) {
|
||||
widgetsResize();
|
||||
|
||||
if ( textWidth + PixelDensity::dpToPxI( mBiggestIcon ) +
|
||||
tMenu->getArrow()->getPixelsSize().getWidth() +
|
||||
PixelDensity::dpToPxI( mStyleConfig.MinRightMargin ) >
|
||||
(Int32)mMaxWidth ) {
|
||||
mMaxWidth =
|
||||
textWidth + mRealPadding.Left + mRealPadding.Right +
|
||||
PixelDensity::dpToPxI( mBiggestIcon + mStyleConfig.MinRightMargin ) +
|
||||
tMenu->getArrow()->getPixelsSize().getWidth();
|
||||
|
||||
if ( Resize ) {
|
||||
resizeControls();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( Control->getPixelsSize().getWidth() > (Int32)mMaxWidth ) {
|
||||
mMaxWidth = Control->getPixelsSize().getWidth();
|
||||
|
||||
if ( Resize ) {
|
||||
resizeControls();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,27 +136,27 @@ bool UIMenu::checkControlSize( UINode* Control, const bool& Resize ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::add( UINode* Control ) {
|
||||
if ( this != Control->getParent() )
|
||||
Control->setParent( this );
|
||||
Uint32 UIMenu::add( UIWidget* widget ) {
|
||||
if ( this != widget->getParent() )
|
||||
widget->setParent( this );
|
||||
|
||||
checkControlSize( Control );
|
||||
widgetCheckSize( widget );
|
||||
|
||||
setControlSize( Control, getCount() );
|
||||
setWidgetSize( widget );
|
||||
|
||||
Control->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY );
|
||||
widget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY );
|
||||
|
||||
mNextPosY += Control->getPixelsSize().getHeight();
|
||||
mNextPosY += widget->getPixelsSize().getHeight();
|
||||
|
||||
mItems.push_back( Control );
|
||||
mItems.push_back( widget );
|
||||
|
||||
resizeMe();
|
||||
|
||||
return mItems.size() - 1;
|
||||
}
|
||||
|
||||
void UIMenu::setControlSize( UINode* Control, const Uint32& ) {
|
||||
Control->setPixelsSize( mSize.getWidth(), Control->getPixelsSize().getHeight() );
|
||||
void UIMenu::setWidgetSize( UIWidget* widget ) {
|
||||
widget->setPixelsSize( mSize.getWidth(), widget->getPixelsSize().getHeight() );
|
||||
}
|
||||
|
||||
Uint32 UIMenu::addSeparator() {
|
||||
@@ -194,12 +175,12 @@ Uint32 UIMenu::addSeparator() {
|
||||
return mItems.size() - 1;
|
||||
}
|
||||
|
||||
UINode* UIMenu::getItem( const Uint32& Index ) {
|
||||
UIWidget* UIMenu::getItem( const Uint32& Index ) {
|
||||
eeASSERT( Index < mItems.size() );
|
||||
return mItems[Index];
|
||||
}
|
||||
|
||||
UINode* UIMenu::getItem( const String& Text ) {
|
||||
UIWidget* UIMenu::getItem( const String& Text ) {
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
if ( mItems[i]->isType( UI_TYPE_MENUITEM ) ) {
|
||||
UIMenuItem* tMenuItem = mItems[i]->asType<UIMenuItem>();
|
||||
@@ -212,7 +193,7 @@ UINode* UIMenu::getItem( const String& Text ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Uint32 UIMenu::getItemIndex( UINode* Item ) {
|
||||
Uint32 UIMenu::getItemIndex( UIWidget* Item ) {
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
if ( mItems[i] == Item )
|
||||
return i;
|
||||
@@ -232,11 +213,11 @@ void UIMenu::remove( const Uint32& Index ) {
|
||||
|
||||
mItems.erase( mItems.begin() + Index );
|
||||
|
||||
rePosControls();
|
||||
resizeControls();
|
||||
widgetsSetPos();
|
||||
widgetsResize();
|
||||
}
|
||||
|
||||
void UIMenu::remove( UINode* Ctrl ) {
|
||||
void UIMenu::remove( UIWidget* Ctrl ) {
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
if ( mItems[i] == Ctrl ) {
|
||||
remove( i );
|
||||
@@ -261,13 +242,13 @@ void UIMenu::insert( const String& Text, Drawable* Icon, const Uint32& Index ) {
|
||||
insert( createMenuItem( Text, Icon ), Index );
|
||||
}
|
||||
|
||||
void UIMenu::insert( UINode* Control, const Uint32& Index ) {
|
||||
void UIMenu::insert( UIWidget* Control, const Uint32& Index ) {
|
||||
mItems.insert( mItems.begin() + Index, Control );
|
||||
|
||||
childAddAt( Control, Index );
|
||||
|
||||
rePosControls();
|
||||
resizeControls();
|
||||
widgetsSetPos();
|
||||
widgetsResize();
|
||||
}
|
||||
|
||||
bool UIMenu::isSubMenu( Node* Ctrl ) {
|
||||
@@ -313,9 +294,13 @@ Uint32 UIMenu::onMessage( const NodeMessage* Msg ) {
|
||||
}
|
||||
|
||||
void UIMenu::onSizeChange() {
|
||||
if ( 0 != mStyleConfig.MinWidth && getSize().getWidth() < (Int32)mStyleConfig.MinWidth ) {
|
||||
setSize( mStyleConfig.MinWidth,
|
||||
PixelDensity::pxToDpI( mNextPosY ) + mPadding.Top + mPadding.Bottom );
|
||||
Float minWidth = 0;
|
||||
if ( !mMinWidthEq.empty() ) {
|
||||
minWidth = lengthFromValueAsDp( mMinWidthEq, CSS::PropertyRelativeTarget::None );
|
||||
}
|
||||
|
||||
if ( 0 != minWidth && getSize().getWidth() < (Int32)minWidth ) {
|
||||
setSize( minWidth, PixelDensity::pxToDpI( mNextPosY ) + mPadding.Top + mPadding.Bottom );
|
||||
}
|
||||
|
||||
UIWidget::onSizeChange();
|
||||
@@ -323,37 +308,37 @@ void UIMenu::onSizeChange() {
|
||||
|
||||
void UIMenu::autoPadding() {
|
||||
if ( mFlags & UI_AUTO_PADDING ) {
|
||||
mPadding = makePadding();
|
||||
setPadding( makePadding() );
|
||||
}
|
||||
}
|
||||
|
||||
void UIMenu::resizeControls() {
|
||||
void UIMenu::widgetsResize() {
|
||||
resizeMe();
|
||||
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
setControlSize( mItems[i], i );
|
||||
setWidgetSize( mItems[i] );
|
||||
}
|
||||
}
|
||||
|
||||
void UIMenu::rePosControls() {
|
||||
void UIMenu::widgetsSetPos() {
|
||||
Uint32 i;
|
||||
mNextPosY = 0;
|
||||
mBiggestIcon = mStyleConfig.MinSpaceForIcons;
|
||||
mBiggestIcon = mIconMinSize.getWidth();
|
||||
|
||||
if ( mFlags & UI_AUTO_SIZE ) {
|
||||
mMaxWidth = 0;
|
||||
|
||||
for ( i = 0; i < mItems.size(); i++ ) {
|
||||
checkControlSize( mItems[i], false );
|
||||
widgetCheckSize( mItems[i], false );
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < mItems.size(); i++ ) {
|
||||
UINode* ctrl = mItems[i];
|
||||
UIWidget* widget = mItems[i];
|
||||
|
||||
ctrl->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY );
|
||||
widget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY );
|
||||
|
||||
mNextPosY += ctrl->getPixelsSize().getHeight();
|
||||
mNextPosY += widget->getPixelsSize().getHeight();
|
||||
}
|
||||
|
||||
resizeMe();
|
||||
@@ -387,7 +372,7 @@ bool UIMenu::hide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void UIMenu::setItemSelected( UINode* Item ) {
|
||||
void UIMenu::setItemSelected( UIWidget* Item ) {
|
||||
if ( NULL != mItemSelected ) {
|
||||
if ( mItemSelected->isType( UI_TYPE_MENUSUBMENU ) ) {
|
||||
UIMenuSubMenu* tMenu = mItemSelected->asType<UIMenuSubMenu>();
|
||||
@@ -408,7 +393,7 @@ void UIMenu::setItemSelected( UINode* Item ) {
|
||||
}
|
||||
}
|
||||
|
||||
void UIMenu::trySelect( UINode* Ctrl, bool Up ) {
|
||||
void UIMenu::trySelect( UIWidget* Ctrl, bool Up ) {
|
||||
if ( mItems.size() ) {
|
||||
if ( !Ctrl->isType( UI_TYPE_MENU_SEPARATOR ) ) {
|
||||
setItemSelected( Ctrl );
|
||||
@@ -515,19 +500,6 @@ Uint32 UIMenu::onKeyDown( const KeyEvent& Event ) {
|
||||
return UIWidget::onKeyDown( Event );
|
||||
}
|
||||
|
||||
Uint32 UIMenu::getMinRightMargin() const {
|
||||
return mStyleConfig.MinRightMargin;
|
||||
}
|
||||
|
||||
void UIMenu::setMinRightMargin( const Uint32& minRightMargin ) {
|
||||
mStyleConfig.MinRightMargin = minRightMargin;
|
||||
rePosControls();
|
||||
}
|
||||
|
||||
const UIMenu::StyleConfig& UIMenu::getStyleConfig() const {
|
||||
return mStyleConfig;
|
||||
}
|
||||
|
||||
static Drawable* getIconDrawable( const std::string& name, UITheme* theme ) {
|
||||
Drawable* iconDrawable = NULL;
|
||||
|
||||
@@ -594,12 +566,9 @@ std::string UIMenu::getPropertyString( const PropertyDefinition* propertyDef,
|
||||
return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::MinWidth:
|
||||
return String::format( "%udp", mStyleConfig.MinWidth );
|
||||
case PropertyId::MinMarginRight:
|
||||
return String::format( "%udp", getMinRightMargin() );
|
||||
case PropertyId::MinIconSpace:
|
||||
return String::format( "%udp", mStyleConfig.MinSpaceForIcons );
|
||||
case PropertyId::MinIconSize:
|
||||
return String::format( "%ddp", mIconMinSize.getWidth() ) + " " +
|
||||
String::format( "%ddp", mIconMinSize.getHeight() );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef, propertyIndex );
|
||||
}
|
||||
@@ -610,15 +579,8 @@ bool UIMenu::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
return false;
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::MinWidth:
|
||||
mStyleConfig.MinWidth = attribute.asDpDimensionI();
|
||||
onSizeChange();
|
||||
break;
|
||||
case PropertyId::MinMarginRight:
|
||||
setMinRightMargin( attribute.asDpDimensionUint() );
|
||||
break;
|
||||
case PropertyId::MinIconSpace:
|
||||
setMinSpaceForIcons( attribute.asDpDimensionUint() );
|
||||
case PropertyId::MinIconSize:
|
||||
setIconMinimumSize( attribute.asSizei() );
|
||||
break;
|
||||
default:
|
||||
return UIWidget::applyProperty( attribute );
|
||||
@@ -635,23 +597,24 @@ void UIMenu::setOwnerNode( UINode* ownerNode ) {
|
||||
mOwnerNode = ownerNode;
|
||||
}
|
||||
|
||||
void UIMenu::setMinSpaceForIcons( const Uint32& minSpaceForIcons ) {
|
||||
// if ( minSpaceForIcons != mStyleConfig.MinSpaceForIcons )
|
||||
{
|
||||
mStyleConfig.MinSpaceForIcons = minSpaceForIcons;
|
||||
mBiggestIcon = eemax( mBiggestIcon, mStyleConfig.MinSpaceForIcons );
|
||||
void UIMenu::setIconMinimumSize( const Sizei& minIconSize ) {
|
||||
mIconMinSize = minIconSize;
|
||||
mBiggestIcon = eemax( mBiggestIcon, mIconMinSize.getWidth() );
|
||||
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
if ( mItems[i]->isType( UI_TYPE_MENUITEM ) ) {
|
||||
UIMenuItem* menuItem = static_cast<UIMenuItem*>( mItems[i] );
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
if ( mItems[i]->isType( UI_TYPE_MENUITEM ) ) {
|
||||
UIMenuItem* menuItem = static_cast<UIMenuItem*>( mItems[i] );
|
||||
|
||||
menuItem->setIconMinimumSize( Sizei( minSpaceForIcons, minSpaceForIcons ) );
|
||||
}
|
||||
menuItem->setIconMinimumSize( mIconMinSize );
|
||||
}
|
||||
|
||||
rePosControls();
|
||||
resizeControls();
|
||||
}
|
||||
|
||||
widgetsSetPos();
|
||||
widgetsResize();
|
||||
}
|
||||
|
||||
const Sizei& UIMenu::getIconMinimumSize() const {
|
||||
return mIconMinSize;
|
||||
}
|
||||
|
||||
void UIMenu::fixMenuPos( Vector2f& Pos, UIMenu* Menu, UIMenu* Parent, UIMenuSubMenu* SubMenu ) {
|
||||
|
||||
@@ -75,7 +75,7 @@ void UIMenuCheckBox::setActive( const bool& active ) {
|
||||
if ( oActive != active ) {
|
||||
UIMenu* Menu = getParent()->asType<UIMenu>();
|
||||
|
||||
if ( !Menu->checkControlSize( this ) ) {
|
||||
if ( !Menu->widgetCheckSize( this ) ) {
|
||||
if ( NULL != getIcon()->getDrawable() ) {
|
||||
setPadding( Rectf( 0, 0, 0, 0 ) );
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ UIMenuItem* UIMenuItem::New() {
|
||||
}
|
||||
|
||||
UIMenuItem::UIMenuItem( const std::string& tag ) : UIPushButton( tag ) {
|
||||
mIcon->setElementTag( getElementTag() + "::image" );
|
||||
mIcon->setElementTag( getElementTag() + "::icon" );
|
||||
mTextBox->setElementTag( getElementTag() + "::text" );
|
||||
applyDefaultTheme();
|
||||
}
|
||||
|
||||
@@ -16,11 +16,13 @@ UIMenuSubMenu::UIMenuSubMenu() :
|
||||
mCbId( 0 ),
|
||||
mCbId2( 0 ),
|
||||
mCurWait( NULL ) {
|
||||
mArrow = UINode::New();
|
||||
mArrow = UIWidget::NewWithTag( getElementTag() + "::arrow" );
|
||||
mArrow->setParent( this );
|
||||
mArrow->setFlags( UI_AUTO_SIZE );
|
||||
mArrow->setVisible( true );
|
||||
mArrow->setEnabled( false );
|
||||
mArrow->addEventListener( Event::OnMarginChange,
|
||||
[&]( const Event* event ) { onSizeChange(); } );
|
||||
|
||||
applyDefaultTheme();
|
||||
}
|
||||
@@ -48,9 +50,8 @@ void UIMenuSubMenu::setTheme( UITheme* Theme ) {
|
||||
|
||||
void UIMenuSubMenu::onSizeChange() {
|
||||
UIMenuItem::onSizeChange();
|
||||
|
||||
mArrow->setPosition( getParent()->getSize().getWidth() - mArrow->getSize().getWidth() -
|
||||
PixelDensity::dpToPx( 1 ),
|
||||
mArrow->setPosition( getSize().getWidth() - mArrow->getSize().getWidth() -
|
||||
PixelDensity::dpToPx( mArrow->getLayoutMargin().Right ),
|
||||
0 );
|
||||
mArrow->centerVertical();
|
||||
}
|
||||
@@ -61,6 +62,10 @@ void UIMenuSubMenu::onAlphaChange() {
|
||||
mArrow->setAlpha( mAlpha );
|
||||
}
|
||||
|
||||
UIWidget* UIMenuSubMenu::getExtraInnerWidget() {
|
||||
return mArrow;
|
||||
}
|
||||
|
||||
void UIMenuSubMenu::onStateChange() {
|
||||
UIMenuItem::onStateChange();
|
||||
|
||||
|
||||
@@ -929,9 +929,9 @@ Sizef UINode::getSkinSize( UISkin* Skin, const Uint32& State ) const {
|
||||
return Sizef::Zero;
|
||||
}
|
||||
|
||||
Sizef UINode::getSkinSize() const {
|
||||
Sizef UINode::getSkinSize( const Uint32& state ) const {
|
||||
if ( NULL != getSkin() ) {
|
||||
return getSkin()->getSize();
|
||||
return getSkin()->getSize( state );
|
||||
}
|
||||
|
||||
return Sizef::Zero;
|
||||
@@ -1124,6 +1124,7 @@ Float UINode::getPropertyRelativeTargetContainerLength(
|
||||
case PropertyRelativeTarget::LocalBlockRadiusHeight:
|
||||
containerLength = getPixelsSize().getHeight() * 0.5f;
|
||||
break;
|
||||
case PropertyRelativeTarget::None:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -211,8 +211,8 @@ std::string UIProgressBar::getPropertyString( const PropertyDefinition* property
|
||||
case PropertyId::DisplayPercent:
|
||||
return mStyleConfig.DisplayPercent ? "true" : "false";
|
||||
case PropertyId::MovementSpeed:
|
||||
return String::fromFloat( getMovementSpeed().x ) + " " +
|
||||
String::fromFloat( getMovementSpeed().y );
|
||||
return String::fromFloat( getMovementSpeed().x, "px" ) + " " +
|
||||
String::fromFloat( getMovementSpeed().y, "px" );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef, propertyIndex );
|
||||
}
|
||||
@@ -236,7 +236,7 @@ bool UIProgressBar::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setDisplayPercent( attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::MovementSpeed:
|
||||
setMovementSpeed( attribute.asVector2f() );
|
||||
setMovementSpeed( attribute.asVector2f( this ) );
|
||||
break;
|
||||
default:
|
||||
return UIWidget::applyProperty( attribute );
|
||||
|
||||
@@ -15,7 +15,7 @@ UIPushButton::UIPushButton( const std::string& tag ) :
|
||||
UIWidget( tag ), mIcon( NULL ), mTextBox( NULL ) {
|
||||
mFlags |= ( UI_AUTO_SIZE | UI_VALIGN_CENTER | UI_HALIGN_CENTER );
|
||||
|
||||
mIcon = UIImage::NewWithTag( "pushbutton::image" );
|
||||
mIcon = UIImage::NewWithTag( "pushbutton::icon" );
|
||||
mIcon->setScaleType( UIScaleType::FitInside )
|
||||
->setLayoutSizeRules( LayoutSizeRule::Fixed, LayoutSizeRule::Fixed )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
@@ -23,21 +23,31 @@ UIPushButton::UIPushButton( const std::string& tag ) :
|
||||
->setVisible( true )
|
||||
->setEnabled( false );
|
||||
|
||||
mTextBox = UITextView::NewWithTag( "pushbutton::text" );
|
||||
mTextBox->setLayoutSizeRules( LayoutSizeRule::WrapContent, LayoutSizeRule::WrapContent )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
->setParent( this )
|
||||
->setVisible( true )
|
||||
->setEnabled( false );
|
||||
|
||||
auto cb = [&]( const Event* event ) {
|
||||
onSizeChange();
|
||||
notifyLayoutAttrChange();
|
||||
};
|
||||
|
||||
mIcon->addEventListener( Event::OnPaddingChange, cb );
|
||||
mIcon->addEventListener( Event::OnMarginChange, cb );
|
||||
mIcon->addEventListener( Event::OnSizeChange, cb );
|
||||
|
||||
mTextBox = UITextView::NewWithTag( "pushbutton::text" );
|
||||
mTextBox->setLayoutSizeRules( LayoutSizeRule::WrapContent, LayoutSizeRule::WrapContent )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
->setParent( this )
|
||||
->setVisible( true )
|
||||
->setEnabled( false );
|
||||
mTextBox->addEventListener( Event::OnFontChanged, cb );
|
||||
mTextBox->addEventListener( Event::OnFontStyleChanged, cb );
|
||||
mTextBox->addEventListener( Event::OnTextChanged, cb );
|
||||
|
||||
if ( NULL != getExtraInnerWidget() ) {
|
||||
getExtraInnerWidget()->addEventListener( Event::OnPaddingChange, cb );
|
||||
getExtraInnerWidget()->addEventListener( Event::OnMarginChange, cb );
|
||||
getExtraInnerWidget()->addEventListener( Event::OnSizeChange, cb );
|
||||
}
|
||||
|
||||
onSizeChange();
|
||||
|
||||
applyDefaultTheme();
|
||||
@@ -56,25 +66,36 @@ bool UIPushButton::isType( const Uint32& type ) const {
|
||||
}
|
||||
|
||||
void UIPushButton::onAutoSize() {
|
||||
if ( ( mFlags & UI_AUTO_SIZE ) && NULL != getSkin() ) {
|
||||
if ( ( ( mFlags & UI_AUTO_SIZE ) && 0 == getSize().getHeight() ) ||
|
||||
mLayoutHeightRule == LayoutSizeRule::WrapContent ) {
|
||||
Float sH = getSkinSize().getHeight();
|
||||
Float sHS = getSkinSize( UIState::StateFlagSelected ).getHeight();
|
||||
Float tH = mTextBox->getPixelsSize().getHeight();
|
||||
Float eH =
|
||||
NULL != getExtraInnerWidget() ? getExtraInnerWidget()->getPixelsSize().getHeight() : 0;
|
||||
Float h = eemax( eemax( PixelDensity::dpToPx( eemax( sH, sHS ) ), tH ), eH );
|
||||
setInternalPixelsHeight( h + mRealPadding.Top + mRealPadding.Bottom );
|
||||
} else if ( ( mFlags & UI_AUTO_SIZE ) && NULL != getSkin() ) {
|
||||
setInternalHeight( getSkinSize().getHeight() );
|
||||
}
|
||||
|
||||
if ( ( mFlags & UI_AUTO_SIZE ) &&
|
||||
( 0 == getSize().getHeight() || mLayoutHeightRule == LayoutSizeRule::WrapContent ) ) {
|
||||
Float h = eemax<Float>( PixelDensity::dpToPx( getSkinSize().getHeight() ),
|
||||
mTextBox->getTextHeight() );
|
||||
|
||||
setInternalPixelsHeight( h + mRealPadding.Top + mRealPadding.Bottom );
|
||||
}
|
||||
|
||||
if ( ( mFlags & UI_AUTO_SIZE ) || mLayoutWidthRule == LayoutSizeRule::WrapContent ) {
|
||||
Int32 txtW = NULL != mTextBox ? mTextBox->getTextWidth() : 0;
|
||||
Int32 txtW = mTextBox->getPixelsSize().getWidth();
|
||||
Int32 iconSize = mIcon->getPixelsSize().getWidth() > 0
|
||||
? mIcon->getPixelsSize().getWidth() +
|
||||
PixelDensity::dpToPxI( mIcon->getLayoutMargin().Left +
|
||||
mIcon->getLayoutMargin().Right )
|
||||
: 0;
|
||||
|
||||
UIWidget* eWidget = getExtraInnerWidget();
|
||||
Int32 eWidgetSize = NULL != eWidget
|
||||
? PixelDensity::dpToPxI( eWidget->getSize().getWidth() +
|
||||
eWidget->getLayoutMargin().Left +
|
||||
eWidget->getLayoutMargin().Right )
|
||||
: 0;
|
||||
|
||||
Int32 minSize =
|
||||
txtW + ( NULL != mIcon ? mIcon->getPixelsSize().getWidth() : 0 ) +
|
||||
PixelDensity::dpToPxI( mStyleConfig.IconHorizontalMargin ) + mRealPadding.Left +
|
||||
mRealPadding.Right +
|
||||
txtW + iconSize + eWidgetSize + mRealPadding.Left + mRealPadding.Right +
|
||||
( NULL != getSkin() ? PixelDensity::dpToPxI( getSkin()->getBorderSize().Left +
|
||||
getSkin()->getBorderSize().Right )
|
||||
: 0 );
|
||||
@@ -109,54 +130,90 @@ void UIPushButton::onSizeChange() {
|
||||
if ( mRealPadding.Right > autoPadding.Right )
|
||||
autoPadding.Right = mRealPadding.Right;
|
||||
|
||||
mIcon->setPixelsPosition( autoPadding.Left + mStyleConfig.IconHorizontalMargin, 0 );
|
||||
mIcon->centerVertical();
|
||||
Vector2f position;
|
||||
Vector2f iconPos;
|
||||
Vector2f ePos;
|
||||
UIWidget* eWidget = getExtraInnerWidget();
|
||||
|
||||
if ( NULL != mTextBox ) {
|
||||
Vector2f position;
|
||||
Float iconWidth = mIcon->getPixelsSize().getWidth() > 0
|
||||
? mIcon->getPixelsSize().getWidth() +
|
||||
PixelDensity::dpToPxI( mIcon->getLayoutMargin().Left +
|
||||
mIcon->getLayoutMargin().Right )
|
||||
: 0;
|
||||
Float eWidth = NULL != eWidget && eWidget->getPixelsSize().getWidth() > 0
|
||||
? eWidget->getPixelsSize().getWidth() +
|
||||
PixelDensity::dpToPxI( eWidget->getLayoutMargin().Left +
|
||||
eWidget->getLayoutMargin().Right )
|
||||
: 0;
|
||||
Float textBoxWidth = mTextBox->getPixelsSize().getWidth();
|
||||
Float totalWidth = textBoxWidth + iconWidth + eWidth;
|
||||
|
||||
switch ( Font::getVerticalAlign( getFlags() ) ) {
|
||||
case UI_VALIGN_CENTER:
|
||||
position.y = ( mSize.getHeight() - mTextBox->getPixelsSize().getHeight() ) / 2;
|
||||
break;
|
||||
case UI_VALIGN_BOTTOM:
|
||||
position.y = mSize.y - mTextBox->getPixelsSize().getHeight() - autoPadding.Bottom;
|
||||
break;
|
||||
case UI_VALIGN_TOP:
|
||||
position.y = autoPadding.Top;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( Font::getHorizontalAlign( getFlags() ) ) {
|
||||
case UI_HALIGN_RIGHT:
|
||||
position.x =
|
||||
mSize.getWidth() - mTextBox->getPixelsSize().getWidth() - autoPadding.Right;
|
||||
break;
|
||||
case UI_HALIGN_CENTER:
|
||||
position.x = ( mSize.getWidth() - mTextBox->getPixelsSize().getWidth() ) / 2;
|
||||
|
||||
if ( NULL != mIcon->getDrawable() ) {
|
||||
Uint32 iconPos =
|
||||
mIcon->getPixelsPosition().x + mIcon->getPixelsSize().getWidth();
|
||||
|
||||
if ( iconPos >= position.x ) {
|
||||
Float px = PixelDensity::dpToPx( 1 );
|
||||
|
||||
position.x = iconPos + px;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case UI_HALIGN_LEFT:
|
||||
position.x = mIcon->getPixelsPosition().x + mIcon->getPixelsSize().getWidth();
|
||||
break;
|
||||
}
|
||||
|
||||
mTextBox->setPixelsPosition( position );
|
||||
switch ( Font::getVerticalAlign( getFlags() ) ) {
|
||||
case UI_VALIGN_CENTER:
|
||||
iconPos.y =
|
||||
eefloor( ( mSize.getHeight() - mIcon->getPixelsSize().getHeight() ) * 0.5f );
|
||||
position.y =
|
||||
eefloor( ( mSize.getHeight() - mTextBox->getPixelsSize().getHeight() ) * 0.5f );
|
||||
ePos.y =
|
||||
NULL != eWidget
|
||||
? eefloor( ( mSize.getHeight() - eWidget->getPixelsSize().getHeight() ) * 0.5f )
|
||||
: 0;
|
||||
break;
|
||||
case UI_VALIGN_BOTTOM:
|
||||
iconPos.y = mSize.y - mIcon->getPixelsSize().getHeight() - autoPadding.Bottom;
|
||||
position.y = mSize.y - mTextBox->getPixelsSize().getHeight() - autoPadding.Bottom;
|
||||
ePos.y = NULL != eWidget
|
||||
? mSize.y - eWidget->getPixelsSize().getHeight() - autoPadding.Bottom
|
||||
: 0;
|
||||
break;
|
||||
case UI_VALIGN_TOP:
|
||||
iconPos.y = autoPadding.Top;
|
||||
position.y = autoPadding.Top;
|
||||
ePos.y = autoPadding.Top;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( NULL != mTextBox && mTextBox->getText().empty() ) {
|
||||
mIcon->center();
|
||||
switch ( Font::getHorizontalAlign( getFlags() ) ) {
|
||||
case UI_HALIGN_RIGHT:
|
||||
position.x = mSize.getWidth() - autoPadding.Right;
|
||||
ePos.x = position.x;
|
||||
|
||||
if ( NULL != eWidget ) {
|
||||
ePos.x = position.x - PixelDensity::dpToPx( eWidget->getLayoutMargin().Right ) -
|
||||
eWidget->getPixelsSize().getWidth();
|
||||
position.x = ePos.x - PixelDensity::dpToPx( eWidget->getLayoutMargin().Left );
|
||||
}
|
||||
|
||||
position.x -= textBoxWidth;
|
||||
|
||||
iconPos.x = position.x - PixelDensity::dpToPxI( mIcon->getLayoutMargin().Right ) -
|
||||
mIcon->getPixelsSize().getWidth();
|
||||
break;
|
||||
case UI_HALIGN_CENTER:
|
||||
position.x = ( mSize.getWidth() - totalWidth ) / 2 + iconWidth;
|
||||
iconPos.x = ( mSize.getWidth() - totalWidth ) / 2 +
|
||||
PixelDensity::dpToPxI( mIcon->getLayoutMargin().Left );
|
||||
|
||||
if ( NULL != eWidget ) {
|
||||
ePos.x = position.x + textBoxWidth +
|
||||
PixelDensity::dpToPx( eWidget->getLayoutMargin().Left );
|
||||
}
|
||||
break;
|
||||
case UI_HALIGN_LEFT:
|
||||
position.x = autoPadding.Left + iconWidth;
|
||||
iconPos.x = autoPadding.Left + PixelDensity::dpToPxI( mIcon->getLayoutMargin().Left );
|
||||
|
||||
if ( NULL != eWidget ) {
|
||||
ePos.x = position.x + textBoxWidth +
|
||||
PixelDensity::dpToPx( eWidget->getLayoutMargin().Left );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
mTextBox->setPixelsPosition( position );
|
||||
mIcon->setPixelsPosition( iconPos );
|
||||
if ( NULL != eWidget ) {
|
||||
eWidget->setPixelsPosition( ePos );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +225,7 @@ void UIPushButton::setTheme( UITheme* Theme ) {
|
||||
}
|
||||
|
||||
void UIPushButton::onThemeLoaded() {
|
||||
autoIconHorizontalMargin();
|
||||
|
||||
onAutoSize();
|
||||
onSizeChange();
|
||||
|
||||
UIWidget::onThemeLoaded();
|
||||
}
|
||||
@@ -195,15 +250,6 @@ const String& UIPushButton::getText() {
|
||||
return mTextBox->getText();
|
||||
}
|
||||
|
||||
void UIPushButton::setIconHorizontalMargin( Int32 margin ) {
|
||||
mStyleConfig.IconHorizontalMargin = margin;
|
||||
onSizeChange();
|
||||
}
|
||||
|
||||
const Int32& UIPushButton::getIconHorizontalMargin() const {
|
||||
return mStyleConfig.IconHorizontalMargin;
|
||||
}
|
||||
|
||||
UITextView* UIPushButton::getTextBox() const {
|
||||
return mTextBox;
|
||||
}
|
||||
@@ -213,6 +259,10 @@ void UIPushButton::onAlphaChange() {
|
||||
|
||||
mIcon->setAlpha( mAlpha );
|
||||
mTextBox->setAlpha( mAlpha );
|
||||
|
||||
if ( NULL != getExtraInnerWidget() ) {
|
||||
getExtraInnerWidget()->setAlpha( mAlpha );
|
||||
}
|
||||
}
|
||||
|
||||
void UIPushButton::onStateChange() {
|
||||
@@ -233,7 +283,6 @@ Uint32 UIPushButton::onKeyDown( const KeyEvent& Event ) {
|
||||
NodeMessage Msg( this, NodeMessage::Click, EE_BUTTON_LMASK );
|
||||
messagePost( &Msg );
|
||||
onMouseClick( Vector2i( 0, 0 ), EE_BUTTON_LMASK );
|
||||
|
||||
pushState( UIState::StatePressed );
|
||||
}
|
||||
|
||||
@@ -248,37 +297,23 @@ Uint32 UIPushButton::onKeyUp( const KeyEvent& Event ) {
|
||||
return UIWidget::onKeyUp( Event );
|
||||
}
|
||||
|
||||
void UIPushButton::autoIconHorizontalMargin() {
|
||||
if ( mStyleConfig.IconAutoMargin ) {
|
||||
Rectf RMargin = makePadding( true, false, false, false, true );
|
||||
setIconHorizontalMargin( RMargin.Left );
|
||||
}
|
||||
}
|
||||
|
||||
const UIPushButton::StyleConfig& UIPushButton::getStyleConfig() const {
|
||||
return mStyleConfig;
|
||||
}
|
||||
|
||||
void UIPushButton::setIconMinimumSize( const Sizei& minIconSize ) {
|
||||
if ( minIconSize != mStyleConfig.IconMinSize ) {
|
||||
mStyleConfig.IconMinSize = minIconSize;
|
||||
if ( minIconSize != mIconMinSize ) {
|
||||
mIconMinSize = minIconSize;
|
||||
|
||||
if ( mStyleConfig.IconMinSize.x != 0 && mStyleConfig.IconMinSize.y != 0 ) {
|
||||
Sizef minSize( eemax( getSize().getWidth(), (Float)mStyleConfig.IconMinSize.x ),
|
||||
eemax( getSize().getHeight(), (Float)mStyleConfig.IconMinSize.y ) );
|
||||
|
||||
if ( minSize != getSize() ) {
|
||||
mIcon->setSize( minSize );
|
||||
onSizeChange();
|
||||
}
|
||||
if ( mIconMinSize.x != 0 && mIconMinSize.y != 0 ) {
|
||||
mIcon->setMinSizeEq( String::fromFloat( mIconMinSize.x, "dp" ),
|
||||
String::fromFloat( mIconMinSize.y, "dp" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIPushButton::setStyleConfig( const StyleConfig& styleConfig ) {
|
||||
setIconMinimumSize( styleConfig.IconMinSize );
|
||||
mStyleConfig = styleConfig;
|
||||
onStateChange();
|
||||
const Sizei& UIPushButton::getIconMinimumSize() const {
|
||||
return mIconMinSize;
|
||||
}
|
||||
|
||||
UIWidget* UIPushButton::getExtraInnerWidget() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string UIPushButton::getPropertyString( const PropertyDefinition* propertyDef,
|
||||
@@ -293,12 +328,8 @@ std::string UIPushButton::getPropertyString( const PropertyDefinition* propertyD
|
||||
// TODO: Implement icon
|
||||
return "";
|
||||
case PropertyId::MinIconSize:
|
||||
return String::format( "%ddp", mStyleConfig.IconMinSize.getWidth() ) + " " +
|
||||
String::format( "%ddp", mStyleConfig.IconMinSize.getHeight() );
|
||||
case PropertyId::IconHorizontalMargin:
|
||||
return String::format( "%ddp", mStyleConfig.IconHorizontalMargin );
|
||||
case PropertyId::IconAutoMargin:
|
||||
return mStyleConfig.IconAutoMargin ? "true" : "false";
|
||||
return String::format( "%ddp", mIconMinSize.getWidth() ) + " " +
|
||||
String::format( "%ddp", mIconMinSize.getHeight() );
|
||||
case PropertyId::Color:
|
||||
case PropertyId::ShadowColor:
|
||||
case PropertyId::SelectedColor:
|
||||
@@ -344,12 +375,6 @@ bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::MinIconSize:
|
||||
setIconMinimumSize( attribute.asSizei() );
|
||||
break;
|
||||
case PropertyId::IconHorizontalMargin:
|
||||
setIconHorizontalMargin( attribute.asDpDimensionI( this ) );
|
||||
break;
|
||||
case PropertyId::IconAutoMargin:
|
||||
mStyleConfig.IconAutoMargin = attribute.asBool();
|
||||
break;
|
||||
case PropertyId::Color:
|
||||
case PropertyId::ShadowColor:
|
||||
case PropertyId::SelectedColor:
|
||||
|
||||
@@ -116,9 +116,11 @@ UIPushButton* UITab::setText( const String& text ) {
|
||||
|
||||
void UITab::onAutoSize() {
|
||||
if ( mFlags & UI_AUTO_SIZE ) {
|
||||
Uint32 w = PixelDensity::pxToDpI( mTextBox->getTextWidth() ) +
|
||||
mStyleConfig.IconHorizontalMargin +
|
||||
( NULL != mIcon ? mIcon->getSize().getWidth() : 0 ) + getSkinSize().getWidth();
|
||||
Uint32 w = mTextBox->getSize().getWidth() +
|
||||
( NULL != mIcon ? mIcon->getSize().getWidth() + mIcon->getLayoutMargin().Left +
|
||||
mIcon->getLayoutMargin().Right
|
||||
: 0 ) +
|
||||
getSkinSize().getWidth();
|
||||
|
||||
UITabWidget* tTabW = getTabWidget();
|
||||
|
||||
@@ -138,7 +140,6 @@ std::string UITab::getPropertyString( const PropertyDefinition* propertyDef,
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
case PropertyId::Name:
|
||||
return getText().toUtf8();
|
||||
case PropertyId::Owns:
|
||||
return mOwnedName;
|
||||
@@ -153,7 +154,6 @@ bool UITab::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
case PropertyId::Name:
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )
|
||||
->getTranslatorString( attribute.asString() ) );
|
||||
|
||||
@@ -14,7 +14,11 @@ UITabWidget* UITabWidget::New() {
|
||||
}
|
||||
|
||||
UITabWidget::UITabWidget() :
|
||||
UIWidget( "tabwidget" ), mTabSelected( NULL ), mTabSelectedIndex( eeINDEX_NOT_FOUND ) {
|
||||
UIWidget( "tabwidget" ),
|
||||
mCtrlContainer( NULL ),
|
||||
mTabContainer( NULL ),
|
||||
mTabSelected( NULL ),
|
||||
mTabSelectedIndex( eeINDEX_NOT_FOUND ) {
|
||||
setHorizontalAlign( UI_HALIGN_CENTER );
|
||||
|
||||
mTabContainer = UIWidget::NewWithTag( "tabwidget::tabcontainer" );
|
||||
@@ -172,7 +176,7 @@ bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setSpecialBorderTabs( attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::TabSeparation:
|
||||
setTabSeparation( attribute.asDpDimensionI() );
|
||||
setTabSeparation( attribute.asDpDimensionI( this ) );
|
||||
break;
|
||||
default:
|
||||
return UIWidget::applyProperty( attribute );
|
||||
|
||||
@@ -459,7 +459,7 @@ std::string UITextInput::getPropertyString( const PropertyDefinition* propertyDe
|
||||
return String::toStr( getMaxLength() );
|
||||
case PropertyId::FreeEditing:
|
||||
return isFreeEditingEnabled() ? "true" : "false";
|
||||
case PropertyId::OnlyNumbers:
|
||||
case PropertyId::Numeric:
|
||||
return getInputTextBuffer()->onlyNumbersAllowed() ? "true" : "false";
|
||||
case PropertyId::AllowFloat:
|
||||
return getInputTextBuffer()->dotsInNumbersAllowed() ? "true" : "false";
|
||||
@@ -502,7 +502,7 @@ bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::FreeEditing:
|
||||
setFreeEditing( attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::OnlyNumbers:
|
||||
case PropertyId::Numeric:
|
||||
getInputTextBuffer()->setAllowOnlyNumbers(
|
||||
attribute.asBool(), getInputTextBuffer()->dotsInNumbersAllowed() );
|
||||
break;
|
||||
|
||||
@@ -338,9 +338,6 @@ String UIWidget::getTooltipText() {
|
||||
}
|
||||
|
||||
void UIWidget::tooltipRemove() {
|
||||
if ( NULL != mTooltip ) {
|
||||
mTooltip->close();
|
||||
}
|
||||
mTooltip = NULL;
|
||||
}
|
||||
|
||||
@@ -576,6 +573,14 @@ const std::string& UIWidget::getMinWidthEq() const {
|
||||
return mMinWidthEq;
|
||||
}
|
||||
|
||||
void UIWidget::setMinSizeEq( const std::string& minWidthEq, const std::string& minHeightEq ) {
|
||||
if ( mMinWidthEq != minWidthEq || mMinHeightEq != minHeightEq ) {
|
||||
mMinWidthEq = minWidthEq;
|
||||
mMinHeightEq = minHeightEq;
|
||||
setSize( mSize );
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::setMinWidthEq( const std::string& minWidthEq ) {
|
||||
if ( mMinWidthEq != minWidthEq ) {
|
||||
mMinWidthEq = minWidthEq;
|
||||
@@ -598,6 +603,14 @@ const std::string& UIWidget::getMaxWidthEq() const {
|
||||
return mMaxWidthEq;
|
||||
}
|
||||
|
||||
void UIWidget::setMaxSizeEq( const std::string& maxWidthEq, const std::string& maxHeightEq ) {
|
||||
if ( mMaxWidthEq != maxWidthEq || mMaxHeightEq != maxHeightEq ) {
|
||||
mMaxWidthEq = maxWidthEq;
|
||||
mMaxHeightEq = maxHeightEq;
|
||||
setSize( mSize );
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::setMaxWidthEq( const std::string& maxWidthEq ) {
|
||||
if ( mMaxWidthEq != maxWidthEq ) {
|
||||
mMaxWidthEq = maxWidthEq;
|
||||
@@ -1674,7 +1687,7 @@ std::string UIWidget::getFlagsString() const {
|
||||
if ( mFlags & UI_AUTO_SIZE )
|
||||
flagvec.push_back( "autosize" );
|
||||
if ( mFlags & UI_MULTI_SELECT )
|
||||
flagvec.push_back( "multi" );
|
||||
flagvec.push_back( "multiselect" );
|
||||
if ( mFlags & UI_AUTO_PADDING )
|
||||
flagvec.push_back( "autopadding" );
|
||||
if ( reportSizeChangeToChilds() )
|
||||
|
||||
@@ -41,12 +41,8 @@ void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu* Menu ) {
|
||||
Button->setText( ButtonText );
|
||||
Button->setVisible( true );
|
||||
Button->setEnabled( true );
|
||||
Button->addEventListener( Event::OnSizeChange, [&]( const Event* event) {
|
||||
refreshButtons();
|
||||
} );
|
||||
|
||||
if ( NULL != mTheme )
|
||||
Button->setThemeSkin( mTheme, "winmenubutton" );
|
||||
Button->addEventListener( Event::OnSizeChange,
|
||||
[&]( const Event* event ) { refreshButtons(); } );
|
||||
|
||||
Menu->setVisible( false );
|
||||
Menu->setEnabled( false );
|
||||
@@ -57,6 +53,9 @@ void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu* Menu ) {
|
||||
|
||||
mButtons.push_back( std::make_pair( Button, Menu ) );
|
||||
|
||||
if ( NULL != mTheme )
|
||||
Button->setThemeSkin( mTheme, "winmenubutton" );
|
||||
|
||||
refreshButtons();
|
||||
}
|
||||
|
||||
@@ -125,33 +124,22 @@ void UIWinMenu::setMenuHeight( const Uint32& menuHeight ) {
|
||||
}
|
||||
|
||||
void UIWinMenu::refreshButtons() {
|
||||
Int32 h = 0, th = 0, ycenter = 0;
|
||||
Int32 ycenter = 0;
|
||||
|
||||
UISkin* skin = getSkin();
|
||||
|
||||
if ( NULL != skin ) {
|
||||
h = getSize().getHeight();
|
||||
|
||||
if ( !mButtons.empty() ) {
|
||||
UISelectButton* tbut = mButtons.begin()->first;
|
||||
|
||||
skin = tbut->getSkin();
|
||||
|
||||
if ( NULL != skin ) {
|
||||
th = skin->getSize( UIState::StateFlagSelected ).getHeight();
|
||||
|
||||
switch ( Font::getVerticalAlign( getFlags() ) ) {
|
||||
case UI_VALIGN_CENTER:
|
||||
ycenter = ( h - th ) / 2;
|
||||
break;
|
||||
case UI_VALIGN_BOTTOM:
|
||||
ycenter = ( h - th );
|
||||
break;
|
||||
case UI_VALIGN_TOP:
|
||||
ycenter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !mButtons.empty() ) {
|
||||
UISelectButton* tbut = mButtons.begin()->first;
|
||||
Float h = mSize.getHeight();
|
||||
Float th = tbut->getPixelsSize().getHeight();
|
||||
switch ( Font::getVerticalAlign( getFlags() ) ) {
|
||||
case UI_VALIGN_CENTER:
|
||||
ycenter = eefloor( ( h - th ) / 2 );
|
||||
break;
|
||||
case UI_VALIGN_BOTTOM:
|
||||
ycenter = ( h - th );
|
||||
break;
|
||||
case UI_VALIGN_TOP:
|
||||
ycenter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user