[DEV] continue integration
This commit is contained in:
parent
ca11f9e116
commit
3a89eaab79
@ -11,44 +11,59 @@
|
||||
#include <gale/context/Context.h>
|
||||
|
||||
|
||||
gale::Application::Application() {
|
||||
GALE_INFO("Constructor Gale Application");
|
||||
gale::Application::Application() :
|
||||
m_needRedraw(true) {
|
||||
GALE_VERBOSE("Constructor Gale Application");
|
||||
}
|
||||
|
||||
gale::Application::~Application() {
|
||||
GALE_INFO("destructor of Gale Application");
|
||||
GALE_VERBOSE("destructor of Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onCreate(gale::Context& _context) {
|
||||
GALE_INFO("Create Gale Application");
|
||||
GALE_VERBOSE("Create Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onStart(gale::Context& _context) {
|
||||
GALE_INFO("Start Gale Application");
|
||||
GALE_VERBOSE("Start Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onResume(gale::Context& _context) {
|
||||
GALE_INFO("Resume Gale Application");
|
||||
GALE_VERBOSE("Resume Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onRun(gale::Context& _context) {
|
||||
GALE_INFO("Run Gale Application");
|
||||
void gale::Application::onRegenerateDisplay(gale::Context& _context) {
|
||||
GALE_VERBOSE("Regenerate Gale Application");
|
||||
markDrawingIsNeeded();
|
||||
}
|
||||
|
||||
void gale::Application::markDrawingIsNeeded() {
|
||||
m_needRedraw = true;
|
||||
}
|
||||
|
||||
bool gale::Application::isDrawingNeeded() {
|
||||
bool tmp = m_needRedraw;
|
||||
m_needRedraw = false;
|
||||
return tmp;
|
||||
}
|
||||
void gale::Application::onDraw(gale::Context& _context) {
|
||||
GALE_VERBOSE("draw Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onPause(gale::Context& _context) {
|
||||
GALE_INFO("Pause Gale Application");
|
||||
GALE_VERBOSE("Pause Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onStop(gale::Context& _context) {
|
||||
GALE_INFO("Stop Gale Application");
|
||||
GALE_VERBOSE("Stop Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::onDestroy(gale::Context& _context) {
|
||||
GALE_INFO("Destroy Gale Application");
|
||||
GALE_VERBOSE("Destroy Gale Application");
|
||||
}
|
||||
|
||||
void gale::Application::exit(int32_t _value) {
|
||||
GALE_INFO("Exit Requested");
|
||||
GALE_VERBOSE("Exit Requested");
|
||||
}
|
||||
|
||||
void gale::Application::onPointer(enum gale::key::type _type, int32_t _pointerID, const vec2& _pos, gale::key::status _state) {
|
||||
|
@ -41,10 +41,15 @@ namespace gale {
|
||||
*/
|
||||
virtual void onResume(gale::Context& _context);
|
||||
/**
|
||||
* @brief Call periodicly the application to draw all it is needed to draw ... (access on the openGL Context).
|
||||
* @brief call application to precalculate drawing.
|
||||
* @param[in] _context Current gale context.
|
||||
*/
|
||||
virtual void onRun(gale::Context& _context);
|
||||
virtual void onRegenerateDisplay(gale::Context& _context);
|
||||
/**
|
||||
* @brief Real draw of the application
|
||||
* @param[in] _context Current gale context.
|
||||
*/
|
||||
virtual void onDraw(gale::Context& _context);
|
||||
/**
|
||||
* @brief The application is Hide / not visible.
|
||||
* @param[in] _context Current gale context.
|
||||
@ -65,6 +70,12 @@ namespace gale {
|
||||
* @param[in] _value value to return on the program
|
||||
*/
|
||||
virtual void exit(int32_t _value);
|
||||
|
||||
private:
|
||||
bool m_needRedraw;
|
||||
public:
|
||||
virtual void markDrawingIsNeeded();
|
||||
virtual bool isDrawingNeeded();
|
||||
public:
|
||||
/**
|
||||
* @brief Get touch/mouse/... event.
|
||||
|
299
gale/Windows.cpp
299
gale/Windows.cpp
@ -1,299 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/types.h>
|
||||
#include <gale/gale.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/context/Context.h>
|
||||
#include <gale/widget/Widget.h>
|
||||
#include <gale/widget/Windows.h>
|
||||
#include <gale/widget/Manager.h>
|
||||
#include <gale/widget/meta/StdPopUp.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Windows"
|
||||
|
||||
//list of local events :
|
||||
extern const char * const galeEventWindowsHideKeyboard = "gale Windows hideKeyboard";
|
||||
|
||||
|
||||
gale::widget::Windows::Windows() :
|
||||
m_colorProperty(nullptr),
|
||||
m_colorBg(-1) {
|
||||
addResourceType("gale::widget::Windows");
|
||||
setCanHaveFocus(true);
|
||||
m_colorProperty = gale::resource::ColorFile::create("THEME:COLOR:Windows.json");
|
||||
if (m_colorProperty != nullptr) {
|
||||
m_colorBg = m_colorProperty->request("background");
|
||||
}
|
||||
//KeyboardShow(KEYBOARD_MODE_CODE);
|
||||
}
|
||||
|
||||
gale::widget::Windows::~Windows() {
|
||||
m_subWidget.reset();
|
||||
m_popUpWidgetList.clear();
|
||||
}
|
||||
|
||||
void gale::widget::Windows::calculateSize(const vec2& _availlable) {
|
||||
GALE_DEBUG(" _availlable : " << _availlable);
|
||||
m_size = _availlable;
|
||||
if (m_subWidget != nullptr) {
|
||||
m_subWidget->calculateMinMaxSize();
|
||||
// TODO : Check if min size is possible ...
|
||||
// TODO : Herited from MinSize .. and expand ???
|
||||
m_subWidget->calculateSize(m_size);
|
||||
}
|
||||
for (auto &it : m_popUpWidgetList) {
|
||||
if(it != nullptr) {
|
||||
it->calculateMinMaxSize();
|
||||
it->calculateSize(m_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<gale::Widget> gale::widget::Windows::getWidgetAtPos(const vec2& _pos) {
|
||||
// calculate relative position
|
||||
vec2 relativePos = relativePosition(_pos);
|
||||
// event go directly on the pop-up
|
||||
if (0 < m_popUpWidgetList.size()) {
|
||||
return m_popUpWidgetList.back()->getWidgetAtPos(_pos);
|
||||
// otherwise in the normal windows
|
||||
} else if (nullptr != m_subWidget) {
|
||||
return m_subWidget->getWidgetAtPos(_pos);
|
||||
}
|
||||
// otherwise the event go to this widget ...
|
||||
return std::dynamic_pointer_cast<gale::Widget>(shared_from_this());
|
||||
}
|
||||
|
||||
void gale::widget::Windows::sysDraw() {
|
||||
//GALE_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
|
||||
// set the size of the open GL system
|
||||
glViewport(0,0,m_size.x(),m_size.y());
|
||||
|
||||
gale::openGL::disable(gale::openGL::FLAG_DITHER);
|
||||
//gale::openGL::disable(gale::openGL::FLAG_BLEND);
|
||||
gale::openGL::disable(gale::openGL::FLAG_STENCIL_TEST);
|
||||
gale::openGL::disable(gale::openGL::FLAG_ALPHA_TEST);
|
||||
gale::openGL::disable(gale::openGL::FLAG_FOG);
|
||||
#if (!defined(__TARGET_OS__Android) && !defined(__TARGET_OS__IOs))
|
||||
glPixelZoom(1.0,1.0);
|
||||
#endif
|
||||
gale::openGL::disable(gale::openGL::FLAG_TEXTURE_2D);
|
||||
gale::openGL::disable(gale::openGL::FLAG_DEPTH_TEST);
|
||||
|
||||
gale::openGL::enable(gale::openGL::FLAG_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// clear the matrix system :
|
||||
mat4 newOne;
|
||||
gale::openGL::setBasicMatrix(newOne);
|
||||
|
||||
gale::DrawProperty displayProp;
|
||||
displayProp.m_windowsSize = m_size;
|
||||
displayProp.m_origin.setValue(0,0);
|
||||
displayProp.m_size = m_size;
|
||||
systemDraw(displayProp);
|
||||
gale::openGL::disable(gale::openGL::FLAG_BLEND);
|
||||
return;
|
||||
}
|
||||
|
||||
void gale::widget::Windows::onRegenerateDisplay() {
|
||||
if (nullptr != m_subWidget) {
|
||||
m_subWidget->onRegenerateDisplay();
|
||||
}
|
||||
for (auto &it : m_popUpWidgetList) {
|
||||
if (it != nullptr) {
|
||||
it->onRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#define TEST_PERFO_WINDOWS
|
||||
|
||||
void gale::widget::Windows::systemDraw(const gale::DrawProperty& _displayProp) {
|
||||
gale::Widget::systemDraw(_displayProp);
|
||||
#ifdef TEST_PERFO_WINDOWS
|
||||
int64_t ___startTime0 = gale::getTime();
|
||||
#endif
|
||||
|
||||
// clear the screen with transparency ...
|
||||
etk::Color<float> colorBg(0.5, 0.5, 0.5, 0.5);
|
||||
if (m_colorProperty != nullptr) {
|
||||
colorBg = m_colorProperty->get(m_colorBg);
|
||||
}
|
||||
glClearColor(colorBg.r(), colorBg.g(), colorBg.b(), colorBg.a());
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
#ifdef TEST_PERFO_WINDOWS
|
||||
float ___localTime0 = (float)(gale::getTime() - ___startTime0) / 1000.0f;
|
||||
GALE_ERROR(" Windows000 : " << ___localTime0 << "ms ");
|
||||
|
||||
int64_t ___startTime1 = gale::getTime();
|
||||
#endif
|
||||
//GALE_WARNING(" WINDOWS draw on " << m_currentDrawId);
|
||||
// first display the windows on the display
|
||||
if (nullptr != m_subWidget) {
|
||||
m_subWidget->systemDraw(_displayProp);
|
||||
//GALE_DEBUG("Draw Windows");
|
||||
}
|
||||
#ifdef TEST_PERFO_WINDOWS
|
||||
float ___localTime1 = (float)(gale::getTime() - ___startTime1) / 1000.0f;
|
||||
GALE_ERROR(" Windows111 : " << ___localTime1 << "ms ");
|
||||
|
||||
int64_t ___startTime2 = gale::getTime();
|
||||
#endif
|
||||
// second display the pop-up
|
||||
for (auto &it : m_popUpWidgetList) {
|
||||
if (it != nullptr) {
|
||||
it->systemDraw(_displayProp);
|
||||
//GALE_DEBUG("Draw Pop-up");
|
||||
}
|
||||
}
|
||||
#ifdef TEST_PERFO_WINDOWS
|
||||
float ___localTime2 = (float)(gale::getTime() - ___startTime2) / 1000.0f;
|
||||
GALE_ERROR(" Windows222 : " << ___localTime2 << "ms ");
|
||||
#endif
|
||||
}
|
||||
|
||||
void gale::widget::Windows::setSubWidget(std::shared_ptr<gale::Widget> _widget) {
|
||||
if (m_subWidget != nullptr) {
|
||||
GALE_INFO("Remove current main windows Widget...");
|
||||
m_subWidget->removeParent();
|
||||
m_subWidget.reset();
|
||||
}
|
||||
if (_widget != nullptr) {
|
||||
m_subWidget = _widget;
|
||||
m_subWidget->setParent(shared_from_this());
|
||||
}
|
||||
|
||||
// Regenerate the size calculation :
|
||||
calculateSize(m_size);
|
||||
}
|
||||
|
||||
void gale::widget::Windows::popUpWidgetPush(std::shared_ptr<gale::Widget> _widget) {
|
||||
if (_widget == nullptr) {
|
||||
// nothing to do an error appear :
|
||||
GALE_ERROR("can not set widget pop-up (null pointer)");
|
||||
return;
|
||||
}
|
||||
m_popUpWidgetList.push_back(_widget);
|
||||
_widget->setParent(shared_from_this());
|
||||
// force the focus on the basic widget ==> this remove many time the virual keyboard area
|
||||
_widget->keepFocus();
|
||||
// Regenerate the size calculation :
|
||||
calculateSize(m_size);
|
||||
// TODO : it is dangerous to access directly to the system ...
|
||||
getContext().resetIOEvent();
|
||||
}
|
||||
|
||||
void gale::widget::Windows::popUpWidgetPop() {
|
||||
if (m_popUpWidgetList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
m_popUpWidgetList.pop_back();
|
||||
}
|
||||
|
||||
void gale::widget::Windows::setBackgroundColor(const etk::Color<float>& _color) {
|
||||
if (m_backgroundColor != _color) {
|
||||
m_backgroundColor = _color;
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
void gale::widget::Windows::setTitle(const std::string& _title) {
|
||||
// TODO : remove this ...
|
||||
std::string title = _title;
|
||||
getContext().setTitle(title);
|
||||
}
|
||||
|
||||
|
||||
void gale::widget::Windows::createPopUpMessage(enum popUpMessageType _type, const std::string& _message) {
|
||||
std::shared_ptr<gale::widget::StdPopUp> tmpPopUp = widget::StdPopUp::create();
|
||||
if (tmpPopUp == nullptr) {
|
||||
GALE_ERROR("Can not create a simple pop-up");
|
||||
return;
|
||||
}
|
||||
switch(_type) {
|
||||
case messageTypeInfo:
|
||||
tmpPopUp->setTitle("<bold>Info</bold>");
|
||||
break;
|
||||
case messageTypeWarning:
|
||||
tmpPopUp->setTitle("<bold><font color=\"orange\">Warning</font></bold>");
|
||||
break;
|
||||
case messageTypeError:
|
||||
tmpPopUp->setTitle("<bold><font color=\"red\">Error</font></bold>");
|
||||
break;
|
||||
case messageTypeCritical:
|
||||
tmpPopUp->setTitle("<bold><font colorBg=\"red\">Critical</font></bold>");
|
||||
break;
|
||||
}
|
||||
tmpPopUp->setComment(_message);
|
||||
tmpPopUp->addButton("close", true);
|
||||
tmpPopUp->setRemoveOnExternClick(true);
|
||||
popUpWidgetPush(tmpPopUp);
|
||||
}
|
||||
|
||||
void gale::widget::Windows::requestDestroyFromChild(const std::shared_ptr<Object>& _child) {
|
||||
auto it = m_popUpWidgetList.begin();
|
||||
while (it != m_popUpWidgetList.end()) {
|
||||
if (*it == _child) {
|
||||
if (*it == nullptr) {
|
||||
m_popUpWidgetList.erase(it);
|
||||
it = m_popUpWidgetList.begin();
|
||||
continue;
|
||||
}
|
||||
(*it)->removeParent();
|
||||
(*it).reset();
|
||||
m_popUpWidgetList.erase(it);
|
||||
it = m_popUpWidgetList.begin();
|
||||
markToRedraw();
|
||||
continue;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
if (m_subWidget == _child) {
|
||||
if (m_subWidget == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_subWidget->removeParent();
|
||||
m_subWidget.reset();
|
||||
markToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<gale::Object> gale::widget::Windows::getSubObjectNamed(const std::string& _objectName) {
|
||||
std::shared_ptr<gale::Object> tmpObject = gale::Widget::getSubObjectNamed(_objectName);
|
||||
if (tmpObject != nullptr) {
|
||||
return tmpObject;
|
||||
}
|
||||
// check direct subwidget
|
||||
if (m_subWidget != nullptr) {
|
||||
tmpObject = m_subWidget->getSubObjectNamed(_objectName);
|
||||
if (tmpObject != nullptr) {
|
||||
return tmpObject;
|
||||
}
|
||||
}
|
||||
// get all subwidget "pop-up"
|
||||
for (auto &it : m_popUpWidgetList) {
|
||||
if (it != nullptr) {
|
||||
tmpObject = it->getSubObjectNamed(_objectName);
|
||||
if (tmpObject != nullptr) {
|
||||
return tmpObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
// not find ...
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void gale::widget::Windows::sysOnKill() {
|
||||
if (onKill() == true) {
|
||||
getContext().stop();
|
||||
}
|
||||
}
|
||||
|
138
gale/Windows.h
138
gale/Windows.h
@ -1,138 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GALE_WINDOWS_H__
|
||||
#define __GALE_WINDOWS_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/widget/Widget.h>
|
||||
#include <etk/Color.h>
|
||||
#include <gale/resource/ColorFile.h>
|
||||
#include <list>
|
||||
|
||||
namespace gale {
|
||||
namespace widget {
|
||||
/**
|
||||
* @brief Windows basic interface
|
||||
*/
|
||||
class Windows : public gale::Widget {
|
||||
protected:
|
||||
std::shared_ptr<gale::resource::ColorFile> m_colorProperty; //!< theme color property
|
||||
int32_t m_colorBg; //!< Default background color of the windows
|
||||
protected:
|
||||
Windows();
|
||||
void init() {
|
||||
gale::Widget::init();
|
||||
};
|
||||
public:
|
||||
virtual ~Windows();
|
||||
// internal event at gale system :
|
||||
public:
|
||||
void sysDraw();
|
||||
void sysOnShow() {};
|
||||
void sysOnHide() {};
|
||||
void sysOnKill();
|
||||
public:
|
||||
virtual void onShow() { };
|
||||
virtual void onHide() { };
|
||||
virtual bool onKill() {
|
||||
// TODO : Check this in speck for android ...
|
||||
return false;
|
||||
};
|
||||
virtual void onReduce() { };
|
||||
virtual void onStateBackground() {};
|
||||
virtual void onStateForeground() {};
|
||||
virtual void onStateSuspend() {};
|
||||
virtual void onStateResume() {};
|
||||
private:
|
||||
std::shared_ptr<gale::Widget> m_subWidget;
|
||||
std::list<std::shared_ptr<gale::Widget>> m_popUpWidgetList;
|
||||
public:
|
||||
void setSubWidget(std::shared_ptr<gale::Widget> _widget);
|
||||
void popUpWidgetPush(std::shared_ptr<gale::Widget> _widget);
|
||||
void popUpWidgetPop();
|
||||
size_t popUpCount() {
|
||||
return m_popUpWidgetList.size();
|
||||
}
|
||||
private:
|
||||
etk::Color<float> m_backgroundColor; //!< reset color of the Main windows
|
||||
public:
|
||||
/**
|
||||
* @brief get the background color.
|
||||
* @return A reference on the color
|
||||
*/
|
||||
const etk::Color<float>& getBackgroundColor() {
|
||||
return m_backgroundColor;
|
||||
};
|
||||
/**
|
||||
* @brief set the background color.
|
||||
* @param[IN] the new requested color.
|
||||
*/
|
||||
void setBackgroundColor(const etk::Color<float>& _color);
|
||||
protected: // Derived function
|
||||
virtual void systemDraw(const gale::DrawProperty& _displayProp);
|
||||
public: // Derived function
|
||||
virtual void onRegenerateDisplay();
|
||||
virtual void calculateSize(const vec2& _availlable);
|
||||
virtual std::shared_ptr<gale::Widget> getWidgetAtPos(const vec2& _pos);
|
||||
virtual void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
|
||||
virtual std::shared_ptr<gale::Object> getSubObjectNamed(const std::string& _objectName);
|
||||
void setTitle(const std::string& _title);
|
||||
public:
|
||||
enum popUpMessageType {
|
||||
messageTypeInfo, //!< information message pop-up
|
||||
messageTypeWarning, //!< warning message pop-up
|
||||
messageTypeError, //!< Error message pop-up
|
||||
messageTypeCritical //!< Critical message pop-up
|
||||
};
|
||||
/**
|
||||
* @brief Create a simple pop-up message on the screen for application error.
|
||||
* @param[in] _type Type of the error.
|
||||
* @param[in] _message message to display (decorated text)
|
||||
*/
|
||||
virtual void createPopUpMessage(enum popUpMessageType _type, const std::string& _message);
|
||||
/**
|
||||
* @brief Create a simple information message
|
||||
* @param[in] _message message to display (decorated text)
|
||||
*/
|
||||
void displayInfoMessage(const std::string& _message) {
|
||||
createPopUpMessage(messageTypeInfo, _message);
|
||||
}
|
||||
/**
|
||||
* @brief Create a simple warning message
|
||||
* @param[in] _message message to display (decorated text)
|
||||
*/
|
||||
void displayWarningMessage(const std::string& _message) {
|
||||
createPopUpMessage(messageTypeWarning, _message);
|
||||
}
|
||||
/**
|
||||
* @brief Create a simple error message
|
||||
* @param[in] _message message to display (decorated text)
|
||||
*/
|
||||
void displayErrorMessage(const std::string& _message) {
|
||||
createPopUpMessage(messageTypeError, _message);
|
||||
}
|
||||
/**
|
||||
* @brief Create a simple critical message
|
||||
* @param[in] _message message to display (decorated text)
|
||||
*/
|
||||
void displayCriticalMessage(const std::string& _message) {
|
||||
createPopUpMessage(messageTypeCritical, _message);
|
||||
}
|
||||
|
||||
|
||||
virtual bool onEventHardwareInput(const gale::key::keyboardSystem& _event, bool _down) {
|
||||
return false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -580,66 +580,48 @@ bool gale::Context::OS_Draw(bool _displayEveryTime) {
|
||||
// set the curent interface :
|
||||
lockContext();
|
||||
processEvents();
|
||||
{
|
||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
||||
if (data == nullptr) {
|
||||
GALE_ERROR("allocation error of message");
|
||||
} else {
|
||||
data->TypeMessage = eSystemMessage::msgInit;
|
||||
m_msgSystem.post(data);
|
||||
}
|
||||
}
|
||||
// call all the widget that neded to do something periodicly
|
||||
// TODO : m_objectManager.timeCall(currentTime);
|
||||
// check if the user selected a windows
|
||||
#if 0
|
||||
if (nullptr != m_windowsCurrent) {
|
||||
if (m_application != nullptr) {
|
||||
// Redraw all needed elements
|
||||
m_windowsCurrent->onRegenerateDisplay();
|
||||
m_application->onRegenerateDisplay(*this);
|
||||
needRedraw = m_application->isDrawingNeeded();
|
||||
}
|
||||
#endif
|
||||
if (m_displayFps == true) {
|
||||
m_FpsSystemEvent.incrementCounter();
|
||||
m_FpsSystemEvent.toc();
|
||||
}
|
||||
//! bool needRedraw = gale::widgetManager::isDrawingNeeded();
|
||||
// TODO : needRedraw = m_widgetManager.isDrawingNeeded();
|
||||
// release the curent interface :
|
||||
unLockContext();
|
||||
}
|
||||
bool hasDisplayDone = false;
|
||||
//! drawing section :
|
||||
//! drawing section:
|
||||
{
|
||||
// Lock openGl context:
|
||||
gale::openGL::lock();
|
||||
if (m_displayFps == true) {
|
||||
m_FpsSystemContext.tic();
|
||||
}
|
||||
#if 0
|
||||
if (nullptr != m_windowsCurrent) {
|
||||
if( true == needRedraw
|
||||
|| true == _displayEveryTime) {
|
||||
if( needRedraw == true
|
||||
|| _displayEveryTime == true) {
|
||||
m_resourceManager.updateContext();
|
||||
if (m_displayFps == true) {
|
||||
m_FpsSystemContext.incrementCounter();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (m_displayFps == true) {
|
||||
m_FpsSystemContext.toc();
|
||||
m_FpsSystem.tic();
|
||||
}
|
||||
#if 0
|
||||
if (nullptr != m_windowsCurrent) {
|
||||
if (m_application != nullptr) {
|
||||
if( true == needRedraw
|
||||
|| true == _displayEveryTime) {
|
||||
m_FpsSystem.incrementCounter();
|
||||
m_windowsCurrent->sysDraw();
|
||||
m_application->onDraw(*this);
|
||||
hasDisplayDone = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (m_displayFps == true) {
|
||||
m_FpsSystem.toc();
|
||||
m_FpsFlush.tic();
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <memory>
|
||||
#include <gale/orientation.h>
|
||||
|
||||
#define MAX_MANAGE_INPUT (15)
|
||||
|
||||
namespace gale {
|
||||
/**
|
||||
* @not-in-doc
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <gale/Application.h>
|
||||
|
||||
#define MAX_MANAGE_INPUT (15)
|
||||
|
||||
namespace gale {
|
||||
namespace context {
|
||||
|
@ -587,26 +587,26 @@ class X11Interface : public gale::Context {
|
||||
enum gale::key::keyboard keyInput;
|
||||
switch (event.xkey.keycode) {
|
||||
//case 80: // keypad
|
||||
case 111: keyInput = gale::key::keyboardUp; break;
|
||||
case 111: keyInput = gale::key::keyboard_up; break;
|
||||
//case 83: // keypad
|
||||
case 113: keyInput = gale::key::keyboardLeft; break;
|
||||
case 113: keyInput = gale::key::keyboard_left; break;
|
||||
//case 85: // keypad
|
||||
case 114: keyInput = gale::key::keyboardRight; break;
|
||||
case 114: keyInput = gale::key::keyboard_right; break;
|
||||
//case 88: // keypad
|
||||
case 116: keyInput = gale::key::keyboardDown; break;
|
||||
case 116: keyInput = gale::key::keyboard_down; break;
|
||||
//case 81: // keypad
|
||||
case 112: keyInput = gale::key::keyboardPageUp; break;
|
||||
case 112: keyInput = gale::key::keyboard_pageUp; break;
|
||||
//case 89: // keypad
|
||||
case 117: keyInput = gale::key::keyboardPageDown; break;
|
||||
case 117: keyInput = gale::key::keyboard_pageDown; break;
|
||||
//case 79: // keypad
|
||||
case 110: keyInput = gale::key::keyboardStart; break;
|
||||
case 110: keyInput = gale::key::keyboard_start; break;
|
||||
//case 87: // keypad
|
||||
case 115: keyInput = gale::key::keyboardEnd; break;
|
||||
case 78: keyInput = gale::key::keyboardStopDefil; break;
|
||||
case 127: keyInput = gale::key::keyboardWait; break;
|
||||
case 115: keyInput = gale::key::keyboard_end; break;
|
||||
case 78: keyInput = gale::key::keyboard_stopDefil; break;
|
||||
case 127: keyInput = gale::key::keyboard_wait; break;
|
||||
//case 90: // keypad
|
||||
case 118:
|
||||
keyInput = gale::key::keyboardInsert;
|
||||
keyInput = gale::key::keyboard_insert;
|
||||
if(event.type == KeyRelease) {
|
||||
if (true == m_guiKeyBoardMode.getInsert()) {
|
||||
m_guiKeyBoardMode.setInsert(false);
|
||||
@ -616,29 +616,29 @@ class X11Interface : public gale::Context {
|
||||
}
|
||||
break;
|
||||
//case 84: keyInput = gale::key::keyboardCenter; break; // Keypad
|
||||
case 67: keyInput = gale::key::keyboardF1; break;
|
||||
case 68: keyInput = gale::key::keyboardF2; break;
|
||||
case 69: keyInput = gale::key::keyboardF3; break;
|
||||
case 70: keyInput = gale::key::keyboardF4; break;
|
||||
case 71: keyInput = gale::key::keyboardF5; break;
|
||||
case 72: keyInput = gale::key::keyboardF6; break;
|
||||
case 73: keyInput = gale::key::keyboardF7; break;
|
||||
case 74: keyInput = gale::key::keyboardF8; break;
|
||||
case 75: keyInput = gale::key::keyboardF9; break;
|
||||
case 76: keyInput = gale::key::keyboardF10; break;
|
||||
case 95: keyInput = gale::key::keyboardF11; break;
|
||||
case 96: keyInput = gale::key::keyboardF12; break;
|
||||
case 66: keyInput = gale::key::keyboardCapLock; m_guiKeyBoardMode.setCapsLock( (event.type == KeyPress) ? true : false); break;
|
||||
case 50: keyInput = gale::key::keyboardShiftLeft; m_guiKeyBoardMode.setShift ( (event.type == KeyPress) ? true : false); break;
|
||||
case 62: keyInput = gale::key::keyboardShiftRight; m_guiKeyBoardMode.setShift ( (event.type == KeyPress) ? true : false); break;
|
||||
case 37: keyInput = gale::key::keyboardCtrlLeft; m_guiKeyBoardMode.setCtrl ( (event.type == KeyPress) ? true : false); break;
|
||||
case 105: keyInput = gale::key::keyboardCtrlRight; m_guiKeyBoardMode.setCtrl ( (event.type == KeyPress) ? true : false); break;
|
||||
case 133: keyInput = gale::key::keyboardMetaLeft; m_guiKeyBoardMode.setMeta ( (event.type == KeyPress) ? true : false); break;
|
||||
case 134: keyInput = gale::key::keyboardMetaRight; m_guiKeyBoardMode.setMeta ( (event.type == KeyPress) ? true : false); break;
|
||||
case 64: keyInput = gale::key::keyboardAlt; m_guiKeyBoardMode.setAlt ( (event.type == KeyPress) ? true : false); break;
|
||||
case 108: keyInput = gale::key::keyboardAltGr; m_guiKeyBoardMode.setAltGr ( (event.type == KeyPress) ? true : false); break;
|
||||
case 135: keyInput = gale::key::keyboardContextMenu; break;
|
||||
case 77: keyInput = gale::key::keyboardNumLock; m_guiKeyBoardMode.setNumLock ( (event.type == KeyPress) ? true : false); break;
|
||||
case 67: keyInput = gale::key::keyboard_f1; break;
|
||||
case 68: keyInput = gale::key::keyboard_f2; break;
|
||||
case 69: keyInput = gale::key::keyboard_f3; break;
|
||||
case 70: keyInput = gale::key::keyboard_f4; break;
|
||||
case 71: keyInput = gale::key::keyboard_f5; break;
|
||||
case 72: keyInput = gale::key::keyboard_f6; break;
|
||||
case 73: keyInput = gale::key::keyboard_f7; break;
|
||||
case 74: keyInput = gale::key::keyboard_f8; break;
|
||||
case 75: keyInput = gale::key::keyboard_f9; break;
|
||||
case 76: keyInput = gale::key::keyboard_f10; break;
|
||||
case 95: keyInput = gale::key::keyboard_f11; break;
|
||||
case 96: keyInput = gale::key::keyboard_f12; break;
|
||||
case 66: keyInput = gale::key::keyboard_capLock; m_guiKeyBoardMode.setCapsLock( (event.type == KeyPress) ? true : false); break;
|
||||
case 50: keyInput = gale::key::keyboard_shiftLeft; m_guiKeyBoardMode.setShift ( (event.type == KeyPress) ? true : false); break;
|
||||
case 62: keyInput = gale::key::keyboard_shiftRight; m_guiKeyBoardMode.setShift ( (event.type == KeyPress) ? true : false); break;
|
||||
case 37: keyInput = gale::key::keyboard_ctrlLeft; m_guiKeyBoardMode.setCtrl ( (event.type == KeyPress) ? true : false); break;
|
||||
case 105: keyInput = gale::key::keyboard_ctrlRight; m_guiKeyBoardMode.setCtrl ( (event.type == KeyPress) ? true : false); break;
|
||||
case 133: keyInput = gale::key::keyboard_metaLeft; m_guiKeyBoardMode.setMeta ( (event.type == KeyPress) ? true : false); break;
|
||||
case 134: keyInput = gale::key::keyboard_metaRight; m_guiKeyBoardMode.setMeta ( (event.type == KeyPress) ? true : false); break;
|
||||
case 64: keyInput = gale::key::keyboard_alt; m_guiKeyBoardMode.setAlt ( (event.type == KeyPress) ? true : false); break;
|
||||
case 108: keyInput = gale::key::keyboard_altGr; m_guiKeyBoardMode.setAltGr ( (event.type == KeyPress) ? true : false); break;
|
||||
case 135: keyInput = gale::key::keyboard_contextMenu; break;
|
||||
case 77: keyInput = gale::key::keyboard_numLock; m_guiKeyBoardMode.setNumLock ( (event.type == KeyPress) ? true : false); break;
|
||||
case 91: // Suppr on keypad
|
||||
find = false;
|
||||
if(m_guiKeyBoardMode.getNumLock() == true){
|
||||
|
@ -1,27 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gale/widget/Widget.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "event::Entry"
|
||||
|
||||
std::ostream& gale::event::operator <<(std::ostream& _os, const gale::event::Entry& _obj) {
|
||||
_os << "{type=" << _obj.getType();
|
||||
_os << " status=" << _obj.getStatus();
|
||||
if (_obj.getType() == gale::key::keyboardChar) {
|
||||
_os << " char=" << _obj.getChar();
|
||||
}
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& gale::event::operator <<(std::ostream& _os, const gale::event::EntrySystem& _obj) {
|
||||
_os << _obj.m_event;
|
||||
return _os;
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GALE_EVENT_ENTRY_H__
|
||||
#define __GALE_EVENT_ENTRY_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/key/key.h>
|
||||
|
||||
namespace gale {
|
||||
namespace event {
|
||||
class Entry {
|
||||
private:
|
||||
enum gale::key::keyboard m_type; //!< type of hardware event
|
||||
enum gale::key::status m_status; //!< status of hardware event
|
||||
gale::key::Special m_specialKey; //!< input key status (prevent change in time..)
|
||||
char32_t m_unicodeData; //!< Unicode data (in some case)
|
||||
public:
|
||||
Entry(enum gale::key::keyboard _type,
|
||||
enum gale::key::status _status,
|
||||
gale::key::Special _specialKey,
|
||||
char32_t _char) :
|
||||
m_type(_type),
|
||||
m_status(_status),
|
||||
m_specialKey(_specialKey),
|
||||
m_unicodeData(_char) {
|
||||
|
||||
};
|
||||
void setType(enum gale::key::keyboard _type) {
|
||||
m_type = _type;
|
||||
};
|
||||
inline const enum gale::key::keyboard& getType() const {
|
||||
return m_type;
|
||||
};
|
||||
void setStatus(enum gale::key::status _status) {
|
||||
m_status = _status;
|
||||
};
|
||||
inline const enum gale::key::status& getStatus() const {
|
||||
return m_status;
|
||||
};
|
||||
void setSpecialKey(const gale::key::Special& _specialKey) {
|
||||
m_specialKey = _specialKey;
|
||||
};
|
||||
inline const gale::key::Special& getSpecialKey() const {
|
||||
return m_specialKey;
|
||||
};
|
||||
void setChar(char32_t _char) {
|
||||
m_unicodeData = _char;
|
||||
};
|
||||
inline const char32_t& getChar() const {
|
||||
return m_unicodeData;
|
||||
};
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const gale::event::Entry& _obj);
|
||||
|
||||
class EntrySystem {
|
||||
public:
|
||||
EntrySystem(enum gale::key::keyboard _type,
|
||||
enum gale::key::status _status,
|
||||
gale::key::Special _specialKey,
|
||||
char32_t _char) :
|
||||
m_event(_type, _status, _specialKey, _char) {
|
||||
|
||||
};
|
||||
gale::event::Entry m_event;
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const gale::event::EntrySystem& _obj);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gale/widget/Widget.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "event::Input"
|
||||
|
||||
std::ostream& gale::event::operator <<(std::ostream& _os, const gale::event::Input& _obj) {
|
||||
_os << "{type=" << _obj.getType();
|
||||
_os << " status=" << _obj.getStatus();
|
||||
_os << " id=" << etk::to_string(_obj.getId());
|
||||
_os << " pos=" << _obj.getPos();
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& gale::event::operator <<(std::ostream& _os, const gale::event::InputSystem& _obj) {
|
||||
_os << _obj.m_event;
|
||||
return _os;
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GALE_EVENT_INPUT_H__
|
||||
#define __GALE_EVENT_INPUT_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace gale {
|
||||
namespace event {
|
||||
class Input {
|
||||
private:
|
||||
enum gale::key::type m_type;
|
||||
enum gale::key::status m_status;
|
||||
uint8_t m_inputId;
|
||||
vec2 m_pos;
|
||||
gale::key::Special m_specialKey; //!< input key status (prevent change in time..)
|
||||
public:
|
||||
Input(enum gale::key::type _type,
|
||||
enum gale::key::status _status,
|
||||
uint8_t _id,
|
||||
const vec2& _pos,
|
||||
gale::key::Special _specialKey):
|
||||
m_type(_type),
|
||||
m_status(_status),
|
||||
m_inputId(_id),
|
||||
m_pos(_pos),
|
||||
m_specialKey(_specialKey) {
|
||||
|
||||
};
|
||||
void setType(enum gale::key::type _type) {
|
||||
m_type = _type;
|
||||
};
|
||||
inline const enum gale::key::type& getType() const {
|
||||
return m_type;
|
||||
};
|
||||
void setStatus(enum gale::key::status _status) {
|
||||
m_status = _status;
|
||||
};
|
||||
inline const enum gale::key::status& getStatus() const {
|
||||
return m_status;
|
||||
};
|
||||
void setId(uint8_t _id) {
|
||||
m_inputId = _id;
|
||||
};
|
||||
inline const uint8_t& getId() const {
|
||||
return m_inputId;
|
||||
};
|
||||
void setPos(const vec2& _pos) {
|
||||
m_pos = _pos;
|
||||
};
|
||||
inline const vec2& getPos() const {
|
||||
return m_pos;
|
||||
};
|
||||
void setSpecialKey(const gale::key::Special& _specialKey) {
|
||||
m_specialKey = _specialKey;
|
||||
};
|
||||
inline const gale::key::Special& getSpecialKey() const {
|
||||
return m_specialKey;
|
||||
};
|
||||
/**
|
||||
* @brief Reset the input property of the curent event.
|
||||
*/
|
||||
void reset() const {
|
||||
// TODO : Call the entry element ant rest it ...
|
||||
}
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const gale::event::Input& _obj);
|
||||
|
||||
class InputSystem {
|
||||
public:
|
||||
InputSystem(enum gale::key::type _type,
|
||||
enum gale::key::status _status,
|
||||
uint8_t _id,
|
||||
const vec2& _pos,
|
||||
std::shared_ptr<gale::Widget> _dest,
|
||||
int32_t _realIdEvent,
|
||||
gale::key::Special _specialKey) :
|
||||
m_event(_type, _status, _id, _pos, _specialKey),
|
||||
m_dest(_dest),
|
||||
m_realIdEvent(_realIdEvent) { };
|
||||
gale::event::Input m_event;
|
||||
private:
|
||||
std::shared_ptr<gale::Widget> m_dest;
|
||||
int32_t m_realIdEvent;
|
||||
public:
|
||||
void setDestWidget(std::shared_ptr<gale::Widget> _dest) {
|
||||
m_dest = _dest;
|
||||
};
|
||||
inline std::shared_ptr<gale::Widget> getDestWidget() const {
|
||||
return m_dest;
|
||||
};
|
||||
void setRealId(int32_t _realIdEvent) {
|
||||
m_realIdEvent = _realIdEvent;
|
||||
};
|
||||
inline int32_t getRealId() const {
|
||||
return m_realIdEvent;
|
||||
};
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const gale::event::InputSystem& _obj);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <gale/widget/Widget.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "event::Time"
|
||||
|
||||
std::ostream& gale::event::operator <<(std::ostream& _os, const gale::event::Time& _obj) {
|
||||
_os << "{time=" << _obj.getTime();
|
||||
_os << " uptime=" << _obj.getApplUpTime();
|
||||
_os << " delta=" << _obj.getDelta();
|
||||
_os << " deltaCall=" << _obj.getDeltaCall();
|
||||
_os << "}";
|
||||
return _os;
|
||||
}
|
||||
|
||||
namespace etk {
|
||||
template<> std::string to_string<gale::event::Time>(gale::event::Time const& _obj) {
|
||||
std::string out;
|
||||
out = "{[gale::event::Time]time=" + etk::to_string(_obj.getTime());
|
||||
out += ";uptime=" + etk::to_string(_obj.getApplUpTime());
|
||||
out += ";delta=" + etk::to_string(_obj.getDelta());
|
||||
out += ";deltaCall=" + etk::to_string(_obj.getDeltaCall());
|
||||
out += "}";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __GALE_EVENT_CALL_TIME_H__
|
||||
#define __GALE_EVENT_CALL_TIME_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
|
||||
namespace gale {
|
||||
namespace event {
|
||||
class Time {
|
||||
private:
|
||||
int64_t m_timeSystem; //!< Current system time (micro-second)
|
||||
int64_t m_timeUpAppl; //!< Current application wake up-time (micro-second)
|
||||
float m_timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second)
|
||||
float m_timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second)
|
||||
public:
|
||||
Time(int64_t _timeSystem,
|
||||
int64_t _timeUpAppl,
|
||||
float _timeDelta,
|
||||
float _timeDeltaCall) :
|
||||
m_timeSystem(_timeSystem),
|
||||
m_timeUpAppl(_timeUpAppl),
|
||||
m_timeDelta(_timeDelta),
|
||||
m_timeDeltaCall(_timeDeltaCall){
|
||||
|
||||
};
|
||||
public:
|
||||
void setTime(int64_t _timeSystem) {
|
||||
m_timeSystem=_timeSystem;
|
||||
};
|
||||
inline int64_t getTime() const {
|
||||
return m_timeSystem;
|
||||
};
|
||||
void setApplWakeUpTime(int64_t _timeUpAppl) {
|
||||
m_timeUpAppl=_timeUpAppl;
|
||||
};
|
||||
inline int64_t getApplWakeUpTime() const {
|
||||
return m_timeUpAppl;
|
||||
};
|
||||
inline int64_t getApplUpTime() const {
|
||||
return m_timeSystem-m_timeUpAppl;
|
||||
};
|
||||
void setDelta(float _timeDelta) {
|
||||
m_timeDelta=_timeDelta;
|
||||
};
|
||||
inline float getDelta() const {
|
||||
return m_timeDelta;
|
||||
};
|
||||
void setDeltaCall(float _timeDeltaCall) {
|
||||
m_timeDeltaCall=_timeDeltaCall;
|
||||
};
|
||||
inline float getDeltaCall() const {
|
||||
return m_timeDeltaCall;
|
||||
};
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const gale::event::Time& _obj);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include <gale/gale.h>
|
||||
#include <gale/widget/Manager.h>
|
||||
#include <gale/context/Context.h>
|
||||
|
||||
#include <gale/context/commandLine.h>
|
||||
|
@ -25,31 +25,31 @@ gale::key::Special::Special() :
|
||||
}
|
||||
void gale::key::Special::update(enum gale::key::keyboard _move, bool _isDown) {
|
||||
switch (_move) {
|
||||
case keyboardInsert:
|
||||
case keyboard_insert:
|
||||
setInsert(_isDown);
|
||||
break;
|
||||
case keyboardCapLock:
|
||||
case keyboard_capLock:
|
||||
setCapsLock(_isDown);
|
||||
break;
|
||||
case keyboardShiftLeft:
|
||||
case keyboardShiftRight:
|
||||
case keyboard_shiftLeft:
|
||||
case keyboard_shiftRight:
|
||||
setShift(_isDown);
|
||||
break;
|
||||
case keyboardCtrlLeft:
|
||||
case keyboardCtrlRight:
|
||||
case keyboard_ctrlLeft:
|
||||
case keyboard_ctrlRight:
|
||||
setCtrl(_isDown);
|
||||
break;
|
||||
case keyboardMetaLeft:
|
||||
case keyboardMetaRight:
|
||||
case keyboard_metaLeft:
|
||||
case keyboard_metaRight:
|
||||
setMeta(_isDown);
|
||||
break;
|
||||
case keyboardAlt:
|
||||
case keyboard_alt:
|
||||
setAlt(_isDown);
|
||||
break;
|
||||
case keyboardAltGr:
|
||||
case keyboard_altGr:
|
||||
setAltGr(_isDown);
|
||||
break;
|
||||
case keyboardNumLock:
|
||||
case keyboard_numLock:
|
||||
setNumLock(_isDown);
|
||||
break;
|
||||
default:
|
||||
|
@ -6,6 +6,7 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/orientation.h>
|
||||
|
||||
static const char* listValues[] = {
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <etk/stdTools.h>
|
||||
#include <mutex>
|
||||
//#define DIRECT_MODE
|
||||
|
@ -183,6 +183,7 @@ namespace gale {
|
||||
* @brief disable Texture on the system
|
||||
* @param[in] flagID The flag requested
|
||||
*/
|
||||
// TODO : rename Disable
|
||||
void desActiveTexture(uint32_t _flagID);
|
||||
/**
|
||||
* @brief draw a specific array == > this enable mode difference ...
|
||||
|
@ -9,9 +9,8 @@
|
||||
#include <etk/types.h>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/resource/Manager.h>
|
||||
#include <gale/resource/FontFreeType.h>
|
||||
#include <gale/gale.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <gale/context/Context.h>
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <etk/types.h>
|
||||
#include <etk/math/Vector4D.h>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <gale/resource/Resource.h>
|
||||
#include <gale/resource/Shader.h>
|
||||
#include <gale/resource/VirtualBufferObject.h>
|
||||
|
@ -14,14 +14,13 @@
|
||||
#include <gale/context/Context.h>
|
||||
|
||||
|
||||
Resource() :
|
||||
gale::Resource::Resource() :
|
||||
m_id(0),
|
||||
m_resourceHasBeenInit(false),
|
||||
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
|
||||
static size_t id = 0;
|
||||
m_id = id++;
|
||||
addResourceType("gale::Resource");
|
||||
setStatusResource(true);
|
||||
};
|
||||
|
||||
void gale::Resource::init() {
|
||||
@ -33,6 +32,42 @@ void gale::Resource::init(const std::string& _name) {
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
const char * const gale::Resource::getObjectType() {
|
||||
if (m_listType.size() == 0) {
|
||||
return "gale::Resource";
|
||||
}
|
||||
return m_listType.back();
|
||||
}
|
||||
|
||||
void gale::Resource::addResourceType(const char* _type) {
|
||||
if (_type == nullptr) {
|
||||
GALE_ERROR(" try to add a type with no value...");
|
||||
return;
|
||||
}
|
||||
m_listType.push_back(_type);
|
||||
}
|
||||
std::string gale::Resource::getTypeDescription() {
|
||||
std::string ret("gale::Resource");
|
||||
for(auto element : m_listType) {
|
||||
ret += "|";
|
||||
ret += element;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool gale::Resource::isTypeCompatible(const std::string& _type) {
|
||||
if (_type == "gale::Resource") {
|
||||
return true;
|
||||
}
|
||||
for(auto element : m_listType) {
|
||||
if (_type == element) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void gale::Resource::updateContext() {
|
||||
GALE_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << shared_from_this().use_count() << " time(s)");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#define DECLARE_RESOURCE_FACTORY(className) \
|
||||
template<typename ... T> static std::shared_ptr<className> create( T&& ... all ) { \
|
||||
std::shared_ptr<className> object(new className()); \
|
||||
std::shared_ptr<className> resource(new className()); \
|
||||
if (resource == nullptr) { \
|
||||
GALE_ERROR("Factory resource error"); \
|
||||
return nullptr; \
|
||||
@ -103,9 +103,6 @@ namespace gale {
|
||||
* :** ...
|
||||
*/
|
||||
class Resource : public std::enable_shared_from_this<gale::Resource> {
|
||||
private:
|
||||
size_t m_id; //!< unique ID definition
|
||||
bool m_resourceHasBeenInit; //!< Know if the init function has bben called
|
||||
protected:
|
||||
/**
|
||||
* @brief generic protected contructor (use factory to create this class)
|
||||
@ -123,9 +120,43 @@ namespace gale {
|
||||
virtual ~Resource() {
|
||||
|
||||
};
|
||||
private:
|
||||
size_t m_id; //!< unique ID definition
|
||||
public:
|
||||
size_t getId() {
|
||||
return m_id;
|
||||
}
|
||||
private:
|
||||
bool m_resourceHasBeenInit; //!< Know if the init function has bben called
|
||||
public:
|
||||
bool resourceHasBeenCorectlyInit() {
|
||||
return m_resourceHasBeenInit;
|
||||
}
|
||||
private:
|
||||
std::vector<const char*> m_listType;
|
||||
public:
|
||||
/**
|
||||
* @brief get the current type of the Resource
|
||||
* @return the last type name of the element
|
||||
*/
|
||||
const char* const getObjectType();
|
||||
/**
|
||||
* @brief Get the herarchic of the Resource type.
|
||||
* @return descriptive string.
|
||||
*/
|
||||
std::string getTypeDescription();
|
||||
/**
|
||||
* @brief check if the element herited from a specific type
|
||||
* @param[in] _type Type to check.
|
||||
* @return true if the element is compatible.
|
||||
*/
|
||||
bool isTypeCompatible(const std::string& _type);
|
||||
protected:
|
||||
/**
|
||||
* @brief Add a type of the list of Object.
|
||||
* @param[in] _type new type to add.
|
||||
*/
|
||||
void addResourceType(const char* _type);
|
||||
protected:
|
||||
std::string m_name; //!< name of the resource ...
|
||||
public:
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <gale/resource/Resource.h>
|
||||
|
||||
namespace gale {
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/gale.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <gale/resource/Manager.h>
|
||||
#include <gale/resource/Texture.h>
|
||||
|
||||
@ -40,11 +40,14 @@ void gale::resource::Texture::init() {
|
||||
gale::Resource::init();
|
||||
}
|
||||
|
||||
gale::resource::Texture::Texture() {
|
||||
gale::resource::Texture::Texture() :
|
||||
m_texId(0),
|
||||
m_endPointSize(1,1),
|
||||
m_loaded(false),
|
||||
m_size(0,0),
|
||||
m_dataType(gale::resource::Texture::dataType_int16),
|
||||
m_dataColorSpace(gale::resource::Texture::color_mono) {
|
||||
addResourceType("gale::compositing::Texture");
|
||||
m_loaded = false;
|
||||
m_texId = 0;
|
||||
m_endPointSize.setValue(1.0,1.0);
|
||||
}
|
||||
|
||||
gale::resource::Texture::~Texture() {
|
||||
@ -68,16 +71,16 @@ void gale::resource::Texture::updateContext() {
|
||||
//--- Mode linear
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
GALE_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" <<m_texId);
|
||||
GALE_INFO("TEXTURE: add [" << getId() << "]=" << m_size << " OGl_Id=" << m_texId);
|
||||
glTexImage2D(GL_TEXTURE_2D, // Target
|
||||
0, // Level
|
||||
GL_RGBA, // Format internal
|
||||
m_data.getWidth(),
|
||||
m_data.getHeight(),
|
||||
m_size.x(),
|
||||
m_size.y(),
|
||||
0, // Border
|
||||
GL_RGBA, // format
|
||||
GL_UNSIGNED_BYTE, // type
|
||||
m_data.getTextureDataPointer() );
|
||||
&((*m_data)[0]) );
|
||||
// now the data is loaded
|
||||
m_loaded = true;
|
||||
}
|
||||
@ -101,7 +104,13 @@ void gale::resource::Texture::flush() {
|
||||
getManager().update(std::dynamic_pointer_cast<gale::Resource>(shared_from_this()));
|
||||
}
|
||||
|
||||
void gale::resource::Texture::setImageSize(ivec2 _newSize) {
|
||||
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
|
||||
m_data.resize(_newSize);
|
||||
void gale::resource::Texture::setTexture(const std::shared_ptr<std::vector<char>>& _data,
|
||||
const ivec2& _size,
|
||||
enum gale::resource::Texture::dataType _dataType,
|
||||
enum gale::resource::Texture::color _dataColorSpace) {
|
||||
m_data = _data;
|
||||
m_size = _size;
|
||||
m_dataType = _dataType;
|
||||
m_dataColorSpace = _dataColorSpace;
|
||||
// TODO : Reload ...
|
||||
}
|
||||
|
@ -11,22 +11,26 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/debug.h>
|
||||
#include <egami/Image.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <gale/resource/Resource.h>
|
||||
|
||||
namespace gale {
|
||||
namespace resource {
|
||||
class Texture : public gale::Resource {
|
||||
public:
|
||||
enum color {
|
||||
color_mono = 0, //!< Monochrome color
|
||||
color_rgb, //!< red/green/blue data
|
||||
color_rgba //!< red/green/blue/alpha data
|
||||
};
|
||||
enum dataType {
|
||||
dataType_int16 = 0, //!< Image data are stored on integer 16 bit for each element
|
||||
dataType_float, //!< Image data are stored on flaoting point value on 32 bit for each element
|
||||
};
|
||||
protected:
|
||||
// openGl Context propoerties :
|
||||
egami::Image m_data;
|
||||
// openGl textureID :
|
||||
GLuint m_texId;
|
||||
// some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0
|
||||
vec2 m_endPointSize;
|
||||
// internal state of the openGl system :
|
||||
bool m_loaded;
|
||||
GLuint m_texId; //!< openGl textureID.
|
||||
vec2 m_endPointSize; //!< some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0.
|
||||
bool m_loaded; //!< internal state of the openGl system.
|
||||
// Gale internal API:
|
||||
public:
|
||||
void updateContext();
|
||||
@ -34,14 +38,14 @@ namespace gale {
|
||||
void removeContextToLate();
|
||||
// middleware interface:
|
||||
public:
|
||||
GLuint getId() const {
|
||||
GLuint getRendererId() const {
|
||||
return m_texId;
|
||||
};
|
||||
const vec2& getUsableSize() const {
|
||||
return m_endPointSize;
|
||||
};
|
||||
const ivec2& getOpenGlSize() const {
|
||||
return m_data.getSize();
|
||||
return m_size;
|
||||
};
|
||||
// Public API:
|
||||
protected:
|
||||
@ -52,14 +56,20 @@ namespace gale {
|
||||
DECLARE_RESOURCE_FACTORY(Texture);
|
||||
virtual ~Texture();
|
||||
public:
|
||||
// you must set the size here, because it will be set in multiple of pow(2)
|
||||
void setImageSize(ivec2 newSize);
|
||||
// get the reference on this image to draw nomething on it ...
|
||||
inline egami::Image& get() {
|
||||
return m_data;
|
||||
};
|
||||
// flush the data to send it at the openGl system
|
||||
void flush();
|
||||
|
||||
private:
|
||||
// Image propoerties:
|
||||
std::shared_ptr<std::vector<char>> m_data; //!< pointer on the image data.
|
||||
ivec2 m_size; //!< size of the image data.
|
||||
enum dataType m_dataType; //!< Type of the image.
|
||||
enum color m_dataColorSpace; //!< Color space of the image.
|
||||
public:
|
||||
void setTexture(const std::shared_ptr<std::vector<char>>& _data,
|
||||
const ivec2& _size,
|
||||
enum gale::resource::Texture::dataType _dataType,
|
||||
enum gale::resource::Texture::color _dataColorSpace);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <gale/debug.h>
|
||||
#include <gale/resource/Resource.h>
|
||||
#include <gale/openGL/openGL.h>
|
||||
#include <gale/renderer/openGL/openGL.h>
|
||||
#include <etk/Color.h>
|
||||
|
||||
namespace gale {
|
||||
|
@ -67,13 +67,6 @@ def create(target):
|
||||
else:
|
||||
debug.error("unknow mode...")
|
||||
|
||||
# event properties :
|
||||
myModule.add_src_file([
|
||||
'gale/event/Entry.cpp',
|
||||
'gale/event/Time.cpp',
|
||||
'gale/event/Input.cpp'
|
||||
])
|
||||
|
||||
# Key properties :
|
||||
myModule.add_src_file([
|
||||
'gale/key/keyboard.cpp',
|
||||
|
40
sample/basic.cpp
Normal file
40
sample/basic.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <gale/gale.h>
|
||||
#include <gale/context/commandLine.h>
|
||||
|
||||
#include <gale/Application.h>
|
||||
#include <gale/context/Context.h>
|
||||
|
||||
|
||||
class MainApplication : public gale::Application {
|
||||
public:
|
||||
void onCreate(gale::Context& _context) {
|
||||
setSize(vec2(800, 600));
|
||||
std::cout << "==> Init APPL (END)" << std::endl;
|
||||
}
|
||||
void onDraw(gale::Context& _context) {
|
||||
std::cout << "Draw (start)" << std::endl;
|
||||
|
||||
std::cout << "Draw (end)" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
return gale::run(new MainApplication(), _argc, _argv);
|
||||
}
|
||||
|
||||
|
20
sample/lutin_gale-sample-basic.py
Normal file
20
sample/lutin_gale-sample-basic.py
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import lutin.tools as tools
|
||||
|
||||
def get_desc():
|
||||
return "Simple windows with gale"
|
||||
|
||||
def create(target):
|
||||
myModule = module.Module(__file__, 'gale-sample-basic', 'BINARY')
|
||||
# add the file to compile:
|
||||
myModule.add_src_file([
|
||||
'basic.cpp'
|
||||
])
|
||||
# add dependency of gale
|
||||
myModule.add_module_depend(['gale'])
|
||||
return myModule
|
||||
|
||||
|
||||
|
||||
|
BIN
sample/lutin_gale-sample-basic.pyc
Normal file
BIN
sample/lutin_gale-sample-basic.pyc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user