Advertisement
Guest User

Untitled

a guest
Aug 25th, 2022
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.04 KB | None | 0 0
  1. From 5ce9f2f9f03075dbb7da5da2966cbfa9492f9584 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Toma=C5=BE=20Vajngerl?= <tomaz.vajngerl@collabora.co.uk>
  3. Date: Sat, 4 Apr 2015 16:05:32 +0900
  4. Subject: [PATCH] gesture: panning support
  5.  
  6. Change-Id: Ic07eddbe741b69685d1a3dde524db7a390056ea7
  7. ---
  8. include/vcl/cmdevt.hxx | 29 ++++++++++++++++++
  9. sw/source/uibase/docvw/edtwin.cxx | 17 +++++++++++
  10. sw/source/uibase/inc/edtwin.hxx | 2 ++
  11. sw/source/uibase/inc/view.hxx | 2 ++
  12. sw/source/uibase/uiview/viewport.cxx | 7 +++++
  13. vcl/inc/salwtype.hxx | 10 +++++++
  14. vcl/inc/unx/gtk/gtkframe.hxx | 8 +++++
  15. vcl/source/window/winproc.cxx | 29 ++++++++++++++++++
  16. vcl/unx/gtk/window/gtksalframe.cxx | 58 ++++++++++++++++++++++++++++++++++++
  17. 9 files changed, 162 insertions(+)
  18.  
  19. diff --git a/include/vcl/cmdevt.hxx b/include/vcl/cmdevt.hxx
  20. index 942d45b..8044c55 100644
  21. --- a/include/vcl/cmdevt.hxx
  22. +++ b/include/vcl/cmdevt.hxx
  23. @@ -374,6 +374,25 @@ public:
  24. double getY() const { return mnY; }
  25. };
  26.  
  27. +class VCL_DLLPUBLIC CommandPanData
  28. +{
  29. + long mnX;
  30. + long mnY;
  31. + long mnType;
  32. +
  33. +public:
  34. + CommandPanData(long nX, long nY, long nType)
  35. + : mnX(nX)
  36. + , mnY(nY)
  37. + , mnType(nType)
  38. + {
  39. + }
  40. +
  41. + long getX() const { return mnX; }
  42. + long getY() const { return mnY; }
  43. + long getType() const { return mnType; }
  44. +};
  45. +
  46.  
  47. // - CommandEvent -
  48. #define COMMAND_CONTEXTMENU ((sal_uInt16)1)
  49. @@ -397,6 +416,7 @@ public:
  50. #define COMMAND_QUERYCHARPOSITION ((sal_uInt16)20)
  51. #define COMMAND_SWIPE ((sal_uInt16)21)
  52. #define COMMAND_LONGPRESS ((sal_uInt16)22)
  53. +#define COMMAND_PAN ((sal_uInt16)23)
  54.  
  55. class VCL_DLLPUBLIC CommandEvent
  56. {
  57. @@ -426,6 +446,7 @@ public:
  58. const CommandSelectionChangeData* GetSelectionChangeData() const;
  59. const CommandSwipeData* GetSwipeData() const;
  60. const CommandLongPressData* GetLongPressData() const;
  61. + const CommandPanData* GetPanData() const;
  62. };
  63.  
  64. inline CommandEvent::CommandEvent()
  65. @@ -524,6 +545,14 @@ inline const CommandLongPressData* CommandEvent::GetLongPressData() const
  66. return NULL;
  67. }
  68.  
  69. +inline const CommandPanData* CommandEvent::GetPanData() const
  70. +{
  71. + if( mnCommand == COMMAND_PAN )
  72. + return (const CommandPanData*)(mpData);
  73. + else
  74. + return NULL;
  75. +}
  76. +
  77. #endif // INCLUDED_VCL_CMDEVT_HXX
  78.  
  79. /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
  80. diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
  81. index f0831ac..f76eab3 100644
  82. --- a/sw/source/uibase/docvw/edtwin.cxx
  83. +++ b/sw/source/uibase/docvw/edtwin.cxx
  84. @@ -5171,6 +5171,23 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
  85. delete m_pShadCrsr, m_pShadCrsr = 0;
  86. bCallBase = !m_rView.HandleWheelCommands( rCEvt );
  87. break;
  88. + case COMMAND_PAN:
  89. + {
  90. + const CommandPanData* pPanData = rCEvt.GetPanData();
  91. + if (pPanData != NULL)
  92. + {
  93. + if (pPanData->getType() == 0)
  94. + {
  95. + mPanPreviousX = m_rView.GetVisArea().TopLeft().Y();
  96. + }
  97. + else if (pPanData->getType() == 1)
  98. + {
  99. + m_rView.MoveView(mPanPreviousX, -pPanData->getY());
  100. + }
  101. + }
  102. + }
  103. + break;
  104. +
  105.  
  106. case COMMAND_STARTEXTTEXTINPUT:
  107. {
  108. diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
  109. index b9d00f9..63dde49 100644
  110. --- a/sw/source/uibase/inc/edtwin.hxx
  111. +++ b/sw/source/uibase/inc/edtwin.hxx
  112. @@ -137,6 +137,8 @@ friend void PageNumNotify( SwViewShell* pVwSh,
  113. sal_uInt16 m_nKS_NUMDOWN_Count; // #i23725#
  114. sal_uInt16 m_nKS_NUMINDENTINC_Count;
  115.  
  116. + sal_Int32 mPanPreviousX;
  117. +
  118. SwFrameControlsManager m_aFrameControlsManager;
  119.  
  120. void LeaveArea(const Point &);
  121. diff --git a/sw/source/uibase/inc/view.hxx b/sw/source/uibase/inc/view.hxx
  122. index 8cd1d5cf..1a36120 100644
  123. --- a/sw/source/uibase/inc/view.hxx
  124. +++ b/sw/source/uibase/inc/view.hxx
  125. @@ -448,6 +448,8 @@ public:
  126. long SetVScrollMax(long lMax);
  127. long SetHScrollMax(long lMax);
  128.  
  129. + void MoveView(long initial, long nDeltaPixel);
  130. +
  131. void SpellError(LanguageType eLang);
  132. bool ExecSpellPopup( const Point& rPt );
  133. void ExecFieldPopup( const Point& rPt, sw::mark::IFieldmark *fieldBM );
  134. diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
  135. index 0477314..2c21382 100644
  136. --- a/sw/source/uibase/uiview/viewport.cxx
  137. +++ b/sw/source/uibase/uiview/viewport.cxx
  138. @@ -619,6 +619,13 @@ long SwView::PhyPageDown()
  139. return 1;
  140. }
  141.  
  142. +void SwView::MoveView(long initial, long nDeltaPixel)
  143. +{
  144. + Point aPoint = m_aVisArea.TopLeft();
  145. + aPoint.Y() = initial + GetEditWin().PixelToLogic(Size(0, nDeltaPixel)).Height();
  146. + SetVisArea(aPoint);
  147. +}
  148. +
  149. long SwView::PageUpCrsr( bool bSelect )
  150. {
  151. if ( !bSelect )
  152. diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx
  153. index 67ad505..4448981 100644
  154. --- a/vcl/inc/salwtype.hxx
  155. +++ b/vcl/inc/salwtype.hxx
  156. @@ -80,6 +80,9 @@ class FontSelectPattern;
  157. #define SALEVENT_QUERYCHARPOSITION ((sal_uInt16)48)
  158. #define SALEVENT_SWIPE ((sal_uInt16)49)
  159. #define SALEVENT_LONGPRESS ((sal_uInt16)50)
  160. +#define SALEVENT_PAN_BEGIN ((sal_uInt16)51)
  161. +#define SALEVENT_PAN_UPDATE ((sal_uInt16)52)
  162. +#define SALEVENT_PAN_END ((sal_uInt16)53)
  163.  
  164. // MOUSELEAVE must send, when the pointer leave the client area and
  165. // the mouse is not captured
  166. @@ -294,6 +297,13 @@ struct SalLongPressEvent
  167. long mnY;
  168. };
  169.  
  170. +struct SalPanEvent
  171. +{
  172. + long mnX;
  173. + long mnY;
  174. + long mnType;
  175. +};
  176. +
  177. typedef void (*SALTIMERPROC)( bool idle );
  178.  
  179. #endif // INCLUDED_VCL_INC_SALWTYPE_HXX
  180. diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
  181. index 2eb0634..0905feb 100644
  182. --- a/vcl/inc/unx/gtk/gtkframe.hxx
  183. +++ b/vcl/inc/unx/gtk/gtkframe.hxx
  184. @@ -217,6 +217,10 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
  185.  
  186. SalMenu* m_pSalMenu;
  187.  
  188. +#if GTK_CHECK_VERSION(3,14,0)
  189. + GtkGesture* m_pPan;
  190. +#endif
  191. +
  192. #if defined(ENABLE_DBUS) && defined(ENABLE_GIO)
  193. public:
  194. void EnsureDbusMenuSynced();
  195. @@ -240,6 +244,10 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
  196. #if GTK_CHECK_VERSION(3,14,0)
  197. static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame);
  198. static void gestureLongPress(GtkGestureLongPress* gesture, gpointer frame);
  199. + static void gestureDragBegin(GtkGesturePan* gesture, gdouble start_x, gdouble start_y, gpointer frame);
  200. + static void gestureDragUpdate(GtkGesturePan* gesture, gdouble start_x, gdouble start_y, gpointer frame);
  201. + static void gestureDragEnd(GtkGesturePan* gesture, gdouble start_x, gdouble start_y, gpointer frame);
  202. + static void gesturePan(GtkGesturePan* gesture, gdouble offset, gpointer frame);
  203. #endif
  204. #else
  205. static gboolean signalExpose( GtkWidget*, GdkEventExpose*, gpointer );
  206. diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
  207. index d3df6d0..547425c 100644
  208. --- a/vcl/source/window/winproc.cxx
  209. +++ b/vcl/source/window/winproc.cxx
  210. @@ -1647,6 +1647,29 @@ static bool ImplHandleLongPress(vcl::Window *pWindow, const SalLongPressEvent& r
  211. return aHandler.HandleEvent();
  212. }
  213.  
  214. +class HandlePanEvent : public HandleGestureEvent
  215. +{
  216. +private:
  217. + CommandPanData maPanData;
  218. +public:
  219. + HandlePanEvent(vcl::Window* pWindow, const SalPanEvent& rEvent)
  220. + : HandleGestureEvent(pWindow, Point(rEvent.mnX, rEvent.mnY))
  221. + , maPanData(rEvent.mnX, rEvent.mnY, rEvent.mnType)
  222. + {
  223. + }
  224. +
  225. + virtual bool CallCommand(vcl::Window* pWindow, const Point& /*rMousePos*/) SAL_OVERRIDE
  226. + {
  227. + return ImplCallCommand(pWindow, COMMAND_PAN, &maPanData);
  228. + }
  229. +};
  230. +
  231. +static bool ImplHandlePanEvent(vcl::Window *pWindow, const SalPanEvent& rEvent)
  232. +{
  233. + HandlePanEvent aHandler(pWindow, rEvent);
  234. + return aHandler.HandleEvent();
  235. +}
  236. +
  237. #define IMPL_PAINT_CHECKRTL ((sal_uInt16)0x0020)
  238.  
  239. static void ImplHandlePaint( vcl::Window* pWindow, const Rectangle& rBoundRect, bool bImmediateUpdate )
  240. @@ -2700,6 +2723,12 @@ bool ImplWindowFrameProc( vcl::Window* pWindow, SalFrame* /*pFrame*/,
  241. nRet = ImplHandleLongPress(pWindow, *static_cast<const SalLongPressEvent*>(pEvent));
  242. break;
  243.  
  244. + case SALEVENT_PAN_BEGIN:
  245. + case SALEVENT_PAN_UPDATE:
  246. + case SALEVENT_PAN_END:
  247. + nRet = ImplHandlePanEvent(pWindow, *(const SalPanEvent*)pEvent);
  248. + break;
  249. +
  250.  
  251. #ifdef DBG_UTIL
  252. default:
  253. diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
  254. index acf170f..2d9362b 100644
  255. --- a/vcl/unx/gtk/window/gtksalframe.cxx
  256. +++ b/vcl/unx/gtk/window/gtksalframe.cxx
  257. @@ -1000,6 +1000,17 @@ void GtkSalFrame::InitCommon()
  258. gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (pLongPress), GTK_PHASE_TARGET);
  259. g_object_weak_ref(G_OBJECT(m_pWindow), reinterpret_cast<GWeakNotify>(g_object_unref), pLongPress);
  260.  
  261. + m_pPan = gtk_gesture_pan_new(m_pWindow, GTK_ORIENTATION_VERTICAL);
  262. + gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (m_pPan), TRUE);
  263. + gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (m_pPan), GTK_PHASE_CAPTURE);
  264. +
  265. + g_signal_connect(m_pPan, "drag-begin", G_CALLBACK(gestureDragBegin), this);
  266. + g_signal_connect(m_pPan, "drag-update", G_CALLBACK(gestureDragUpdate), this);
  267. + g_signal_connect(m_pPan, "drag-end", G_CALLBACK(gestureDragEnd), this);
  268. + g_signal_connect(m_pPan, "pan", G_CALLBACK(gesturePan), this);
  269. + gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER (m_pPan), GTK_PHASE_TARGET);
  270. + g_object_weak_ref(G_OBJECT(m_pWindow), reinterpret_cast<GWeakNotify>(g_object_unref), m_pPan);
  271. +
  272. #endif
  273.  
  274. #else
  275. @@ -3221,6 +3232,13 @@ gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer
  276. {
  277. GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
  278.  
  279. +#if GTK_CHECK_VERSION(3,14,0)
  280. + if (gtk_gesture_is_recognized(pThis->m_pPan))
  281. + {
  282. + return true;
  283. + }
  284. +#endif
  285. +
  286. SalMouseEvent aEvent;
  287. sal_uInt16 nEventType = 0;
  288. switch( pEvent->type )
  289. @@ -3384,6 +3402,46 @@ void GtkSalFrame::gestureLongPress(GtkGestureLongPress* gesture, gpointer frame)
  290. pThis->CallCallback(SALEVENT_LONGPRESS, &aEvent);
  291. }
  292.  
  293. +void GtkSalFrame::gestureDragBegin(GtkGesturePan* /*gesture*/, gdouble start_x, gdouble start_y, gpointer frame)
  294. +{
  295. + GtkSalFrame* pThis = (GtkSalFrame*)frame;
  296. +
  297. + SalPanEvent aEvent;
  298. + aEvent.mnX = long(start_x);
  299. + aEvent.mnY = long(start_y);
  300. + aEvent.mnType = 0;
  301. + pThis->CallCallback(SALEVENT_PAN_BEGIN, &aEvent);
  302. +}
  303. +
  304. +void GtkSalFrame::gestureDragUpdate(GtkGesturePan* /*gesture*/, gdouble start_x, gdouble start_y, gpointer frame)
  305. +{
  306. + GtkSalFrame* pThis = (GtkSalFrame*)frame;
  307. +
  308. + SalPanEvent aEvent;
  309. + aEvent.mnX = long(start_x);
  310. + aEvent.mnY = long(start_y);
  311. + aEvent.mnType = 1;
  312. + pThis->CallCallback(SALEVENT_PAN_UPDATE, &aEvent);
  313. +}
  314. +
  315. +void GtkSalFrame::gestureDragEnd(GtkGesturePan* /*gesture*/, gdouble start_x, gdouble start_y, gpointer frame)
  316. +{
  317. + GtkSalFrame* pThis = (GtkSalFrame*)frame;
  318. +
  319. + SalPanEvent aEvent;
  320. + aEvent.mnX = long(start_x);
  321. + aEvent.mnY = long(start_y);
  322. + aEvent.mnType = 2;
  323. + pThis->CallCallback(SALEVENT_PAN_END, &aEvent);
  324. +}
  325. +
  326. +void GtkSalFrame::gesturePan(GtkGesturePan* /*gesture*/, gdouble offset, gpointer frame)
  327. +{
  328. + //GtkSalFrame* pThis = (GtkSalFrame*)frame;
  329. +
  330. + printf("%f\n", offset);
  331. +}
  332. +
  333. #endif
  334.  
  335. gboolean GtkSalFrame::signalMotion( GtkWidget*, GdkEventMotion* pEvent, gpointer frame )
  336. --
  337. 2.1.0
  338.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement