[Libreoffice-commits] core.git: 4 commits - android/experimental vcl/android vcl/inc vcl/source
Tor Lillqvist
tml at iki.fi
Sat Mar 2 11:00:26 PST 2013
android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java | 53 +++++++
vcl/android/androidinst.cxx | 69 ++++++----
vcl/inc/vcl/event.hxx | 60 ++++++++
vcl/inc/vcl/svapp.hxx | 4
vcl/inc/vcl/vclevent.hxx | 2
vcl/source/app/svapp.cxx | 14 ++
6 files changed, 172 insertions(+), 30 deletions(-)
New commits:
commit c859cc21cd4b577b4e7df8955375fcc5df2bd980
Author: Tor Lillqvist <tml at iki.fi>
Date: Sat Mar 2 20:58:15 2013 +0200
Start hacking on zoom and scroll events at the VCL "public" level
On the internal ("Sal") VCL level they will correspond to wheel mouse events,
I guess.
Change-Id: Ia422f892d73afe501f529020c2aed9ff8fca99f9
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 7fa7779..fdac1ec 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -922,10 +922,9 @@ Java_org_libreoffice_experimental_desktop_Desktop_key(JNIEnv * /* env */,
jchar c,
jshort /* timestamp */)
{
- KeyEvent aEvent(c, c, 0);
-
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
if (pFocus) {
+ KeyEvent aEvent(c, c, 0);
Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent);
Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent);
}
@@ -942,30 +941,30 @@ Java_org_libreoffice_experimental_desktop_Desktop_touch(JNIEnv * /* env */,
jint y,
jshort /* timestamp */)
{
- MouseEvent aEvent;
-
- sal_uLong nEvent;
- switch (action) {
- case AMOTION_EVENT_ACTION_DOWN:
- aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
- nEvent = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
- break;
- case AMOTION_EVENT_ACTION_UP:
- aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
- nEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
- break;
- case AMOTION_EVENT_ACTION_MOVE:
- aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLEMOVE, MOUSE_LEFT);
- nEvent = VCLEVENT_WINDOW_MOUSEMOVE;
- break;
- default:
- LOGE("Java_org_libreoffice_experimental_desktop_Desktop_touch: Invalid action %d", action);
- return;
- }
-
SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
- if (pFocus)
+ if (pFocus) {
+ MouseEvent aEvent;
+ sal_uLong nEvent;
+
+ switch (action) {
+ case AMOTION_EVENT_ACTION_DOWN:
+ aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
+ nEvent = VCLEVENT_WINDOW_MOUSEBUTTONDOWN;
+ break;
+ case AMOTION_EVENT_ACTION_UP:
+ aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLECLICK, MOUSE_LEFT);
+ nEvent = VCLEVENT_WINDOW_MOUSEBUTTONUP;
+ break;
+ case AMOTION_EVENT_ACTION_MOVE:
+ aEvent = MouseEvent(Point(x, y), 1, MOUSE_SIMPLEMOVE, MOUSE_LEFT);
+ nEvent = VCLEVENT_WINDOW_MOUSEMOVE;
+ break;
+ default:
+ LOGE("Java_org_libreoffice_experimental_desktop_Desktop_touch: Invalid action %d", action);
+ return;
+ }
Application::PostMouseEvent(nEvent, pFocus->GetWindow(), &aEvent);
+ }
else
LOGW("No focused frame to emit event on");
}
@@ -978,12 +977,13 @@ Java_org_libreoffice_experimental_desktop_Desktop_zoom(JNIEnv * /* env */,
jint x,
jint y)
{
- (void) x;
- (void) y;
-
- if (scale > 1.05) {
- } else if (scale < 0.95) {
+ SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame();
+ if (pFocus) {
+ ZoomEvent aEvent( Point( x, y ), scale);
+ Application::PostZoomEvent(VCLEVENT_WINDOW_ZOOM, pFocus->GetWindow(), &aEvent);
}
+ else
+ LOGW("No focused frame to emit event on");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/vcl/event.hxx b/vcl/inc/vcl/event.hxx
index de7464d..e89d52a 100644
--- a/vcl/inc/vcl/event.hxx
+++ b/vcl/inc/vcl/event.hxx
@@ -177,6 +177,66 @@ inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks,
mnCode = nButtons | nModifier;
}
+class VCL_DLLPUBLIC ZoomEvent
+{
+private:
+ Point maCenter;
+ float mfScale;
+
+public:
+ ZoomEvent() :
+ mfScale( 1 )
+ {
+ }
+
+ ZoomEvent( const Point& rCenter,
+ float fScale ) :
+ maCenter( rCenter ),
+ mfScale( fScale )
+ {
+ }
+
+ const Point& GetCenter() const
+ {
+ return maCenter;
+ }
+
+ float GetScale() const
+ {
+ return mfScale;
+ }
+};
+
+class VCL_DLLPUBLIC ScrollEvent
+{
+private:
+ int mnXOffset;
+ int mnYOffset;
+
+public:
+ ScrollEvent() :
+ mnXOffset( 0 ),
+ mnYOffset( 0 )
+ {
+ }
+
+ ScrollEvent( int xOffset, int yOffset ) :
+ mnXOffset( xOffset ),
+ mnYOffset( yOffset )
+ {
+ }
+
+ int GetXOffset() const
+ {
+ return mnXOffset;
+ }
+
+ int GetYOffset() const
+ {
+ return mnYOffset;
+ }
+};
+
// -------------
// - HelpEvent -
// -------------
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index a3eb6b7..e3e0779 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -50,6 +50,8 @@ class KeyCode;
class NotifyEvent;
class KeyEvent;
class MouseEvent;
+class ZoomEvent;
+class ScrollEvent;
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/connection/XConnection.hpp>
@@ -229,6 +231,8 @@ public:
static sal_uLong PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent );
static sal_uLong PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent );
+ static sal_uLong PostZoomEvent( sal_uLong nEvent, Window *pWin, ZoomEvent* pZoomEvent );
+ static sal_uLong PostScrollEvent( sal_uLong nEvent, Window *pWin, ScrollEvent* pScrollEvent );
static void RemoveMouseAndKeyEvents( Window *pWin );
static sal_uLong PostUserEvent( const Link& rLink, void* pCaller = NULL );
diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx
index ab7062e..bc4fa01 100644
--- a/vcl/inc/vcl/vclevent.hxx
+++ b/vcl/inc/vcl/vclevent.hxx
@@ -67,6 +67,8 @@ namespace com { namespace sun { namespace star {
#define VCLEVENT_WINDOW_ENABLED 1020
#define VCLEVENT_WINDOW_DISABLED 1021
#define VCLEVENT_WINDOW_DATACHANGED 1022 // pData = DataChangedEvent*
+#define VCLEVENT_WINDOW_ZOOM 1023 // pData = ZoomEvent*
+#define VCLEVENT_WINDOW_SCROLL 1024 // pData = ScrollEvent*
// VclWindowEvent
#define VCLEVENT_CONTROL_GETFOCUS 1100
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 17d5f61..dcd88ef 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -887,6 +887,20 @@ sal_uLong Application::PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEven
return nEventId;
}
+sal_uLong Application::PostZoomEvent( sal_uLong nEvent, Window *pWin, ZoomEvent* pZoomEvent )
+{
+ const SolarMutexGuard aGuard;
+ sal_uLong nEventId = 0;
+
+ if( pWin && pZoomEvent )
+ {
+ // Implement...
+ (void) nEvent;
+ }
+
+ return nEventId;
+}
+
// -----------------------------------------------------------------------------
IMPL_STATIC_LINK_NOINSTANCE( Application, PostEventHandler, void*, pCallData )
commit ec7986d43be123f66a952ab9619c4beccd0c8446
Author: Tor Lillqvist <tml at iki.fi>
Date: Sat Mar 2 20:56:04 2013 +0200
Try to make the temporary pinch/spread hack look nicer
Change-Id: Id293e04c089b9304721f83fb4eb77cffab67cedd
diff --git a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
index 7664bf8..786bcad 100644
--- a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
+++ b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
@@ -162,6 +162,7 @@ public class Desktop
{
Bitmap mBitmap;
boolean renderedOnce;
+ boolean scalingInProgress;
ScaleGestureDetector gestureDetector;
float scale = 1;
@@ -189,6 +190,7 @@ public class Desktop
Log.i(TAG, "onScaleBegin: pivot=(" + detector.getFocusX() + ", " + detector.getFocusY() + ")");
setPivotX(detector.getFocusX());
setPivotY(detector.getFocusY());
+ scalingInProgress = true;
return true;
}
@@ -211,6 +213,7 @@ public class Desktop
scale = 1;
setScaleX(scale);
setScaleY(scale);
+ scalingInProgress = false;
}
});
}
@@ -229,7 +232,8 @@ public class Desktop
renderedOnce = true;
// re-call ourselves a bit later ...
- invalidate();
+ if (!scalingInProgress)
+ invalidate();
}
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
@@ -263,7 +267,12 @@ public class Desktop
@Override public boolean onTouchEvent(MotionEvent event)
{
- if (gestureDetector.onTouchEvent(event))
+ Log.i(TAG, "onTouchEvent, scalingInProgress=" + scalingInProgress);
+
+ // For now, when during scaling we just scale the bitmap
+ // view, if a scaling gesture is in progress no other
+ // touch processing should be done.
+ if (gestureDetector.onTouchEvent(event) && scalingInProgress)
return true;
if (!renderedOnce)
commit bcfd6ac251afeba25413c0ffa7fd2344d11bf308
Author: Tor Lillqvist <tml at iki.fi>
Date: Fri Mar 1 15:32:38 2013 +0200
RTL_CONSTASCII_USTRINGPARAM removal
Change-Id: I0c50dea9d86d3ec15ec327883867a384cbf2a6e8
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 46e6588..7fa7779 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -715,16 +715,15 @@ public:
// Clobber the UI fonts
#if 0
psp::FastPrintFontInfo aInfo;
- aInfo.m_aFamilyName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Roboto" ) );
+ aInfo.m_aFamilyName = rtl::OUString( "Roboto" );
aInfo.m_eItalic = ITALIC_NORMAL;
aInfo.m_eWeight = WEIGHT_NORMAL;
aInfo.m_eWidth = WIDTH_NORMAL;
psp::PrintFontManager::get().matchFont( aInfo, rSettings.GetUILocale() );
#endif
- // FIXME: is 12 point enough ?
- Font aFont( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Roboto" ) ),
- Size( 0, 14 ) );
+ // FIXME: is 14 point enough ?
+ Font aFont( rtl::OUString( "Roboto" ), Size( 0, 14 ) );
StyleSettings aStyleSet = rSettings.GetStyleSettings();
aStyleSet.SetAppFont( aFont );
@@ -776,7 +775,7 @@ void SalAbort( const rtl::OUString& rErrorText, bool bDumpCore )
const OUString& SalGetDesktopEnvironment()
{
- static rtl::OUString aEnv( RTL_CONSTASCII_USTRINGPARAM( "android" ) );
+ static rtl::OUString aEnv( "android" );
return aEnv;
}
commit a8ee2fd020477ceee9ca91976e2ea90de45141af
Author: Tor Lillqvist <tml at iki.fi>
Date: Fri Mar 1 15:19:16 2013 +0200
Start hacking on zooming
Change-Id: Ibc9aad490c4616d339e95352a0b8a7f7bed93070
diff --git a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
index d4ded73..7664bf8 100644
--- a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
+++ b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java
@@ -50,6 +50,7 @@ public class Desktop
public static native void setViewSize(int width, int height);
public static native void key(char c, short timestamp);
public static native void touch(int action, int x, int y, short timestamp);
+ public static native void zoom(float scale, int x, int y);
/**
* This class contains the state that is initialized once and never changes
@@ -162,19 +163,55 @@ public class Desktop
Bitmap mBitmap;
boolean renderedOnce;
ScaleGestureDetector gestureDetector;
+ float scale = 1;
public BitmapView()
{
super(Desktop.this);
setFocusableInTouchMode(true);
+
+ // While a scale gesture (two-finger pinch / spread to
+ // zoom out / in) is in progress we just scale the bitmap
+ // view (UI elements too, which of course is a bit silly).
+ // When the scale gesture has finished, we ask LO to zoom
+ // the document (and reset the view scale, it will be
+ // replaced by one where the document (not UI elements) is
+ // displayed at a different zoom level).
+
+ // Is that sane? Would it be too slow to ask LO to zoom
+ // continuously while the gesture is in progress?
+
gestureDetector =
new ScaleGestureDetector(Desktop.this,
new ScaleGestureDetector.SimpleOnScaleGestureListener() {
+ @Override public boolean onScaleBegin(ScaleGestureDetector detector)
+ {
+ Log.i(TAG, "onScaleBegin: pivot=(" + detector.getFocusX() + ", " + detector.getFocusY() + ")");
+ setPivotX(detector.getFocusX());
+ setPivotY(detector.getFocusY());
+ return true;
+ }
+
@Override public boolean onScale(ScaleGestureDetector detector)
{
- Log.i(TAG, "onScale: " + detector.getScaleFactor());
+ float s = detector.getScaleFactor();
+ if (s > 0.95 && s < 1.05)
+ return false;
+ scale *= s;
+ Log.i(TAG, "onScale: " + s + " => " + scale);
+ setScaleX(scale);
+ setScaleY(scale);
return true;
}
+
+ @Override public void onScaleEnd(ScaleGestureDetector detector)
+ {
+ Log.i(TAG, "onScaleEnd: " + scale);
+ Desktop.zoom(scale, (int) detector.getFocusX(), (int) detector.getFocusY());
+ scale = 1;
+ setScaleX(scale);
+ setScaleY(scale);
+ }
});
}
@@ -226,7 +263,8 @@ public class Desktop
@Override public boolean onTouchEvent(MotionEvent event)
{
- gestureDetector.onTouchEvent(event);
+ if (gestureDetector.onTouchEvent(event))
+ return true;
if (!renderedOnce)
return super.onTouchEvent(event);
diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx
index 2c54a0e..46e6588 100644
--- a/vcl/android/androidinst.cxx
+++ b/vcl/android/androidinst.cxx
@@ -971,4 +971,20 @@ Java_org_libreoffice_experimental_desktop_Desktop_touch(JNIEnv * /* env */,
LOGW("No focused frame to emit event on");
}
+// public static native void zoom(float scale, int x, int y);
+extern "C" SAL_JNI_EXPORT void JNICALL
+Java_org_libreoffice_experimental_desktop_Desktop_zoom(JNIEnv * /* env */,
+ jobject /* clazz */,
+ jfloat scale,
+ jint x,
+ jint y)
+{
+ (void) x;
+ (void) y;
+
+ if (scale > 1.05) {
+ } else if (scale < 0.95) {
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list