[DEV] add the management of the screen display size
This commit is contained in:
parent
b83589e174
commit
0de61c3dc1
@ -52,6 +52,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
// inport the ewol package :
|
// inport the ewol package :
|
||||||
import org.ewol.interfaceJNI;
|
import org.ewol.interfaceJNI;
|
||||||
@ -106,6 +107,10 @@ public class __PROJECT_NAME__ extends Activity {
|
|||||||
ActivityParamSetArchiveDir(0, apkFilePath);
|
ActivityParamSetArchiveDir(0, apkFilePath);
|
||||||
|
|
||||||
|
|
||||||
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
interfaceJNI.DisplayPropertyMetrics(metrics.xdpi, metrics.ydpi);
|
||||||
|
|
||||||
// call C init ...
|
// call C init ...
|
||||||
interfaceJNI.ActivityOnCreate();
|
interfaceJNI.ActivityOnCreate();
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ public class interfaceJNI {
|
|||||||
public static native void ActivityOnPause();
|
public static native void ActivityOnPause();
|
||||||
public static native void ActivityOnStop();
|
public static native void ActivityOnStop();
|
||||||
public static native void ActivityOnDestroy();
|
public static native void ActivityOnDestroy();
|
||||||
|
// set display properties :
|
||||||
|
public static native void DisplayPropertyMetrics(float ratioX, float ratioY);
|
||||||
// IO native function :
|
// IO native function :
|
||||||
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
|
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
|
||||||
public static native void IOInputEventMotion(int pointerID, float x, float y);
|
public static native void IOInputEventMotion(int pointerID, float x, float y);
|
||||||
|
64
sources/ewol/DisplayConv.cpp
Normal file
64
sources/ewol/DisplayConv.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ewol/DisplayConv.h>
|
||||||
|
#include <ewol/debug.h>
|
||||||
|
|
||||||
|
static vec2 ratioInch(65475,75654);
|
||||||
|
static vec2 ratioMillimeter(76545,46547445);
|
||||||
|
|
||||||
|
static const float numberOfMillimeterInOneInch = 25.4f;
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::DC_Init(void)
|
||||||
|
{
|
||||||
|
ratioInch.setValue(96,96);
|
||||||
|
ratioMillimeter = ratioInch/numberOfMillimeterInOneInch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec2 ewol::InchToPixel(const vec2& inch)
|
||||||
|
{
|
||||||
|
return vec2(inch.x()*ratioInch.x(), inch.y()*ratioInch.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec2 ewol::MillemeterToPixel(const vec2& millimeter)
|
||||||
|
{
|
||||||
|
return vec2(millimeter.x()*ratioMillimeter.x(), millimeter.y()*ratioMillimeter.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec2 ewol::PixelToInch(const vec2& pixel)
|
||||||
|
{
|
||||||
|
return vec2(pixel.x()/ratioInch.x(), pixel.y()/ratioInch.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec2 ewol::PixelToMillemeter(const vec2& pixel)
|
||||||
|
{
|
||||||
|
return vec2(pixel.x()/ratioMillimeter.x(), pixel.y()/ratioMillimeter.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::SetPixelPerInch(const vec2& ratio)
|
||||||
|
{
|
||||||
|
ratioInch = ratio;
|
||||||
|
ratioMillimeter = ratioInch/numberOfMillimeterInOneInch;
|
||||||
|
EWOL_INFO("Set a new Inch/milimeter Ratio for the screen : ratioInch=" << ratioInch << " ratioMm=" << ratioMillimeter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::SetPixelPerMillimeter(const vec2& ratio)
|
||||||
|
{
|
||||||
|
ratioMillimeter = ratio;
|
||||||
|
ratioInch = ratioMillimeter*numberOfMillimeterInOneInch;
|
||||||
|
EWOL_INFO("Set a new Inch/milimeter Ratio for the screen : ratioInch=" << ratioInch << " ratioMm=" << ratioMillimeter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
73
sources/ewol/DisplayConv.h
Normal file
73
sources/ewol/DisplayConv.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __DISPLAY_CONV_H__
|
||||||
|
#define __DISPLAY_CONV_H__
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <etk/UString.h>
|
||||||
|
#include <etk/math/Vector2D.h>
|
||||||
|
|
||||||
|
namespace ewol
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief basic init
|
||||||
|
*/
|
||||||
|
void DC_Init(void);
|
||||||
|
/**
|
||||||
|
* @brief convert a dimention in Inch to a pixel dimension
|
||||||
|
* @param[in] inch Dimention in Inch
|
||||||
|
* @return dimention in Pixel
|
||||||
|
*/
|
||||||
|
vec2 InchToPixel(const vec2& inch);
|
||||||
|
/**
|
||||||
|
* @brief convert a dimention in millimeter to a pixel dimension
|
||||||
|
* @param[in] millimeter Dimention in millimeter
|
||||||
|
* @return dimention in Pixel
|
||||||
|
*/
|
||||||
|
vec2 MillemeterToPixel(const vec2& millimeter);
|
||||||
|
/**
|
||||||
|
* @brief convert a dimention in pourcent to a pixel dimension
|
||||||
|
* @param[in] pourcent Dimention in pourcent
|
||||||
|
* @return dimention in Pixel
|
||||||
|
*/
|
||||||
|
//vec2 PourcentToPixel(const vec2& pourcent);
|
||||||
|
/**
|
||||||
|
* @brief convert a dimention in Pixel to a inch dimension
|
||||||
|
* @param[in] pixel Dimention in pixel
|
||||||
|
* @return dimention in Inch
|
||||||
|
*/
|
||||||
|
vec2 PixelToInch(const vec2& pixel);
|
||||||
|
/**
|
||||||
|
* @brief convert a dimention in Pixel to a Millemeter dimension
|
||||||
|
* @param[in] pixel Dimention in pixel
|
||||||
|
* @return dimention in Millemeter
|
||||||
|
*/
|
||||||
|
vec2 PixelToMillemeter(const vec2& pixel);
|
||||||
|
/**
|
||||||
|
* @brief convert a dimention in Pixel to a pourcent dimension
|
||||||
|
* @param[in] pixel Dimention in pixel
|
||||||
|
* @return dimention in pourcent
|
||||||
|
*/
|
||||||
|
//vec2 PixelToPourcent(const vec2& pixel);
|
||||||
|
/**
|
||||||
|
* @brief Set the Inch ratio for calculation
|
||||||
|
* @param[in] Ratio Inch ration for the screen calculation interpolation
|
||||||
|
* @note: same as @ref SetPixelPerMillimeter (internal manage convertion)
|
||||||
|
*/
|
||||||
|
void SetPixelPerInch(const vec2& ratio);
|
||||||
|
/**
|
||||||
|
* @brief Set the Milimeter ratio for calculation
|
||||||
|
* @param[in] Ratio Milimeter ration for the screen calculation interpolation
|
||||||
|
* @note: same as @ref SetPixelPerInch (internal manage convertion)
|
||||||
|
*/
|
||||||
|
void SetPixelPerMillimeter(const vec2& ratio);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -13,13 +13,15 @@
|
|||||||
#include <ewol/renderer/os/gui.h>
|
#include <ewol/renderer/os/gui.h>
|
||||||
#include <ewol/commandLine.h>
|
#include <ewol/commandLine.h>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.h>
|
||||||
|
#include <ewol/DisplayConv.h>
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "ewol"
|
#define __class__ "ewol"
|
||||||
|
|
||||||
|
|
||||||
int32_t ewol::Run(int32_t argc, const char* argv[])
|
int32_t ewol::Run(int32_t argc, const char* argv[])
|
||||||
{
|
{
|
||||||
|
// init display convertions:
|
||||||
|
ewol::DC_Init();
|
||||||
|
|
||||||
EWOL_DEBUG("Store commangLine in the specific system");
|
EWOL_DEBUG("Store commangLine in the specific system");
|
||||||
ewol::commandLine::Clean();
|
ewol::commandLine::Clean();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <ewol/renderer/os/eSystem.h>
|
#include <ewol/renderer/os/eSystem.h>
|
||||||
#include <ewol/renderer/audio/audio.h>
|
#include <ewol/renderer/audio/audio.h>
|
||||||
#include <ewol/renderer/os/gui.h>
|
#include <ewol/renderer/os/gui.h>
|
||||||
|
#include <ewol/DisplayConv.h>
|
||||||
|
|
||||||
// get a resources from the java environement :
|
// get a resources from the java environement :
|
||||||
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
static JNIEnv* JavaVirtualMachinePointer = NULL; // the JVM
|
||||||
@ -413,6 +414,12 @@ extern "C"
|
|||||||
eSystem::SetKeyboard(guiKeyBoardSpecialKeyMode, uniChar, isdown);
|
eSystem::SetKeyboard(guiKeyBoardSpecialKeyMode, uniChar, isdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Java_org_ewol_interfaceJNI_DisplayPropertyMetrics( JNIEnv* env, jobject thiz, jfloat ratioX, jfloat ratioY)
|
||||||
|
{
|
||||||
|
// set the internal system ratio properties ...
|
||||||
|
ewol::SetPixelPerInch(vec2(ratioX,ratioY));
|
||||||
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SYSTEM_KEY__VOLUME_UP = 1,
|
SYSTEM_KEY__VOLUME_UP = 1,
|
||||||
SYSTEM_KEY__VOLUME_DOWN,
|
SYSTEM_KEY__VOLUME_DOWN,
|
||||||
@ -486,7 +493,6 @@ extern "C"
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <ewol/renderer/ResourceManager.h>
|
#include <ewol/renderer/ResourceManager.h>
|
||||||
#include <ewol/renderer/os/eSystem.h>
|
#include <ewol/renderer/os/eSystem.h>
|
||||||
|
#include <ewol/DisplayConv.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -168,6 +169,9 @@ bool CreateX11Context(void)
|
|||||||
EWOL_INFO("Display opened.");
|
EWOL_INFO("Display opened.");
|
||||||
}
|
}
|
||||||
int Xscreen = DefaultScreen(m_display);
|
int Xscreen = DefaultScreen(m_display);
|
||||||
|
// set the DPI for the current screen :
|
||||||
|
ewol::SetPixelPerMillimeter(vec2((float)DisplayWidth(m_display, Xscreen)/(float)DisplayWidthMM(m_display, Xscreen),
|
||||||
|
(float)DisplayHeight(m_display, Xscreen)/(float)DisplayHeightMM(m_display, Xscreen)));
|
||||||
// get an appropriate visual
|
// get an appropriate visual
|
||||||
m_visual = glXChooseVisual(m_display, Xscreen, attrListDbl);
|
m_visual = glXChooseVisual(m_display, Xscreen, attrListDbl);
|
||||||
if (NULL == m_visual) {
|
if (NULL == m_visual) {
|
||||||
|
@ -6,7 +6,8 @@ FILE_LIST:= ewol/ewol.cpp \
|
|||||||
ewol/config.cpp \
|
ewol/config.cpp \
|
||||||
ewol/commandLine.cpp \
|
ewol/commandLine.cpp \
|
||||||
ewol/key.cpp \
|
ewol/key.cpp \
|
||||||
ewol/cursor.cpp
|
ewol/cursor.cpp \
|
||||||
|
ewol/DisplayConv.cpp
|
||||||
|
|
||||||
# Basic Eobject of EWOL
|
# Basic Eobject of EWOL
|
||||||
FILE_LIST+= ewol/eObject/EObject.cpp \
|
FILE_LIST+= ewol/eObject/EObject.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user