tdf#42030 Add UI label for page preview zoom slider
* Scale before the page preview zoom slider * zoom % after the page preview zoom slider Change-Id: I893852bf48e31b36a028f9ee282d47a627bb0086 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159362 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
#include <tbzoomsliderctrl.hxx>
|
||||
#include <i18nutil/unicode.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <utility>
|
||||
@@ -102,8 +104,7 @@ const tools::Long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance
|
||||
|
||||
sal_uInt16 ScZoomSlider::Offset2Zoom( tools::Long nOffset ) const
|
||||
{
|
||||
Size aSliderWindowSize = GetOutputSizePixel();
|
||||
const tools::Long nControlWidth = aSliderWindowSize.Width();
|
||||
const tools::Long nControlWidth = GetSliderLength();
|
||||
sal_uInt16 nRet = 0;
|
||||
|
||||
if( nOffset < nSliderXOffset )
|
||||
@@ -154,8 +155,7 @@ sal_uInt16 ScZoomSlider::Offset2Zoom( tools::Long nOffset ) const
|
||||
|
||||
tools::Long ScZoomSlider::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
|
||||
{
|
||||
Size aSliderWindowSize = GetOutputSizePixel();
|
||||
const tools::Long nControlWidth = aSliderWindowSize.Width();
|
||||
const tools::Long nControlWidth = GetSliderLength();
|
||||
tools::Long nRect = nSliderXOffset;
|
||||
|
||||
const tools::Long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
|
||||
@@ -183,6 +183,8 @@ ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent,
|
||||
sal_uInt16 nCurrentZoom ):
|
||||
InterimItemWindow(pParent, "modules/scalc/ui/zoombox.ui", "ZoomBox"),
|
||||
mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom)),
|
||||
mxPercentage(m_xBuilder->weld_label("current_zoom")),
|
||||
mxLabel(m_xBuilder->weld_label("zoom_label")),
|
||||
mxWeld(new weld::CustomWeld(*m_xBuilder, "zoom", *mxWidget))
|
||||
{
|
||||
Size aLogicalSize( 115, 40 );
|
||||
@@ -190,7 +192,14 @@ ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent,
|
||||
Size aPreferredSize(aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight);
|
||||
mxWidget->GetDrawingArea()->set_size_request(aPreferredSize.Width(), aPreferredSize.Height());
|
||||
mxWidget->SetOutputSizePixel(aPreferredSize);
|
||||
mxWidget->SetSliderLength(aPreferredSize.Width() + nIncDecWidth);
|
||||
|
||||
aPreferredSize.setWidth(aPreferredSize.Width() + mxLabel->get_pixel_size(mxLabel->get_label()).Width()
|
||||
+ mxPercentage->get_pixel_size(mxPercentage->get_label()).Width());
|
||||
|
||||
SetSizePixel(aPreferredSize);
|
||||
OUString sCurrentZoom(unicode::formatPercent(nCurrentZoom, Application::GetSettings().GetUILanguageTag()));
|
||||
mxPercentage->set_label(sCurrentZoom);
|
||||
}
|
||||
|
||||
ScZoomSliderWnd::~ScZoomSliderWnd()
|
||||
@@ -236,12 +245,12 @@ bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt )
|
||||
mnCurrentZoom = mnCurrentZoom - 5;
|
||||
}
|
||||
// click to + button
|
||||
else if ( aPoint.X() >= aSliderWindowSize.Width() - nSliderXOffset + nButtonLeftOffset &&
|
||||
aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset + nButtonRightOffset )
|
||||
else if ( aPoint.X() >= GetSliderLength() - nSliderXOffset + nButtonLeftOffset &&
|
||||
aPoint.X() <= GetSliderLength() - nSliderXOffset + nButtonRightOffset )
|
||||
{
|
||||
mnCurrentZoom = mnCurrentZoom + 5;
|
||||
}
|
||||
else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset )
|
||||
else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= GetSliderLength() - nSliderXOffset )
|
||||
{
|
||||
mnCurrentZoom = Offset2Zoom( aPoint.X() );
|
||||
}
|
||||
@@ -276,7 +285,7 @@ bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt )
|
||||
bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt )
|
||||
{
|
||||
Size aSliderWindowSize = GetOutputSizePixel();
|
||||
const tools::Long nControlWidth = aSliderWindowSize.Width();
|
||||
const tools::Long nControlWidth = GetSliderLength();
|
||||
const short nButtons = rMEvt.GetButtons();
|
||||
|
||||
// check mouse move with button pressed
|
||||
@@ -312,6 +321,8 @@ bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt )
|
||||
|
||||
void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
|
||||
{
|
||||
OUString sCurrentZoom(unicode::formatPercent(pZoomSliderItem->GetValue(), Application::GetSettings().GetUILanguageTag()));
|
||||
mxPercentage->set_label(sCurrentZoom);
|
||||
mxWidget->UpdateFromItem(pZoomSliderItem);
|
||||
}
|
||||
|
||||
@@ -377,6 +388,7 @@ void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext)
|
||||
pVDev->SetOutputSizePixel(aSliderWindowSize);
|
||||
|
||||
tools::Rectangle aSlider = aRect;
|
||||
aSlider.setWidth(GetSliderLength());
|
||||
|
||||
aSlider.AdjustTop((aSliderWindowSize.Height() - nSliderHeight) / 2 - 1 );
|
||||
aSlider.SetBottom( aSlider.Top() + nSliderHeight );
|
||||
@@ -449,7 +461,7 @@ void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext)
|
||||
pVDev->DrawImage(aImagePoint, maDecreaseButton);
|
||||
|
||||
// draw increase button
|
||||
aImagePoint.setX( aRect.Left() + aSliderWindowSize.Width() - nIncDecWidth - (nSliderXOffset - nIncDecWidth) / 2 );
|
||||
aImagePoint.setX( aRect.Left() + GetSliderLength() - nIncDecWidth - (nSliderXOffset - nIncDecWidth) / 2 );
|
||||
pVDev->DrawImage(aImagePoint, maIncreaseButton);
|
||||
|
||||
rRenderContext.DrawOutDev(Point(0, 0), aSliderWindowSize, Point(0, 0), aSliderWindowSize, *pVDev);
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
class ScZoomSlider final : public weld::CustomWidgetController
|
||||
{
|
||||
private:
|
||||
sal_uInt16 mnSliderLength;
|
||||
sal_uInt16 mnCurrentZoom;
|
||||
sal_uInt16 mnMinZoom;
|
||||
sal_uInt16 mnMaxZoom;
|
||||
@@ -64,6 +65,8 @@ public:
|
||||
|
||||
void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem);
|
||||
|
||||
void SetSliderLength(sal_uInt16 nLength) { mnSliderLength = nLength; }
|
||||
sal_uInt16 GetSliderLength() const { return mnSliderLength; }
|
||||
virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
|
||||
virtual bool MouseMove( const MouseEvent& rMEvt ) override;
|
||||
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
|
||||
@@ -73,6 +76,8 @@ class ScZoomSliderWnd final : public InterimItemWindow
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<ScZoomSlider> mxWidget;
|
||||
std::unique_ptr<weld::Label> mxPercentage;
|
||||
std::unique_ptr<weld::Label> mxLabel;
|
||||
std::unique_ptr<weld::CustomWeld> mxWeld;
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface domain="sc">
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkBox" id="ZoomBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="zoom">
|
||||
<object class="GtkLabel" id="zoom_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="zoombox|zoom_label">Scale</property>
|
||||
<property name="mnemonic_widget">zoom</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@@ -21,5 +20,32 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="zoom">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="current_zoom">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="no">percentage</property>
|
||||
<property name="mnemonic_widget">zoom</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
Reference in New Issue
Block a user