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

@@ -1,6 +1,7 @@
/*
* A Scroll Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -139,31 +140,26 @@ namespace nana
_m_background(graph);
unsigned width, height;
int x, y;
::nana::rectangle r(graph.size());
if(vertical_)
{
x = 0;
y = graph.height() - fixedsize;
width = graph.width();
height = fixedsize;
r.y = r.height - fixedsize;
r.height = fixedsize;
}
else
{
x = graph.width() - fixedsize;
y = 0;
width = fixedsize;
height = graph.height();
r.x = r.width - fixedsize;
r.width = fixedsize;
}
int state = ((_m_check() == false || what == buttons::none) ? states::none : states::highlight);
int moused_state = (_m_check() ? (metrics_.pressed ? states::selected : states::actived) : states::none);
//draw first
_m_draw_button(graph, 0, 0, width, height, buttons::first, (buttons::first == what ? moused_state : state));
_m_draw_button(graph, { 0, 0, r.width, r.height }, buttons::first, (buttons::first == what ? moused_state : state));
//draw second
_m_draw_button(graph, x, y, width, height, buttons::second, (buttons::second == what ? moused_state : state));
_m_draw_button(graph, r, buttons::second, (buttons::second == what ? moused_state : state));
//draw scroll
_m_draw_scroll(graph, (buttons::scroll == what ? moused_state : states::highlight));
@@ -172,7 +168,7 @@ namespace nana
//private:
void drawer::_m_background(graph_reference graph)
{
graph.rectangle(0xF0F0F0, true);
graph.rectangle(true, {0xf0, 0xf0, 0xf0});
if(metrics_.pressed && _m_check())
{
@@ -193,45 +189,44 @@ namespace nana
return;
if(width && height)
graph.rectangle(x, y, width, height, 0xDCDCDC, true);
graph.rectangle({ x, y, width, height }, true, {0xDC, 0xDC, 0xDC});
}
}
void drawer::_m_button_frame(graph_reference graph, int x, int y, unsigned width, unsigned height, int state)
void drawer::_m_button_frame(graph_reference graph, rectangle r, int state)
{
if(state)
{
unsigned color = 0x979797; //highlight
::nana::expr_color clr{0x97, 0x97, 0x97}; //highlight
switch(state)
{
case states::actived:
color = 0x86D5FD; break;
clr.from_rgb(0x86, 0xD5, 0xFD); break;
case states::selected:
color = 0x3C7FB1; break;
clr.from_rgb(0x3C, 0x7F, 0xB1); break;
}
graph.rectangle(rectangle(x, y, width, height), color, false);
graph.rectangle(r, false, clr);
unsigned color_x = graph.mix(color, 0xFFFFFF, 0.5);
graph.set_color(clr.blend(colors::white, 0.5));
//unsigned color_x = graph.mix(color, 0xFFFFFF, 0.5); //deprecated
x += 2;
y += 2;
width -= 4;
height -= 4;
r.pare_off(2);
if(vertical_)
{
unsigned half = width / 2;
graph.rectangle(x + (width - half), y, half, height, color_x, true);
width -= half;
unsigned half = r.width / 2;
graph.rectangle({ r.x + static_cast<int>(r.width - half), r.y, half, r.height }, true);
r.width -= half;
}
else
{
unsigned half = height / 2;
graph.rectangle(x, y + height - half, width, half, color_x, true);
height -= half;
unsigned half = r.height / 2;
graph.rectangle({r.x, r.y + static_cast<int>(r.height - half), r.width, half}, true);
r.height -= half;
}
graph.shadow_rectangle(x, y, width, height, 0xFFFFFF, color_x, !vertical_);
//graph.shadow_rectangle(x, y, width, height, 0xFFFFFF, color_x, !vertical_);
graph.gradual_rectangle(r, colors::white, clr, !vertical_);
}
}
@@ -275,34 +270,27 @@ namespace nana
{
if(_m_check())
{
int x, y;
unsigned width, height;
::nana::rectangle r(graph.size());
if(vertical_)
{
x = 0;
y = fixedsize + metrics_.scroll_pos;
width = graph.width();
height = static_cast<unsigned>(metrics_.scroll_length);
r.y = fixedsize + metrics_.scroll_pos;
r.height = static_cast<unsigned>(metrics_.scroll_length);
}
else
{
x = fixedsize + metrics_.scroll_pos;
y = 0;
width = static_cast<unsigned>(metrics_.scroll_length);
height = graph.height();
r.x = fixedsize + metrics_.scroll_pos;
r.width = static_cast<unsigned>(metrics_.scroll_length);
}
_m_button_frame(graph, x, y, width, height, state);
_m_button_frame(graph, r, state);
}
}
void drawer::_m_draw_button(graph_reference graph, int x, int y, unsigned width, unsigned height, buttons what, int state)
void drawer::_m_draw_button(graph_reference graph, rectangle r, buttons what, int state)
{
if(_m_check())
_m_button_frame(graph, x, y, width, height, state);
_m_button_frame(graph, r, state);
using namespace nana::paint::gadget;
@@ -314,12 +302,12 @@ namespace nana
{
if(vertical_)
{
y = static_cast<int>(sz.height - fixedsize);
r.y = static_cast<int>(sz.height - fixedsize);
dir = directions::to_south;
}
else
{
x = static_cast<int>(sz.width - fixedsize);
r.x = static_cast<int>(sz.width - fixedsize);
dir = directions::to_east;
}
}
@@ -327,11 +315,11 @@ namespace nana
dir = vertical_ ? directions::to_north : directions::to_west;
if(vertical_)
x = (static_cast<int>(sz.width) - 16) / 2;
r.x = (static_cast<int>(sz.width) - 16) / 2;
else
y = (static_cast<int>(sz.height) - 16) / 2;
r.y = (static_cast<int>(sz.height) - 16) / 2;
arrow_16_pixels(graph, x, y, _m_check() ? 0x0 : 0x808080, (states::none == state ? 0 : 1), dir);
arrow_16_pixels(graph, r.x, r.y, (_m_check() ? expr_color(colors::black) : expr_color(0x80, 0x80, 0x80)), (states::none == state ? 0 : 1), dir);
}
}
//end class drawer