[DEV] rework to record event in the main loop
This commit is contained in:
parent
5c5a3d7dee
commit
718b0b0964
@ -76,39 +76,6 @@ void gale::Context::unLockContext() {
|
|||||||
mutexInterface().unlock();
|
mutexInterface().unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace gale {
|
|
||||||
class eSystemMessage {
|
|
||||||
public :
|
|
||||||
// can not set a union ...
|
|
||||||
enum gale::context::clipBoard::clipboardListe clipboardID;
|
|
||||||
// InputId
|
|
||||||
enum gale::key::type inputType;
|
|
||||||
int32_t inputId;
|
|
||||||
// generic dimentions
|
|
||||||
vec2 dimention;
|
|
||||||
// keyboard events :
|
|
||||||
bool repeateKey; //!< special flag for the repeating key on the PC interface
|
|
||||||
bool stateIsDown;
|
|
||||||
char32_t keyboardChar;
|
|
||||||
enum gale::key::keyboard keyboardMove;
|
|
||||||
gale::key::Special keyboardSpecial;
|
|
||||||
|
|
||||||
eSystemMessage() :
|
|
||||||
clipboardID(gale::context::clipBoard::clipboardStd),
|
|
||||||
inputType(gale::key::type_unknow),
|
|
||||||
inputId(-1),
|
|
||||||
dimention(0,0),
|
|
||||||
repeateKey(false),
|
|
||||||
stateIsDown(false),
|
|
||||||
keyboardChar(0),
|
|
||||||
keyboardMove(gale::key::keyboard_unknow)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void gale::Context::inputEventTransfertWidget(std::shared_ptr<gale::Widget> _source,
|
void gale::Context::inputEventTransfertWidget(std::shared_ptr<gale::Widget> _source,
|
||||||
std::shared_ptr<gale::Widget> _destination) {
|
std::shared_ptr<gale::Widget> _destination) {
|
||||||
@ -128,25 +95,21 @@ void gale::Context::inputEventUnGrabPointer() {
|
|||||||
void gale::Context::processEvents() {
|
void gale::Context::processEvents() {
|
||||||
int32_t nbEvent = 0;
|
int32_t nbEvent = 0;
|
||||||
//GALE_DEBUG(" ******** Event");
|
//GALE_DEBUG(" ******** Event");
|
||||||
gale::eSystemMessage* data = nullptr;
|
std::shared_ptr<gale::context::LoopAction> data;
|
||||||
while (m_msgSystem.count()>0) {
|
while (m_msgSystem.count()>0) {
|
||||||
nbEvent++;
|
nbEvent++;
|
||||||
if (data != nullptr) {
|
|
||||||
delete(data);
|
|
||||||
data = nullptr;
|
|
||||||
}
|
|
||||||
m_msgSystem.wait(data);
|
m_msgSystem.wait(data);
|
||||||
//GALE_DEBUG("EVENT");
|
if (data == nullptr) {
|
||||||
switch (data->TypeMessage) {
|
continue;
|
||||||
case eSystemMessage::msgClipboardArrive:
|
|
||||||
{
|
|
||||||
std::shared_ptr<gale::Application> appl = m_application;
|
|
||||||
if (appl != nullptr) {
|
|
||||||
appl->onClipboardEvent(data->clipboardID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (m_imulationActive == true) {
|
||||||
|
std::string dataExecuted = data->createString();
|
||||||
|
m_simulationFile.filePuts(dataExecuted);
|
||||||
|
m_simulationFile.filePuts("\n");
|
||||||
|
GALE_VERBOSE("plop: " + dataExecuted);
|
||||||
|
}
|
||||||
|
data->doAction(*this);
|
||||||
|
data.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +141,8 @@ void gale::Context::setArchiveDir(int _mode, const char* _str) {
|
|||||||
gale::Context::Context(gale::Application* _application, int32_t _argc, const char* _argv[]) :
|
gale::Context::Context(gale::Application* _application, int32_t _argc, const char* _argv[]) :
|
||||||
//m_application(std::make_shared<gale::Application>(_application)),
|
//m_application(std::make_shared<gale::Application>(_application)),
|
||||||
m_application(_application),
|
m_application(_application),
|
||||||
|
m_imulationActive(false),
|
||||||
|
m_simulationFile("gale.gsim"),
|
||||||
//m_objectManager(*this),
|
//m_objectManager(*this),
|
||||||
m_previousDisplayTime(0),
|
m_previousDisplayTime(0),
|
||||||
// TODO : m_input(*this),
|
// TODO : m_input(*this),
|
||||||
@ -211,9 +176,9 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
|||||||
if (m_commandLine.get(iii) == "--gale-fps") {
|
if (m_commandLine.get(iii) == "--gale-fps") {
|
||||||
m_displayFps=true;
|
m_displayFps=true;
|
||||||
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-file=") == true) {
|
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-file=") == true) {
|
||||||
|
m_simulationFile.setName(std::string(m_commandLine.get(iii).begin()+23, m_commandLine.get(iii).end()) );
|
||||||
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-mode=") == true) {
|
} else if (etk::start_with(m_commandLine.get(iii), "--gale-simulation-mode=") == true) {
|
||||||
|
m_imulationActive = true;
|
||||||
} else if (m_commandLine.get(iii) == "--gale-simulation-stop") {
|
} else if (m_commandLine.get(iii) == "--gale-simulation-stop") {
|
||||||
|
|
||||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||||
@ -226,7 +191,7 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
|||||||
GALE_PRINT("gale - help : ");
|
GALE_PRINT("gale - help : ");
|
||||||
GALE_PRINT(" " << etk::getApplicationName() << " [options]");
|
GALE_PRINT(" " << etk::getApplicationName() << " [options]");
|
||||||
GALE_PRINT(" --gale-simulation-file=XXX.gsim");
|
GALE_PRINT(" --gale-simulation-file=XXX.gsim");
|
||||||
GALE_PRINT(" Enable the simulation mode of the gale IO, parameter: file (default:simulation Gale.gsim)");
|
GALE_PRINT(" Enable the simulation mode of the gale IO, parameter: file (default:simulation gale.gsim)");
|
||||||
GALE_PRINT(" --gale-simulation-mode=XXX");
|
GALE_PRINT(" --gale-simulation-mode=XXX");
|
||||||
GALE_PRINT(" Mode of the simulation");
|
GALE_PRINT(" Mode of the simulation");
|
||||||
GALE_PRINT(" - record Record all input of the playing element (default)");
|
GALE_PRINT(" - record Record all input of the playing element (default)");
|
||||||
@ -273,6 +238,10 @@ gale::Context::Context(gale::Application* _application, int32_t _argc, const cha
|
|||||||
#else
|
#else
|
||||||
forceOrientation(gale::orientation_screenAuto);
|
forceOrientation(gale::orientation_screenAuto);
|
||||||
#endif
|
#endif
|
||||||
|
if (m_imulationActive == true) {
|
||||||
|
// in simulation case:
|
||||||
|
m_simulationFile.fileOpenWrite();
|
||||||
|
}
|
||||||
// release the curent interface :
|
// release the curent interface :
|
||||||
unLockContext();
|
unLockContext();
|
||||||
GALE_INFO(" == > Gale system init (END)");
|
GALE_INFO(" == > Gale system init (END)");
|
||||||
@ -305,6 +274,10 @@ gale::Context::~Context() {
|
|||||||
// release the curent interface :
|
// release the curent interface :
|
||||||
unLockContext();
|
unLockContext();
|
||||||
GALE_INFO(" == > Gale system Un-Init (END)");
|
GALE_INFO(" == > Gale system Un-Init (END)");
|
||||||
|
if (m_imulationActive == true) {
|
||||||
|
// in simulation case:
|
||||||
|
m_simulationFile.fileClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gale::Context::requestUpdateSize() {
|
void gale::Context::requestUpdateSize() {
|
||||||
@ -366,7 +339,7 @@ void gale::Context::OS_SetKeyboard(gale::key::Special& _special,
|
|||||||
state = gale::key::status_upRepeate;
|
state = gale::key::status_upRepeate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionKeyboard>(_special
|
m_msgSystem.post(std::make_shared<gale::context::LoopActionKeyboard>(_special,
|
||||||
gale::key::keyboard_char,
|
gale::key::keyboard_char,
|
||||||
state,
|
state,
|
||||||
_myChar));
|
_myChar));
|
||||||
@ -384,7 +357,7 @@ void gale::Context::OS_SetKeyboardMove(gale::key::Special& _special,
|
|||||||
state = gale::key::status_upRepeate;
|
state = gale::key::status_upRepeate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_msgSystem.post(std::make_shared<gale::context::LoopActionKeyboard>(_special
|
m_msgSystem.post(std::make_shared<gale::context::LoopActionKeyboard>(_special,
|
||||||
_move,
|
_move,
|
||||||
state));
|
state));
|
||||||
}
|
}
|
||||||
@ -399,14 +372,7 @@ void gale::Context::OS_Show() {
|
|||||||
|
|
||||||
|
|
||||||
void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID) {
|
void gale::Context::OS_ClipBoardArrive(enum gale::context::clipBoard::clipboardListe _clipboardID) {
|
||||||
gale::eSystemMessage *data = new gale::eSystemMessage();
|
m_msgSystem.post(std::make_shared<gale::context::LoopActionClipboardArrive>(_clipboardID));
|
||||||
if (data == nullptr) {
|
|
||||||
GALE_ERROR("allocationerror of message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
data->TypeMessage = eSystemMessage::msgClipboardArrive;
|
|
||||||
data->clipboardID = _clipboardID;
|
|
||||||
m_msgSystem.post(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gale::Context::clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
|
void gale::Context::clipBoardGet(enum gale::context::clipBoard::clipboardListe _clipboardID) {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define __GALE_CONTEXT_H__
|
#define __GALE_CONTEXT_H__
|
||||||
|
|
||||||
#include <etk/os/Fifo.h>
|
#include <etk/os/Fifo.h>
|
||||||
|
#include <etk/os/FSNode.h>
|
||||||
#include <gale/debug.h>
|
#include <gale/debug.h>
|
||||||
#include <gale/gale.h>
|
#include <gale/gale.h>
|
||||||
#include <gale/key/key.h>
|
#include <gale/key/key.h>
|
||||||
@ -22,15 +23,13 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <gale/orientation.h>
|
#include <gale/orientation.h>
|
||||||
#include <gale/context/clipBoard.h>
|
#include <gale/context/clipBoard.h>
|
||||||
|
#include <gale/context/LoopAction.h>
|
||||||
|
|
||||||
#define MAX_MANAGE_INPUT (15)
|
#define MAX_MANAGE_INPUT (15)
|
||||||
|
|
||||||
namespace gale {
|
namespace gale {
|
||||||
/**
|
|
||||||
* @not-in-doc
|
|
||||||
*/
|
|
||||||
class eSystemMessage;
|
|
||||||
class Context/* : private gale::object::RemoveEvent */{
|
class Context/* : private gale::object::RemoveEvent */{
|
||||||
|
friend gale::context::LoopActionResize;
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<gale::Application> m_application; //!< Application handle
|
std::shared_ptr<gale::Application> m_application; //!< Application handle
|
||||||
public:
|
public:
|
||||||
@ -63,10 +62,14 @@ namespace gale {
|
|||||||
* @note this un-lock the main mutex
|
* @note this un-lock the main mutex
|
||||||
*/
|
*/
|
||||||
void unLockContext();
|
void unLockContext();
|
||||||
|
private:
|
||||||
|
// simulation area:
|
||||||
|
bool m_imulationActive;
|
||||||
|
etk::FSNode m_simulationFile;
|
||||||
private:
|
private:
|
||||||
int64_t m_previousDisplayTime; // this is to limit framerate ... in case...
|
int64_t m_previousDisplayTime; // this is to limit framerate ... in case...
|
||||||
// TODO : gale::context::InputManager m_input;
|
// TODO : gale::context::InputManager m_input;
|
||||||
etk::Fifo<gale::eSystemMessage*> m_msgSystem;
|
etk::Fifo<std::shared_ptr<gale::context::LoopAction> > m_msgSystem;
|
||||||
bool m_displayFps;
|
bool m_displayFps;
|
||||||
gale::context::Fps m_FpsSystemEvent;
|
gale::context::Fps m_FpsSystemEvent;
|
||||||
gale::context::Fps m_FpsSystemContext;
|
gale::context::Fps m_FpsSystemContext;
|
||||||
|
@ -6,6 +6,24 @@
|
|||||||
* @license APACHE v2.0 (see license file)
|
* @license APACHE v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <etk/etk.h>
|
||||||
|
|
||||||
|
#include <etk/tool.h>
|
||||||
|
#include <etk/os/Fifo.h>
|
||||||
|
#include <etk/Hash.h>
|
||||||
|
#include <etk/thread/tools.h>
|
||||||
|
#include <mutex>
|
||||||
|
#include <date/date.h>
|
||||||
|
#include <gale/gale.h>
|
||||||
|
#include <gale/Dimension.h>
|
||||||
|
#include <gale/debug.h>
|
||||||
|
|
||||||
|
#include <gale/context/LoopAction.h>
|
||||||
|
#include <gale/context/Context.h>
|
||||||
|
|
||||||
etk::Hash<std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> >& getList() {
|
etk::Hash<std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> >& getList() {
|
||||||
static etk::Hash<std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> > list;
|
static etk::Hash<std::function<std::shared_ptr<gale::context::LoopAction>(const std::string&)> > list;
|
||||||
return list;
|
return list;
|
||||||
@ -30,7 +48,7 @@ void gale::context::addFactory(const std::string& _type, const std::function<std
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Keep name in lower case :
|
//Keep name in lower case :
|
||||||
std::string nameLower = etk::tolower(_name);
|
std::string nameLower = etk::tolower(_type);
|
||||||
if (true == getList().exist(nameLower)) {
|
if (true == getList().exist(nameLower)) {
|
||||||
GALE_WARNING("Replace Creator of a loop action : " << nameLower);
|
GALE_WARNING("Replace Creator of a loop action : " << nameLower);
|
||||||
getList()[nameLower] = _func;
|
getList()[nameLower] = _func;
|
||||||
@ -48,18 +66,24 @@ gale::context::LoopAction::~LoopAction() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void gale::context::LoopActionInit::doAction(gale::Context& _context) {
|
void gale::context::LoopActionInit::doAction(gale::Context& _context) {
|
||||||
|
std::shared_ptr<gale::Application> appl = _context.getApplication();
|
||||||
// this is due to the openGL context
|
// this is due to the openGL context
|
||||||
if (_context.m_application == nullptr) {
|
if (appl == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_context.m_application->onCreate(*this);
|
appl->onCreate(_context);
|
||||||
_context.m_application->onStart(*this);
|
appl->onStart(_context);
|
||||||
_context.m_application->onResume(*this);
|
appl->onResume(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionInit::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":INIT";
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
gale::context::LoopActionResize::LoopActionResize(const vec2& _size) :
|
gale::context::LoopActionResize::LoopActionResize(const vec2& _size) :
|
||||||
m_size(_size) {
|
m_size(_size) {
|
||||||
|
|
||||||
@ -72,10 +96,35 @@ void gale::context::LoopActionResize::doAction(gale::Context& _context) {
|
|||||||
_context.forceRedrawAll();
|
_context.forceRedrawAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionResize::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":RESIZE:" + etk::to_string(m_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
gale::context::LoopActionView::LoopActionView(bool _show) :
|
||||||
|
m_show(_show) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void gale::context::LoopActionView::doAction(gale::Context& _context) {
|
||||||
|
GALE_TODO("kjhkjhkhkjh");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionView::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":VIEW:" + etk::to_string(m_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void gale::context::LoopActionRecalculateSize::doAction(gale::Context& _context) {
|
void gale::context::LoopActionRecalculateSize::doAction(gale::Context& _context) {
|
||||||
_context.forceRedrawAll();
|
_context.forceRedrawAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionRecalculateSize::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":RECALCULATE_SIZE";
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
gale::context::LoopActionInput::LoopActionInput(enum gale::key::type _type,
|
gale::context::LoopActionInput::LoopActionInput(enum gale::key::type _type,
|
||||||
enum gale::key::status _status,
|
enum gale::key::status _status,
|
||||||
int32_t _pointerID,
|
int32_t _pointerID,
|
||||||
@ -88,15 +137,22 @@ gale::context::LoopActionInput::LoopActionInput(enum gale::key::type _type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gale::context::LoopActionInput::doAction(gale::Context& _context) {
|
void gale::context::LoopActionInput::doAction(gale::Context& _context) {
|
||||||
if (_context.m_application == nullptr) {
|
std::shared_ptr<gale::Application> appl = _context.getApplication();
|
||||||
|
if (appl == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_context.m_application->onPointer(m_type,
|
appl->onPointer(m_type,
|
||||||
m_pointerID,
|
m_pointerID,
|
||||||
m_pos,
|
m_pos,
|
||||||
m_status);
|
m_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionInput::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":INPUT:" + etk::to_string(m_type) + ":" + etk::to_string(m_status) + ":" + etk::to_string(m_pointerID) + ":" + etk::to_string(m_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
gale::context::LoopActionKeyboard::LoopActionKeyboard(const gale::key::Special& _special,
|
gale::context::LoopActionKeyboard::LoopActionKeyboard(const gale::key::Special& _special,
|
||||||
enum gale::key::keyboard _type,
|
enum gale::key::keyboard _type,
|
||||||
enum gale::key::status _state,
|
enum gale::key::status _state,
|
||||||
@ -109,11 +165,38 @@ gale::context::LoopActionKeyboard::LoopActionKeyboard(const gale::key::Special&
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gale::context::LoopActionKeyboard::doAction(gale::Context& _context) {
|
void gale::context::LoopActionKeyboard::doAction(gale::Context& _context) {
|
||||||
if (_context.m_application == nullptr) {
|
std::shared_ptr<gale::Application> appl = _context.getApplication();
|
||||||
|
if (appl == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_context.m_application->onKeyboard(m_special,
|
appl->onKeyboard(m_special,
|
||||||
m_type,
|
m_type,
|
||||||
m_char,
|
m_char,
|
||||||
m_state);
|
m_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionKeyboard::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":KEYBOARD:" + etk::to_string(m_special) + ":" + etk::to_string(m_type) + ":" + etk::to_string(m_state) + ":" + etk::to_string(uint64_t(m_char));
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
gale::context::LoopActionClipboardArrive::LoopActionClipboardArrive(enum gale::context::clipBoard::clipboardListe _id) :
|
||||||
|
m_id(_id) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void gale::context::LoopActionClipboardArrive::doAction(gale::Context& _context) {
|
||||||
|
std::shared_ptr<gale::Application> appl = _context.getApplication();
|
||||||
|
if (appl != nullptr) {
|
||||||
|
appl->onClipboardEvent(m_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string gale::context::LoopActionClipboardArrive::createString() {
|
||||||
|
return etk::to_string(m_timestamp) + ":CLIPBOARD_ARRIVE:" + etk::to_string(m_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,25 +14,10 @@
|
|||||||
#include <gale/gale.h>
|
#include <gale/gale.h>
|
||||||
#include <gale/key/key.h>
|
#include <gale/key/key.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
m_timestamp
|
|
||||||
#define MAX_MANAGE_INPUT (15)
|
#define MAX_MANAGE_INPUT (15)
|
||||||
|
|
||||||
namespace gale {
|
namespace gale {
|
||||||
namespace context {
|
namespace context {
|
||||||
/**
|
|
||||||
* @brief Create action from the simulation string line
|
|
||||||
* @param[in] _lineToParse Simulation string line
|
|
||||||
* @return Created action.
|
|
||||||
*/
|
|
||||||
std::shared_ptr<LoopAction> createAction(const std::string& _lineToParse);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Add a factory to create an event from a specific type
|
|
||||||
* @param[in] _type Type of the action
|
|
||||||
* @param[in] _func function to call to create
|
|
||||||
* @return Created action.
|
|
||||||
*/
|
|
||||||
void addFactory(const std::string& _type, const std::function<std::shared_ptr<LoopAction>(const std::string&)>& _func);
|
|
||||||
|
|
||||||
class LoopAction : public std::enable_shared_from_this<LoopAction> {
|
class LoopAction : public std::enable_shared_from_this<LoopAction> {
|
||||||
protected:
|
protected:
|
||||||
@ -41,35 +26,66 @@ namespace gale {
|
|||||||
LoopAction();
|
LoopAction();
|
||||||
virtual ~LoopAction();
|
virtual ~LoopAction();
|
||||||
virtual void doAction(gale::Context& _context) = 0;
|
virtual void doAction(gale::Context& _context) = 0;
|
||||||
virtual std::string createString() { return "" };
|
virtual std::string createString() = 0;
|
||||||
}
|
};
|
||||||
|
/**
|
||||||
|
* @brief Create action from the simulation string line
|
||||||
|
* @param[in] _lineToParse Simulation string line
|
||||||
|
* @return Created action.
|
||||||
|
*/
|
||||||
|
std::shared_ptr<LoopAction> createAction(const std::string& _lineToParse);
|
||||||
|
/**
|
||||||
|
* @brief Add a factory to create an event from a specific type
|
||||||
|
* @param[in] _type Type of the action
|
||||||
|
* @param[in] _func function to call to create
|
||||||
|
* @return Created action.
|
||||||
|
*/
|
||||||
|
void addFactory(const std::string& _type, const std::function<std::shared_ptr<LoopAction>(const std::string&)>& _func);
|
||||||
|
|
||||||
class LoopActionInit : public LoopAction {
|
class LoopActionInit : public LoopAction {
|
||||||
public:
|
public:
|
||||||
LoopActionInit() {};
|
LoopActionInit() {};
|
||||||
virtual void doAction(gale::Context& _context);
|
virtual void doAction(gale::Context& _context);
|
||||||
}
|
virtual std::string createString();
|
||||||
|
};
|
||||||
|
|
||||||
class LoopActionResize : public LoopAction {
|
class LoopActionResize : public LoopAction {
|
||||||
protected:
|
protected:
|
||||||
vec2 m_size;
|
vec2 m_size;
|
||||||
public:
|
public:
|
||||||
LoopActionResize(const vec2& _size);
|
LoopActionResize(const vec2& _size);
|
||||||
virtual void doAction(gale::Context& _context);
|
virtual void doAction(gale::Context& _context);
|
||||||
}
|
virtual std::string createString();
|
||||||
|
};
|
||||||
|
|
||||||
|
class LoopActionView : public LoopAction {
|
||||||
|
protected:
|
||||||
|
bool m_show;
|
||||||
|
public:
|
||||||
|
LoopActionView(bool _show);
|
||||||
|
virtual void doAction(gale::Context& _context);
|
||||||
|
virtual std::string createString();
|
||||||
|
};
|
||||||
|
|
||||||
class LoopActionRecalculateSize : public LoopAction {
|
class LoopActionRecalculateSize : public LoopAction {
|
||||||
public:
|
public:
|
||||||
LoopActionRecalculateSize() {};
|
LoopActionRecalculateSize() {};
|
||||||
virtual void doAction(gale::Context& _context);
|
virtual void doAction(gale::Context& _context);
|
||||||
}
|
virtual std::string createString();
|
||||||
|
};
|
||||||
|
|
||||||
class LoopActionInput : public LoopAction {
|
class LoopActionInput : public LoopAction {
|
||||||
private:
|
private:
|
||||||
enum gale::key::type m_type;
|
enum gale::key::type m_type;
|
||||||
enum gale::key::status m_statusm
|
enum gale::key::status m_status;
|
||||||
int32_t m_pointerID;
|
int32_t m_pointerID;
|
||||||
const vec2& m_pos;
|
const vec2& m_pos;
|
||||||
public:
|
public:
|
||||||
LoopActionInput(enum gale::key::type _type, enum gale::key::status _status, int32_t _pointerID, const vec2& _pos);
|
LoopActionInput(enum gale::key::type _type, enum gale::key::status _status, int32_t _pointerID, const vec2& _pos);
|
||||||
virtual void doAction(gale::Context& _context);
|
virtual void doAction(gale::Context& _context);
|
||||||
}
|
virtual std::string createString();
|
||||||
|
};
|
||||||
|
|
||||||
class LoopActionKeyboard : public LoopAction {
|
class LoopActionKeyboard : public LoopAction {
|
||||||
private:
|
private:
|
||||||
gale::key::Special m_special;
|
gale::key::Special m_special;
|
||||||
@ -79,7 +95,17 @@ namespace gale {
|
|||||||
public:
|
public:
|
||||||
LoopActionKeyboard(const gale::key::Special& _special, enum gale::key::keyboard _type, enum gale::key::status _state, char32_t _char=u32char::Null);
|
LoopActionKeyboard(const gale::key::Special& _special, enum gale::key::keyboard _type, enum gale::key::status _state, char32_t _char=u32char::Null);
|
||||||
virtual void doAction(gale::Context& _context);
|
virtual void doAction(gale::Context& _context);
|
||||||
}
|
virtual std::string createString();
|
||||||
|
};
|
||||||
|
|
||||||
|
class LoopActionClipboardArrive : public LoopAction {
|
||||||
|
private:
|
||||||
|
enum gale::context::clipBoard::clipboardListe m_id;
|
||||||
|
public:
|
||||||
|
LoopActionClipboardArrive(enum gale::context::clipBoard::clipboardListe _id);
|
||||||
|
virtual void doAction(gale::Context& _context);
|
||||||
|
virtual std::string createString();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,11 @@ std::ostream& gale::operator <<(std::ostream& _os, const enum gale::context::cli
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<enum gale::context::clipBoard::clipboardListe>(const enum gale::context::clipBoard::clipboardListe& _obj) {
|
||||||
|
return clipboardDescriptionString[_obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gale::context::clipBoard::init() {
|
void gale::context::clipBoard::init() {
|
||||||
GALE_INFO("Initialyse ClipBoards");
|
GALE_INFO("Initialyse ClipBoards");
|
||||||
|
@ -201,7 +201,7 @@ void gale::key::Special::setInsert(bool _value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& gale::key::operator <<(std::ostream& _os, const gale::key::Special _obj) {
|
std::ostream& gale::key::operator <<(std::ostream& _os, const gale::key::Special& _obj) {
|
||||||
_os << " capLock=" << _obj.getCapsLock();
|
_os << " capLock=" << _obj.getCapsLock();
|
||||||
_os << " shift=" << _obj.getShift();
|
_os << " shift=" << _obj.getShift();
|
||||||
_os << " ctrl=" << _obj.getCtrl();
|
_os << " ctrl=" << _obj.getCtrl();
|
||||||
@ -212,3 +212,55 @@ std::ostream& gale::key::operator <<(std::ostream& _os, const gale::key::Special
|
|||||||
_os << " insert=" << _obj.getInsert();
|
_os << " insert=" << _obj.getInsert();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<gale::key::Special>(const gale::key::Special& _obj) {
|
||||||
|
std::string out;
|
||||||
|
if (_obj.getCapsLock() == true) {
|
||||||
|
out = "CAPS";
|
||||||
|
}
|
||||||
|
if (_obj.getShift() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "SHIFT";
|
||||||
|
}
|
||||||
|
if (_obj.getCtrl() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "CTRL";
|
||||||
|
}
|
||||||
|
if (_obj.getMeta() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "META";
|
||||||
|
}
|
||||||
|
if (_obj.getAlt() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "ALT";
|
||||||
|
}
|
||||||
|
if (_obj.getAltGr() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "ALTGR";
|
||||||
|
}
|
||||||
|
if (_obj.getNumLock() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "NUM_LOCK";
|
||||||
|
}
|
||||||
|
if (_obj.getInsert() == true) {
|
||||||
|
if (out.size() > 0) {
|
||||||
|
out += "|";
|
||||||
|
}
|
||||||
|
out = "INSERT";
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
@ -112,7 +112,7 @@ namespace gale {
|
|||||||
*/
|
*/
|
||||||
void update(enum gale::key::keyboard _move, bool _isDown);
|
void update(enum gale::key::keyboard _move, bool _isDown);
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream& _os, const gale::key::Special _obj);
|
std::ostream& operator <<(std::ostream& _os, const gale::key::Special& _obj);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,3 +60,10 @@ std::ostream& gale::key::operator <<(std::ostream& _os, const enum gale::key::ke
|
|||||||
_os << keyboardDescriptionString[_obj];
|
_os << keyboardDescriptionString[_obj];
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<enum gale::key::keyboard>(const enum gale::key::keyboard& _obj) {
|
||||||
|
return keyboardDescriptionString[_obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -32,4 +32,9 @@ std::ostream& gale::key::operator <<(std::ostream& _os, const enum gale::key::st
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<enum gale::key::status>(const enum gale::key::status& _obj) {
|
||||||
|
return statusDescriptionString[_obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -21,3 +21,8 @@ std::ostream& gale::operator <<(std::ostream& _os, const enum gale::key::type _o
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<enum gale::key::type>(const enum gale::key::type& _obj) {
|
||||||
|
return typeDescriptionString[_obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -947,7 +947,7 @@ int32_t gale::openGL::program::getUniformLocation(int64_t _prog, const std::stri
|
|||||||
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
#ifdef GALE_SIMULATION_OPENGL_AVAILLABLE
|
||||||
if (s_simulationMode == false) {
|
if (s_simulationMode == false) {
|
||||||
#endif
|
#endif
|
||||||
GLint val = glGetUniformLocation(GLuint(_prog), _name.c_str());
|
val = glGetUniformLocation(GLuint(_prog), _name.c_str());
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
checkGlError("glGetUniformLocation", __LINE__);
|
checkGlError("glGetUniformLocation", __LINE__);
|
||||||
GALE_WARNING("glGetUniformLocation(\"" << _name << "\") = " << val);
|
GALE_WARNING("glGetUniformLocation(\"" << _name << "\") = " << val);
|
||||||
|
@ -32,6 +32,7 @@ def create(target):
|
|||||||
'gale/context/commandLine.cpp',
|
'gale/context/commandLine.cpp',
|
||||||
'gale/context/Context.cpp',
|
'gale/context/Context.cpp',
|
||||||
'gale/context/cursor.cpp',
|
'gale/context/cursor.cpp',
|
||||||
|
'gale/context/LoopAction.cpp',
|
||||||
#'gale/context/InputManager.cpp'
|
#'gale/context/InputManager.cpp'
|
||||||
])
|
])
|
||||||
if target.name=="Linux":
|
if target.name=="Linux":
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user