[DEV] first idea of the select and spin element

This commit is contained in:
Edouard DUPIN 2016-02-08 21:15:02 +01:00
parent 0bbbb59a81
commit 3aece8d7b8
19 changed files with 507 additions and 29 deletions

View File

@ -0,0 +1,7 @@
{
entry-shaper:"{ewol}THEME:GUI:SelectEntry.json",
up-shaper:"{ewol}THEME:GUI:SelectUp.json",
up-data:"<label>Up</label>",
down-shaper:"{ewol}THEME:GUI:SelectDown.json",
down-data:"<label>Down</label>",
}

View File

@ -0,0 +1,23 @@
{
mode:2,
display-outside:false,
padding-out-left:0,
padding-out-right:0,
padding-out-top:1,
padding-out-buttom:1,
border-left:1,
border-right:0,
border-top:1,
border-buttom:1,
padding-in-left:1,
padding-in-right:1,
padding-in-top:1,
padding-in-buttom:1,
change-time:356,
program:"{ewol}THEME:GUI:Button.prog",
color:"{ewol}THEME:COLOR:Button.json"
}

View File

@ -0,0 +1,23 @@
{
mode:2,
display-outside:false,
padding-out-left:0,
padding-out-right:0,
padding-out-top:1,
padding-out-buttom:1,
border-left:1,
border-right:0,
border-top:1,
border-buttom:1,
padding-in-left:2,
padding-in-right:2,
padding-in-top:1,
padding-in-buttom:1,
change-time:356,
program:"{ewol}THEME:GUI:Entry.prog",
color:"{ewol}THEME:COLOR:Entry.json"
}

View File

@ -0,0 +1,23 @@
{
mode:2,
display-outside:false,
padding-out-left:0,
padding-out-right:0,
padding-out-top:1,
padding-out-buttom:1,
border-left:1,
border-right:1,
border-top:1,
border-buttom:1,
padding-in-left:1,
padding-in-right:1,
padding-in-top:1,
padding-in-buttom:1,
change-time:356,
program:"{ewol}THEME:GUI:Button.prog",
color:"{ewol}THEME:COLOR:Button.json"
}

View File

@ -85,7 +85,7 @@ void ewol::compositing::Shaper::loadProgram() {
return;
}
m_config = ewol::resource::ConfigFile::create(m_name);
if (nullptr != m_config) {
if (m_config != nullptr) {
m_confIdMode = m_config->request("mode");
m_confIdDisplayOutside = m_config->request("display-outside");
m_confIdPaddingOut[shaperPosLeft] = m_config->request("padding-out-left");

View File

@ -180,23 +180,22 @@ void ewol::widget::Button::onLostFocus() {
}
void ewol::widget::Button::CheckStatus() {
if (true == m_buttonPressed) {
if (m_buttonPressed == true) {
changeStatusIn(STATUS_PRESSED);
} else {
if (true == m_mouseHover) {
changeStatusIn(STATUS_HOVER);
} else {
if (true == m_value) {
changeStatusIn(STATUS_DOWN);
} else {
changeStatusIn(STATUS_UP);
}
}
return;
}
if (m_mouseHover == true) {
changeStatusIn(STATUS_HOVER);
return;
}
if (m_value == true) {
changeStatusIn(STATUS_DOWN);
}
changeStatusIn(STATUS_UP);
}
void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper->changeStatusIn(_newStatusId) ) {
if (m_shaper->changeStatusIn(_newStatusId) == true) {
periodicCallEnable();
markToRedraw();
}
@ -204,7 +203,7 @@ void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) {
void ewol::widget::Button::periodicCall(const ewol::event::Time& _event) {
if (false == m_shaper->periodicCall(_event) ) {
if (m_shaper->periodicCall(_event) == false) {
periodicCallDisable();
}
markToRedraw();

View File

@ -145,16 +145,15 @@ std::shared_ptr<ewol::Widget> ewol::widget::Container::getWidgetAtPos(const vec2
return nullptr;
};
bool ewol::widget::Container::loadXML(const std::shared_ptr<const exml::Element>& _node) {
if (_node == nullptr) {
return false;
}
// parse generic properties :
// parse generic properties:
ewol::Widget::loadXML(_node);
// remove previous element :
// remove previous element:
subWidgetRemove();
// parse all the elements :
// parse all the elements:
for(size_t iii=0; iii< _node->size(); iii++) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii);
if (pNode == nullptr) {

View File

@ -38,10 +38,10 @@ ewol::widget::Entry::Entry() :
addObjectType("ewol::widget::Entry");
}
void ewol::widget::Entry::init(const std::string& _newData) {
void ewol::widget::Entry::init(const std::string& _newData, const std::string& _shaperName) {
ewol::Widget::init();
m_data.set(_newData);
m_shaper.setString("{ewol}THEME:GUI:Entry.json");
m_shaper.setString(_shaperName);
setCanHaveFocus(true);
try {

View File

@ -48,7 +48,8 @@ namespace ewol {
* @param[in] _newData The USting that might be set in the Entry box (no event generation!!)
*/
Entry();
void init(const std::string& _newData = "");
void init(const std::string& _newData = "",
const std::string& _shaperName="{ewol}THEME:GUI:Entry.json");
public:
DECLARE_WIDGET_FACTORY(Entry, "Entry");
/**

View File

@ -27,6 +27,7 @@
#include <ewol/widget/WSlider.h>
#include <ewol/widget/ListFileSystem.h>
#include <ewol/widget/Composer.h>
#include <ewol/widget/Select.h>
#include <vector>
#undef __class__
@ -55,6 +56,7 @@ ewol::widget::Manager::Manager() :
ewol::widget::WSlider::createManagerWidget(*this);
ewol::widget::ListFileSystem::createManagerWidget(*this);
ewol::widget::Composer::createManagerWidget(*this);
ewol::widget::Select::createManagerWidget(*this);
}
ewol::widget::Manager::~Manager() {

74
ewol/widget/Select.cpp Normal file
View File

@ -0,0 +1,74 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/widget/Select.h>
#undef __class__
#define __class__ "Select"
// DEFINE for the shader display system :
#define STATUS_UP (0)
#define STATUS_HOVER (2)
#define STATUS_PRESSED (1)
#define STATUS_DOWN (3)
ewol::widget::Select::Select() :
signalValueString(*this, "valueString", "select value change in a sring mode"),
signalValue(*this, "value", "Select value change"),
m_value(*this, "value", false, "Value of the Select") {
addObjectType("ewol::widget::Select");
}
void ewol::widget::Select::init(const std::string& _shaperName) {
ewol::widget::SpinBase::init(ewol::widget::spinPosition_noneRight, _shaperName);
//m_shaper->setSource(_shaperName);
//m_shaperIdSize = m_shaper->requestConfig("box-size");
//m_shaperIdSizeInsize = m_shaper->requestConfig("box-inside");
}
ewol::widget::Select::~Select() {
}
void ewol::widget::Select::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) {
ewol::widget::SpinBase::onParameterChangeValue(_paramPointer);
if (_paramPointer == m_value) {
markToRedraw();
}
}
bool ewol::widget::Select::loadXML(const std::shared_ptr<const exml::Element>& _node) {
if (_node == nullptr) {
return false;
}
// parse generic properties:
ewol::Widget::loadXML(_node);
// remove previous element:
//subWidgetRemove();
// parse all the elements:
for(size_t iii=0; iii< _node->size(); iii++) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii);
if (pNode == nullptr) {
// trash here all that is not element
continue;
}
if (pNode->getValue() != "option") {
EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node='" << pNode->getValue() << "' not in : [option]" );
continue;
}
std::string valId = pNode->getAttribute("id");
std::string valIsSelected = pNode->getAttribute("select");
std::string valText = pNode->getText();
EWOL_WARNING("Add option : id='" << valId << "' select='" << valIsSelected << "' text='" << valText << "'");
}
return true;
}

67
ewol/widget/Select.h Normal file
View File

@ -0,0 +1,67 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <etk/types.h>
#include <ewol/widget/meta/SpinBase.h>
namespace ewol {
namespace widget {
/**
* @brief a composed Select is a Select with an inside composed with the specify XML element
* ==> this permit to generate standard element simple
*/
class Select : public ewol::widget::SpinBase {
public:
// Event list of properties
ewol::Signal<std::string> signalValueString;
ewol::Signal<int32_t> signalValue;
protected:
/**
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
Select();
void init(const std::string& _shaperName="{ewol}THEME:GUI:Select.json");
public:
DECLARE_WIDGET_FACTORY(Select, "Select");
/**
* @brief Destructor
*/
virtual ~Select();
/**
* @brief set the shaper name (use the contructer one this permit to not noad unused shaper)
* @param[in] _shaperName The new shaper filename
*/
void setShaperName(const std::string& _shaperName) {
//m_shaper.setString(_shaperName);
}
protected:
ewol::parameter::Value<int32_t> m_value; //!< Current state of the Select.
public:
/**
* @brief set the currentValue of the Select (pressed or not)
* @note Work only in toggle mode
* @param[in] _val New value of the Select
*/
void setValue(int32_t _val) {
m_value.set(_val);
}
/**
* @brief get the current Select value.
* @return True : The Select is pressed.
* @return false : The Select is released.
*/
bool getValue() const {
return m_value;
};
virtual void onParameterChangeValue(const ewol::parameter::Ref& _paramPointer);
virtual bool loadXML(const std::shared_ptr<const exml::Element>& _node);
};
};
};

View File

@ -42,7 +42,7 @@ namespace ewol {
public:
DECLARE_WIDGET_FACTORY(Sizer, "Sizer");
/**
* @brief Desstructor
* @brief Destructor
*/
virtual ~Sizer();
/**

View File

@ -0,0 +1,130 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/meta/SpinBase.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Composer.h>
void ewol::widget::SpinBase::init(ewol::widget::Manager& _widgetManager) {
}
ewol::widget::SpinBase::SpinBase() :
m_confIdEntryShaper(-1),
m_confIdUpShaper(-1),
m_confIdDownShaper(-1),
m_confIdUpData(-1),
m_confIdDownData(-1),
m_spinMode(*this, "mode", ewol::widget::spinPosition_RightRight, "The display spin mode") {
addObjectType("ewol::widget::SpinBase");
m_spinMode.add(ewol::widget::spinPosition_noneNone, "none-none");
m_spinMode.add(ewol::widget::spinPosition_noneRight, "none-right");
m_spinMode.add(ewol::widget::spinPosition_leftNone, "left-none");
m_spinMode.add(ewol::widget::spinPosition_leftRight, "left-right");
m_spinMode.add(ewol::widget::spinPosition_leftLeft, "left-left");
m_spinMode.add(ewol::widget::spinPosition_RightRight, "right-right");
}
void ewol::widget::SpinBase::init(enum ewol::widget::spinPosition _mode,
const std::string& _shaperName) {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeHori);
lockExpand(bvec2(true,true));
m_config = ewol::resource::ConfigFile::create(_shaperName);
if (m_config != nullptr) {
m_confIdEntryShaper = m_config->request("entry-shaper");
m_confIdUpShaper = m_config->request("up-shaper");
m_confIdDownShaper = m_config->request("down-shaper");
m_confIdUpData = m_config->request("up-data");
m_confIdDownData = m_config->request("down-data");
}
m_spinMode = _mode;
updateGui();
}
ewol::widget::SpinBase::~SpinBase() {
}
void ewol::widget::SpinBase::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) {
ewol::widget::Sizer::onParameterChangeValue(_paramPointer);
if (_paramPointer == m_spinMode) {
updateGui();
}
}
void ewol::widget::SpinBase::updateGui() {
subWidgetRemoveAll();
markToRedraw();
requestUpdateSize();
if (m_widgetEntry == nullptr) {
// TODO : Check shaper pointer
std::string shaper = m_config->getString(m_confIdEntryShaper);
m_widgetEntry = ewol::widget::Entry::create("", shaper);
if (m_widgetEntry != nullptr) {
m_widgetEntry->setExpand(bvec2(true,false));
m_widgetEntry->setFill(bvec2(true,true));
// TODO : Connect
}
}
if (m_widgetButtonDown == nullptr) {
std::string shaper = m_config->getString(m_confIdDownShaper);
m_widgetButtonDown = ewol::widget::Button::create(shaper);
if (m_widgetButtonDown != nullptr) {
m_widgetButtonDown->setExpand(bvec2(false,false));
m_widgetButtonDown->setFill(bvec2(true,true));
std::string data = m_config->getString(m_confIdDownData);
std::shared_ptr<ewol::Widget> widget = ewol::widget::composerGenerate(ewol::widget::Composer::String, data);
m_widgetButtonDown->setSubWidget(widget);
// TODO : Connect
}
}
if (m_widgetButtonUp == nullptr) {
std::string shaper = m_config->getString(m_confIdUpShaper);
m_widgetButtonUp = ewol::widget::Button::create(shaper);
if (m_widgetButtonUp != nullptr) {
m_widgetButtonUp->setExpand(bvec2(false,false));
m_widgetButtonUp->setFill(bvec2(true,true));
std::string data = m_config->getString(m_confIdUpData);
std::shared_ptr<ewol::Widget> widget = ewol::widget::composerGenerate(ewol::widget::Composer::String, data);
m_widgetButtonUp->setSubWidget(widget);
// TODO : Connect
}
}
switch (m_spinMode) {
case ewol::widget::spinPosition_noneNone:
subWidgetAdd(m_widgetEntry);
break;
case ewol::widget::spinPosition_noneRight:
subWidgetAdd(m_widgetEntry);
subWidgetAdd(m_widgetButtonUp);
break;
case ewol::widget::spinPosition_leftNone:
subWidgetAdd(m_widgetButtonDown);
subWidgetAdd(m_widgetEntry);
break;
case ewol::widget::spinPosition_leftRight:
subWidgetAdd(m_widgetButtonDown);
subWidgetAdd(m_widgetEntry);
subWidgetAdd(m_widgetButtonUp);
break;
case ewol::widget::spinPosition_leftLeft:
subWidgetAdd(m_widgetButtonDown);
subWidgetAdd(m_widgetButtonUp);
subWidgetAdd(m_widgetEntry);
break;
case ewol::widget::spinPosition_RightRight:
subWidgetAdd(m_widgetEntry);
subWidgetAdd(m_widgetButtonDown);
subWidgetAdd(m_widgetButtonUp);
break;
}
}

115
ewol/widget/meta/SpinBase.h Normal file
View File

@ -0,0 +1,115 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/ContainerN.h>
#include <ewol/widget/Manager.h>
#include <etk/Color.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/Sizer.h>
namespace ewol {
namespace widget {
enum spinPosition {
/** show like:
* *------------------------*
* | |
* *------------------------*
*/
spinPosition_noneNone,
/** show like:
* *--------------------*---*
* | | |
* *--------------------*---*
*/
spinPosition_noneRight,
/** show like:
* *---*--------------------*
* | | |
* *---*--------------------*
*/
spinPosition_leftNone,
/** show like:
* *---*----------------*---*
* | | | |
* *---*----------------*---*
*/
spinPosition_leftRight,
/** show like:
* *---*---*----------------*
* | | | |
* *---*---*----------------*
*/
spinPosition_leftLeft,
/** show like:
* *----------------*---*---*
* | | | |
* *----------------*---*---*
*/
spinPosition_RightRight
};
/**
* @ingroup ewolWidgetGroup
*/
class SpinBase : public ewol::widget::Sizer {
public:
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void init(ewol::widget::Manager& _widgetManager);
public:
protected:
std::shared_ptr<ewol::resource::ConfigFile> m_config;
int32_t m_confIdEntryShaper;
int32_t m_confIdUpShaper;
int32_t m_confIdDownShaper;
int32_t m_confIdUpData;
int32_t m_confIdDownData;
ewol::parameter::List<enum ewol::widget::spinPosition> m_spinMode; //!< How to display the spin base
protected:
/**
* @brief Constructor
* @param[in] _mode The mode to display the elements
*/
SpinBase();
void init(enum ewol::widget::spinPosition _mode=ewol::widget::spinPosition_RightRight,
const std::string& _shaperName="{ewol}THEME:GUI:Spin.json");
public:
/**
* @brief Destructor
*/
virtual ~SpinBase();
/**
* @brief set the mode to display elements.
* @param[in] _mode The mode to display the elements.
*/
void setMode(enum ewol::widget::spinPosition _mode) {
m_spinMode.set(_mode);
}
/**
* @brief get the mode to display elements.
* @return The current mode to display the elements.
*/
enum ewol::widget::spinPosition getMode() const {
return m_spinMode;
}
protected:
std::shared_ptr<ewol::widget::Entry> m_widgetEntry;
std::shared_ptr<ewol::widget::Button> m_widgetButtonDown;
std::shared_ptr<ewol::widget::Button> m_widgetButtonUp;
void updateGui();
public: // Derived function
virtual void onParameterChangeValue(const ewol::parameter::Ref& _paramPointer);
};
}
}

View File

@ -189,9 +189,11 @@ def create(target, module_name):
'ewol/widget/meta/Parameter.cpp',
'ewol/widget/meta/ParameterList.cpp',
'ewol/widget/meta/StdPopUp.cpp',
'ewol/widget/meta/SpinBase.cpp',
'ewol/widget/PopUp.cpp',
'ewol/widget/ProgressBar.cpp',
'ewol/widget/Scroll.cpp',
'ewol/widget/Select.cpp',
'ewol/widget/Sizer.cpp',
'ewol/widget/Slider.cpp',
'ewol/widget/Spacer.cpp',
@ -230,12 +232,14 @@ def create(target, module_name):
'ewol/widget/Joystick.h',
'ewol/widget/Widget.h',
'ewol/widget/meta/StdPopUp.h',
'ewol/widget/meta/SpinBase.h',
'ewol/widget/meta/ParameterList.h',
'ewol/widget/meta/ColorChooser.h',
'ewol/widget/meta/Parameter.h',
'ewol/widget/meta/FileChooser.h',
'ewol/widget/Image.h',
'ewol/widget/List.h'
'ewol/widget/List.h',
'ewol/widget/Select.h'
])
my_module.copy_path('data/theme/shape/square/*','theme/shape/square')

View File

@ -44,7 +44,7 @@ static const char * l_eventChangeWidgetPrevious = "event-change-widget-test-pre
appl::MainWindows::MainWindows() :
m_gravity(ewol::gravity_buttomLeft),
m_idWidget(0) {
m_idWidget(-1) {
APPL_DEBUG("CREATE WINDOWS ... ");
addObjectType("appl::MainWindows");
}
@ -116,26 +116,37 @@ void appl::MainWindows::onCallbackWidgetChange(int32_t _increment) {
std::string tmpConstruct;
switch(m_idWidget) {
case 0:
tmpConstruct = std::string()
+ "<select>\n"
+ " <option id='1'>plop 1</option>\n"
+ " <option id='2'>plop 2</option>\n"
+ " <option id='3' select='true'>plop 3</option>\n"
+ " <option id='4'>plop 4</option>\n"
+ " <option id='5'>plop 5</option>\n"
+ "</select>\n";
tmpDescription = "TestButton";
break;
case 1:
tmpConstruct = std::string()
+ "<button name='[TEST]Button:TO-TEST' expand='false,false' fill='false,false' >\n"
+ " <label>My <font color='#FF0000'>Button</font> <br/> And Some under line<br/> plop <br/> and an other super long line ...</label>\n"
+ "</button>\n";
tmpDescription = "TestButton";
break;
case 1:
case 2:
tmpConstruct = "<ButtonColor/>";
tmpDescription = "TestButtonColor";
break;
case 2:
case 3:
tmpConstruct = "<label>Simple string</label>\n";
tmpDescription = "TestLabel";
break;
case 3:
case 4:
tmpConstruct = "<image src='DATA:sphere.png'/>\n";
tmpDescription = "TestImage";
break;
case 4:
tmpConstruct = "<checkbox/>\n";
case 5:
tmpConstruct = "<checkbox><label>Simple string</label></checkbox>\n";
tmpDescription = "TestCheckbox";
break;
default:

View File

View File