Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 5ce9f2f9f03075dbb7da5da2966cbfa9492f9584 Mon Sep 17 00:00:00 2001
- From: =?UTF-8?q?Toma=C5=BE=20Vajngerl?= <tomaz.vajngerl@collabora.co.uk>
- Date: Sat, 4 Apr 2015 16:05:32 +0900
- Subject: [PATCH] gesture: panning support
- Change-Id: Ic07eddbe741b69685d1a3dde524db7a390056ea7
- ---
- include/vcl/cmdevt.hxx | 29 ++++++++++++++++++
- sw/source/uibase/docvw/edtwin.cxx | 17 +++++++++++
- sw/source/uibase/inc/edtwin.hxx | 2 ++
- sw/source/uibase/inc/view.hxx | 2 ++
- sw/source/uibase/uiview/viewport.cxx | 7 +++++
- vcl/inc/salwtype.hxx | 10 +++++++
- vcl/inc/unx/gtk/gtkframe.hxx | 8 +++++
- vcl/source/window/winproc.cxx | 29 ++++++++++++++++++
- vcl/unx/gtk/window/gtksalframe.cxx | 58 ++++++++++++++++++++++++++++++++++++
- 9 files changed, 162 insertions(+)
- diff --git a/include/vcl/cmdevt.hxx b/include/vcl/cmdevt.hxx
- index 942d45b..8044c55 100644
- --- a/include/vcl/cmdevt.hxx
- +++ b/include/vcl/cmdevt.hxx
- @@ -374,6 +374,25 @@ public:
- double getY() const { return mnY; }
- };
- +class VCL_DLLPUBLIC CommandPanData
- +{
- + long mnX;
- + long mnY;
- + long mnType;
- +
- +public:
- + CommandPanData(long nX, long nY, long nType)
- + : mnX(nX)
- + , mnY(nY)
- + , mnType(nType)
- + {
- + }
- +
- + long getX() const { return mnX; }
- + long getY() const { return mnY; }
- + long getType() const { return mnType; }
- +};
- +
- // - CommandEvent -
- #define COMMAND_CONTEXTMENU ((sal_uInt16)1)
- @@ -397,6 +416,7 @@ public:
- #define COMMAND_QUERYCHARPOSITION ((sal_uInt16)20)
- #define COMMAND_SWIPE ((sal_uInt16)21)
- #define COMMAND_LONGPRESS ((sal_uInt16)22)
- +#define COMMAND_PAN ((sal_uInt16)23)
- class VCL_DLLPUBLIC CommandEvent
- {
- @@ -426,6 +446,7 @@ public:
- const CommandSelectionChangeData* GetSelectionChangeData() const;
- const CommandSwipeData* GetSwipeData() const;
- const CommandLongPressData* GetLongPressData() const;
- + const CommandPanData* GetPanData() const;
- };
- inline CommandEvent::CommandEvent()
- @@ -524,6 +545,14 @@ inline const CommandLongPressData* CommandEvent::GetLongPressData() const
- return NULL;
- }
- +inline const CommandPanData* CommandEvent::GetPanData() const
- +{
- + if( mnCommand == COMMAND_PAN )
- + return (const CommandPanData*)(mpData);
- + else
- + return NULL;
- +}
- +
- #endif // INCLUDED_VCL_CMDEVT_HXX
- /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
- diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
- index f0831ac..f76eab3 100644
- --- a/sw/source/uibase/docvw/edtwin.cxx
- +++ b/sw/source/uibase/docvw/edtwin.cxx
- @@ -5171,6 +5171,23 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
- delete m_pShadCrsr, m_pShadCrsr = 0;
- bCallBase = !m_rView.HandleWheelCommands( rCEvt );
- break;
- + case COMMAND_PAN:
- + {
- + const CommandPanData* pPanData = rCEvt.GetPanData();
- + if (pPanData != NULL)
- + {
- + if (pPanData->getType() == 0)
- + {
- + mPanPreviousX = m_rView.GetVisArea().TopLeft().Y();
- + }
- + else if (pPanData->getType() == 1)
- + {
- + m_rView.MoveView(mPanPreviousX, -pPanData->getY());
- + }
- + }
- + }
- + break;
- +
- case COMMAND_STARTEXTTEXTINPUT:
- {
- diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
- index b9d00f9..63dde49 100644
- --- a/sw/source/uibase/inc/edtwin.hxx
- +++ b/sw/source/uibase/inc/edtwin.hxx
- @@ -137,6 +137,8 @@ friend void PageNumNotify( SwViewShell* pVwSh,
- sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
- sal_uInt16 m_nKS_NUMINDENTINC_Count;
- + sal_Int32 mPanPreviousX;
- +
- SwFrameControlsManager m_aFrameControlsManager;
- void LeaveArea(const Point &);
- diff --git a/sw/source/uibase/inc/view.hxx b/sw/source/uibase/inc/view.hxx
- index 8cd1d5cf..1a36120 100644
- --- a/sw/source/uibase/inc/view.hxx
- +++ b/sw/source/uibase/inc/view.hxx
- @@ -448,6 +448,8 @@ public:
- long SetVScrollMax(long lMax);
- long SetHScrollMax(long lMax);
- + void MoveView(long initial, long nDeltaPixel);
- +
- void SpellError(LanguageType eLang);
- bool ExecSpellPopup( const Point& rPt );
- void ExecFieldPopup( const Point& rPt, sw::mark::IFieldmark *fieldBM );
- diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
- index 0477314..2c21382 100644
- --- a/sw/source/uibase/uiview/viewport.cxx
- +++ b/sw/source/uibase/uiview/viewport.cxx
- @@ -619,6 +619,13 @@ long SwView::PhyPageDown()
- return 1;
- }
- +void SwView::MoveView(long initial, long nDeltaPixel)
- +{
- + Point aPoint = m_aVisArea.TopLeft();
- + aPoint.Y() = initial + GetEditWin().PixelToLogic(Size(0, nDeltaPixel)).Height();
- + SetVisArea(aPoint);
- +}
- +
- long SwView::PageUpCrsr( bool bSelect )
- {
- if ( !bSelect )
- diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx
- index 67ad505..4448981 100644
- --- a/vcl/inc/salwtype.hxx
- +++ b/vcl/inc/salwtype.hxx
- @@ -80,6 +80,9 @@ class FontSelectPattern;
- #define SALEVENT_QUERYCHARPOSITION ((sal_uInt16)48)
- #define SALEVENT_SWIPE ((sal_uInt16)49)
- #define SALEVENT_LONGPRESS ((sal_uInt16)50)
- +#define SALEVENT_PAN_BEGIN ((sal_uInt16)51)
- +#define SALEVENT_PAN_UPDATE ((sal_uInt16)52)
- +#define SALEVENT_PAN_END ((sal_uInt16)53)
- // MOUSELEAVE must send, when the pointer leave the client area and
- // the mouse is not captured
- @@ -294,6 +297,13 @@ struct SalLongPressEvent
- long mnY;
- };
- +struct SalPanEvent
- +{
- + long mnX;
- + long mnY;
- + long mnType;
- +};
- +
- typedef void (*SALTIMERPROC)( bool idle );
- #endif // INCLUDED_VCL_INC_SALWTYPE_HXX
- diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
- index 2eb0634..0905feb 100644
- --- a/vcl/inc/unx/gtk/gtkframe.hxx
- +++ b/vcl/inc/unx/gtk/gtkframe.hxx
- @@ -217,6 +217,10 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
- SalMenu* m_pSalMenu;
- +#if GTK_CHECK_VERSION(3,14,0)
- + GtkGesture* m_pPan;
- +#endif
- +
- #if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
- public:
- void EnsureDbusMenuSynced();
- @@ -240,6 +244,10 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
- #if GTK_CHECK_VERSION(3,14,0)
- static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame);
- static void gestureLongPress(GtkGestureLongPress* gesture, gpointer frame);
- + static void gestureDragBegin(GtkGesturePan* gesture, gdouble start_x, gdouble start_y, gpointer frame);
- + static void gestureDragUpdate(GtkGesturePan* gesture, gdouble start_x, gdouble start_y, gpointer frame);
- + static void gestureDragEnd(GtkGesturePan* gesture, gdouble start_x, gdouble start_y, gpointer frame);
- + static void gesturePan(GtkGesturePan* gesture, gdouble offset, gpointer frame);
- #endif
- #else
- static gboolean signalExpose( GtkWidget*, GdkEventExpose*, gpointer );
- diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
- index d3df6d0..547425c 100644
- --- a/vcl/source/window/winproc.cxx
- +++ b/vcl/source/window/winproc.cxx
- @@ -1647,6 +1647,29 @@ static bool ImplHandleLongPress(vcl::Window *pWindow, const SalLongPressEvent& r
- return aHandler.HandleEvent();
- }
- +class HandlePanEvent : public HandleGestureEvent
- +{
- +private:
- + CommandPanData maPanData;
- +public:
- + HandlePanEvent(vcl::Window* pWindow, const SalPanEvent& rEvent)
- + : HandleGestureEvent(pWindow, Point(rEvent.mnX, rEvent.mnY))
- + , maPanData(rEvent.mnX, rEvent.mnY, rEvent.mnType)
- + {
- + }
- +
- + virtual bool CallCommand(vcl::Window* pWindow, const Point& /*rMousePos*/) SAL_OVERRIDE
- + {
- + return ImplCallCommand(pWindow, COMMAND_PAN, &maPanData);
- + }
- +};
- +
- +static bool ImplHandlePanEvent(vcl::Window *pWindow, const SalPanEvent& rEvent)
- +{
- + HandlePanEvent aHandler(pWindow, rEvent);
- + return aHandler.HandleEvent();
- +}
- +
- #define IMPL_PAINT_CHECKRTL ((sal_uInt16)0x0020)
- static void ImplHandlePaint( vcl::Window* pWindow, const Rectangle& rBoundRect, bool bImmediateUpdate )
- @@ -2700,6 +2723,12 @@ bool ImplWindowFrameProc( vcl::Window* pWindow, SalFrame* /*pFrame*/,
- nRet = ImplHandleLongPress(pWindow, *static_cast<const SalLongPressEvent*>(pEvent));
- break;
- + case SALEVENT_PAN_BEGIN:
- + case SALEVENT_PAN_UPDATE:
- + case SALEVENT_PAN_END:
- + nRet = ImplHandlePanEvent(pWindow, *(const SalPanEvent*)pEvent);
- + break;
- +
- #ifdef DBG_UTIL
- default:
- diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
- index acf170f..2d9362b 100644
- --- a/vcl/unx/gtk/window/gtksalframe.cxx
- +++ b/vcl/unx/gtk/window/gtksalframe.cxx
- @@ -1000,6 +1000,17 @@ void GtkSalFrame::InitCommon()
- gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (pLongPress), GTK_PHASE_TARGET);
- g_object_weak_ref(G_OBJECT(m_pWindow), reinterpret_cast<GWeakNotify>(g_object_unref), pLongPress);
- + m_pPan = gtk_gesture_pan_new(m_pWindow, GTK_ORIENTATION_VERTICAL);
- + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (m_pPan), TRUE);
- + gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (m_pPan), GTK_PHASE_CAPTURE);
- +
- + g_signal_connect(m_pPan, "drag-begin", G_CALLBACK(gestureDragBegin), this);
- + g_signal_connect(m_pPan, "drag-update", G_CALLBACK(gestureDragUpdate), this);
- + g_signal_connect(m_pPan, "drag-end", G_CALLBACK(gestureDragEnd), this);
- + g_signal_connect(m_pPan, "pan", G_CALLBACK(gesturePan), this);
- + gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (m_pPan), GTK_PHASE_TARGET);
- + g_object_weak_ref(G_OBJECT(m_pWindow), reinterpret_cast<GWeakNotify>(g_object_unref), m_pPan);
- +
- #endif
- #else
- @@ -3221,6 +3232,13 @@ gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer
- {
- GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
- +#if GTK_CHECK_VERSION(3,14,0)
- + if (gtk_gesture_is_recognized(pThis->m_pPan))
- + {
- + return true;
- + }
- +#endif
- +
- SalMouseEvent aEvent;
- sal_uInt16 nEventType = 0;
- switch( pEvent->type )
- @@ -3384,6 +3402,46 @@ void GtkSalFrame::gestureLongPress(GtkGestureLongPress* gesture, gpointer frame)
- pThis->CallCallback(SALEVENT_LONGPRESS, &aEvent);
- }
- +void GtkSalFrame::gestureDragBegin(GtkGesturePan* /*gesture*/, gdouble start_x, gdouble start_y, gpointer frame)
- +{
- + GtkSalFrame* pThis = (GtkSalFrame*)frame;
- +
- + SalPanEvent aEvent;
- + aEvent.mnX = long(start_x);
- + aEvent.mnY = long(start_y);
- + aEvent.mnType = 0;
- + pThis->CallCallback(SALEVENT_PAN_BEGIN, &aEvent);
- +}
- +
- +void GtkSalFrame::gestureDragUpdate(GtkGesturePan* /*gesture*/, gdouble start_x, gdouble start_y, gpointer frame)
- +{
- + GtkSalFrame* pThis = (GtkSalFrame*)frame;
- +
- + SalPanEvent aEvent;
- + aEvent.mnX = long(start_x);
- + aEvent.mnY = long(start_y);
- + aEvent.mnType = 1;
- + pThis->CallCallback(SALEVENT_PAN_UPDATE, &aEvent);
- +}
- +
- +void GtkSalFrame::gestureDragEnd(GtkGesturePan* /*gesture*/, gdouble start_x, gdouble start_y, gpointer frame)
- +{
- + GtkSalFrame* pThis = (GtkSalFrame*)frame;
- +
- + SalPanEvent aEvent;
- + aEvent.mnX = long(start_x);
- + aEvent.mnY = long(start_y);
- + aEvent.mnType = 2;
- + pThis->CallCallback(SALEVENT_PAN_END, &aEvent);
- +}
- +
- +void GtkSalFrame::gesturePan(GtkGesturePan* /*gesture*/, gdouble offset, gpointer frame)
- +{
- + //GtkSalFrame* pThis = (GtkSalFrame*)frame;
- +
- + printf("%f\n", offset);
- +}
- +
- #endif
- gboolean GtkSalFrame::signalMotion( GtkWidget*, GdkEventMotion* pEvent, gpointer frame )
- --
- 2.1.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement