diff --git a/Sources/Main.cpp b/Sources/Main.cpp index 7854c77e..fcc9e761 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -60,7 +60,7 @@ class Plop :public ewol::Windows ewol::Test * myTest = new ewol::Test(); mySizerVert->SubWidgetAdd(myTest); - myButton = new ewol::Button(" 4 4 BT"); + myButton = new ewol::Button("4 4 BT"); //myButton->SetExpendY(true); mySizerVert->SubWidgetAdd(myButton); diff --git a/Sources/ewolOObject2DColored.cpp b/Sources/ewolOObject2DColored.cpp index 010f5590..2d974c7b 100644 --- a/Sources/ewolOObject2DColored.cpp +++ b/Sources/ewolOObject2DColored.cpp @@ -488,6 +488,51 @@ void ewol::OObject2DColored::Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radiu } } +void ewol::OObject2DColored::CirclePart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness, etkFloat_t angleStart, etkFloat_t angleStop) +{ + ResetCount(); + if (radius<0) { + radius *= -1; + } + if (radius < thickness/2) { + Disc(x, y, thickness/2 + radius); + } + + angleStart -= 90; + angleStop -= 90; + etkFloat_t AStart = angleStart * (M_PI)/180; + etkFloat_t AStop = angleStop * (M_PI)/180; + etkFloat_t angleLinear = (angleStop-angleStart)* (M_PI)/180; + + int32_t nbOcurence = radius; + if (nbOcurence < 10) + { + nbOcurence = 10; + } + for (int32_t iii=0; iii " << angleStop << " ocurence=" << (angleLinear*180/(M_PI)) ); + + int32_t nbOcurence = radius*0.50; + if (nbOcurence < 15) + { + nbOcurence = 15; + } + + for (int32_t iii=0; iiiSetColor(0.0, 0.0, 0.0, 1.0); tmpOObjects->Rectangle( 2, 2, m_size.x-4, m_size.y-4); @@ -91,24 +111,37 @@ void ewol::Button::OnRegenerateDisplay(void) tmpOObjects->Rectangle( 3, 3, m_size.x-6, m_size.y-6); AddOObject(tmpOObjects, "BouttonDecoration"); - color_ts textColorFg; - textColorFg.red = 0.0; - textColorFg.green = 0.0; - textColorFg.blue = 0.0; - textColorFg.alpha = 1.0; - - - ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, textColorFg); + */ + ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, m_textColorFg); int32_t fontId = GetDefaultFontId(); int32_t fontHeight = ewol::GetHeight(fontId); int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str()); int32_t posy = (m_size.y - fontHeight - 6)/2 + 3; int32_t posx = (m_size.x - fontWidth - 6)/2 + 3; - tmpText->Text(posx, posy, m_label.c_str()); + tmpText->Text(posx+2, posy+3, m_label.c_str()); + + ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored; + int32_t radius = fontHeight / 2; + tmpOObjects->SetColor(m_textColorBg); + tmpOObjects->Rectangle( ((m_size.x-fontWidth-10)/2)+radius, posy, fontWidth-radius, radius*2); + tmpOObjects->SetColor(m_textColorFg); + EWOL_DEBUG("m_textColorFg=(" << m_textColorFg.red << " " << m_textColorFg.green << " " << m_textColorFg.blue << " " << m_textColorFg.alpha << ")" ); + tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy, ((m_size.x-fontWidth-10)/2)+fontWidth, posy, 1); + tmpOObjects->Line( ((m_size.x-fontWidth-10)/2)+radius, posy+fontHeight, ((m_size.x-fontWidth-10)/2)+fontWidth, posy+fontHeight, 1); + posy += fontHeight/2; + tmpOObjects->SetColor(m_textColorBg); + tmpOObjects->DiscPart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, 180, 360); + tmpOObjects->SetColor(m_textColorFg); + tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+radius, posy, radius, 1, 180, 360); + tmpOObjects->SetColor(m_textColorBg); + tmpOObjects->DiscPart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, 0, 180); + tmpOObjects->SetColor(m_textColorFg); + tmpOObjects->CirclePart(((m_size.x-fontWidth-10)/2)+fontWidth, posy, radius, 1, 0, 180); + + AddOObject(tmpOObjects, "BouttonDecoration"); AddOObject(tmpText, "BouttonText"); - - + // Regenerate the event Area: EventAreaRemoveAll(); coord origin; @@ -118,6 +151,9 @@ void ewol::Button::OnRegenerateDisplay(void) size.x = m_size.x-6; size.y = m_size.y-6; AddEventArea(origin, size, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventButtonPressed); + AddEventArea(origin, size, FLAG_EVENT_INPUT_ENTER, ewolEventButtonEnter); + AddEventArea(origin, size, FLAG_EVENT_INPUT_LEAVE, ewolEventButtonLeave); + } /* @@ -135,7 +171,8 @@ bool ewol::Button::OnEventArea(const char * generateEventId, etkFloat_t x, etkFl if(ewolEventButtonPressed == generateEventId) { EWOL_INFO("BT pressed ... " << m_label); eventIsOK = true; + } else if(ewolEventButtonEnter == generateEventId) { + OnRegenerateDisplay(); } - return eventIsOK; } diff --git a/Sources/widget/ewolButton.h b/Sources/widget/ewolButton.h index 62e521ff..19df1b42 100644 --- a/Sources/widget/ewolButton.h +++ b/Sources/widget/ewolButton.h @@ -35,6 +35,7 @@ namespace ewol { public: Button(void); Button(etk::String newLabel); + void Init(void); virtual ~Button(void); virtual bool CalculateMinSize(void); void SetLabel(etk::String newLabel); @@ -46,6 +47,8 @@ namespace ewol { bool GetValue(void); private: etk::String m_label; + color_ts m_textColorFg; //!< Text color + color_ts m_textColorBg; //!< Background color public: virtual void OnRegenerateDisplay(void); public: diff --git a/Sources/widget/ewolTest.cpp b/Sources/widget/ewolTest.cpp index d1da222e..639223ed 100644 --- a/Sources/widget/ewolTest.cpp +++ b/Sources/widget/ewolTest.cpp @@ -127,7 +127,10 @@ void ewol::Test::OnRegenerateDisplay(void) } else { tmpOObjects->Circle(100, 100, 100, 50); } - + tmpOObjects->SetColor(1.0, 1.0, 0.0, 1.0); + tmpOObjects->DiscPart(150, 60, 60, 45, 180); + tmpOObjects->SetColor(0.0, 0.0, 0.0, 1.0); + tmpOObjects->CirclePart(150, 60, 60, 2, 45, 180); AddOObject(tmpOObjects, "BouttonDecoration");