Kaydet (Commit) 47a77d7d authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Ruler: disable snapping, tooltips

It is now possible to disable snapping of the ruler at dragging
with holding the ALT key and coarse snapping with ALT+SHIFT key.

Tooltips are shown when hovering over indents and borders.

Change-Id: Ib1e9639e1e2824f2a75b5abd35765bbbd02c87f7
üst b44a8ddc
......@@ -474,16 +474,11 @@ Tips zur Benutzung des Lineals:
*************************************************************************/
// -----------
// - WinBits -
// -----------
#define WB_EXTRAFIELD ((WinBits)0x00004000)
#define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
#define WB_STDRULER WB_HORZ
struct ImplRulerHitTest;
#define WB_EXTRAFIELD ((WinBits)0x00004000)
#define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
#define WB_STDRULER WB_HORZ
// - Ruler-Type -
......@@ -541,7 +536,7 @@ struct RulerBorder
struct RulerIndent
{
long nPos;
long nPos;
sal_uInt16 nStyle;
};
......@@ -572,6 +567,21 @@ struct RulerLine
sal_uInt16 nStyle;
};
struct RulerSelection
{
long nPos;
RulerType eType;
sal_uInt16 nAryPos;
sal_uInt16 mnDragSize;
bool bSize;
bool bSizeBar;
bool bExpandTest;
RulerSelection() :
bExpandTest( false )
{}
};
struct RulerUnitData
{
MapUnit eMapUnit; // MAP_UNIT for calculaion
......@@ -635,6 +645,9 @@ private:
sal_Bool mbAutoWinWidth;
sal_Bool mbActive;
sal_uInt8 mnUpdateFlags;
RulerSelection maHoverSelection;
Link maStartDragHdl;
Link maDragHdl;
Link maEndDragHdl;
......@@ -642,8 +655,8 @@ private:
Link maDoubleClickHdl;
Link maExtraDownHdl;
boost::scoped_ptr<ImplRulerHitTest> mpCurrentHitTest;
boost::scoped_ptr<ImplRulerHitTest> mpPreviousHitTest;
boost::scoped_ptr<RulerSelection> mpCurrentHitTest;
boost::scoped_ptr<RulerSelection> mpPreviousHitTest;
SVT_DLLPRIVATE void ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 );
SVT_DLLPRIVATE void ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 );
......@@ -669,11 +682,11 @@ private:
using Window::ImplHitTest;
SVT_DLLPRIVATE sal_Bool ImplHitTest( const Point& rPosition,
ImplRulerHitTest* pHitTest,
RulerSelection* pHitTest,
sal_Bool bRequiredStyle = sal_False,
sal_uInt16 nRequiredStyle = 0 ) const;
SVT_DLLPRIVATE sal_Bool ImplDocHitTest( const Point& rPos, RulerType eDragType, ImplRulerHitTest* pHitTest ) const;
SVT_DLLPRIVATE sal_Bool ImplStartDrag( ImplRulerHitTest* pHitTest, sal_uInt16 nModifier );
SVT_DLLPRIVATE sal_Bool ImplDocHitTest( const Point& rPos, RulerType eDragType, RulerSelection* pHitTest ) const;
SVT_DLLPRIVATE sal_Bool ImplStartDrag( RulerSelection* pHitTest, sal_uInt16 nModifier );
SVT_DLLPRIVATE void ImplDrag( const Point& rPos );
SVT_DLLPRIVATE void ImplEndDrag();
......@@ -751,6 +764,8 @@ public:
RulerType GetClickType() const { return meDragType; }
sal_uInt16 GetClickAryPos() const { return mnDragAryPos; }
RulerSelection GetHoverSelection() const { return maHoverSelection; }
using Window::GetType;
RulerType GetType( const Point& rPos, sal_uInt16* pAryPos = NULL ) const;
......
......@@ -101,6 +101,9 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
sal_Bool bListening;
sal_Bool bActive;
bool mbCoarseSnapping;
bool mbSnapping;
void StartListening_Impl();
long GetCorrectedDragPos(sal_Bool bLeft = sal_True, sal_Bool bRight = sal_True );
void DrawLine_Impl(long &lTabPos, int, sal_Bool Horizontal=sal_True);
......@@ -135,7 +138,7 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
void UpdateObject();
// Convert position to stick to ruler ticks
long MakePositionSticky(long rValue, bool aSnapToFrameMargin = true) const;
long MakePositionSticky(long rValue, long aPointOfReference, bool aSnapToFrameMargin = true) const;
long PixelHAdjust(long lPos, long lPos2) const;
long PixelVAdjust(long lPos, long lPos2) const;
......@@ -157,6 +160,8 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
long ConvertPosLogic(long lPos) const;
long ConvertSizeLogic(long lSize) const;
long RoundToCurrentMapMode(long lValue) const;
long GetFirstLineIndent() const;
long GetLeftIndent() const;
long GetRightIndent() const;
......
......@@ -100,21 +100,6 @@ public:
ImplRulerData& operator=( const ImplRulerData& rData );
};
struct ImplRulerHitTest
{
long nPos;
RulerType eType;
sal_uInt16 nAryPos;
sal_uInt16 mnDragSize;
bool bSize;
bool bSizeBar;
bool bExpandTest;
ImplRulerHitTest() :
bExpandTest( false )
{}
};
ImplRulerData::ImplRulerData() :
nNullVirOff (0),
nRulVirOff (0),
......@@ -435,7 +420,7 @@ void Ruler::ImplInvertLines( sal_Bool bErase )
void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nBottom )
{
long nCenter = nTop + ((nBottom - nTop) / 2);
double nCenter = nTop + ((nBottom - nTop) / 2);
long nTickLength3 = (nBottom - nTop) * 0.5;
long nTickLength2 = nTickLength3 * 0.66;
......@@ -626,7 +611,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB
(nTickLength == nTickLength2 && nTickGap2 > 6) ||
(nTickLength == nTickLength3 && nTickGap3 > 6) )
{
long nT1 = nCenter - (nTickLength / 2);
long nT1 = nCenter - (nTickLength / 2.0);
long nT2 = nT1 + nTickLength - 1;
long nT;
......@@ -1410,7 +1395,7 @@ void Ruler::ImplUpdate( sal_Bool bMustCalc )
}
}
sal_Bool Ruler::ImplHitTest( const Point& rPos, ImplRulerHitTest* pHitTest,
sal_Bool Ruler::ImplHitTest( const Point& rPos, RulerSelection* pHitTest,
sal_Bool bRequireStyle, sal_uInt16 nRequiredStyle ) const
{
sal_Int32 i;
......@@ -1713,7 +1698,7 @@ sal_Bool Ruler::ImplHitTest( const Point& rPos, ImplRulerHitTest* pHitTest,
}
sal_Bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
ImplRulerHitTest* pHitTest ) const
RulerSelection* pHitTest ) const
{
Point aPos = rPos;
sal_Bool bRequiredStyle = sal_False;
......@@ -1780,7 +1765,7 @@ sal_Bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
return sal_False;
}
sal_Bool Ruler::ImplStartDrag( ImplRulerHitTest* pHitTest, sal_uInt16 nModifier )
sal_Bool Ruler::ImplStartDrag( RulerSelection* pHitTest, sal_uInt16 nModifier )
{
// don't trigger drag if a border that was clicked can not be changed
if ( (pHitTest->eType == RULER_TYPE_BORDER) &&
......@@ -1972,7 +1957,7 @@ void Ruler::MouseButtonDown( const MouseEvent& rMEvt )
}
else
{
boost::scoped_ptr<ImplRulerHitTest> pHitTest(new ImplRulerHitTest);
boost::scoped_ptr<RulerSelection> pHitTest(new RulerSelection);
bool bHitTestResult = ImplHitTest(aMousePos, pHitTest.get());
if ( nMouseClicks == 1 )
......@@ -2019,10 +2004,14 @@ void Ruler::MouseMove( const MouseEvent& rMEvt )
{
PointerStyle ePtrStyle = POINTER_ARROW;
mpCurrentHitTest.reset(new ImplRulerHitTest);
mpCurrentHitTest.reset(new RulerSelection);
maHoverSelection.eType = RULER_TYPE_DONTKNOW;
if (ImplHitTest( rMEvt.GetPosPixel(), mpCurrentHitTest.get() ))
{
maHoverSelection = *mpCurrentHitTest.get();
if (mpCurrentHitTest->bSize)
{
if (mnWinStyle & WB_HORZ)
......@@ -2280,10 +2269,11 @@ sal_Bool Ruler::StartDocDrag( const MouseEvent& rMEvt, RulerType eDragType )
{
if ( !mbDrag )
{
Point aMousePos = rMEvt.GetPosPixel();
sal_uInt16 nMouseClicks = rMEvt.GetClicks();
sal_uInt16 nMouseModifier = rMEvt.GetModifier();
ImplRulerHitTest aHitTest;
Point aMousePos = rMEvt.GetPosPixel();
sal_uInt16 nMouseClicks = rMEvt.GetClicks();
sal_uInt16 nMouseModifier = rMEvt.GetModifier();
RulerSelection aHitTest;
if(eDragType != RULER_TYPE_DONTKNOW)
aHitTest.bExpandTest = true;
......@@ -2351,7 +2341,7 @@ void Ruler::CancelDrag()
RulerType Ruler::GetType( const Point& rPos, sal_uInt16* pAryPos ) const
{
ImplRulerHitTest aHitTest;
RulerSelection aHitTest;
// update ruler
if ( IsReallyVisible() && mbFormat )
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment