[Picross-commit] SF.net SVN: picross:[121] branches/engine_split/android/src/picross/ specific
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2013-01-15 15:27:31
|
Revision: 121 http://sourceforge.net/p/picross/code/121 Author: yvan_norsa Date: 2013-01-15 15:27:28 +0000 (Tue, 15 Jan 2013) Log Message: ----------- touch events Modified Paths: -------------- branches/engine_split/android/src/picross/specific/game/ui/GameUI.java branches/engine_split/android/src/picross/specific/grid/ui/GridController.java branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java branches/engine_split/android/src/picross/specific/ui/MenuUI.java Added Paths: ----------- branches/engine_split/android/src/picross/specific/grid/ui/Point.java Modified: branches/engine_split/android/src/picross/specific/game/ui/GameUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/game/ui/GameUI.java 2013-01-15 14:39:40 UTC (rev 120) +++ branches/engine_split/android/src/picross/specific/game/ui/GameUI.java 2013-01-15 15:27:28 UTC (rev 121) @@ -50,6 +50,12 @@ import android.graphics.Canvas; +import picross.specific.grid.ui.GridUI; + +import picross.specific.grid.ui.UIBox; + +import android.view.MotionEvent; + /** * The game UI. * @@ -67,7 +73,7 @@ /** Panel holding the buttons. */ //private JPanel buttonsPanel; - private GridView grid; + private GridUI grid; /*** Constructor ***/ @@ -84,9 +90,10 @@ MenuController listener) { super(context); - this.grid = gridView; + this.grid = (GridUI) gridView; - picross.specific.grid.ui.UIBox.staticInit(context.getResources()); + // HACK should not be here + UIBox.staticInit(context.getResources()); // FIXME /* @@ -137,9 +144,17 @@ } //GameUI.log.debug("onDraw(" + canvas + ")"); - ((picross.specific.grid.ui.GridUI) this.grid).draw(canvas); + this.grid.draw(canvas); } + @Override + public boolean onTouchEvent (MotionEvent event) { + this.grid.onTouch(null, event); + + // FIXME + return true; + } + /*** Method ***/ /** Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridController.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/GridController.java 2013-01-15 14:39:40 UTC (rev 120) +++ branches/engine_split/android/src/picross/specific/grid/ui/GridController.java 2013-01-15 15:27:28 UTC (rev 121) @@ -45,14 +45,16 @@ import picross.common.grid.ui.GridCommands; +import android.view.View; +import android.view.MotionEvent; + /** * Grid controller. * * @author Y. Norsa */ public final class GridController extends Controller - // FIXME -{//implements MouseListener, MouseMotionListener { +implements View.OnTouchListener { /*** Fields ***/ @@ -102,45 +104,21 @@ } } - /*** Methods implanted from the interface MouseListener ***/ + @Override + public boolean onTouch(View view, MotionEvent event) { + if (event.getAction() != MotionEvent.ACTION_DOWN) { + return false; + } - /** {@inheritDoc} */ - /* - @Override - public void mouseClicked(MouseEvent e) { } - */ - /** {@inheritDoc} */ - /* - @Override - public void mouseEntered(MouseEvent e) { } - */ - /** {@inheritDoc} */ - /* - @Override - public void mouseExited(MouseEvent e) { - this.view.rolloverEnded(); - this.view.highlightEnded(); - } - */ - /** {@inheritDoc} */ - /* - @Override - public void mousePressed(MouseEvent e) { - this.view.rolloverEnded(); - } - */ - /** {@inheritDoc} */ - // FIXME - /* - @Override - public void mouseReleased(MouseEvent e) { - this.checkAndFill(e); + this.checkAndFill(event); this.eraseMode = false; this.fireEventPerformed(GridCommands.END_ACTION_CMD); + + // FIXME + return true; } - */ - /*** Methods implanted from the interface MouseMotionListener ***/ + /** {@inheritDoc} */ // FIXME /* @@ -149,23 +127,7 @@ this.checkAndFill(e); } */ - /** {@inheritDoc} */ - // FIXME - /* - @Override - public void mouseMoved(MouseEvent e) { - Point point = e.getPoint(); - if (this.view.isInGrid(point)) { - int row = this.view.getRow(point); - int column = this.view.getColumn(point); - - this.view.setRollover(row, column); - } else { - this.view.rolloverEnded(); - } - } - */ /*** Methods ***/ /** @@ -175,9 +137,9 @@ * @param e mouse event to handle */ - // FIXME - /* - private void checkAndFill(MouseEvent e) { + private void checkAndFill(MotionEvent e) { + // FIXME + /* int modifiers = e.getModifiers(); if (modifiers != MouseEvent.BUTTON1_MASK @@ -185,30 +147,28 @@ return; } + */ + Point point = new Point(e.getX(), e.getY()); - Point point = e.getPoint(); - if (this.view.isInGrid(point)) { int row = this.view.getRow(point); -- int column = this.view.getColumn(point); + int column = this.view.getColumn(point); GridAction type; if (this.eraseMode) { type = GridAction.EMPTY; } else { - type = GridController.modifiersToType(modifiers); + // FIXME + //type = GridController.modifiersToType(modifiers); + type = GridAction.CHECK; } - this.view.rolloverHighlight(row, column); - this.fireEventPerformed(GridCommands.FILL_CMD, new FillCommand(row, column, type)); - } else { - this.view.highlightEnded(); } } - */ + /** * Converts a mouse click to an action. * Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-15 14:39:40 UTC (rev 120) +++ branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-15 15:27:28 UTC (rev 121) @@ -59,12 +59,15 @@ import picross.engine.PicrossLogger; import picross.engine.PicrossLogHelper; +import android.view.MotionEvent; +import android.view.View; + /** * Grid UI. * * @author Y. Norsa */ -public final class GridUI /*extends JPanel*/ implements GridView { +public final class GridUI /*extends JPanel*/ implements GridView, View.OnTouchListener { /*** Constants ***/ /** Space left before the top hints. */ @@ -614,8 +617,6 @@ * @param point point to be tested * @return boolean telling if the point is inside the grid */ - // FIXME - /* boolean isInGrid(Point point) { double x = point.getX(); double y = point.getY(); @@ -623,21 +624,19 @@ return (x >= this.leftBoundary && x < this.rightBoundary && y >= this.topBoundary && y < this.bottomBoundary); } - */ + /** * Allows to get the row number corresponding to a point inside the grid. * * @param point a point inside the grid * @return the row corresponding to the point */ - // FIXME - /* int getRow(Point point) { double y = point.getY() - this.topBoundary; return (int) (y / GridUI.BOX_HEIGHT); } - */ + /** * Allows to get the column number corresponding to a point * inside the grid. @@ -645,14 +644,12 @@ * @param point a point inside the grid * @return the column corresponding to the point */ - // FIXME - /* int getColumn(Point point) { double x = point.getX() - this.leftBoundary; return (int) (x / GridUI.BOX_WIDTH); } - */ + /** Removes the listeners to disable the grid. */ void disableGrid() { // FIXME @@ -701,6 +698,14 @@ this.boxes[row][col].updateState(box); } + @Override + public boolean onTouch(View view, MotionEvent event) { + this.controller.onTouch(null, event); + + // FIXME + return true; + } + private static class Line2D { private int x1; private int y1; Added: branches/engine_split/android/src/picross/specific/grid/ui/Point.java =================================================================== --- branches/engine_split/android/src/picross/specific/grid/ui/Point.java (rev 0) +++ branches/engine_split/android/src/picross/specific/grid/ui/Point.java 2013-01-15 15:27:28 UTC (rev 121) @@ -0,0 +1,52 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2011 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.specific.grid.ui; + +class Point { + private float x; + private float y; + + Point(float x, float y) { + this.x = x; + this.y = y; + } + + double getX() { + return this.x; + } + + double getY() { + return this.y; + } +} Property changes on: branches/engine_split/android/src/picross/specific/grid/ui/Point.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Modified: branches/engine_split/android/src/picross/specific/ui/MenuUI.java =================================================================== --- branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-15 14:39:40 UTC (rev 120) +++ branches/engine_split/android/src/picross/specific/ui/MenuUI.java 2013-01-15 15:27:28 UTC (rev 121) @@ -335,6 +335,11 @@ @Override public boolean onTouchEvent (MotionEvent event) { + if (event.getAction() != MotionEvent.ACTION_DOWN) { + MenuUI.log.debug("ignoring action with value " + event.getAction()); + return false; + } + float x = event.getX(); float y = event.getY(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |