summaryrefslogtreecommitdiff
path: root/starmath/source
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-05-14 03:11:17 +0000
committerJan-Marek Glogowski <glogow@fbihome.de>2019-05-15 19:38:29 +0200
commit87b8c32f2f72fc9373abe1fc53a2d47183c5f5d3 (patch)
tree6c43c5dad68473e52ee68609a00b0c16dae1fa16 /starmath/source
parentf9c94cfdde6c0af621cf80467a9d83c789699093 (diff)
SM fix element control scrollbar
The element layouting must always be done without a scrollbar, so it can be decided, if a scrollbar is needed. If it's needed the first paint will update the scrollbar accordingly. This also sets the scrollbar's page size to the control height, so clicking in an empty area will correctly scroll the widget not just a single pixel. Change-Id: Ib9a0eb1952bc0355f683cd8d116c61f9c9d462c4 Reviewed-on: https://gerrit.libreoffice.org/72315 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'starmath/source')
-rw-r--r--starmath/source/ElementsDockingWindow.cxx38
1 files changed, 26 insertions, 12 deletions
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index ab0ad7dd689e..36af328f1ced 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -238,6 +238,7 @@ SmElementsControl::SmElementsControl(vcl::Window *pParent)
, mpCurrentElement(nullptr)
, mbVerticalMode(true)
, mxScroll(VclPtr<ScrollBar>::Create(this, WB_VERT))
+ , mbFirstPaintAfterLayout(false)
{
set_id("element_selector");
SetMapMode( MapMode(MapUnit::Map100thMM) );
@@ -248,7 +249,6 @@ SmElementsControl::SmElementsControl(vcl::Window *pParent)
maFormat.SetBaseSize(PixelToLogic(Size(0, SmPtsTo100th_mm(12))));
mxScroll->SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) );
- mxScroll->Show();
}
SmElementsControl::~SmElementsControl()
@@ -268,14 +268,19 @@ void SmElementsControl::setVerticalMode(bool bVerticalMode)
mbVerticalMode = bVerticalMode;
}
+/**
+ * !pContext => layout only
+ *
+ * Layouting is always done without a scrollbar and will show or hide it.
+ * The first paint (mbFirstPaintAfterLayout) therefore needs to update a
+ * visible scrollbar, because the layouting was wrong.
+ **/
void SmElementsControl::LayoutOrPaintContents(vcl::RenderContext *pContext)
{
- bool bOldVisibleState = mxScroll->IsVisible();
-
- sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
-
- sal_Int32 nControlWidth = GetOutputSizePixel().Width() - nScrollbarWidth;
- sal_Int32 nControlHeight = GetOutputSizePixel().Height();
+ const sal_Int32 nScrollbarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+ const sal_Int32 nControlWidth = GetOutputSizePixel().Width()
+ - (pContext && mxScroll->IsVisible() ? nScrollbarWidth : 0);
+ const sal_Int32 nControlHeight = GetOutputSizePixel().Height();
sal_Int32 boxX = maMaxElementDimensions.Width() + 10;
sal_Int32 boxY = maMaxElementDimensions.Height() + 10;
@@ -379,15 +384,21 @@ void SmElementsControl::LayoutOrPaintContents(vcl::RenderContext *pContext)
}
if (pContext)
- return;
+ {
+ if (!mbFirstPaintAfterLayout || !mxScroll->IsVisible())
+ return;
+ mbFirstPaintAfterLayout = false;
+ }
+ else
+ mbFirstPaintAfterLayout = true;
sal_Int32 nTotalControlHeight = y + boxY + mxScroll->GetThumbPos();
-
if (nTotalControlHeight > GetOutputSizePixel().Height())
{
mxScroll->SetRangeMax(nTotalControlHeight);
mxScroll->SetPosSizePixel(Point(nControlWidth, 0), Size(nScrollbarWidth, nControlHeight));
mxScroll->SetVisibleSize(nControlHeight);
+ mxScroll->SetPageSize(nControlHeight);
mxScroll->Show();
}
else
@@ -397,6 +408,12 @@ void SmElementsControl::LayoutOrPaintContents(vcl::RenderContext *pContext)
}
}
+void SmElementsControl::Resize()
+{
+ Window::Resize();
+ LayoutOrPaintContents(nullptr);
+}
+
void SmElementsControl::ApplySettings(vcl::RenderContext& rRenderContext)
{
rRenderContext.SetBackground(COL_WHITE);
@@ -461,7 +478,6 @@ void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
mpCurrentElement = nullptr;
if (rMouseEvent.IsLeaveWindow())
{
- LayoutOrPaintContents();
Invalidate();
return;
}
@@ -476,7 +492,6 @@ void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
if (pPrevElement != element)
{
mpCurrentElement = element;
- LayoutOrPaintContents();
Invalidate();
return;
}
@@ -541,7 +556,6 @@ void SmElementsControl::DoScroll(long nDelta)
aRect.AdjustRight( -(mxScroll->GetSizePixel().Width()) );
Scroll( 0, -nDelta, aRect );
mxScroll->SetPosPixel(aNewPoint);
- LayoutOrPaintContents();
Invalidate();
}