summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorVasily Melenchuk <Vasily.Melenchuk@cib.de>2018-06-26 11:24:43 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-06-28 14:02:46 +0200
commitd77f8eef165a7c6fd97cc06dcbc4ead55e7b633c (patch)
treeac7db08c222abe22975cce394830003232d24025 /vcl
parentf4c73f90da2a2c31f0d29572180aa97e10c3dbad (diff)
tdf#86612: statusbar: hide some elements if width is not sufficient
new statusbar element property mandatory=true/false to determine if this element can be hidden if total statusbar width is not enough to fit all elements. marked some calc and draw statusbar elements as not mandatory. Change-Id: I20e26d3c4bd865e94ea48632a1e97d55f3fa712f Reviewed-on: https://gerrit.libreoffice.org/56443 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/status.cxx60
1 files changed, 48 insertions, 12 deletions
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 57f881cfbd48..61b467b8360d 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -217,22 +217,58 @@ void StatusBar::ImplFormat()
long nExtraWidth;
long nExtraWidth2;
long nX;
- sal_uInt16 nAutoSizeItems = 0;
+ sal_uInt16 nAutoSizeItems;
+ bool bChanged;
+
+ do {
+ // sum up widths
+ nAutoSizeItems = 0;
+ mnItemsWidth = STATUSBAR_OFFSET_X;
+ bChanged = false;
+ long nOffset = 0;
+ for ( const auto & pItem : mvItemList ) {
+ if ( pItem->mbVisible )
+ {
+ if ( pItem->mnBits & StatusBarItemBits::AutoSize ) {
+ nAutoSizeItems++;
+ }
- // sum up widths
- mnItemsWidth = STATUSBAR_OFFSET_X;
- long nOffset = 0;
- for (auto & pItem : mvItemList) {
- if ( pItem->mbVisible )
- {
- if ( pItem->mnBits & StatusBarItemBits::AutoSize ) {
- nAutoSizeItems++;
+ mnItemsWidth += pItem->mnWidth + nOffset;
+ nOffset = pItem->mnOffset;
}
+ }
- mnItemsWidth += pItem->mnWidth + nOffset;
- nOffset = pItem->mnOffset;
+ if ( mnDX > 0 && mnDX < mnItemsWidth )
+ {
+ // Total width of items is more than available width
+ // Try to hide secondary elements, if any
+ for ( auto & pItem : mvItemList )
+ {
+ if ( pItem->mbVisible && !(pItem->mnBits & StatusBarItemBits::Mandatory) )
+ {
+ pItem->mbVisible = false;
+ bChanged = true;
+ break;
+ }
+ }
}
- }
+ else if ( mnDX > mnItemsWidth )
+ {
+ // Width of statusbar is sufficient.
+ // Try to restore hidden items, if any
+ for ( auto & pItem : mvItemList )
+ {
+ if ( !pItem->mbVisible &&
+ !(pItem->mnBits & StatusBarItemBits::Mandatory) &&
+ pItem->mnWidth + nOffset + mnItemsWidth < mnDX )
+ {
+ pItem->mbVisible = true;
+ bChanged = true;
+ break;
+ }
+ }
+ }
+ } while ( bChanged );
if ( GetStyle() & WB_RIGHT )
{