summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-03-28 17:43:29 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-01 16:39:52 +0900
commit5409c8b90fe6ce8e85ca6e74e09045ec52a49716 (patch)
tree38c18ac19720193ef4f4414a0347c87dc173a601 /vcl
parent4a352772f28cdc8edd36d8c7b7178c9dcd5892a8 (diff)
tdf#124148 add configurable margin for the listbox pop-up list
This is needed to increase the area of lisbox entries in the pop-up list so it is easier to select with touch. Reviewed-on: https://gerrit.libreoffice.org/69889 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit ce9dab8c161e29769131cec741a6a9cceec8552d) Change-Id: Iedb910508de26c903dc3f50f645f567d4c988940
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/listbox.hxx4
-rw-r--r--vcl/inc/svdata.hxx2
-rw-r--r--vcl/source/control/imp_listbox.cxx54
-rw-r--r--vcl/source/control/listbox.cxx4
-rw-r--r--vcl/source/gdi/FileDefinitionWidgetDraw.cxx1
5 files changed, 44 insertions, 21 deletions
diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx
index 402275af73a0..c241a4a0515c 100644
--- a/vcl/inc/listbox.hxx
+++ b/vcl/inc/listbox.hxx
@@ -50,6 +50,8 @@ struct ImplEntryType
ListBoxEntryFlags mnFlags;
long mnHeight;
+ long getHeightWithMargin() const;
+
ImplEntryType( const OUString& rStr, const Image& rImage ) :
maStr( rStr ),
maImage( rImage ),
@@ -313,6 +315,7 @@ public:
tools::Rectangle GetBoundingRectangle( sal_Int32 nItem ) const;
long GetEntryHeight() const { return mnMaxHeight; }
+ long GetEntryHeightWithMargin() const;
long GetMaxEntryWidth() const { return mnMaxWidth; }
void SetScrollHdl( const Link<ImplListBoxWindow*,void>& rLink ) { maScrollHdl = rLink; }
@@ -437,6 +440,7 @@ public:
Size CalcSize( sal_Int32 nMaxLines ) const { return maLBWindow->CalcSize( nMaxLines ); }
long GetEntryHeight() const { return maLBWindow->GetEntryHeight(); }
+ long GetEntryHeightWithMargin() const{ return maLBWindow->GetEntryHeightWithMargin(); }
long GetMaxEntryWidth() const { return maLBWindow->GetMaxEntryWidth(); }
void SetScrollHdl( const Link<ImplListBox*,void>& rLink ) { maScrollHdl = rLink; }
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index f0473f2dd2c4..bbe9a75b379c 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -303,6 +303,8 @@ struct ImplSVNWFData
// floating toolbars that can be redocked because there's no way to track
// that the toolbar is over a dockable area.
bool mbCanDetermineWindowPosition = true;
+
+ int mnListBoxEntryMargin = 0;
};
struct BlendFrameCache
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 2161c041077e..2f4f52fde220 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -305,7 +305,7 @@ long ImplEntryList::GetAddedHeight( sal_Int32 i_nEndIndex, sal_Int32 i_nBeginInd
sal_Int32 nIndex = nStart;
while( nIndex != LISTBOX_ENTRY_NOTFOUND && nIndex < nStop )
{
- long nPosHeight = GetEntryPtr( nIndex )->mnHeight;
+ long nPosHeight = GetEntryPtr( nIndex )->getHeightWithMargin();
if (nHeight > ::std::numeric_limits<long>::max() - nPosHeight)
{
SAL_WARN( "vcl", "ImplEntryList::GetAddedHeight: truncated");
@@ -323,7 +323,7 @@ long ImplEntryList::GetAddedHeight( sal_Int32 i_nEndIndex, sal_Int32 i_nBeginInd
long ImplEntryList::GetEntryHeight( sal_Int32 nPos ) const
{
ImplEntryType* pImplEntry = GetEntry( nPos );
- return pImplEntry ? pImplEntry->mnHeight : 0;
+ return pImplEntry ? pImplEntry->getHeightWithMargin() : 0;
}
OUString ImplEntryList::GetEntryText( sal_Int32 nPos ) const
@@ -558,7 +558,7 @@ void ImplListBoxWindow::ImplCalcMetrics()
if( mnCurrentPos != LISTBOX_ENTRY_NOTFOUND )
{
- Size aSz( GetOutputSizePixel().Width(), mpEntryList->GetEntryPtr( mnCurrentPos )->mnHeight );
+ Size aSz( GetOutputSizePixel().Width(), mpEntryList->GetEntryPtr( mnCurrentPos )->getHeightWithMargin() );
maFocusRect.SetSize( aSz );
}
}
@@ -601,6 +601,11 @@ struct ImplEntryMetrics
long nImgHeight;
};
+long ImplEntryType::getHeightWithMargin() const
+{
+ return mnHeight + ImplGetSVData()->maNWFData.mnListBoxEntryMargin;
+}
+
void ImplListBoxWindow::EnableQuickSelection( bool b )
{
maQuickSelectionEngine.SetEnabled( b );
@@ -779,9 +784,10 @@ sal_Int32 ImplListBoxWindow::GetEntryPosForPoint( const Point& rPoint ) const
sal_Int32 nSelect = mnTop;
const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nSelect );
- while( pEntry && rPoint.Y() > pEntry->mnHeight + nY )
+ long nEntryHeight = pEntry->getHeightWithMargin();
+ while( pEntry && rPoint.Y() > nEntryHeight + nY )
{
- nY += pEntry->mnHeight;
+ nY += nEntryHeight;
pEntry = mpEntryList->GetEntryPtr( ++nSelect );
}
if( pEntry == nullptr )
@@ -806,6 +812,12 @@ bool ImplListBoxWindow::IsVisible( sal_Int32 i_nEntry ) const
return bRet;
}
+long ImplListBoxWindow::GetEntryHeightWithMargin() const
+{
+ long nMargin = ImplGetSVData()->maNWFData.mnListBoxEntryMargin;
+ return mnMaxHeight + nMargin;
+}
+
sal_Int32 ImplListBoxWindow::GetLastVisibleEntry() const
{
sal_Int32 nPos = mnTop;
@@ -1693,7 +1705,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32
long nWidth = GetOutputSizePixel().Width();
long nY = mpEntryList->GetAddedHeight(nPos, mnTop);
- tools::Rectangle aRect(Point(0, nY), Size(nWidth, pEntry->mnHeight));
+ tools::Rectangle aRect(Point(0, nY), Size(nWidth, pEntry->getHeightWithMargin()));
if (mpEntryList->IsEntryPosSelected(nPos))
{
@@ -1740,6 +1752,8 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32
if (!pEntry)
return;
+ long nEntryHeight = pEntry->getHeightWithMargin();
+
// when changing this function don't forget to adjust ImplWin::DrawEntry()
if (mbInUserDraw)
@@ -1754,7 +1768,8 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32
if (!!aImage)
{
aImgSz = aImage.GetSizePixel();
- Point aPtImg(mnBorder - mnLeft, nY + ((pEntry->mnHeight - aImgSz.Height()) / 2));
+
+ Point aPtImg(mnBorder - mnLeft, nY + ((nEntryHeight - aImgSz.Height()) / 2));
// pb: #106948# explicit mirroring for calc
if (mbMirroring)
@@ -1801,7 +1816,7 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32
nMaxWidth = GetOutputSizePixel().Width() - 2 * mnBorder;
tools::Rectangle aTextRect(Point(mnBorder - mnLeft, nY),
- Size(nMaxWidth, pEntry->mnHeight));
+ Size(nMaxWidth, nEntryHeight));
if (!bDrawTextAtImagePos && (mpEntryList->HasEntryImage(nPos) || IsUserDrawEnabled()))
{
@@ -1835,7 +1850,7 @@ void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32
rRenderContext.SetLineColor((GetBackground().GetColor() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY);
Point aStartPos(0, nY);
if (nPos == mnSeparatorPos)
- aStartPos.Y() += pEntry->mnHeight - 1;
+ aStartPos.Y() += pEntry->getHeightWithMargin() - 1;
Point aEndPos(aStartPos);
aEndPos.X() = GetOutputSizePixel().Width();
rRenderContext.DrawLine(aStartPos, aEndPos);
@@ -1863,12 +1878,13 @@ void ImplListBoxWindow::ImplDoPaint(vcl::RenderContext& rRenderContext, const to
for (sal_Int32 i = mnTop; i < nCount && nY < nHeight + mnMaxHeight; i++)
{
const ImplEntryType* pEntry = mpEntryList->GetEntryPtr(i);
- if (nY + pEntry->mnHeight >= rRect.Top() &&
+ long nEntryHeight = pEntry->getHeightWithMargin();
+ if (nY + nEntryHeight >= rRect.Top() &&
nY <= rRect.Bottom() + mnMaxHeight)
{
ImplPaint(rRenderContext, i);
}
- nY += pEntry->mnHeight;
+ nY += nEntryHeight;
}
long nHeightDiff = mpEntryList->GetAddedHeight(mnCurrentPos, mnTop);
@@ -1947,7 +1963,7 @@ void ImplListBoxWindow::SetTopEntry( sal_Int32 nTop )
if( nTop > nLastEntry )
nTop = nLastEntry;
const ImplEntryType* pLast = mpEntryList->GetEntryPtr( nLastEntry );
- while( nTop > 0 && mpEntryList->GetAddedHeight( nLastEntry, nTop-1 ) + pLast->mnHeight <= nWHeight )
+ while( nTop > 0 && mpEntryList->GetAddedHeight( nLastEntry, nTop-1 ) + pLast->getHeightWithMargin() <= nWHeight )
nTop--;
if ( nTop != mnTop )
@@ -2019,7 +2035,7 @@ Size ImplListBoxWindow::CalcSize(sal_Int32 nMaxLines) const
// FIXME: ListBoxEntryFlags::MultiLine
Size aSz;
- aSz.Height() = nMaxLines * mnMaxHeight;
+ aSz.Height() = nMaxLines * GetEntryHeightWithMargin();
aSz.Width() = mnMaxWidth + 2*mnBorder;
return aSz;
}
@@ -2027,8 +2043,8 @@ Size ImplListBoxWindow::CalcSize(sal_Int32 nMaxLines) const
tools::Rectangle ImplListBoxWindow::GetBoundingRectangle( sal_Int32 nItem ) const
{
const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nItem );
- Size aSz( GetSizePixel().Width(), pEntry ? pEntry->mnHeight : GetEntryHeight() );
- long nY = mpEntryList->GetAddedHeight( nItem, GetTopEntry() ) + GetEntryList()->GetMRUCount()*GetEntryHeight();
+ Size aSz( GetSizePixel().Width(), pEntry ? pEntry->getHeightWithMargin() : GetEntryHeightWithMargin() );
+ long nY = mpEntryList->GetAddedHeight( nItem, GetTopEntry() ) + GetEntryList()->GetMRUCount()*GetEntryHeightWithMargin();
tools::Rectangle aRect( Point( 0, nY ), aSz );
return aRect;
}
@@ -2251,7 +2267,7 @@ void ImplListBox::ImplCheckScrollBars()
Size aOutSz = GetOutputSizePixel();
sal_Int32 nEntries = GetEntryList()->GetEntryCount();
- sal_uInt16 nMaxVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight());
+ sal_uInt16 nMaxVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeightWithMargin());
// vertical ScrollBar
if( nEntries > nMaxVisEntries )
@@ -2291,7 +2307,7 @@ void ImplListBox::ImplCheckScrollBars()
if ( !mbVScroll ) // maybe we do need one now
{
- nMaxVisEntries = (sal_uInt16) ( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeight() );
+ nMaxVisEntries = (sal_uInt16) ( ( aOutSz.Height() - mpHScrollBar->GetSizePixel().Height() ) / GetEntryHeightWithMargin() );
if( nEntries > nMaxVisEntries )
{
bArrange = true;
@@ -2333,7 +2349,7 @@ void ImplListBox::ImplInitScrollBars()
if ( mbVScroll )
{
sal_Int32 nEntries = GetEntryList()->GetEntryCount();
- sal_uInt16 nVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeight());
+ sal_uInt16 nVisEntries = (sal_uInt16) (aOutSz.Height() / GetEntryHeightWithMargin());
mpVScrollBar->SetRangeMax( nEntries );
mpVScrollBar->SetVisibleSize( nVisEntries );
mpVScrollBar->SetPageSize( nVisEntries - 1 );
@@ -3030,7 +3046,7 @@ Size ImplListBoxFloatingWindow::CalcFloatSize()
// align height to entries...
long nInnerHeight = aFloatSz.Height() - nTop - nBottom;
- long nEntryHeight = mpImplLB->GetEntryHeight();
+ long nEntryHeight = mpImplLB->GetEntryHeightWithMargin();
if ( nInnerHeight % nEntryHeight )
{
nInnerHeight /= nEntryHeight;
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index b6729a3b2904..1bc1e052ca75 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -1229,7 +1229,7 @@ Size ListBox::CalcSubEditSize() const
aSz = mpImplLB->CalcSize (mnLineCount ? mnLineCount : mpImplLB->GetEntryList()->GetEntryCount());
else
{
- aSz.Height() = mpImplLB->CalcSize( 1 ).Height();
+ aSz.Height() = mpImplLB->GetEntryHeight();
// Size to maxmimum entry width
aSz.Width() = mpImplLB->GetMaxEntryWidth();
@@ -1323,7 +1323,7 @@ void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines
{
Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel();
rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth);
- rnLines = (sal_uInt16) (aOutSz.Height()/mpImplLB->GetEntryHeight());
+ rnLines = (sal_uInt16) (aOutSz.Height()/mpImplLB->GetEntryHeightWithMargin());
}
else
{
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index a31ef7a59bfc..5d2497aabcfc 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -80,6 +80,7 @@ FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics)
pSVData->maNWFData.mbProgressNeedsErase = true;
pSVData->maNWFData.mnStatusBarLowerRightOffset = 10;
pSVData->maNWFData.mbCanDrawWidgetAnySize = true;
+ pSVData->maNWFData.mnListBoxEntryMargin = 20;
}
bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, ControlPart ePart)