updated scrollbar resources; spreadsheet example improved

This commit is contained in:
Vadim Lopatin 2015-11-30 16:09:19 +03:00
parent efeb1b94d4
commit 1dfa3c60eb
19 changed files with 93 additions and 10 deletions

View File

@ -218,6 +218,19 @@ class SpreadSheetWidget : WidgetGroupDefaultDrawing, OnScrollHandler, CellSelect
/// Callback for handling of view scroll (top left visible cell change) /// Callback for handling of view scroll (top left visible cell change)
void onViewScrolled(GridWidgetBase source, int col, int row) { void onViewScrolled(GridWidgetBase source, int col, int row) {
if (source == _viewTopLeft) {
_viewTopRight.scrollTo(-1, row, source, false);
_viewBottomLeft.scrollTo(col, -1, source, false);
} else if (source == _viewTopRight) {
_viewTopLeft.scrollTo(-1, row, source, false);
_viewBottomRight.scrollTo(col, -1, source, false);
} else if (source == _viewBottomLeft) {
_viewTopLeft.scrollTo(col, -1, source, false);
_viewBottomRight.scrollTo(-1, row, source, false);
} else if (source == _viewBottomRight) {
_viewTopRight.scrollTo(col, -1, source, false);
_viewBottomLeft.scrollTo(-1, row, source, false);
}
} }
} }

View File

@ -623,7 +623,7 @@ class ScrollBar : AbstractSlider, OnClickHandler {
this(string resourceId) { this(string resourceId) {
super("SLIDER", resourceId); super("SLIDER", resourceId);
styleId = STYLE_BUTTON_NOMARGINS; styleId = STYLE_SCROLLBAR_BUTTON;
trackHover = true; trackHover = true;
} }
@ -801,8 +801,8 @@ class ScrollBar : AbstractSlider, OnClickHandler {
_btnForward = new ImageButton("FORWARD", style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_DOWN : ATTR_SCROLLBAR_BUTTON_RIGHT)); _btnForward = new ImageButton("FORWARD", style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_DOWN : ATTR_SCROLLBAR_BUTTON_RIGHT));
_pageUp = new PageScrollButton("PAGE_UP"); _pageUp = new PageScrollButton("PAGE_UP");
_pageDown = new PageScrollButton("PAGE_DOWN"); _pageDown = new PageScrollButton("PAGE_DOWN");
_btnBack.styleId = STYLE_SCROLLBAR_BUTTON; _btnBack.styleId = STYLE_SCROLLBAR_BUTTON_TRANSPARENT;
_btnForward.styleId = STYLE_SCROLLBAR_BUTTON; _btnForward.styleId = STYLE_SCROLLBAR_BUTTON_TRANSPARENT;
_indicator = new SliderButton(style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_INDICATOR_VERTICAL : ATTR_SCROLLBAR_INDICATOR_HORIZONTAL)); _indicator = new SliderButton(style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_INDICATOR_VERTICAL : ATTR_SCROLLBAR_INDICATOR_HORIZONTAL));
addChild(_btnBack); addChild(_btnBack);
addChild(_btnForward); addChild(_btnForward);

View File

@ -535,12 +535,12 @@ class GridWidgetBase : ScrollWidgetBase {
return scrollTo(_headerCols + _fixedCols + _scrollCol + dx, _headerRows + _fixedRows + _scrollRow + dy); return scrollTo(_headerCols + _fixedCols + _scrollCol + dx, _headerRows + _fixedRows + _scrollRow + dy);
} }
/// set scroll position to show specified cell as top left in scrollable area /// set scroll position to show specified cell as top left in scrollable area; col or row -1 value means no change
bool scrollTo(int col, int row) { bool scrollTo(int col, int row, GridWidgetBase source = null, bool doNotify = true) {
int oldx = _scrollCol; int oldx = _scrollCol;
int oldy = _scrollRow; int oldy = _scrollRow;
int newScrollCol = col - _headerCols - _fixedCols; int newScrollCol = col == -1 ? _scrollCol : col - _headerCols - _fixedCols;
int newScrollRow = row - _headerRows - _fixedRows; int newScrollRow = row == -1 ? _scrollRow : row - _headerRows - _fixedRows;
if (newScrollCol > _maxScrollCol) if (newScrollCol > _maxScrollCol)
newScrollCol = _maxScrollCol; newScrollCol = _maxScrollCol;
if (newScrollCol < 0) if (newScrollCol < 0)
@ -565,7 +565,13 @@ class GridWidgetBase : ScrollWidgetBase {
//if (changed) //if (changed)
updateScrollBars(); updateScrollBars();
invalidate(); invalidate();
return oldx != _scrollCol || oldy != _scrollRow; bool changed = oldx != _scrollCol || oldy != _scrollRow;
if (doNotify && changed && viewScrolled.assigned) {
if (source is null)
source = this;
viewScrolled(source, col, row);
}
return changed;
} }
/// process horizontal scrollbar event /// process horizontal scrollbar event
@ -635,6 +641,9 @@ class GridWidgetBase : ScrollWidgetBase {
if (scrolled) { if (scrolled) {
updateScrollBars(); updateScrollBars();
invalidate(); invalidate();
if (viewScrolled.assigned) {
viewScrolled(this, _scrollCol + _headerCols + _fixedCols, _scrollRow + _headerRows + _fixedRows);
}
} }
} }

