[DEV] end of first step of the color management

This commit is contained in:
Edouard DUPIN 2014-01-18 14:33:36 +01:00
parent 961415a05d
commit 10f9e7c60f
21 changed files with 140 additions and 50 deletions

View File

@ -2,9 +2,9 @@
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_border", color:"#FFF" },
{ name:"EW_foreground", color:"#777A" },
{ name:"EW_foreground", color:"#000A" },
{ name:"EW_foregroundHover", color:"#0066" },
{ name:"EW_foregroundSelected", color:"#0606" },
{ name:"EW_foregroundSelected", color:"#060A" },
{ name:"EW_foregroundPressed", color:"#6006" },
]
}

View File

@ -3,7 +3,11 @@
{ name:"EW_background", color:"#0000" },
{ name:"EW_foreground", color:"#000A" },
{ name:"EW_foregroundSelected", color:"#FFF3" },
{ name:"EW_foregroundHover", color:"#00F2" },
{ name:"EW_border", color:"#000F" },
{ name:"EW_foregroundHover", color:"#0082" },
{ name:"EW_border", color:"#FFFF" },
{ name:"text-foreground", color:"#CCCF" },
{ name:"text-background", color:"#0000" },
{ name:"text-cursor", color:"#00AF" },
{ name:"text-selection", color:"#0A0F" },
]
}

View File

@ -0,0 +1,8 @@
{
"color": [
{ name:"text", color:"#EEEF" },
{ name:"background1", color:"#111F" },
{ name:"background2", color:"#333F" },
{ name:"selected", color:"#338F" },
]
}

View File

@ -1,7 +1,7 @@
{
"color": [
{ name:"EW_background", color:"#000A" },
{ name:"EW_foreground", color:"#555A" },
{ name:"EW_foreground", color:"#000000F8" },
{ name:"EW_border", color:"#FFFF" },
]
}

View File

@ -0,0 +1,5 @@
{
"color": [
{ name:"background", color:"#222F" },
]
}

View File

@ -4,7 +4,7 @@
{ name:"EW_border", color:"#000" },
{ name:"EW_foreground", color:"#8884" },
{ name:"EW_foregroundHover", color:"#00A6" },
{ name:"EW_foregroundSelected", color:"#0A06" },
{ name:"EW_foregroundSelected", color:"#0A0A" },
{ name:"EW_foregroundPressed", color:"#A006" },
]
}

View File

@ -3,7 +3,11 @@
{ name:"EW_background", color:"#0000" },
{ name:"EW_foreground", color:"#FFFA" },
{ name:"EW_foregroundSelected", color:"#0005" },
{ name:"EW_foregroundHover", color:"#00F5" },
{ name:"EW_border", color:"#FFFF" },
{ name:"EW_foregroundHover", color:"#55F5" },
{ name:"EW_border", color:"#000F" },
{ name:"text-foreground", color:"#222F" },
{ name:"text-background", color:"#0000" },
{ name:"text-cursor", color:"#00FF" },
{ name:"text-selection", color:"#0A0F" },
]
}

View File

@ -0,0 +1,8 @@
{
"color": [
{ name:"text", color:"#111F" },
{ name:"background1", color:"#EEEF" },
{ name:"background2", color:"#BBBF" },
{ name:"selected", color:"#88FF" },
]
}

View File

@ -1,7 +1,7 @@
{
"color": [
{ name:"EW_background", color:"#888A" },
{ name:"EW_foreground", color:"#FFFA" },
{ name:"EW_border", color:"#FFFF" },
{ name:"EW_foreground", color:"#FFFFFFF0" },
{ name:"EW_border", color:"#000F" },
]
}

View File

@ -0,0 +1,5 @@
{
"color": [
{ name:"background", color:"#888F" },
]
}

View File

@ -292,3 +292,11 @@ bool ewol::compositing::Shaper::hasSources(void) {
return m_GLprogram!=NULL;
}
const etk::Color<float>& ewol::compositing::Shaper::getColor(int32_t _id) {
static const etk::Color<float> errorValue(0,0,0,0);
if (m_colorProperty == NULL) {
return errorValue;
}
return m_colorProperty->get(_id);
}

View File

@ -172,6 +172,24 @@ namespace ewol {
* @brief update the internal vertex table.
*/
void updateVertex(void);
public:
/**
* @brief Get an ID on the color instance element
* @param[in] _name Name of the element requested
* @return The Id of the color
*/
int32_t requestColor(const std::string& _name) {
if (m_colorProperty == NULL) {
return -1;
}
return m_colorProperty->request(_name);
}
/**
* @brief Get The color associated at an ID.
* @param[in] _id Id of the color
* @return the reference on the color
*/
const etk::Color<float>& getColor(int32_t _id);
};
};
};

