1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-13 00:04:19 +00:00

Minor fixes for mac compilation. Android stuff.

This commit is contained in:
Julian Storer 2011-02-05 15:15:45 +00:00
parent 571a2626da
commit 08339c92e2
23 changed files with 1233 additions and 616 deletions

View file

@ -0,0 +1,94 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-10 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
package com.juce;
import android.content.Context;
import android.view.*;
import android.graphics.*;
//==============================================================================
public class ComponentPeerView extends View
{
public ComponentPeerView (Context context)
{
super (context);
}
//==============================================================================
private native void handlePaint (Canvas canvas);
@Override
public void draw (Canvas canvas)
{
handlePaint (canvas);
}
//==============================================================================
private native void handleMouseDown (float x, float y, long time);
private native void handleMouseDrag (float x, float y, long time);
private native void handleMouseUp (float x, float y, long time);
@Override
public boolean onTouchEvent (MotionEvent event)
{
System.out.println (event.toString());
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN: handleMouseDown (event.getX(), event.getY(), event.getEventTime()); return true;
case MotionEvent.ACTION_MOVE: handleMouseDrag (event.getX(), event.getY(), event.getEventTime()); return true;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: handleMouseUp (event.getX(), event.getY(), event.getEventTime()); return true;
default: break;
}
return false;
}
//==============================================================================
@Override
protected void onSizeChanged (int w, int h, int oldw, int oldh)
{
}
@Override
protected void onLayout (boolean changed, int left, int top, int right, int bottom)
{
}
public void setViewName (String newName)
{
}
public boolean isVisible()
{
return true;
}
public void setVisible (boolean b)
{
}
}

View file

@ -0,0 +1,131 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-10 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
package com.juce;
import android.app.Activity;
import android.os.Bundle;
import android.content.*;
import android.view.*;
import com.juce.ComponentPeerView;
//==============================================================================
public class JuceAppActivity extends Activity
{
//==============================================================================
static
{
System.loadLibrary ("juce_jni");
}
@Override
public void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
messageHandler = new android.os.Handler();
viewHolder = new ViewHolder (this);
setContentView (viewHolder);
WindowManager wm = (WindowManager) getSystemService (WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
launchApp (getApplicationInfo().publicSourceDir,
getApplicationInfo().dataDir,
display.getWidth(), display.getHeight());
}
@Override
protected void onDestroy()
{
quitApp();
super.onDestroy();
}
//==============================================================================
public native void launchApp (String appFile, String appDataDir,
int screenWidth, int screenHeight);
public native void quitApp();
//==============================================================================
public static void printToConsole (String s)
{
System.out.println (s);
}
//==============================================================================
public native void deliverMessage (long value);
private android.os.Handler messageHandler;
public void postMessage (long value)
{
messageHandler.post (new MessageCallback (this, value));
}
class MessageCallback implements java.lang.Runnable
{
public MessageCallback (JuceAppActivity app_, long value_)
{
app = app_;
value = value_;
}
public void run()
{
app.deliverMessage (value);
}
private JuceAppActivity app;
private long value;
}
//==============================================================================
private ViewHolder viewHolder;
public ComponentPeerView createNewView()
{
ComponentPeerView v = new ComponentPeerView (this);
viewHolder.addView (v);
return v;
}
public void deleteView (ComponentPeerView view)
{
viewHolder.removeView (view);
}
class ViewHolder extends ViewGroup
{
public ViewHolder (Context context)
{
super (context);
}
protected void onLayout (boolean changed, int left, int top, int right, int bottom)
{
}
}
}