amelioration of the color system

This commit is contained in:
Edouard Dupin 2012-03-10 21:46:43 +01:00
parent 1dfac7819a
commit 64a079f615
4 changed files with 38 additions and 9 deletions

View File

@ -223,6 +223,7 @@ bool ewol::ButtonColor::OnEventInput(int32_t IdInput, eventInputType_te typeEven
m_widgetContextMenu->SetPositionMark(ewol::CONTEXT_MENU_MARK_BOTTOM, newPosition );
ewol::ColorChooser * myColorChooser = new ewol::ColorChooser();
myColorChooser->SetColor(m_textColorBg);
// set it in the pop-up-system :
m_widgetContextMenu->SubWidgetSet(myColorChooser);
myColorChooser->RegisterOnEvent(this, ewolEventColorChooserChange, ewolEventColorChooserChange);

View File

@ -88,6 +88,8 @@ void ewol::ColorBar::SetCurrentColor(color_ts newOne)
{
m_currentColor = newOne;
m_currentColor.alpha = 1.0;
// estimate the cursor position :
// TODO : Later when really needed ...
}
void ewol::ColorBar::OnRegenerateDisplay(void)

View File

@ -113,9 +113,14 @@ void ewol::Slider::OnRegenerateDisplay(void)
tmpOObjects->SetColor(m_textColorFg);
// draw a line :
tmpOObjects->Line(dotRadius, m_size.y/2, m_size.x-dotRadius, m_size.y/2, 1);
color_ts borderDot = m_textColorFg;
borderDot.alpha /= 2;
tmpOObjects->SetColor(borderDot);
tmpOObjects->Disc(4+((etkFloat_t)(m_value-m_min)/(etkFloat_t)(m_max-m_min))*(etkFloat_t)(m_size.x-2*dotRadius), m_size.y/2, dotRadius);
tmpOObjects->SetColor(m_textColorFg);
tmpOObjects->Disc(4+((etkFloat_t)(m_value-m_min)/(etkFloat_t)(m_max-m_min))*(etkFloat_t)(m_size.x-2*dotRadius), m_size.y/2, dotRadius/1.6);
AddOObject(tmpOObjects);
}
}
@ -140,11 +145,14 @@ bool ewol::Slider::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, co
|| ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
// get the new position :
EWOL_DEBUG("Event on Slider (" << relativePos.x << "," << relativePos.y << ")");
int32_t oldValue = m_value;
m_value = m_min + (etkFloat_t)(relativePos.x - dotRadius) / (etkFloat_t)(m_size.x-2*dotRadius) * (etkFloat_t)(m_max-m_min);
m_value = etk_max(etk_min(m_value, m_max), m_min);
EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
GenerateEventId(ewolEventSliderChange);
MarkToReedraw();
if (oldValue != m_value) {
EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
GenerateEventId(ewolEventSliderChange);
MarkToReedraw();
}
return true;
}
}

View File

@ -163,13 +163,18 @@ color_ts ewol::ColorChooser::GetColor(void)
*/
void ewol::ColorChooser::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
if (NULL == CallerObject) {
return;
}
//EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" ==> data=\"" << data << "\"" );
if (eventColorBarHasChange == eventId) {
//==> colorBar has change ...
etkFloat_t tmpAlpha = m_currentColor.alpha;
// the colorbar has no notion of the alpha ==> keep it ...
if (NULL != m_widgetColorBar) {
m_currentColor = m_widgetColorBar->GetCurrentColor();
}
m_currentColor.alpha = tmpAlpha;
if (NULL != m_widgetRed) {
m_widgetRed->SetValue(m_currentColor.red * 255.);
}
@ -183,12 +188,25 @@ void ewol::ColorChooser::OnReceiveMessage(ewol::EObject * CallerObject, const ch
m_widgetAlpha->SetValue(m_currentColor.alpha * 255.);
}
GenerateEventId(ewolEventColorChooserChange);
return;
} else if (eventColorSpecificHasChange == eventId) {
//==> Entry has change ...
return;
// Slider has changes his color ==> get the one change ...
if (CallerObject == m_widgetRed) {
m_currentColor.red = m_widgetRed->GetValue() / 255.;
}
if (CallerObject == m_widgetGreen) {
m_currentColor.green = m_widgetGreen->GetValue() / 255.;
}
if (CallerObject == m_widgetBlue) {
m_currentColor.blue = m_widgetBlue->GetValue() / 255.;
}
if (CallerObject == m_widgetAlpha) {
m_currentColor.alpha = m_widgetAlpha->GetValue() / 255.;
}
if (NULL != m_widgetColorBar) {
m_widgetColorBar->SetCurrentColor(m_currentColor);
}
GenerateEventId(ewolEventColorChooserChange);
}
return;
};