mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 10:06:35 +03:00
Added ScrollBarType.
--HG-- branch : dev
This commit is contained in:
@@ -8,6 +8,11 @@ namespace EE { namespace UI {
|
||||
|
||||
class EE_API UIScrollBar : public UIWidget {
|
||||
public:
|
||||
enum ScrollBarType {
|
||||
TwoButtons,
|
||||
NoButtons
|
||||
};
|
||||
|
||||
static UIScrollBar * New( const UI_ORIENTATION & orientation = UI_VERTICAL );
|
||||
|
||||
UIScrollBar( const UI_ORIENTATION& orientation = UI_VERTICAL );
|
||||
@@ -54,12 +59,18 @@ class EE_API UIScrollBar : public UIWidget {
|
||||
|
||||
UIControl * setOrientation( const UI_ORIENTATION & orientation );
|
||||
|
||||
ScrollBarType getScrollBarType() const;
|
||||
|
||||
void setScrollBarType(const ScrollBarType & scrollBarType);
|
||||
|
||||
bool getExpandBackground() const;
|
||||
|
||||
void setExpandBackground( bool expandBackground );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
|
||||
protected:
|
||||
ScrollBarType mScrollBarType;
|
||||
UISlider * mSlider;
|
||||
UIControlAnim * mBtnUp;
|
||||
UIControlAnim * mBtnDown;
|
||||
|
||||
@@ -78,6 +78,8 @@ class EE_API UITable : public UITouchDragableWidget {
|
||||
Rect getContainerPadding() const;
|
||||
|
||||
void setContainerPadding( const Rect & containerPadding);
|
||||
|
||||
void loadFromXmlNode(const pugi::xml_node & node);
|
||||
protected:
|
||||
friend class UIItemContainer<UITable>;
|
||||
friend class UITableCell;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.3.1, 2017-08-06T01:19:20. -->
|
||||
<!-- Written by QtCreator 4.3.1, 2017-08-10T00:48:42. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -28,13 +28,7 @@
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.2">
|
||||
<value type="QString" key="language">Nim</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">NimGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">3</value>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
|
||||
@@ -1032,6 +1032,17 @@ void UIListBox::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
setSelected( ait->as_uint() );
|
||||
} else if ( "selectedtext" == name ) {
|
||||
setSelected( ait->as_string() );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,12 @@ UIScrollBar * UIScrollBar::New( const UI_ORIENTATION& orientation ) {
|
||||
}
|
||||
|
||||
UIScrollBar::UIScrollBar( const UI_ORIENTATION& orientation ) :
|
||||
UIWidget()
|
||||
UIWidget(),
|
||||
#ifdef EE_PLATFORM_TOUCH
|
||||
mScrollBarType( NoButtons )
|
||||
#else
|
||||
mScrollBarType( TwoButtons )
|
||||
#endif
|
||||
{
|
||||
mFlags |= UI_AUTO_SIZE;
|
||||
|
||||
@@ -115,22 +120,46 @@ void UIScrollBar::adjustChilds() {
|
||||
|
||||
mBtnUp->setPosition( 0, 0 );
|
||||
|
||||
if ( !isVertical() ) {
|
||||
mBtnDown->setPosition( mSize.getWidth() - mBtnDown->getSize().getWidth(), 0 );
|
||||
mSlider->setSize( mSize.getWidth() - mBtnDown->getSize().getWidth() - mBtnUp->getSize().getWidth(), mSize.getHeight() );
|
||||
mSlider->setPosition( mBtnUp->getSize().getWidth(), 0 );
|
||||
switch ( mScrollBarType ) {
|
||||
case NoButtons:
|
||||
{
|
||||
mBtnDown->setVisible( false )->setEnabled( false );
|
||||
mBtnUp->setVisible( false )->setEnabled( false );
|
||||
|
||||
mBtnDown->centerVertical();
|
||||
mBtnUp->centerVertical();
|
||||
mSlider->centerVertical();
|
||||
} else {
|
||||
mBtnDown->setPosition( 0, mSize.getHeight() - mBtnDown->getSize().getHeight() );
|
||||
mSlider->setSize( mSize.getWidth(), mSize.getHeight() - mBtnDown->getSize().getHeight() - mBtnUp->getSize().getHeight() );
|
||||
mSlider->setPosition( 0, mBtnUp->getSize().getHeight() );
|
||||
if ( !isVertical() ) {
|
||||
mSlider->setSize( mSize )->setPosition( 0, 0 )->centerVertical();
|
||||
} else {
|
||||
mSlider->setSize( mSize )->setPosition( 0, 0 )->centerHorizontal();
|
||||
}
|
||||
|
||||
mBtnDown->centerHorizontal();
|
||||
mBtnUp->centerHorizontal();
|
||||
mSlider->centerHorizontal();
|
||||
break;
|
||||
}
|
||||
case TwoButtons:
|
||||
default:
|
||||
{
|
||||
mBtnDown->setVisible( true )->setEnabled( true );
|
||||
mBtnUp->setVisible( true )->setEnabled( true );
|
||||
|
||||
if ( !isVertical() ) {
|
||||
mBtnDown->setPosition( mSize.getWidth() - mBtnDown->getSize().getWidth(), 0 );
|
||||
mSlider->setSize( mSize.getWidth() - mBtnDown->getSize().getWidth() - mBtnUp->getSize().getWidth(), mSize.getHeight() );
|
||||
mSlider->setPosition( mBtnUp->getSize().getWidth(), 0 );
|
||||
|
||||
mBtnDown->centerVertical();
|
||||
mBtnUp->centerVertical();
|
||||
mSlider->centerVertical();
|
||||
} else {
|
||||
mBtnDown->setPosition( 0, mSize.getHeight() - mBtnDown->getSize().getHeight() );
|
||||
mSlider->setSize( mSize.getWidth(), mSize.getHeight() - mBtnDown->getSize().getHeight() - mBtnUp->getSize().getHeight() );
|
||||
mSlider->setPosition( 0, mBtnUp->getSize().getHeight() );
|
||||
|
||||
mBtnDown->centerHorizontal();
|
||||
mBtnUp->centerHorizontal();
|
||||
mSlider->centerHorizontal();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +275,18 @@ void UIScrollBar::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
mSlider->loadFromXmlNode( node );
|
||||
}
|
||||
|
||||
UIScrollBar::ScrollBarType UIScrollBar::getScrollBarType() const {
|
||||
return mScrollBarType;
|
||||
}
|
||||
|
||||
void UIScrollBar::setScrollBarType( const ScrollBarType & scrollBarType ) {
|
||||
if ( mScrollBarType != scrollBarType ) {
|
||||
mScrollBarType = scrollBarType;
|
||||
|
||||
adjustChilds();
|
||||
}
|
||||
}
|
||||
|
||||
UI_ORIENTATION UIScrollBar::getOrientation() const {
|
||||
return mSlider->getOrientation();
|
||||
}
|
||||
|
||||
@@ -242,6 +242,17 @@ void UIScrollView::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScroll->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <eepp/ui/uitable.hpp>
|
||||
#include <eepp/ui/uimanager.hpp>
|
||||
#include <eepp/helper/pugixml/pugixml.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -616,4 +617,49 @@ bool UITable::isTouchOverAllowedChilds() {
|
||||
return isMouseOverMeOrChilds() && !mVScrollBar->isMouseOverMeOrChilds() && !mHScrollBar->isMouseOverMeOrChilds();
|
||||
}
|
||||
|
||||
void UITable::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
UITouchDragableWidget::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "rowheight" == name ) {
|
||||
setRowHeight( ait->as_int() );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = ait->as_int();
|
||||
setContainerPadding( Rect( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setContainerPadding( Rect( ait->as_int(), mContainerPadding.Top, mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setContainerPadding( Rect( mContainerPadding.Left, mContainerPadding.Top, ait->as_int(), mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setContainerPadding( Rect( mContainerPadding.Left, ait->as_int(), mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setContainerPadding( Rect( mContainerPadding.Left, mContainerPadding.Top, mContainerPadding.Right, ait->as_int() ) );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -278,10 +278,8 @@ void EETest::createUI() {
|
||||
|
||||
mThemeName = "uitheme";
|
||||
|
||||
if ( PixelDensity::getPixelDensity() >= 2 ) {
|
||||
if ( PixelDensity::getPixelDensity() >= 1.1 ) {
|
||||
mThemeName += "2x";
|
||||
} else if ( PixelDensity::getPixelDensity() >= 1.1 ) {
|
||||
//mThemeName += "1.5x";
|
||||
}
|
||||
|
||||
createUIThemeTextureAtlas();
|
||||
|
||||
Reference in New Issue
Block a user