UITabWidget padding.

--HG--
branch : dev-widget-padding
This commit is contained in:
Martín Lucas Golini
2018-12-16 20:30:24 -03:00
parent 8c55c37f8e
commit 08bcbe1ca1
3 changed files with 67 additions and 48 deletions

View File

@@ -1,45 +1,55 @@
<hbox layout_width="match_parent" layout_height="match_parent">
<vbox id="lvbox" layout_width="match_parent" layout_weight="0.5" layout_height="match_parent" backgroundColor="#222" layout_marginTop="20dp" padding="12dp">
<TextView layout_width="wrap_content" layout_height="wrap_content" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#333" />
<TextView layout_width="wrap_content" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="24dp" backgroundColor="#333" gravity="center" />
<CheckBox layout_width="wrap_content" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#333" />
<RadioButton layout_width="wrap_content" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#333" />
<TextInput layout_width="300dp" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="24dp" />
<Image layout_width="wrap_content" layout_height="wrap_content" src="file://assets/tiles/1.png" backgroundColor="#444" layout_marginTop="8dp" scaleType="fit_inside" padding="8dp" />
<DropDownList layout_width="300dp" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="16dp" padding="8dp">
<item>Test</item>
<item>Test 2</item>
<item>Test 3</item>
</DropDownList>
<ComboBox layout_width="300dp" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="16dp" padding="8dp">
<item>Test</item>
<item>Test 2</item>
<item>Test 3</item>
</ComboBox>
<TextView layout_width="match_parent" layout_height="wrap_content" text="testing match_parent" layout_marginTop="8dp" textSize="24dp" backgroundColor="#333" gravity="center" />
</vbox>
<vbox id="rvbox" layout_width="match_parent" layout_weight="0.5" layout_height="match_parent" backgroundColor="#323232" layout_marginTop="20dp" padding="12dp">
<RelativeLayout id="rrl" layout_width="match_parent" layout_height="match_parent" backgroundColor="#999" padding="24dp">
<TextView layout_width="match_parent" layout_height="match_parent" text="testing match_parent" textSize="24dp" padding="12dp" backgroundColor="#333" gravity="center" />
<TextView id="el1" layout_width="wrap_content" layout_height="wrap_content" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#242424" />
<TextView layout_width="wrap_content" layout_height="wrap_content" text="testing margin" textSize="24dp" padding="12dp" backgroundColor="#242424" layout_gravity="top|right" layout_margin="12dp" />
<TextView id="tm" layout_width="wrap_content" layout_height="wrap_content" text="testing margin" textSize="24dp" backgroundColor="#242424" layout_gravity="bottom|left" layout_margin="12dp" />
<TextView id="tmp" layout_width="wrap_content" layout_height="wrap_content" text="testing margin padding" textSize="24dp" backgroundColor="#242424" layout_gravity="bottom|right" layout_margin="12dp" padding="12dp" />
<Loader layout_width="350dp" layout_height="350dp" layout_gravity="center" fillColor="#999" padding="44dp" outlinethickness="8dp" />
<vbox layout_width="match_parent" layout_height="match_parent">
<TabWidget layout_width="match_parent" layout_height="match_parent" paddingLeft="8dp" paddingRight="8dp" paddingBottom="8dp" paddingTop="20dp">
<hbox id="test_1" layout_width="match_parent" layout_height="match_parent">
<vbox id="lvbox" layout_width="match_parent" layout_weight="0.5" layout_height="match_parent" backgroundColor="#222" padding="12dp">
<TextView layout_width="wrap_content" layout_height="wrap_content" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#333" />
<TextView layout_width="wrap_content" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="24dp" backgroundColor="#333" gravity="center" />
<CheckBox layout_width="wrap_content" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#333" />
<RadioButton layout_width="wrap_content" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#333" />
<TextInput layout_width="300dp" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="24dp" padding="24dp" />
<Image layout_width="wrap_content" layout_height="wrap_content" src="file://assets/tiles/1.png" backgroundColor="#444" layout_marginTop="8dp" scaleType="fit_inside" padding="8dp" />
<DropDownList layout_width="300dp" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="16dp" padding="8dp">
<item>Test</item>
<item>Test 2</item>
<item>Test 3</item>
</DropDownList>
<ComboBox layout_width="300dp" layout_height="wrap_content" layout_marginTop="8dp" text="testing padding" textSize="16dp" padding="8dp">
<item>Test</item>
<item>Test 2</item>
<item>Test 3</item>
</ComboBox>
<TextView layout_width="match_parent" layout_height="wrap_content" text="testing match_parent" layout_marginTop="8dp" textSize="24dp" backgroundColor="#333" gravity="center" />
</vbox>
<vbox id="rvbox" layout_width="match_parent" layout_weight="0.5" layout_height="match_parent" backgroundColor="#323232" layout_marginTop="20dp" padding="12dp">
<RelativeLayout id="rrl" layout_width="match_parent" layout_height="match_parent" backgroundColor="#999" padding="24dp">
<TextView layout_width="match_parent" layout_height="match_parent" text="testing match_parent" textSize="24dp" padding="12dp" backgroundColor="#333" gravity="center" />
<TextView id="el1" layout_width="wrap_content" layout_height="wrap_content" text="testing padding" textSize="24dp" padding="12dp" backgroundColor="#242424" />
<TextView layout_width="wrap_content" layout_height="wrap_content" text="testing margin" textSize="24dp" padding="12dp" backgroundColor="#242424" layout_gravity="top|right" layout_margin="12dp" />
<TextView id="tm" layout_width="wrap_content" layout_height="wrap_content" text="testing margin" textSize="24dp" backgroundColor="#242424" layout_gravity="bottom|left" layout_margin="12dp" />
<TextView id="tmp" layout_width="wrap_content" layout_height="wrap_content" text="testing margin padding" textSize="24dp" backgroundColor="#242424" layout_gravity="bottom|right" layout_margin="12dp" padding="12dp" />
<Loader layout_width="350dp" layout_height="350dp" layout_gravity="center" fillColor="#999" padding="44dp" outlinethickness="8dp" />
<Sprite layout_width="96dp" layout_height="96dp" src="bn" padding="8dp" backgroundColor="#888" gravity="center" layout_marginTop="56dp" gravity="right|bottom" />
<TextureRegion layout_width="96dp" layout_height="96dp" src="bn01" padding="8dp" backgroundColor="#787" gravity="center" layout_marginTop="162dp" gravity="right|bottom" />
<Sprite layout_width="96dp" layout_height="96dp" src="bn" padding="8dp" backgroundColor="#888" gravity="center" layout_marginTop="56dp" gravity="right|bottom" />
<TextureRegion layout_width="96dp" layout_height="96dp" src="bn01" padding="8dp" backgroundColor="#787" gravity="center" layout_marginTop="162dp" gravity="right|bottom" />
<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!" textSize="16dp" icon="ok" layout_gravity="left|bottom" gravity="center" layout_width="wrap_content" layout_height="wrap_content" layout_marginBottom="8dp" padding="8dp" layout_to_top_of="tm" />
<Slider id="slider" halfslider="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" />
<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!" textSize="16dp" icon="ok" layout_gravity="left|bottom" gravity="center" layout_width="wrap_content" layout_height="wrap_content" layout_marginBottom="8dp" padding="8dp" layout_to_top_of="tm" />
<Slider id="slider" halfslider="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" layout_marginBottom="140dp" />
</RelativeLayout>
</vbox>
</hbox>
<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" layout_marginBottom="140dp" />
</RelativeLayout>
</vbox>
</hbox>
<hbox id="test_2" layout_width="match_parent" layout_height="match_parent">
</hbox>
<Tab name="Test 1" owns="test_1" />
<Tab name="Test 2" owns="test_2" />
</TabWidget>
</vbox>

