diff --git a/data/theme/color/black/Button.json b/data/theme/color/black/Button.json index bfb2939c..337ef3d5 100644 --- a/data/theme/color/black/Button.json +++ b/data/theme/color/black/Button.json @@ -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" }, ] } diff --git a/data/theme/color/black/Entry.json b/data/theme/color/black/Entry.json index d5ea50d8..0c7a498c 100644 --- a/data/theme/color/black/Entry.json +++ b/data/theme/color/black/Entry.json @@ -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" }, ] } diff --git a/data/theme/color/black/ListFileSystem.json b/data/theme/color/black/ListFileSystem.json new file mode 100644 index 00000000..31c15874 --- /dev/null +++ b/data/theme/color/black/ListFileSystem.json @@ -0,0 +1,8 @@ +{ + "color": [ + { name:"text", color:"#EEEF" }, + { name:"background1", color:"#111F" }, + { name:"background2", color:"#333F" }, + { name:"selected", color:"#338F" }, + ] +} \ No newline at end of file diff --git a/data/theme/color/black/PopUp.json b/data/theme/color/black/PopUp.json index 641441db..8071f8e2 100644 --- a/data/theme/color/black/PopUp.json +++ b/data/theme/color/black/PopUp.json @@ -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" }, ] } diff --git a/data/theme/color/black/Windows.json b/data/theme/color/black/Windows.json new file mode 100644 index 00000000..5d5d5bf7 --- /dev/null +++ b/data/theme/color/black/Windows.json @@ -0,0 +1,5 @@ +{ + "color": [ + { name:"background", color:"#222F" }, + ] +} diff --git a/data/theme/color/white/Button.json b/data/theme/color/white/Button.json index 40a380ce..a15c7144 100644 --- a/data/theme/color/white/Button.json +++ b/data/theme/color/white/Button.json @@ -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" }, ] } diff --git a/data/theme/color/white/Entry.json b/data/theme/color/white/Entry.json index c762c2cc..4619621e 100644 --- a/data/theme/color/white/Entry.json +++ b/data/theme/color/white/Entry.json @@ -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" }, ] } diff --git a/data/theme/color/white/ListFileSystem.json b/data/theme/color/white/ListFileSystem.json new file mode 100644 index 00000000..c9d7dc19 --- /dev/null +++ b/data/theme/color/white/ListFileSystem.json @@ -0,0 +1,8 @@ +{ + "color": [ + { name:"text", color:"#111F" }, + { name:"background1", color:"#EEEF" }, + { name:"background2", color:"#BBBF" }, + { name:"selected", color:"#88FF" }, + ] +} \ No newline at end of file diff --git a/data/theme/color/white/PopUp.json b/data/theme/color/white/PopUp.json index 02c624ff..00cc22ef 100644 --- a/data/theme/color/white/PopUp.json +++ b/data/theme/color/white/PopUp.json @@ -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" }, ] -} +} \ No newline at end of file diff --git a/data/theme/color/white/Windows.json b/data/theme/color/white/Windows.json new file mode 100644 index 00000000..d645bb76 --- /dev/null +++ b/data/theme/color/white/Windows.json @@ -0,0 +1,5 @@ +{ + "color": [ + { name:"background", color:"#888F" }, + ] +} \ No newline at end of file diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index 12f4c138..63a87971 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -292,3 +292,11 @@ bool ewol::compositing::Shaper::hasSources(void) { return m_GLprogram!=NULL; } + +const etk::Color& ewol::compositing::Shaper::getColor(int32_t _id) { + static const etk::Color errorValue(0,0,0,0); + if (m_colorProperty == NULL) { + return errorValue; + } + return m_colorProperty->get(_id); +} diff --git a/sources/ewol/compositing/Shaper.h b/sources/ewol/compositing/Shaper.h index a7e9e9bd..d88286be 100644 --- a/sources/ewol/compositing/Shaper.h +++ b/sources/ewol/compositing/Shaper.h @@ -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& getColor(int32_t _id); }; }; }; diff --git a/sources/ewol/widget/ContextMenu.cpp b/sources/ewol/widget/ContextMenu.cpp index c8843c53..e484f2e3 100644 --- a/sources/ewol/widget/ContextMenu.cpp +++ b/sources/ewol/widget/ContextMenu.cpp @@ -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); } diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index 3cb24e45..3adfa3fc 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -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= 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); diff --git a/sources/ewol/widget/Entry.h b/sources/ewol/widget/Entry.h index ec91d859..76a11a8a 100644 --- a/sources/ewol/widget/Entry.h +++ b/sources/ewol/widget/Entry.h @@ -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 diff --git a/sources/ewol/widget/Label.cpp b/sources/ewol/widget/Label.cpp index 3d52bd11..d53e8bf4 100644 --- a/sources/ewol/widget/Label.cpp +++ b/sources/ewol/widget/Label.cpp @@ -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)); } diff --git a/sources/ewol/widget/Label.h b/sources/ewol/widget/Label.h index a6e36f3b..b64c11a5 100644 --- a/sources/ewol/widget/Label.h +++ b/sources/ewol/widget/Label.h @@ -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: diff --git a/sources/ewol/widget/ListFileSystem.cpp b/sources/ewol/widget/ListFileSystem.cpp index 57bc4733..89c1707f 100644 --- a/sources/ewol/widget/ListFileSystem.cpp +++ b/sources/ewol/widget/ListFileSystem.cpp @@ -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(); - } + _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; }; diff --git a/sources/ewol/widget/ListFileSystem.h b/sources/ewol/widget/ListFileSystem.h index 407add79..d67e7e56 100644 --- a/sources/ewol/widget/ListFileSystem.h +++ b/sources/ewol/widget/ListFileSystem.h @@ -11,6 +11,7 @@ #include #include +#include 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); diff --git a/sources/ewol/widget/Windows.cpp b/sources/ewol/widget/Windows.cpp index 77809a24..ecda114b 100644 --- a/sources/ewol/widget/Windows.cpp +++ b/sources/ewol/widget/Windows.cpp @@ -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 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; diff --git a/sources/ewol/widget/Windows.h b/sources/ewol/widget/Windows.h index beb156d2..1ddb8d86 100644 --- a/sources/ewol/widget/Windows.h +++ b/sources/ewol/widget/Windows.h @@ -13,6 +13,7 @@ #include #include #include +#include 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);