summaryrefslogtreecommitdiffstats
path: root/samples/BrowserPlugin
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2010-03-01 08:18:02 -0500
committerDerek Sollenberger <djsollen@google.com>2010-03-01 09:35:49 -0500
commit7364d2bc453a88133c65777b38003f05361135dd (patch)
tree9e1eb1dd5b4c18e7fb4781547e481ba0b7d2bd72 /samples/BrowserPlugin
parent5b6741451725eca6774a0030e19daf186d5c102e (diff)
downloadandroid_development-7364d2bc453a88133c65777b38003f05361135dd.tar.gz
android_development-7364d2bc453a88133c65777b38003f05361135dd.tar.bz2
android_development-7364d2bc453a88133c65777b38003f05361135dd.zip
Add full-screen option to the sample paint plugin.
Diffstat (limited to 'samples/BrowserPlugin')
-rw-r--r--samples/BrowserPlugin/jni/paint/PaintPlugin.cpp25
-rw-r--r--samples/BrowserPlugin/jni/paint/PaintPlugin.h1
2 files changed, 25 insertions, 1 deletions
diff --git a/samples/BrowserPlugin/jni/paint/PaintPlugin.cpp b/samples/BrowserPlugin/jni/paint/PaintPlugin.cpp
index e478897d0..1ec86c2c1 100644
--- a/samples/BrowserPlugin/jni/paint/PaintPlugin.cpp
+++ b/samples/BrowserPlugin/jni/paint/PaintPlugin.cpp
@@ -37,6 +37,7 @@ extern ANPPathInterfaceV0 gPathI;
extern ANPSurfaceInterfaceV0 gSurfaceI;
extern ANPSystemInterfaceV0 gSystemI;
extern ANPTypefaceInterfaceV0 gTypefaceI;
+extern ANPWindowInterfaceV0 gWindowI;
///////////////////////////////////////////////////////////////////////////////
@@ -49,6 +50,7 @@ PaintPlugin::PaintPlugin(NPP inst) : SurfaceSubPlugin(inst) {
memset(&m_drawingSurface, 0, sizeof(m_drawingSurface));
memset(&m_inputToggle, 0, sizeof(m_inputToggle));
memset(&m_colorToggle, 0, sizeof(m_colorToggle));
+ memset(&m_fullScreenToggle, 0, sizeof(m_fullScreenToggle));
memset(&m_clearSurface, 0, sizeof(m_clearSurface));
// initialize the drawing surface
@@ -170,7 +172,7 @@ void PaintPlugin::drawCleanPlugin(ANPCanvas* canvas) {
m_inputToggle.top - fontMetrics.fTop, m_paintSurface);
// draw the color selector button
- m_colorToggle.left = (W/2) - (buttonWidth/2);
+ m_colorToggle.left = (W/3) - (buttonWidth/2);
m_colorToggle.top = H - buttonHeight - 5;
m_colorToggle.right = m_colorToggle.left + buttonWidth;
m_colorToggle.bottom = m_colorToggle.top + buttonHeight;
@@ -179,6 +181,17 @@ void PaintPlugin::drawCleanPlugin(ANPCanvas* canvas) {
gCanvasI.drawText(canvas, colorText, strlen(colorText), m_colorToggle.left + 5,
m_colorToggle.top - fontMetrics.fTop, m_paintSurface);
+ // draw the full-screen toggle button
+ m_fullScreenToggle.left = ((W*2)/3) - (buttonWidth/2);
+ m_fullScreenToggle.top = H - buttonHeight - 5;
+ m_fullScreenToggle.right = m_fullScreenToggle.left + buttonWidth;
+ m_fullScreenToggle.bottom = m_fullScreenToggle.top + buttonHeight;
+ gCanvasI.drawRect(canvas, &m_fullScreenToggle, m_paintButton);
+ const char* fullScreenText = "Full";
+ gCanvasI.drawText(canvas, fullScreenText, strlen(fullScreenText),
+ m_fullScreenToggle.left + 5,
+ m_fullScreenToggle.top - fontMetrics.fTop, m_paintSurface);
+
// draw the clear canvas button
m_clearSurface.left = W - buttonWidth - 5;
m_clearSurface.top = H - buttonHeight - 5;
@@ -306,6 +319,8 @@ int16 PaintPlugin::handleEvent(const ANPEvent* evt) {
toggleInputMethod();
else if (rect == &m_colorToggle)
togglePaintColor();
+ else if (rect == &m_fullScreenToggle)
+ gWindowI.requestFullScreen(inst());
else if (rect == &m_clearSurface)
drawCleanPlugin();
}
@@ -316,6 +331,12 @@ int16 PaintPlugin::handleEvent(const ANPEvent* evt) {
switch (evt->data.other[0]) {
case kSurfaceCreated_CustomEvent:
gLogI.log(kDebug_ANPLogType, " ---- customEvent: surfaceCreated");
+ /* The second draw call is added to cover up a problem in this
+ plugin and is not a recommended usage pattern. This plugin
+ does not correctly make partial updates to the double
+ buffered surface and this second call hides that problem.
+ */
+ drawCleanPlugin();
drawCleanPlugin();
break;
case kSurfaceChanged_CustomEvent: {
@@ -358,6 +379,8 @@ ANPRectF* PaintPlugin::validTouch(int x, int y) {
return &m_inputToggle;
else if (fx > m_colorToggle.left && fx < m_colorToggle.right && fy > m_colorToggle.top && fy < m_colorToggle.bottom)
return &m_colorToggle;
+ else if (fx > m_fullScreenToggle.left && fx < m_fullScreenToggle.right && fy > m_fullScreenToggle.top && fy < m_fullScreenToggle.bottom)
+ return &m_fullScreenToggle;
else if (fx > m_clearSurface.left && fx < m_clearSurface.right && fy > m_clearSurface.top && fy < m_clearSurface.bottom)
return &m_clearSurface;
else
diff --git a/samples/BrowserPlugin/jni/paint/PaintPlugin.h b/samples/BrowserPlugin/jni/paint/PaintPlugin.h
index 4867a706a..035e51b3a 100644
--- a/samples/BrowserPlugin/jni/paint/PaintPlugin.h
+++ b/samples/BrowserPlugin/jni/paint/PaintPlugin.h
@@ -58,6 +58,7 @@ private:
ANPRectF m_drawingSurface;
ANPRectF m_inputToggle;
ANPRectF m_colorToggle;
+ ANPRectF m_fullScreenToggle;
ANPRectF m_clearSurface;
ANPPaint* m_paintSurface;