View File

@@ -154,6 +154,8 @@ class EE_API UITabWidget : public UIWidget {
virtual void onChildCountChange();
virtual void onPaddingChange();
void setTabSelected( UITab * Tab );
void setTabContainerSize();

View File

@@ -81,9 +81,10 @@ void UITabWidget::onThemeLoaded() {
}
void UITabWidget::setContainerSize() {
mTabContainer->setPixelsSize( mSize.getWidth(), mStyleConfig.TabWidgetHeight );
mCtrlContainer->setPosition( 0, mStyleConfig.TabWidgetHeight );
mCtrlContainer->setPixelsSize( mSize.getWidth(), mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabWidgetHeight ) );
mTabContainer->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, mStyleConfig.TabWidgetHeight );
mTabContainer->setPosition( mPadding.Left, mPadding.Top );
mCtrlContainer->setPosition( mPadding.Left, mPadding.Top + mStyleConfig.TabWidgetHeight );
mCtrlContainer->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabWidgetHeight ) - mRealPadding.Top - mRealPadding.Bottom );
}
void UITabWidget::draw() {
@@ -94,15 +95,15 @@ void UITabWidget::draw() {
if ( smooth ) GLi->lineSmooth( false );
Primitives P;
Vector2f p1( mScreenPos.x, mScreenPos.y + mTabContainer->getRealSize().getHeight() + mStyleConfig.LineBelowTabsYOffset );
Vector2f p1( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top + mTabContainer->getRealSize().getHeight() + mStyleConfig.LineBelowTabsYOffset );
Vector2f p2( mScreenPos.x + mTabContainer->getRealPosition().x, p1.y );
P.setLineWidth( PixelDensity::dpToPx( 1 ) );
P.setColor( Color( mStyleConfig.LineBelowTabsColor, mAlpha ) );
P.drawLine( Line2f( Vector2f( (int)p1.x, (int)p1.y ), Vector2f( (int)p2.x, (int)p2.y ) ) );
Vector2f p3( mScreenPos.x + mTabContainer->getRealPosition().x + mTabContainer->getRealSize().getWidth(), mScreenPos.y + mTabContainer->getRealSize().getHeight() + mStyleConfig.LineBelowTabsYOffset );
Vector2f p4( mScreenPos.x + mSize.getWidth(), p3.y );
Vector2f p3( mScreenPos.x + mTabContainer->getRealPosition().x + mTabContainer->getRealSize().getWidth(), mScreenPos.y + mRealPadding.Top + mTabContainer->getRealSize().getHeight() + mStyleConfig.LineBelowTabsYOffset );
Vector2f p4( mScreenPos.x + mRealPadding.Left + mCtrlContainer->getRealSize().getWidth(), p3.y );
P.drawLine( Line2f( Vector2f( (int)p3.x, (int)p3.y ), Vector2f( (int)p4.x, (int)p4.y ) ) );
@@ -748,6 +749,12 @@ void UITabWidget::onChildCountChange() {
UIWidget::onChildCountChange();
}
void UITabWidget::onPaddingChange() {
onSizeChange();
UIWidget::onPaddingChange();
}
void UITabWidget::applyThemeToTabs() {
if ( mStyleConfig.SpecialBorderTabs ) {
for ( Uint32 i = 0; i < mTabs.size(); i++ ) {