Breaking changes for expr_color

expr_color is a temporary class name for new color type experiment.
This commit is contained in:
cnjinhao
2014-12-17 11:20:47 +08:00
parent 74c09eb9b3
commit 42788db077
58 changed files with 1135 additions and 824 deletions

View File

@@ -73,14 +73,15 @@ namespace nana
void background(graph_reference graph, window wd, const nana::rectangle& r, const ui_element& ue)
{
ui_el_ = ue;
style_.bgcolor = API::background(wd);
style_.fgcolor = API::foreground(wd);
style_.bgcolor = API::bgcolor(wd);
style_.fgcolor = API::fgcolor(wd);
if(ue.what == ue.none || (API::window_enabled(wd) == false))
{ //the mouse is out of the widget.
style_.bgcolor = nana::paint::graphics::mix(style_.bgcolor, 0xA0C9F5, 0.9);
style_.bgcolor.blend(expr_color{ 0xa0, 0xc9, 0xf5 }, 0.9);
//style_.bgcolor = nana::paint::graphics::mix(style_.bgcolor, 0xA0C9F5, 0.9); //deprecated
}
graph.rectangle(r, style_.bgcolor, true);
graph.rectangle(r, true, style_.bgcolor);
}
virtual void root_arrow(graph_reference graph, const nana::rectangle& r, mouse_action state)
@@ -90,7 +91,7 @@ namespace nana
if(ui_el_.what == ui_el_.item_root)
{
_m_item_bground(graph, r.x + 1, r.y, r.width - 2, r.height, (state == mouse_action::pressed ? mouse_action::pressed : mouse_action::over));
graph.rectangle(r, 0x3C7FB1, false);
graph.rectangle(r, false, expr_color{ 0x3C, 0x7F, 0xB1 });
if(state == mouse_action::pressed)
{
++x;
@@ -98,7 +99,7 @@ namespace nana
}
}
else
graph.rectangle(r, style_.bgcolor, true);
graph.rectangle(r, true, style_.bgcolor);
nana::paint::gadget::arrow_16_pixels(graph, x, y,
style_.fgcolor, 3, nana::paint::gadget::directions::to_west);
@@ -126,18 +127,26 @@ namespace nana
int top = r.y + 1;
unsigned width = r.width - 2;
unsigned height = r.height - 2;
::nana::expr_color clr{ 0x3C, 0x7F, 0xB1 };
if(has_child)
{
int left = r.x + r.width - 16;
_m_item_bground(graph, left, top, 15, height, state_arrow);
width -= 16;
--left;
graph.line(left, top, left, r.y + height, 0x3C7FB1);
//graph.line(left, top, left, r.y + height, 0x3C7FB1);//deprecated
graph.set_color(clr);
graph.line({ left, top }, { left, r.y + static_cast<int>(height) });
}
_m_item_bground(graph, r.x + 1, top, width, height, state_name);
graph.rectangle(r, 0x3C7FB1, false);
//graph.rectangle(r, 0x3C7FB1, false); //deprecated
graph.set_color(clr);
graph.rectangle(r, false);
}
graph.string(strpos.x, strpos.y, style_.fgcolor, name);
//graph.string(strpos.x, strpos.y, style_.fgcolor, name); //deprecated
graph.string(strpos, name, style_.fgcolor);
if(has_child)
{
@@ -148,9 +157,19 @@ namespace nana
void border(graph_reference graph)
{
graph.rectangle(0xF0F0F0, false);
graph.rectangle_line(nana::rectangle(graph.size()).pare_off(1),
0x9DABB9, 0x484E55, 0x484E55, 0x9DABB9);
rectangle r{ graph.size() };
graph.set_color({ 0xf0, 0xf0, 0xf0 });
graph.rectangle(r, false);
expr_color lb(0x9d, 0xab, 0xb9);
expr_color tr(0x48, 0x4e, 0x55);
graph.frame_rectangle(r.pare_off(1), lb, tr, tr, lb);
//deprecated
//graph.rectangle(0xF0F0F0, false);
//graph.rectangle_line(nana::rectangle(graph.size()).pare_off(1),
// 0x9DABB9, 0x484E55, 0x484E55, 0x9DABB9);
}
private:
void _m_item_bground(graph_reference graph, int x, int y, unsigned width, unsigned height, mouse_action state)
@@ -158,38 +177,55 @@ namespace nana
const unsigned half = (height - 2) / 2;
int left = x + 1;
int top = y + 1;
nana::color_t upcol, downcol;
//nana::color_t upcol, downcol; // deprecated
nana::expr_color clr_top(0xea, 0xea, 0xea), clr_bottom(0xdc, 0xdc, 0xdc);
switch(state)
{
case mouse_action::over:
upcol = 0x0DFF2FC;
downcol = 0xA9DAF5;
clr_top = expr_color(0xdf, 0xf2, 0xfc);
clr_bottom = expr_color(0xa9, 0xda, 0xf5);
//upcol = 0x0DFF2FC; //deprecated
//downcol = 0xA9DAF5;
break;
case mouse_action::pressed:
upcol = 0xA6D7F2;
downcol = 0x92C4F6;
//upcol = 0xA6D7F2; //deprecated
//downcol = 0x92C4F6;
clr_top = expr_color(0xa6, 0xd7, 0xf2);
clr_bottom = expr_color(0x92, 0xc4, 0xf6);
++left;
++top;
break;
case mouse_action::normal:
//case mouse_action::normal: //deprecated
default:
upcol = 0xEAEAEA;
downcol = 0xDCDCDC;
//upcol = 0xEAEAEA; //deprecated
//downcol = 0xDCDCDC;
break;
}
graph.rectangle(left, top, width - 2, half, upcol, true);
graph.rectangle(left, top + static_cast<int>(half), width - 2, (height - 2) - half, downcol, true);
graph.rectangle(rectangle{ left, top, width - 2, half }, true, clr_top);
graph.rectangle(rectangle{ left, top + static_cast<int>(half), width - 2, (height - 2) - half }, true, clr_bottom);
//graph.rectangle(left, top, width - 2, half, upcol, true); //deprecated
//graph.rectangle(left, top + static_cast<int>(half), width - 2, (height - 2) - half, downcol, true);
if(mouse_action::pressed == state)
{
int bottom = y + height - 1;
int right = x + width - 1;
graph.line(x, y, right, y, 0x6E8D9F);
graph.line(x, y + 1, x, bottom, 0x6E8D9F);
graph.set_color(expr_color(0x6e, 0x8d, 0x9f));
graph.line(point{ x, y }, point{right, y});
graph.line(point{ x, y + 1 }, point{ x, bottom });
++x;
++y;
graph.line(x, y, right, y, 0xA6C7D9);
graph.line(x, y + 1, x, bottom, 0xA6C7D9);
graph.set_color(expr_color(0xa6, 0xc7, 0xd9));
graph.line(point{ x, y }, point{ right, y });
graph.line(point{ x, y + 1 }, point{ x, bottom });
//graph.line(x, y, right, y, 0x6E8D9F); //deprecated
//graph.line(x, y + 1, x, bottom, 0x6E8D9F);
//++x;
//++y;
//graph.line(x, y, right, y, 0xA6C7D9);
//graph.line(x, y + 1, x, bottom, 0xA6C7D9);
}
}
@@ -197,8 +233,10 @@ namespace nana
ui_element ui_el_;
struct style_tag
{
nana::color_t bgcolor;
nana::color_t fgcolor;
//nana::color_t bgcolor;
//nana::color_t fgcolor;
expr_color bgcolor;
expr_color fgcolor;
}style_;
};
@@ -369,7 +407,6 @@ namespace nana
};
scheme()
: graph_(nullptr)
{
proto_.ui_renderer = pat::cloneable<renderer>(interior_renderer());
style_.mode = mode::normal;
@@ -379,7 +416,8 @@ namespace nana
void attach(window wd, nana::paint::graphics* graph)
{
window_ = wd;
API::background(wd, 0xFFFFFF);
//API::background(wd, 0xFFFFFF); //deprecated
API::bgcolor(wd, colors::white);
graph_ = graph;
}
@@ -637,7 +675,7 @@ namespace nana
nana::rectangle _m_make_root_rectangle() const
{
return nana::rectangle(1, 1, 16, _m_item_fix_scale());
return{ 1, 1, 16, _m_item_fix_scale() };
}
//_m_make_rectangle
@@ -765,8 +803,8 @@ namespace nana
}
}
private:
window window_;
nana::paint::graphics * graph_;
window window_{nullptr};
nana::paint::graphics * graph_{nullptr};
nana::string splitstr_;
std::size_t head_;
unsigned item_height_;