edn/sources/appl/global.cpp

201 lines
6.4 KiB
C++
Raw Normal View History

2016-05-02 22:01:55 +02:00
/** @file
* @author Edouard DUPIN
2012-11-25 11:55:06 +01:00
* @copyright 2010, Edouard DUPIN, all right reserved
* @license GPL v3 (see license file)
*/
2012-04-24 09:42:14 +02:00
#include <appl/global.h>
#include <appl/globalMsg.h>
2013-12-13 21:50:40 +01:00
#include <ewol/object/Object.h>
#include <ewol/context/Context.h>
#include <gale/resource/Manager.h>
2012-11-06 18:08:44 +01:00
#include <etk/os/FSNode.h>
2013-12-13 21:50:40 +01:00
class myParamGlobal : public ewol::Object {
2013-05-28 22:09:53 +02:00
public:
eproperty::Value<bool> m_displayEOL;
eproperty::Value<bool> m_AutoIndent;
eproperty::Value<bool> m_displayTabChar;
eproperty::Value<bool> m_displaySpaceChar;
2013-05-28 22:09:53 +02:00
public :
2014-08-13 22:30:47 +02:00
myParamGlobal() :
2016-03-02 21:51:44 +01:00
m_displayEOL(this, "eol", false, "Display end of line character"),
m_AutoIndent(this, "auto-indent", true, "Auto indent when create new line"),
m_displayTabChar(this, "display-tab", true, "Display the Tab char"),
m_displaySpaceChar(this, "display-space", true, "Display the space char") {
2013-10-07 22:04:21 +02:00
m_static = true; // Note : set the object static notification( Must be set or assert at the end of process)
2016-02-15 22:04:10 +01:00
propertyName.set("edn_global_param");
2013-05-28 22:09:53 +02:00
}
};
static myParamGlobal& l_obj() {
2013-05-28 22:09:53 +02:00
static myParamGlobal s_obj;
return s_obj;
}
void globals::init() {
2013-10-07 22:04:21 +02:00
//ewol::userConfig::addUserConfig(&l_obj());
}
void globals::UnInit() {
2013-05-28 22:09:53 +02:00
// nothing to do ...
//ewol::userConfig::RmUserConfig(&l_obj());
}
// -----------------------------------------------------------
bool globals::isSetDisplayEndOfLine() {
2013-05-28 22:09:53 +02:00
return l_obj().m_displayEOL;
}
2013-10-09 22:00:24 +02:00
void globals::setDisplayEndOfLine(bool newVal) {
2016-02-24 22:31:46 +01:00
l_obj().m_displayEOL.set(newVal);
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
bool globals::isSetDisplaySpaceChar() {
2013-05-28 22:09:53 +02:00
return l_obj().m_displaySpaceChar;
}
2013-10-09 22:00:24 +02:00
void globals::setDisplaySpaceChar(bool _newVal) {
2016-02-24 22:31:46 +01:00
l_obj().m_displaySpaceChar.set(_newVal);
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
2012-07-23 17:21:44 +02:00
// -----------------------------------------------------------
bool globals::isSetDisplayTabChar() {
2013-05-28 22:09:53 +02:00
return l_obj().m_displayTabChar;
2012-07-23 17:21:44 +02:00
}
2013-10-09 22:00:24 +02:00
void globals::setDisplayTabChar(bool _newVal) {
2016-02-24 22:31:46 +01:00
l_obj().m_displayTabChar.set(_newVal);
2012-07-23 17:21:44 +02:00
//ewol::widgetMessageMultiCast::Send(-1, ednMsgUserDisplayChange);
}
// -----------------------------------------------------------
bool globals::isSetAutoIndent() {
2013-05-28 22:09:53 +02:00
return l_obj().m_AutoIndent;
}
2013-10-09 22:00:24 +02:00
void globals::setAutoIndent(bool _newVal) {
2016-02-24 22:31:46 +01:00
l_obj().m_AutoIndent.set(_newVal);
}
// -----------------------------------------------------------
bool globals::OrderTheBufferList() {
2012-10-18 11:09:19 +02:00
return true;
}
// -----------------------------------------------------------
int32_t globals::getNbColoneBorder() {
return 6;
}
int32_t globals::getNbLineBorder() {
return 3;
}
2012-07-23 17:21:44 +02:00
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/Spacer.h>
globals::ParameterGlobalsGui::ParameterGlobalsGui() {
addObjectType("globals::ParameterGlobalsGui");
}
void globals::ParameterGlobalsGui::init() {
ewol::widget::Sizer::init();
propertyMode.set(ewol::widget::Sizer::modeVert);
std::shared_ptr<ewol::widget::CheckBox> myCheckbox;
std::shared_ptr<ewol::widget::Spacer> mySpacer;
2012-07-23 17:21:44 +02:00
mySpacer = ewol::widget::Spacer::create();
2014-06-05 22:01:24 +02:00
if (nullptr == mySpacer) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
2016-02-15 22:04:10 +01:00
mySpacer->propertyExpand.set(bvec2(true,true));
2013-10-07 22:04:21 +02:00
subWidgetAdd(mySpacer);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create();
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
//TODO : myCheckbox->propertyLabel.set("Automatic Indentation");
2016-02-15 22:04:10 +01:00
myCheckbox->propertyExpand.set(bvec2(true,false));
myCheckbox->propertyValue.set(isSetAutoIndent());
2016-02-19 23:33:00 +01:00
myCheckbox->signalValue.connect(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackIndentation);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create();
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
//TODO : myCheckbox->propertyLabel.set("Display space char (' ')");
2016-02-15 22:04:10 +01:00
myCheckbox->propertyExpand.set(bvec2(true,false));
myCheckbox->propertyValue.set(isSetDisplaySpaceChar());
2016-02-19 23:33:00 +01:00
myCheckbox->signalValue.connect(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackSpace);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create();
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
//TODO : myCheckbox->propertyLabel.set("Display tabulation char ('\\t')");
2016-02-15 22:04:10 +01:00
myCheckbox->propertyExpand.set(bvec2(true,false));
myCheckbox->propertyValue.set(isSetDisplayTabChar());
2016-02-19 23:33:00 +01:00
myCheckbox->signalValue.connect(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackTabulation);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create();
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-07-23 17:21:44 +02:00
} else {
//TODO : myCheckbox->propertyLabel.set("Display end of line ('\\n')");
2016-02-15 22:04:10 +01:00
myCheckbox->propertyExpand.set(bvec2(true,false));
myCheckbox->propertyValue.set(isSetDisplayEndOfLine());
2016-02-19 23:33:00 +01:00
myCheckbox->signalValue.connect(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackEndOfLine);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-07-23 17:21:44 +02:00
}
myCheckbox = ewol::widget::CheckBox::create();
2014-06-05 22:01:24 +02:00
if (nullptr == myCheckbox) {
2013-10-07 22:04:21 +02:00
APPL_ERROR("Can not allocate widget == > display might be in error");
2012-11-06 18:08:44 +01:00
} else {
//TODO : myCheckbox->propertyLabel.set("switch Rounded/default");
2016-02-15 22:04:10 +01:00
myCheckbox->propertyExpand.set(bvec2(true,false));
myCheckbox->propertyValue.set(isSetDisplayEndOfLine());
2016-02-19 23:33:00 +01:00
myCheckbox->signalValue.connect(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackRounded);
2013-10-07 22:04:21 +02:00
subWidgetAdd(myCheckbox);
2012-11-06 18:08:44 +01:00
}
2012-07-23 17:21:44 +02:00
}
globals::ParameterGlobalsGui::~ParameterGlobalsGui() {
2012-07-23 17:21:44 +02:00
}
void globals::ParameterGlobalsGui::onCallbackEndOfLine(const bool& _value) {
setDisplayEndOfLine(_value);
}
void globals::ParameterGlobalsGui::onCallbackIndentation(const bool& _value) {
setAutoIndent(_value);
}
void globals::ParameterGlobalsGui::onCallbackSpace(const bool& _value) {
setDisplaySpaceChar(_value);
}
void globals::ParameterGlobalsGui::onCallbackTabulation(const bool& _value) {
setDisplayTabChar(_value);
}
void globals::ParameterGlobalsGui::onCallbackRounded(const bool& _value) {
if (_value == true) {
etk::theme::setName("GUI", "rounded");;
} else {
etk::theme::setName("GUI", "default");;
2012-07-23 17:21:44 +02:00
}
// Reload shaders and graphic system ...
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
2012-08-19 16:56:59 +02:00
}