View File

@ -69,6 +69,8 @@ immutable string STYLE_VSPACER = "VSPACER";
immutable string STYLE_SCROLLBAR = "SCROLLBAR"; immutable string STYLE_SCROLLBAR = "SCROLLBAR";
/// standard style id for ScrollBar button /// standard style id for ScrollBar button
immutable string STYLE_SCROLLBAR_BUTTON = "SCROLLBAR_BUTTON"; immutable string STYLE_SCROLLBAR_BUTTON = "SCROLLBAR_BUTTON";
/// standard style id for ScrollBar button
immutable string STYLE_SCROLLBAR_BUTTON_TRANSPARENT = "SCROLLBAR_BUTTON_TRANSPARENT";
/// standard style id for ScrollBar page control /// standard style id for ScrollBar page control
immutable string STYLE_PAGE_SCROLL = "PAGE_SCROLL"; immutable string STYLE_PAGE_SCROLL = "PAGE_SCROLL";
/// standard style id for Slider /// standard style id for Slider

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/scrollbar_btn_background_pressed" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/scrollbar_btn_background_normal" />
<item android:state_enabled="true" android:state_hovered="true"
android:drawable="@drawable/scrollbar_btn_background_hover" />
<item android:state_enabled="true"
android:drawable="@drawable/scrollbar_btn_background_normal" />
<item
android:drawable="@drawable/scrollbar_btn_background_disabled" />
</selector>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/btn_pressed_dark" />
<item android:state_focused="true" android:state_default="true" android:state_enabled="true"
android:drawable="@drawable/btn_default_dark" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/btn_normal_dark" />
<item android:state_enabled="true" android:state_default="true"
android:drawable="@drawable/btn_default_dark" />
<item android:state_enabled="true" android:state_hovered="true"
android:drawable="@drawable/btn_hover_dark" />
<item android:state_enabled="true"
android:drawable="@drawable/btn_normal_dark" />
<item
android:drawable="@drawable/btn_disabled_dark" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 B

After

Width:  |  Height:  |  Size: 339 B

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/scrollbar_btn_background_pressed" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/scrollbar_btn_background_normal" />
<item android:state_enabled="true" android:state_hovered="true"
android:drawable="@drawable/scrollbar_btn_background_hover" />
<item android:state_enabled="true"
android:drawable="@null" />
<item
android:drawable="@null" />
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 129 B

View File

@ -131,10 +131,16 @@
<drawable id="scrollbar_indicator_vertical" value="scrollbar_indicator_vertical"/> <drawable id="scrollbar_indicator_vertical" value="scrollbar_indicator_vertical"/>
<drawable id="scrollbar_indicator_horizontal" value="scrollbar_indicator_horizontal"/> <drawable id="scrollbar_indicator_horizontal" value="scrollbar_indicator_horizontal"/>
<style id="SCROLLBAR" <style id="SCROLLBAR"
backgroundColor="#C0808080" backgroundColor="#dce2e8"
align="Center" align="Center"
/> />
<style id="SCROLLBAR_BUTTON" parent="BUTTON" <style id="SCROLLBAR_BUTTON"
backgroundImageId="scrollbar_btn_background"
align="Center"
/>
<style id="SCROLLBAR_BUTTON_TRANSPARENT"
backgroundImageId="scrollbar_btn_transparent_background"
align="Center"
/> />
<style id="SLIDER" <style id="SLIDER"
/> />

View File

@ -213,12 +213,19 @@ res/menu_item_background.xml
res/menu_item_background_dark.xml res/menu_item_background_dark.xml
res/popup_menu_background_normal.9.png res/popup_menu_background_normal.9.png
res/popup_menu_background_normal_dark.9.png res/popup_menu_background_normal_dark.9.png
res/scrollbar_btn_background.xml
res/scrollbar_btn_background_dark.xml
res/scrollbar_btn_background_disabled.9.png
res/scrollbar_btn_background_hover.9.png
res/scrollbar_btn_background_normal.9.png
res/scrollbar_btn_background_pressed.9.png
res/scrollbar_btn_down.png res/scrollbar_btn_down.png
res/scrollbar_btn_down_dark.png res/scrollbar_btn_down_dark.png
res/scrollbar_btn_left.png res/scrollbar_btn_left.png
res/scrollbar_btn_left_dark.png res/scrollbar_btn_left_dark.png
res/scrollbar_btn_right.png res/scrollbar_btn_right.png
res/scrollbar_btn_right_dark.png res/scrollbar_btn_right_dark.png
res/scrollbar_btn_transparent_background.xml
res/scrollbar_btn_up.png res/scrollbar_btn_up.png
res/scrollbar_btn_up_dark.png res/scrollbar_btn_up_dark.png
res/scrollbar_indicator_horizontal.png res/scrollbar_indicator_horizontal.png