additional tab control styles
After Width: | Height: | Size: 189 B |
After Width: | Height: | Size: 184 B |
After Width: | Height: | Size: 189 B |
After Width: | Height: | Size: 189 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 187 B |
After Width: | Height: | Size: 193 B |
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:constantSize="true"
|
||||
android:dither="false"
|
||||
android:variablePadding="false" >
|
||||
<item
|
||||
android:drawable="tab_btn_dark_up_hover"
|
||||
android:state_hovered="true" />
|
||||
<item
|
||||
android:drawable="tab_btn_dark_up_selected_focused"
|
||||
android:state_selected="true" android:state_window_focused="true" />
|
||||
<item
|
||||
android:drawable="tab_btn_dark_up_focused"
|
||||
android:state_window_focused="true" />
|
||||
<item
|
||||
android:drawable="tab_btn_dark_up_selected"
|
||||
android:state_selected="true" />
|
||||
<item
|
||||
android:drawable="tab_btn_dark_up_normal" />
|
||||
</selector>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:drawable="tab_up_background_dark_focused"
|
||||
android:state_window_focused="true" />
|
||||
<item
|
||||
android:drawable="tab_up_background_dark_normal" />
|
||||
</selector>
|
|
@ -102,6 +102,23 @@
|
|||
<state state_hovered="true" backgroundColor="#F0404080"/>
|
||||
</style>
|
||||
|
||||
<style id="TAB_UP_DARK"
|
||||
backgroundImageId="tab_up_background_dark"
|
||||
layoutWidth="FILL_PARENT"
|
||||
>
|
||||
</style>
|
||||
<style id="TAB_UP_BUTTON_DARK"
|
||||
backgroundImageId="tab_btn_dark_up"
|
||||
/>
|
||||
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
||||
textColor="#000000"
|
||||
align="Center"
|
||||
>
|
||||
<state state_selected="true" state_focused="true" textColor="#000000"/>
|
||||
<state state_selected="true" textColor="#000000"/>
|
||||
<state state_focused="true" textColor="#000000"/>
|
||||
<state state_hovered="true" textColor="#808000"/>
|
||||
</style>
|
||||
<style id="TAB_UP"
|
||||
backgroundImageId="tab_up_background"
|
||||
layoutWidth="FILL_PARENT"
|
||||
|
|
|
@ -94,6 +94,10 @@ class TabItemWidget : HorizontalLayout {
|
|||
clickable = true;
|
||||
trackHover = true;
|
||||
}
|
||||
void setStyles(string tabButtonStyle, string tabButtonTextStyle) {
|
||||
styleId = tabButtonStyle;
|
||||
_label.styleId = tabButtonTextStyle;
|
||||
}
|
||||
protected bool onClick(Widget source) {
|
||||
if (source.compareId("CLOSE")) {
|
||||
Log.d("tab close button pressed");
|
||||
|
@ -185,6 +189,9 @@ class TabControl : WidgetGroupDefaultDrawing {
|
|||
protected bool _enableCloseButton;
|
||||
protected TabItemWidget[] _sortedItems;
|
||||
|
||||
protected string _tabStyle;
|
||||
protected string _tabButtonStyle;
|
||||
protected string _tabButtonTextStyle;
|
||||
|
||||
/// signal of tab change (e.g. by clicking on tab header)
|
||||
Signal!TabHandler onTabChangedListener;
|
||||
|
@ -196,15 +203,28 @@ class TabControl : WidgetGroupDefaultDrawing {
|
|||
/// create with ID parameter
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
setStyles(STYLE_TAB_UP, STYLE_TAB_UP_BUTTON, STYLE_TAB_UP_BUTTON_TEXT);
|
||||
_items = new TabItemList();
|
||||
_moreButton = new ImageButton("MORE", "tab_more");
|
||||
_moreButton.styleId = STYLE_BUTTON_TRANSPARENT;
|
||||
_moreButton.onClickListener = &onClick;
|
||||
_moreButton.margins(Rect(3,3,3,6));
|
||||
_enableCloseButton = true;
|
||||
styleId = STYLE_TAB_UP;
|
||||
styleId = _tabStyle;
|
||||
addChild(_moreButton); // first child is always MORE button, the rest corresponds to tab list
|
||||
}
|
||||
void setStyles(string tabStyle, string tabButtonStyle, string tabButtonTextStyle) {
|
||||
_tabStyle = tabStyle;
|
||||
_tabButtonStyle = tabButtonStyle;
|
||||
_tabButtonTextStyle = tabButtonTextStyle;
|
||||
styleId = _tabStyle;
|
||||
for (int i = 1; i < _children.count; i++) {
|
||||
TabItemWidget w = cast(TabItemWidget)_children[i];
|
||||
if (w) {
|
||||
w.setStyles(_tabButtonStyle, _tabButtonTextStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// returns tab count
|
||||
@property int tabCount() const {
|
||||
return _items.length;
|
||||
|
@ -272,6 +292,7 @@ class TabControl : WidgetGroupDefaultDrawing {
|
|||
TabItemWidget widget = new TabItemWidget(item, enableCloseButton);
|
||||
widget.parent = this;
|
||||
widget.onClickListener = &onClick;
|
||||
widget.setStyles(_tabButtonStyle, _tabButtonTextStyle);
|
||||
_children.insert(widget, index);
|
||||
updateTabs();
|
||||
requestLayout();
|
||||
|
@ -560,6 +581,11 @@ class TabWidget : VerticalLayout, TabHandler {
|
|||
return _tabControl.tabIndex(id);
|
||||
}
|
||||
|
||||
/// change style ids
|
||||
void setStyles(string tabStyle, string tabButtonStyle, string tabButtonTextStyle) {
|
||||
_tabControl.setStyles(tabStyle, tabButtonStyle, tabButtonTextStyle);
|
||||
}
|
||||
|
||||
private bool _tabNavigationInProgress;
|
||||
|
||||
/// process key event, return true if event is processed.
|
||||
|
|