summaryrefslogtreecommitdiff
path: root/vcl/source/control
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir.extern@allotropia.de>2023-10-08 21:51:12 +0300
committerSarper Akdemir <sarper.akdemir.extern@allotropia.de>2023-10-30 08:17:18 +0100
commitdf79eedf6989ab4c2913a23a7e72079bd719168b (patch)
tree429b451dd9c48be33aedf8e9a67313b9c156cef7 /vcl/source/control
parent3d5cafbe1727a95a54eb4a65d98d6d79ec46f0c8 (diff)
tdf#157518: vcl: Introduce vcl control LevelBar
Introduces LevelBar that shares implementation with Progress(Bar). LevelBar is to be as a level indicator, e.g. password strength level. Currently with native backends for gtk and Windows. Currently, except on gtk - the colors of the bar at different levels are hardcoded and not dependent on any kind of themeing. On Windows it follows the styling of progress bar of type "Meter" according to the uxguide: https://learn.microsoft.com/en-us/windows/win32/uxguide/progress-bars#meters Change-Id: Id772cda23615e9582463bf589e4674fd4588c864 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157826 Tested-by: Jenkins Reviewed-by: Sarper Akdemir <sarper.akdemir.extern@allotropia.de>
Diffstat (limited to 'vcl/source/control')
-rw-r--r--vcl/source/control/prgsbar.cxx27
1 files changed, 17 insertions, 10 deletions
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index 6b7a7007c599..e15c7c055dbe 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -39,12 +39,15 @@ void ProgressBar::ImplInit()
ImplInitSettings( true, true, true );
}
-static WinBits clearProgressBarBorder( vcl::Window const * pParent, WinBits nOrgStyle )
+static WinBits clearProgressBarBorder( vcl::Window const * pParent, WinBits nOrgStyle, ProgressBar::BarStyle eBarStyle )
{
WinBits nOutStyle = nOrgStyle;
if( pParent && (nOrgStyle & WB_BORDER) != 0 )
{
- if( pParent->IsNativeControlSupported( ControlType::Progress, ControlPart::Entire ) )
+ if (pParent->IsNativeControlSupported(eBarStyle == ProgressBar::BarStyle::Progress
+ ? ControlType::Progress
+ : ControlType::LevelBar,
+ ControlPart::Entire))
nOutStyle &= WB_BORDER;
}
return nOutStyle;
@@ -52,11 +55,12 @@ static WinBits clearProgressBarBorder( vcl::Window const * pParent, WinBits nOrg
Size ProgressBar::GetOptimalSize() const
{
- return Size(150, 20);
+ return meBarStyle == BarStyle::Progress ? Size(150, 20) : Size(150,10);
}
-ProgressBar::ProgressBar( vcl::Window* pParent, WinBits nWinStyle ) :
- Window( pParent, clearProgressBarBorder( pParent, nWinStyle ) )
+ProgressBar::ProgressBar( vcl::Window* pParent, WinBits nWinStyle, BarStyle eBarStyle ) :
+ Window( pParent, clearProgressBarBorder( pParent, nWinStyle, eBarStyle ) ),
+ meBarStyle(eBarStyle)
{
SetOutputSizePixel( GetOptimalSize() );
ImplInit();
@@ -74,8 +78,10 @@ void ProgressBar::ImplInitSettings( bool bFont,
if ( bBackground )
{
- if( !IsControlBackground() &&
- IsNativeControlSupported( ControlType::Progress, ControlPart::Entire ) )
+ if (!IsControlBackground()
+ && IsNativeControlSupported(meBarStyle == BarStyle::Progress ? ControlType::Progress
+ : ControlType::LevelBar,
+ ControlPart::Entire))
{
if( GetStyle() & WB_BORDER )
SetBorderStyle( WindowBorderStyle::REMOVEBORDER );
@@ -144,9 +150,10 @@ void ProgressBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt1
maPos.setX( (aSize.Width() - nMaxWidth) / 2 );
}
- ::DrawProgress(this, rRenderContext, maPos, PROGRESSBAR_OFFSET, mnPrgsWidth, mnPrgsHeight,
- /*nPercent1=*/0, nNewPerc * 100, mnPercentCount,
- tools::Rectangle(Point(), GetSizePixel()));
+ ::DrawProgress(
+ this, rRenderContext, maPos, PROGRESSBAR_OFFSET, mnPrgsWidth, mnPrgsHeight,
+ /*nPercent1=*/0, nNewPerc * 100, mnPercentCount, tools::Rectangle(Point(), GetSizePixel()),
+ meBarStyle == BarStyle::Progress ? ControlType::Progress : ControlType::LevelBar);
}
void ProgressBar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)