implement drawBoardArrow, but without setting tranparency correctly.

This commit is contained in:
eehouse 2010-01-03 01:02:14 +00:00
parent 1b350e0c34
commit ef188164e2
7 changed files with 42 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

View file

@ -75,7 +75,7 @@ public class BoardActivity extends Activity implements XW_UtilCtxt, Runnable {
Utils.logf( "calling game_makeNewGame; passing bytes: " + dictBytes.length ); Utils.logf( "calling game_makeNewGame; passing bytes: " + dictBytes.length );
m_jniGamePtr = XwJNI.game_makeNewGame( m_gi, this, m_view, 0, m_jniGamePtr = XwJNI.game_makeNewGame( m_gi, this, m_view, 0,
m_prefs, null, dictBytes ); m_prefs, null, dictBytes );
m_view.startHandling( m_jniGamePtr, m_gi ); m_view.startHandling( this, m_jniGamePtr, m_gi );
XwJNI.server_do( m_jniGamePtr ); XwJNI.server_do( m_jniGamePtr );
} }

View file

@ -10,6 +10,8 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import org.eehouse.android.xw4.jni.*; import org.eehouse.android.xw4.jni.*;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.graphics.drawable.Drawable;
import android.content.res.Resources;
public class BoardView extends View implements DrawCtx, public class BoardView extends View implements DrawCtx,
BoardHandler { BoardHandler {
@ -23,6 +25,8 @@ public class BoardView extends View implements DrawCtx,
private int m_trayOwner; private int m_trayOwner;
private Rect m_valRect; private Rect m_valRect;
private Rect m_letterRect; private Rect m_letterRect;
Drawable m_rightArrow;
Drawable m_downArrow;
private static final int BLACK = 0xFF000000; private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF; private static final int WHITE = 0xFFFFFFFF;
@ -142,9 +146,13 @@ public class BoardView extends View implements DrawCtx,
return m_boardSet; return m_boardSet;
} }
public void startHandling( int gamePtr, CurGameInfo gi ) { public void startHandling( Context context, int gamePtr, CurGameInfo gi ) {
m_jniGamePtr = gamePtr; m_jniGamePtr = gamePtr;
m_gi = gi; m_gi = gi;
Resources res = context.getResources();
m_downArrow = res.getDrawable( R.drawable.downarrow );
m_rightArrow = res.getDrawable( R.drawable.rightarrow );
} }
// DrawCtxt interface implementation // DrawCtxt interface implementation
@ -210,6 +218,16 @@ public class BoardView extends View implements DrawCtx,
return true; return true;
} }
public void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts,
int flags )
{
rect.inset( 2, 2 );
Utils.logf( "drawBoardArrow" );
Drawable arrow = vert? m_downArrow : m_rightArrow;
arrow.setBounds( rect );
arrow.draw( m_canvas );
}
public boolean trayBegin ( Rect rect, int owner, int dfs ) { public boolean trayBegin ( Rect rect, int owner, int dfs ) {
m_trayOwner = owner; m_trayOwner = owner;
return true; return true;

View file

@ -1,8 +1,10 @@
package org.eehouse.android.xw4.jni; package org.eehouse.android.xw4.jni;
import android.content.Context;
public interface BoardHandler { public interface BoardHandler {
void startHandling( int gamePtr, CurGameInfo gi ); void startHandling( Context context, int gamePtr, CurGameInfo gi );
} }

View file

@ -23,6 +23,8 @@ public interface DrawCtx {
boolean drawCell( Rect rect, String text, Object[] bitmaps, int tile, boolean drawCell( Rect rect, String text, Object[] bitmaps, int tile,
int owner, int bonus, int hintAtts, int flags ); int owner, int bonus, int hintAtts, int flags );
void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts,
int flags );
boolean trayBegin ( Rect rect, int owner, int dfs ); boolean trayBegin ( Rect rect, int owner, int dfs );
void drawTile( Rect rect, String text, Object[] bitmaps, int val, int flags ); void drawTile( Rect rect, String text, Object[] bitmaps, int val, int flags );

View file

@ -223,6 +223,22 @@ and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
return XP_TRUE; return XP_TRUE;
} }
static void
and_draw_drawBoardArrow(DrawCtx* dctx, const XP_Rect* rect, XWBonusType bonus,
XP_Bool vert, HintAtts hintAtts, CellFlags flags )
{
LOG_FUNC();
AndDraw* draw = (AndDraw*)dctx;
JNIEnv* env = draw->env;
const char* sig = "(Landroid/graphics/Rect;IZII)V";
jmethodID mid = getMethodID( env, draw->j_draw, "drawBoardArrow", sig );
jobject jrect = makeJRect( env, rect );
(*env)->CallVoidMethod( env, draw->j_draw, mid,
jrect, bonus, vert, hintAtts, flags );
(*env)->DeleteLocalRef( env, jrect );
}
static XP_Bool static XP_Bool
and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner, and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner,
DrawFocusState dfs ) DrawFocusState dfs )
@ -406,6 +422,7 @@ makeDraw( MPFORMAL JNIEnv *env, jobject j_draw )
SET_PROC(drawRemText); SET_PROC(drawRemText);
SET_PROC(score_drawPlayer); SET_PROC(score_drawPlayer);
SET_PROC(drawCell); SET_PROC(drawCell);
SET_PROC(drawBoardArrow);
SET_PROC(trayBegin); SET_PROC(trayBegin);
SET_PROC(drawTile); SET_PROC(drawTile);