View File

@ -67,7 +67,7 @@ void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
// pop-up fill all the display :
m_size = _availlable;
vec2 padding = m_shaper.getPadding();
EWOL_DEBUG("our origin=" << m_origin << " size=" << m_size);
EWOL_VERBOSE("our origin=" << m_origin << " size=" << m_size);
if (NULL != m_subWidget) {
vec2 subWidgetSize;
vec2 subWidgetOrigin;
@ -122,7 +122,7 @@ void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
}
break;
}
EWOL_DEBUG(" == > sub origin=" << subWidgetOrigin << " size=" << subWidgetSize);
EWOL_VERBOSE(" == > sub origin=" << subWidgetOrigin << " size=" << subWidgetSize);
m_subWidget->setOrigin(subWidgetOrigin);
m_subWidget->calculateSize(subWidgetSize);
}

View File

@ -62,6 +62,10 @@ ewol::widget::Entry::Entry(std::string _newData) :
m_textWhenNothing("") {
addObjectType("ewol::widget::Entry");
m_textColorBg.setA(0xAF);
m_colorIdTextFg = m_shaper.requestColor("text-foreground");
m_colorIdTextBg = m_shaper.requestColor("text-background");
m_colorIdCursor = m_shaper.requestColor("text-cursor");
m_colorIdSelection = m_shaper.requestColor("text-selection");
setCanHaveFocus(true);
addEventId(eventClick);
addEventId(eventEnter);
@ -104,7 +108,7 @@ void ewol::widget::Entry::calculateMinMaxSize(void) {
ewol::Widget::calculateMinMaxSize();
// get generic padding
vec2 padding = m_shaper.getPadding();
int32_t minHeight = m_oObjectText.calculateSize(char32_t('A')).y();
int32_t minHeight = m_text.calculateSize(char32_t('A')).y();
vec2 minimumSizeBase(20, minHeight);
// add padding :
minimumSizeBase += padding*2.0f;
@ -133,14 +137,20 @@ void ewol::widget::Entry::setValue(const std::string& _newData) {
void ewol::widget::Entry::onDraw(void) {
m_shaper.draw();
m_oObjectText.draw();
m_text.draw();
}
void ewol::widget::Entry::onRegenerateDisplay(void) {
if (true == needRedraw()) {
m_shaper.clear();
m_oObjectText.clear();
m_text.clear();
if (m_colorIdTextFg >= 0) {
m_text.setDefaultColorFg(m_shaper.getColor(m_colorIdTextFg));
m_text.setDefaultColorBg(m_shaper.getColor(m_colorIdTextBg));
m_text.setCursorColor(m_shaper.getColor(m_colorIdCursor));
m_text.setSelectionColor(m_shaper.getColor(m_colorIdSelection));
}
updateTextPosition();
vec2 padding = m_shaper.getPadding();
@ -156,7 +166,7 @@ void ewol::widget::Entry::onRegenerateDisplay(void) {
vec2 tmpSizeText = tmpSizeShaper - padding * 2.0f;
vec2 tmpOriginText = (m_size - tmpSizeText) / 2.0f;
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
int32_t minHeight = m_oObjectText.calculateSize(char32_t('A')).y();
int32_t minHeight = m_text.calculateSize(char32_t('A')).y();
if (tmpSizeText.y()>minHeight) {
tmpOriginText += vec2(0,(tmpSizeText.y()-minHeight)/2.0f);
}
@ -166,21 +176,21 @@ void ewol::widget::Entry::onRegenerateDisplay(void) {
tmpSizeText = vec2ClipInt32(tmpSizeText);
tmpOriginText = vec2ClipInt32(tmpOriginText);
m_oObjectText.setClippingWidth(tmpOriginText, tmpSizeText);
m_oObjectText.setPos(tmpOriginText+vec2(m_displayStartPosition,0));
m_text.setClippingWidth(tmpOriginText, tmpSizeText);
m_text.setPos(tmpOriginText+vec2(m_displayStartPosition,0));
if (m_displayCursorPosSelection != m_displayCursorPos) {
m_oObjectText.setCursorSelection(m_displayCursorPos, m_displayCursorPosSelection);
m_text.setCursorSelection(m_displayCursorPos, m_displayCursorPosSelection);
} else {
m_oObjectText.setCursorPos(m_displayCursorPos);
m_text.setCursorPos(m_displayCursorPos);
}
if (0!=m_data.size()) {
m_oObjectText.print(m_data);
m_text.print(m_data);
} else {
if (0!=m_textWhenNothing.size()) {
m_oObjectText.printDecorated(m_textWhenNothing);
m_text.printDecorated(m_textWhenNothing);
}
}
m_oObjectText.setClippingMode(false);
m_text.setClippingMode(false);
m_shaper.setOrigin(tmpOriginShaper);
m_shaper.setSize(tmpSizeShaper);
@ -195,13 +205,13 @@ void ewol::widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection
relPos.setX(relPos.x()-m_displayStartPosition - padding.x());
// try to find the new cursor position :
std::string tmpDisplay = std::string(m_data, 0, m_displayStartPosition);
int32_t displayHidenSize = m_oObjectText.calculateSize(tmpDisplay).x();
int32_t displayHidenSize = m_text.calculateSize(tmpDisplay).x();
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
int32_t newCursorPosition = -1;
int32_t tmpTextOriginX = padding.x();
for (size_t iii=0; iii<m_data.size(); iii++) {
tmpDisplay = std::string(m_data, 0, iii);
int32_t tmpWidth = m_oObjectText.calculateSize(tmpDisplay).x() - displayHidenSize;
int32_t tmpWidth = m_text.calculateSize(tmpDisplay).x() - displayHidenSize;
if (tmpWidth >= relPos.x()-tmpTextOriginX) {
newCursorPosition = iii;
break;
@ -335,7 +345,7 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) {
}
}
else if( ewol::key::typeMouse == _event.getType()
&& 2 == _event.getId()) {
&& _event.getId() == 2) {
if( _event.getStatus() == ewol::key::statusDown
|| _event.getStatus() == ewol::key::statusMove
|| _event.getStatus() == ewol::key::statusUp) {
@ -510,7 +520,7 @@ void ewol::widget::Entry::updateTextPosition(void) {
tmpSizeX = m_size.x();
}
int32_t tmpUserSize = tmpSizeX - 2*(padding.x());
int32_t totalWidth = m_oObjectText.calculateSize(m_data).x();
int32_t totalWidth = m_text.calculateSize(m_data).x();
// Check if the data inside the display can be contain in the entry box
if (totalWidth < tmpUserSize) {
// all can be display :
@ -518,7 +528,7 @@ void ewol::widget::Entry::updateTextPosition(void) {
} else {
// all can not be set :
std::string tmpDisplay = std::string(m_data, 0, m_displayCursorPos);
int32_t pixelCursorPos = m_oObjectText.calculateSize(tmpDisplay).x();
int32_t pixelCursorPos = m_text.calculateSize(tmpDisplay).x();
// check if the Cussor is visible at 10px nearest the border :
int32_t tmp1 = pixelCursorPos+m_displayStartPosition;
EWOL_DEBUG("cursorPos=" << pixelCursorPos << "px maxSize=" << tmpUserSize << "px tmp1=" << tmp1);

View File

@ -48,7 +48,11 @@ namespace ewol {
static void init(ewol::widget::Manager& _widgetManager);
private:
ewol::compositing::Shaper m_shaper;
ewol::compositing::Text m_oObjectText; //!< text display m_text
int32_t m_colorIdTextFg; //!< color property of the text foreground
int32_t m_colorIdTextBg; //!< color property of the text background
int32_t m_colorIdCursor; //!< color property of the text cursor
int32_t m_colorIdSelection; //!< color property of the text selection
ewol::compositing::Text m_text; //!< text display m_text
public:
/**
* @brief Contuctor

View File

@ -120,8 +120,6 @@ void ewol::widget::Label::onRegenerateDisplay(void) {
// clean the element
m_text.reset();
if (m_colorProperty != NULL) {
EWOL_DEBUG("set FG : " << m_colorProperty->get(m_colorDefaultFgText));
EWOL_DEBUG("set BG : " << m_colorProperty->get(m_colorDefaultBgText));
m_text.setDefaultColorFg(m_colorProperty->get(m_colorDefaultFgText));
m_text.setDefaultColorBg(m_colorProperty->get(m_colorDefaultBgText));
}

View File

@ -34,7 +34,7 @@ namespace ewol {
private:
ewol::compositing::Text m_text; //!< Compositing text element.
std::u32string m_label; //!< decorated text to display.
ewol::resource::ColorFile* m_colorProperty; //!< theme color proterty
ewol::resource::ColorFile* m_colorProperty; //!< theme color property
int32_t m_colorDefaultFgText; //!< Default color of the text
int32_t m_colorDefaultBgText; //!< Default Background color of the text
public:

View File

@ -46,6 +46,13 @@ ewol::widget::ListFileSystem::ListFileSystem(void) :
#if defined(__TARGET_OS__Windows)
m_folder = "c:/";
#endif
m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:ListFileSystem.json");
if (m_colorProperty != NULL) {
m_colorIdText = m_colorProperty->request("text");
m_colorIdBackground1 = m_colorProperty->request("background1");
m_colorIdBackground2 = m_colorProperty->request("background2");
m_colorIdBackgroundSelected = m_colorProperty->request("selected");
}
addEventId(eventFileSelect);
addEventId(eventFileValidate);
addEventId(eventFolderSelect);
@ -75,7 +82,7 @@ void ewol::widget::ListFileSystem::clearList(void) {
};
etk::Color<> ewol::widget::ListFileSystem::getBasicBG(void) {
return etk::Color<>(0x00000010);
return m_colorProperty->get(m_colorIdBackground1);
}
@ -148,22 +155,16 @@ bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std
if( _raw-offset >= 0
&& _raw-offset < (int32_t)m_list.size()
&& NULL != m_list[_raw-offset]) {
/*if (etk::FSN_FILE == m_list[raw-offset]->getNodeType()) {
myTextToWrite = m_list[raw-offset]->getRight().getRight();
myTextToWrite += " ";
myTextToWrite += m_list[raw-offset]->getNameFile();
} else */{
_myTextToWrite = m_list[_raw-offset]->getNameFile();
}
}
_fg = etk::color::black;
_fg = m_colorProperty->get(m_colorIdText);
if (_raw % 2) {
_bg = 0xFFFFFF00;
_bg = m_colorProperty->get(m_colorIdBackground1);
} else {
_bg = 0xBFBFBFFF;
_bg = m_colorProperty->get(m_colorIdBackground2);
}
if (m_selectedLine == _raw) {
_bg = 0x8F8FFFFF;
_bg = m_colorProperty->get(m_colorIdBackgroundSelected);
}
return true;
};

View File

@ -11,6 +11,7 @@
#include <ewol/widget/List.h>
#include <etk/os/FSNode.h>
#include <ewol/resource/ColorFile.h>
namespace ewol {
namespace widget {
@ -37,6 +38,12 @@ namespace ewol {
public:
ListFileSystem(void);
~ListFileSystem(void);
protected:
ewol::resource::ColorFile* m_colorProperty; //!< theme color property.
int32_t m_colorIdText; //!< Color of the text.
int32_t m_colorIdBackground1; //!< Color of the Background.
int32_t m_colorIdBackground2; //!< Color of the Background 2.
int32_t m_colorIdBackgroundSelected; //!< Color of line selected.
protected : // Derived function from the List...
virtual etk::Color<> getBasicBG(void);
virtual uint32_t getNuberOfColomn(void);

View File

@ -24,11 +24,16 @@ extern const char * const ewolEventWindowsHideKeyboard = "ewol Windows hideKey
ewol::widget::Windows::Windows(void) :
m_backgroundColor(0.750, 0.750, 0.750, 0.5) {
m_colorProperty(NULL),
m_colorBg(-1) {
addObjectType("ewol::widget::Windows");
setCanHaveFocus(true);
m_subWidget = NULL;
setDecorationDisable();
m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:Windows.json");
if (m_colorProperty != NULL) {
m_colorBg = m_colorProperty->request("background");
}
//KeyboardShow(KEYBOARD_MODE_CODE);
}
@ -133,10 +138,11 @@ void ewol::widget::Windows::systemDraw(const ewol::DrawProperty& _displayProp) {
#endif
// clear the screen with transparency ...
glClearColor(m_backgroundColor.r(),
m_backgroundColor.g(),
m_backgroundColor.b(),
m_backgroundColor.a());
etk::Color<float> colorBg(0.5, 0.5, 0.5, 0.5);
if (m_colorProperty != NULL) {
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)(ewol::getTime() - ___startTime0) / 1000.0f;

View File

@ -13,6 +13,7 @@
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <etk/Color.h>
#include <ewol/resource/ColorFile.h>
namespace ewol {
namespace widget {
@ -20,6 +21,9 @@ namespace ewol {
* @ingroup ewolWidgetGroup
*/
class Windows : public ewol::Widget {
protected:
ewol::resource::ColorFile* m_colorProperty; //!< theme color property
int32_t m_colorBg; //!< Default background color of the windows
public:
Windows(void);
virtual ~Windows(void);