From 32d55bcdc608380621c7c19b502ca238fa948422 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 6 Apr 2014 18:45:45 +0200 Subject: [PATCH] [DEV] add correct version for Admods and back button and image part display --- build | 2 +- external/airtaudio | 2 +- external/ogg | 2 +- sources/android/src/org/ewol/Ewol.java | 6 +- .../android/src/org/ewol/EwolActivity.java | 5 +- .../src/org/ewol/EwolSurfaceViewGL.java | 21 +++--- .../android/src/org/ewol/EwolWallpaper.java | 3 + sources/ewol/context/Android/Context.cpp | 27 ++++--- sources/ewol/context/Context.cpp | 11 +++ sources/ewol/context/Context.h | 8 +++ sources/ewol/key/keyboard.cpp | 20 ++++++ sources/ewol/key/keyboard.h | 13 ++++ sources/ewol/resource/TexturedFont.cpp | 6 +- sources/ewol/widget/Image.cpp | 70 ++++++++++++++++--- sources/ewol/widget/Image.h | 32 +++++++++ sources/ewol/widget/Widget.cpp | 2 + sources/ewol/widget/Windows.cpp | 11 +++ sources/ewol/widget/Windows.h | 9 +++ 18 files changed, 206 insertions(+), 44 deletions(-) diff --git a/build b/build index b48a5672..b7cc1ef4 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit b48a5672b6c3a981160bb5ec61df46cde8d823a9 +Subproject commit b7cc1ef456bc7635a1eff57f8c3e0919adb6b7a8 diff --git a/external/airtaudio b/external/airtaudio index b30ff780..7ea04602 160000 --- a/external/airtaudio +++ b/external/airtaudio @@ -1 +1 @@ -Subproject commit b30ff7808fe7205aa166dc4a856566a6ecfd9b85 +Subproject commit 7ea04602a2cbf9b2ae26ff7ba1d338d773a413db diff --git a/external/ogg b/external/ogg index d0f4c63e..841f4079 160000 --- a/external/ogg +++ b/external/ogg @@ -1 +1 @@ -Subproject commit d0f4c63e4571e022cad80a25a9386483546aa334 +Subproject commit 841f407905ad4f2d3434c20c4f3b4b4eec9ebdeb diff --git a/sources/android/src/org/ewol/Ewol.java b/sources/android/src/org/ewol/Ewol.java index 787bae56..b7c6aae6 100644 --- a/sources/android/src/org/ewol/Ewol.java +++ b/sources/android/src/org/ewol/Ewol.java @@ -82,8 +82,8 @@ public class Ewol { EWaudioPlayback(instanceID, bufferData, frames, nbChannels); } - public void keyboardEventKeySystem(int keyVal, boolean isDown) { - EWkeyboardEventKeySystem(instanceID, keyVal, isDown); + public boolean keyboardEventKeySystem(int keyVal, boolean isDown) { + return EWkeyboardEventKeySystem(instanceID, keyVal, isDown); } // renderer Event : public void renderInit() { @@ -127,7 +127,7 @@ public class Ewol { // Audio section ... public native void EWaudioPlayback(int instanceId, short[] bufferData, int frames, int nbChannels); - private native void EWkeyboardEventKeySystem(int instanceId, int keyVal, boolean isDown); + private native boolean EWkeyboardEventKeySystem(int instanceId, int keyVal, boolean isDown); // renderer Event : private native void EWrenderInit(int instanceId); private native void EWrenderResize(int instanceId, int w, int h); diff --git a/sources/android/src/org/ewol/EwolActivity.java b/sources/android/src/org/ewol/EwolActivity.java index 3d084d62..7c2b389d 100644 --- a/sources/android/src/org/ewol/EwolActivity.java +++ b/sources/android/src/org/ewol/EwolActivity.java @@ -47,15 +47,13 @@ import java.io.IOException; import org.ewol.Ewol; - - /** * @brief Class : * */ public abstract class EwolActivity extends Activity implements EwolCallback, EwolConstants { private static Context mContext; - private EwolSurfaceViewGL mGLView; + protected EwolSurfaceViewGL mGLView = null; private Ewol EWOL; // clipboard section private String tmpClipBoard; // TODO : Remove this ==> clipboard acces does not work @@ -63,6 +61,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo private EwolAudioTask mStreams; private Thread mAudioThread; private boolean mAudioStarted; + static { try { System.loadLibrary("ewol"); diff --git a/sources/android/src/org/ewol/EwolSurfaceViewGL.java b/sources/android/src/org/ewol/EwolSurfaceViewGL.java index 31b39537..99fe1564 100644 --- a/sources/android/src/org/ewol/EwolSurfaceViewGL.java +++ b/sources/android/src/org/ewol/EwolSurfaceViewGL.java @@ -216,27 +216,24 @@ public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants { Log.i("Surface GL", "get event : " + keyCode + " is down : " + isDown); switch(keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_DOWN, isDown); - return false; + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_DOWN, isDown); case KeyEvent.KEYCODE_VOLUME_UP: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_UP, isDown); - return false; + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_UP, isDown); case KeyEvent.KEYCODE_MENU: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_MENU, isDown); - return false; + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_MENU, isDown); case KeyEvent.KEYCODE_CAMERA: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_CAMERA, isDown); - return false; + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_CAMERA, isDown); case KeyEvent.KEYCODE_HOME: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_HOME, isDown); - return false; + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_HOME, isDown); case KeyEvent.KEYCODE_POWER: - EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_POWER, isDown); - return false; + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_POWER, isDown); case KeyEvent.KEYCODE_BACK: // the back key is wrapped in the key to simplify PC validation ... + return EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_BACK, isDown); + /* EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_BACK, isDown); return false; + */ case KeyEvent.KEYCODE_DEL: EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_DEL, isDown); return true; diff --git a/sources/android/src/org/ewol/EwolWallpaper.java b/sources/android/src/org/ewol/EwolWallpaper.java index 6f9140d3..d2dbcd5b 100644 --- a/sources/android/src/org/ewol/EwolWallpaper.java +++ b/sources/android/src/org/ewol/EwolWallpaper.java @@ -5,6 +5,7 @@ * * @license BSD v3 (see license file) */ + package org.ewol; import android.app.ActivityManager; @@ -209,3 +210,5 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall return false; } } + + diff --git a/sources/ewol/context/Android/Context.cpp b/sources/ewol/context/Android/Context.cpp index be2ad5ac..b4755140 100644 --- a/sources/ewol/context/Android/Context.cpp +++ b/sources/ewol/context/Android/Context.cpp @@ -589,6 +589,9 @@ class AndroidContext : public ewol::Context { OS_SetKeyboard(m_guiKeyBoardSpecialKeyMode, _myChar, _isDown, _isARepeateKey); } + bool ANDROID_systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) { + return systemKeyboradEvent(_key, _down); + } void ANDROID_SetKeyboardMove(int _move, bool _isDown, bool _isARepeateKey=false) { // direct wrapping : enum ewol::key::keyboard move = (enum ewol::key::keyboard)_move; @@ -956,7 +959,7 @@ extern "C" { } // TODO : set a return true or false if we want to grep this event ... - void Java_org_ewol_Ewol_EWkeyboardEventKeySystem(JNIEnv* _env, + bool Java_org_ewol_Ewol_EWkeyboardEventKeySystem(JNIEnv* _env, jobject _thiz, jint _id, jint _keyVal, @@ -967,31 +970,35 @@ extern "C" { || NULL == s_listInstance[_id] ) { EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id); // TODO : generate error in java to stop the current instance - return; + return false; } switch (_keyVal) { case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_UP: - EWOL_DEBUG("IO keyboard Key system \"VOLUME_UP\" is down=" << _isdown); - break; + EWOL_VERBOSE("IO keyboard Key system \"VOLUME_UP\" is down=" << _isdown); + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemVolumeUp, _isdown); case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_VOLUME_DOWN: EWOL_DEBUG("IO keyboard Key system \"VOLUME_DOWN\" is down=" << _isdown); - break; + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemVolumeDown, _isdown); case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_MENU: EWOL_DEBUG("IO keyboard Key system \"MENU\" is down=" << _isdown); - break; + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemMenu, _isdown); case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_CAMERA: EWOL_DEBUG("IO keyboard Key system \"CAMERA\" is down=" << _isdown); - break; + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemCamera, _isdown); case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_HOME: EWOL_DEBUG("IO keyboard Key system \"HOME\" is down=" << _isdown); - break; + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemHome, _isdown); case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_POWER: EWOL_DEBUG("IO keyboard Key system \"POWER\" is down=" << _isdown); - break; + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemPower, _isdown); + case org_ewol_EwolConstants_EWOL_SYSTEM_KEY_BACK: + EWOL_DEBUG("IO keyboard Key system \"BACK\" is down=" << _isdown); + return s_listInstance[_id]->ANDROID_systemKeyboradEvent(ewol::key::keyboardSystemBack, _isdown); default: - EWOL_DEBUG("IO keyboard Key system event : \"" << _keyVal << "\" is down=" << _isdown); + EWOL_ERROR("IO keyboard Key system event : \"" << _keyVal << "\" is down=" << _isdown); break; } + return false; } diff --git a/sources/ewol/context/Context.cpp b/sources/ewol/context/Context.cpp index 1dccea9a..a04b685b 100644 --- a/sources/ewol/context/Context.cpp +++ b/sources/ewol/context/Context.cpp @@ -723,3 +723,14 @@ void ewol::Context::keyboardShow(void) { void ewol::Context::keyboardHide(void) { EWOL_INFO("keyboardHide: NOT implemented ..."); } + + +bool ewol::Context::systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) { + if (m_windowsCurrent == NULL) { + return false; + } + lockContext(); + bool ret = m_windowsCurrent->onEventHardwareInput(_key, _down); + unLockContext(); + return ret; +} \ No newline at end of file diff --git a/sources/ewol/context/Context.h b/sources/ewol/context/Context.h index d9764341..bb047c8d 100644 --- a/sources/ewol/context/Context.h +++ b/sources/ewol/context/Context.h @@ -337,6 +337,14 @@ namespace ewol { * @param[in] _fileName Name of the image to load */ void setInitImage(const std::string& _fileName); + protected: + /** + * @brief HARDWARE keyboard event from the system + * @param[in] _key event type + * @param[in] _status Up or down status + * @return Keep the event or not + */ + virtual bool systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down); }; /** * @brief From everyware in the program, we can get the context inteface. diff --git a/sources/ewol/key/keyboard.cpp b/sources/ewol/key/keyboard.cpp index 95ddfa1d..2f5ed961 100644 --- a/sources/ewol/key/keyboard.cpp +++ b/sources/ewol/key/keyboard.cpp @@ -58,3 +58,23 @@ etk::CCout& ewol::key::operator <<(etk::CCout& _os, const enum ewol::key::keyboa return _os; } +static const char* keyboardSystemDescriptionString[ewol::key::keyboardSystemCount+1] = { + "keyboardSystemUnknow", + "keyboardSystemVolumeUp", + "keyboardSystemVolumeDown", + "keyboardSystemMenu", + "keyboardSystemCamera", + "keyboardSystemHome", + "keyboardSystemPower", + "keyboardSystemBack", + "keyboardSystemCount" +}; + +etk::CCout& ewol::key::operator <<(etk::CCout& _os, const enum ewol::key::keyboardSystem _obj) { + if (_obj >= 0 && _obj getName() << "' count=" << _object->getCounter()); + EWOL_INFO("RELEASE: TexturedFont : file : '" << _object->getName() << "' count=" << _object->getCounter()); std::string name = _object->getName(); int32_t count = _object->getCounter() - 1; ewol::Resource* object2 = static_cast(_object); diff --git a/sources/ewol/widget/Image.cpp b/sources/ewol/widget/Image.cpp index 8c476803..a39fa937 100644 --- a/sources/ewol/widget/Image.cpp +++ b/sources/ewol/widget/Image.cpp @@ -32,12 +32,16 @@ const char * const ewol::widget::Image::configSize = "size"; const char * const ewol::widget::Image::configBorder = "border"; const char * const ewol::widget::Image::configSource = "src"; const char * const ewol::widget::Image::configDistanceField = "distance-field"; +const char * const ewol::widget::Image::configPartStart = "part-start"; +const char * const ewol::widget::Image::configPartStop = "part-stop"; ewol::widget::Image::Image(const std::string& _file, const ewol::Dimension& _border) : m_colorProperty(NULL), m_colorId(-1), - m_imageSize(vec2(0,0)), - m_keepRatio(true) { + m_imageSize(vec2(0.0f,0.0f)), + m_keepRatio(true), + m_posStart(0.0f,0.0f), + m_posStop(1.0f,1.0f) { addObjectType("ewol::widget::Image"); addEventId(eventPressed); registerConfig(configRatio, "bool", NULL, "Keep ratio of the image"); @@ -45,6 +49,8 @@ ewol::widget::Image::Image(const std::string& _file, const ewol::Dimension& _bor registerConfig(configBorder, "Dimension", NULL, "Border of the image"); registerConfig(configSource, "string", "Image source path"); registerConfig(configDistanceField, "bool", "Distance field mode"); + registerConfig(configPartStart, "vec2", NULL, "Start display position in the image [0.0 .. 1.0]"); + registerConfig(configPartStop, "vec2", NULL, "Stop display position in the image [0.0 .. 1.0]"); m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:Image.json"); if (m_colorProperty != NULL) { m_colorId = m_colorProperty->request("foreground"); @@ -79,13 +85,36 @@ void ewol::widget::Image::setBorder(const ewol::Dimension& _border) { } void ewol::widget::Image::setKeepRatio(bool _keep) { - if (m_keepRatio != _keep) { - // copy data : - m_keepRatio = _keep; - // force redraw all : - markToRedraw(); - requestUpdateSize(); + if (m_keepRatio == _keep) { + return; } + // copy data : + m_keepRatio = _keep; + // force redraw all : + markToRedraw(); + requestUpdateSize(); +} + +void ewol::widget::Image::setStartPos(const vec2& _pos) { + if (m_posStart == _pos) { + return; + } + // copy data : + m_posStart = _pos; + // force redraw all : + markToRedraw(); + requestUpdateSize(); +} + +void ewol::widget::Image::setStopPos(const vec2& _pos) { + if (m_posStop == _pos) { + return; + } + // copy data : + m_posStop = _pos; + // force redraw all : + markToRedraw(); + requestUpdateSize(); } void ewol::widget::Image::setImageSize(const ewol::Dimension& _size) { @@ -128,6 +157,9 @@ void ewol::widget::Image::onRegenerateDisplay(void) { vec2 imageRealSize = m_minSize - imageBoder; vec2 imageRealSizeMax = m_size - imageBoder; + vec2 ratioSizeDisplayRequested = m_posStop - m_posStart; + //imageRealSizeMax *= ratioSizeDisplayRequested; + if (m_userFill.x() == true) { imageRealSize.setX(imageRealSizeMax.x()); } else { @@ -140,7 +172,9 @@ void ewol::widget::Image::onRegenerateDisplay(void) { } if (m_keepRatio == true) { vec2 tmpSize = m_compositing.getRealSize(); - float ratio = tmpSize.x() / tmpSize.y(); + //float ratio = tmpSize.x() / tmpSize.y(); + float ratio = (tmpSize.x()*ratioSizeDisplayRequested.x()) / (tmpSize.y() * ratioSizeDisplayRequested.y()); + //float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y()); float ratioCurrent = imageRealSize.x() / imageRealSize.y(); if (ratio == ratioCurrent) { // nothing to do ... @@ -157,7 +191,7 @@ void ewol::widget::Image::onRegenerateDisplay(void) { // set the somposition properties : m_compositing.setPos(origin); - m_compositing.print(imageRealSize); + m_compositing.printPart(imageRealSize, m_posStart, m_posStop); //EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin); EWOL_VERBOSE("Paint Image :" << m_fileName << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize); } @@ -258,6 +292,14 @@ bool ewol::widget::Image::onSetConfig(const ewol::object::Config& _conf) { setDistanceField(std::stob(_conf.getData())); return true; } + if (_conf.getConfig() == configPartStart) { + setStartPos(vec2(_conf.getData())); + return true; + } + if (_conf.getConfig() == configPartStop) { + setStopPos(vec2(_conf.getData())); + return true; + } return false; } @@ -285,6 +327,14 @@ bool ewol::widget::Image::onGetConfig(const char* _config, std::string& _result) _result = std::to_string(getDistanceField()); return true; } + if (_config == configPartStart) { + _result = (std::string)getStartPos(); + return true; + } + if (_config == configPartStop) { + _result = (std::string)getStopPos(); + return true; + } return false; } diff --git a/sources/ewol/widget/Image.h b/sources/ewol/widget/Image.h index 1ec6467f..929910d9 100644 --- a/sources/ewol/widget/Image.h +++ b/sources/ewol/widget/Image.h @@ -32,6 +32,8 @@ namespace ewol { static const char * const configBorder; static const char * const configSource; static const char * const configDistanceField; + static const char * const configPartStart; + static const char * const configPartStop; public: /** * @brief Main call of recording the widget on the List of "widget named creator" @@ -117,6 +119,36 @@ namespace ewol { bool getKeepRatio(void) const { return m_keepRatio; }; + protected: + vec2 m_posStart; //!< position in the image to start the sisplay (when we want not to display all the image) + public: + /** + * @brief set the current 'start' position in the image to display. + * @param[in] _keep The new position in the image vec2([0..1],[0..1]) + */ + void setStartPos(const vec2& _pos); + /** + * @brief get the current 'start' position in the image to display. + * @return The Position of the display in image + */ + vec2 getStartPos(void) const { + return m_posStart; + }; + protected: + vec2 m_posStop; //!< position in the image to start the sisplay (when we want not to display all the image) + public: + /** + * @brief set the current 'stop' position in the image to display. + * @param[in] _keep The new position in the image vec2([0..1],[0..1]) + */ + void setStopPos(const vec2& _pos); + /** + * @brief get the current 'stop' position in the image to display. + * @return The Position of the display in image + */ + vec2 getStopPos(void) const { + return m_posStop; + }; public: /** * @brief Set distance field rendering mode diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index ce7d4f6d..38ee49b4 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -180,6 +180,7 @@ void ewol::Widget::onObjectRemove(ewol::Object* _removeObject) { void ewol::Widget::hide(void) { if (m_hide == false) { + EWOL_WARNING("HIDE widget: '" << getName() << "'"); m_hide = true; markToRedraw(); requestUpdateSize(); @@ -188,6 +189,7 @@ void ewol::Widget::hide(void) { void ewol::Widget::show(void) { if (m_hide == true) { + EWOL_WARNING("SHOW widget: '" << getName() << "'"); m_hide = false; markToRedraw(); requestUpdateSize(); diff --git a/sources/ewol/widget/Windows.cpp b/sources/ewol/widget/Windows.cpp index ecda114b..5844844f 100644 --- a/sources/ewol/widget/Windows.cpp +++ b/sources/ewol/widget/Windows.cpp @@ -201,6 +201,17 @@ void ewol::widget::Windows::popUpWidgetPush(ewol::Widget* _widget) { getContext().resetIOEvent(); } +void ewol::widget::Windows::popUpWidgetPop(void) { + if (m_popUpWidgetList.size() == 0) { + return; + } + ewol::Widget* widget = m_popUpWidgetList[m_popUpWidgetList.size()-1]; + if (widget == NULL) { + return; + } + widget->removeObject(); +} + void ewol::widget::Windows::onObjectRemove(ewol::Object* _removeObject) { // First step call parrent : ewol::Widget::onObjectRemove(_removeObject); diff --git a/sources/ewol/widget/Windows.h b/sources/ewol/widget/Windows.h index 1ddb8d86..cec8a905 100644 --- a/sources/ewol/widget/Windows.h +++ b/sources/ewol/widget/Windows.h @@ -57,6 +57,10 @@ namespace ewol { public: void setSubWidget(ewol::Widget* _widget); void popUpWidgetPush(ewol::Widget* _widget); + void popUpWidgetPop(void); + size_t popUpCount(void) { + return m_popUpWidgetList.size(); + } private: etk::Color m_backgroundColor; //!< reset color of the Main windows public: @@ -121,6 +125,11 @@ namespace ewol { void displayCriticalMessage(const std::string& _message) { createPopUpMessage(messageTypeCritical, _message); } + + + virtual bool onEventHardwareInput(const ewol::key::keyboardSystem& _event, bool _down) { + return false; + }; }; }; };