Added listbox color scheme

This commit is contained in:
cnjinhao
2014-12-30 06:28:23 +08:00
parent 052d34a746
commit aa12254844
22 changed files with 142 additions and 107 deletions

View File

@@ -298,10 +298,8 @@ namespace nana{ namespace drawerbase
nana::rectangle r(graph.size());
r.pare_off(1);
::nana::color from(colors::white);
from.blend(attr_.bgcolor, 0.8);
::nana::color to(colors::black);
to.blend(attr_.bgcolor, 0.05);
auto from = attr_.bgcolor.blend(colors::white, 0.2);
auto to = attr_.bgcolor.blend(colors::black, 0.95);
if (element_state::pressed == attr_.e_state)
{

View File

@@ -78,7 +78,7 @@ namespace nana
if(ue.what == ue.none || (API::window_enabled(wd) == false))
{ //the mouse is out of the widget.
style_.bgcolor.blend(color{ 0xa0, 0xc9, 0xf5 }, 0.9);
style_.bgcolor = style_.bgcolor.blend(color{ 0xa0, 0xc9, 0xf5 }, 0.9);
}
graph.rectangle(r, true, style_.bgcolor);
}

View File

@@ -1693,10 +1693,11 @@ namespace nana
// the state of the struct does not effect on member funcions, therefore all data members are public.
struct essence_t
{
enum class state_t{normal, highlighted, pressed, grabed, floated};
enum class state_t{normal, highlighted, pressed, grabbed, floated};
enum class where_t{unknown = -1, header, lister, checker};
nana::paint::graphics *graph{nullptr};
::nana::listbox::scheme_type* scheme_ptr{nullptr};
::nana::paint::graphics *graph{nullptr};
bool auto_draw{true};
bool checkable{false};
bool if_image{false};
@@ -2207,9 +2208,14 @@ namespace nana
_m_draw(essence_->header.cont(), r);
const int y = r.y + r.height - 1;
essence_->graph->line({ r.x, y }, { r.x + static_cast<int>(r.width), y }, { 0xDE, 0xDF, 0xE1 });
essence_->graph->line({ r.x, y }, { r.x + static_cast<int>(r.width), y }, _m_border_color());
}
private:
::nana::color _m_border_color() const
{
return essence_->scheme_ptr->header_bgcolor.get_color().blend(colors::black, 0.8);
}
size_type _m_target_strip(int x, const nana::rectangle& rect, size_type grab, bool& place_front)
{
//convert x to header logic coordinate.
@@ -2268,32 +2274,36 @@ namespace nana
if(next_x > rect.x)
{
_m_draw_item(graph, x, rect.y, height, txtop, txtcolor, i, (i.index == essence_->pointer_where.second ? state : essence_t::state_t::normal));
graph.line({ next_x - 1, rect.y }, { next_x - 1, bottom_y }, { 0xDE, 0xDF, 0xE1 });
graph.line({ next_x - 1, rect.y }, { next_x - 1, bottom_y }, _m_border_color());
}
if(next_x > rect.right())
break;
x = next_x;
if(x - rect.x > static_cast<int>(rect.width)) break;
}
}
if(x - rect.x < static_cast<int>(rect.width))
graph.rectangle({ x, rect.y, rect.width - x + rect.x, height }, true, { 0xF1, 0xF2, 0xF4 });
graph.rectangle({ x, rect.y, rect.width - x + rect.x, height }, true, essence_->scheme_ptr->header_bgcolor);
}
template<typename Item>
void _m_draw_item(graph_reference graph, int x, int y, unsigned height, int txtop, const ::nana::color& fgcolor, const Item& item, essence_t::state_t state)
{
essence_->scheme_ptr->header_bgcolor.get_color();
::nana::color bgcolor;
typedef essence_t::state_t state_t;
switch(state)
{
case state_t::normal: bgcolor.from_rgb(0xf1, 0xf2, 0xf4); break;
case state_t::highlighted: bgcolor = colors::white; break;
case state_t::normal: bgcolor = essence_->scheme_ptr->header_bgcolor.get_color(); break;
case state_t::highlighted: bgcolor = essence_->scheme_ptr->header_bgcolor.get_color().blend(colors::white, 0.5); break;
case state_t::pressed:
case state_t::grabed: bgcolor.from_rgb(0x8B, 0xD6, 0xF6); break;
case state_t::floated: bgcolor.from_rgb(0xBA, 0xBB, 0xBC); break;
case state_t::grabbed: bgcolor = essence_->scheme_ptr->header_grabbed.get_color(); break;
case state_t::floated: bgcolor = essence_->scheme_ptr->header_floated.get_color(); break;
}
graph.rectangle({ x, y, item.pixels, height }, true, bgcolor);
graph.gradual_rectangle({ x, y, item.pixels, height }, bgcolor.blend(colors::white, 0.9), bgcolor.blend(colors::black, 0.9), true);
graph.string({ x + 5, txtop }, item.text, fgcolor);
if(item.index == essence_->lister.sort_index())
@@ -2467,7 +2477,7 @@ namespace nana
bgcolor = nana::color(0xD5, 0xEF, 0xFC);
if (state == essence_t::state_t::highlighted)
bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8);
bgcolor = bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8);
auto graph = essence_->graph;
graph->set_color(bgcolor);
@@ -2501,8 +2511,8 @@ namespace nana
void _m_draw_item(const item_t& item, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, const std::vector<size_type>& seqs, nana::color bgcolor, nana::color fgcolor, essence_t::state_t state) const
{
if(item.flags.selected)
bgcolor = nana::color(0xD5, 0xEF, 0xFC);
if (item.flags.selected)
bgcolor = essence_->scheme_ptr->item_selected;
else if (!item.bgcolor.invisible())
bgcolor = item.bgcolor;
@@ -2511,7 +2521,12 @@ namespace nana
auto graph = essence_->graph;
if (essence_t::state_t::highlighted == state)
bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8);
{
if (item.flags.selected)
bgcolor = bgcolor.blend(colors::black, 0.98);
else
bgcolor = bgcolor.blend(essence_->scheme_ptr->item_selected, 0.7);
}
unsigned show_w = width - essence_->scroll.offset_x;
if(show_w >= r.width) show_w = r.width;
@@ -2541,7 +2556,7 @@ namespace nana
{
case essence_t::state_t::highlighted:
estate = element_state::hovered; break;
case essence_t::state_t::grabed:
case essence_t::state_t::grabbed:
estate = element_state::pressed; break;
default: break;
}
@@ -2573,10 +2588,10 @@ namespace nana
{
if (!item.flags.selected)
{
auto cell_bgcolor = m_cell.custom_format->bgcolor;
if (essence_t::state_t::highlighted == state)
cell_bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8);
graph->set_color(cell_bgcolor);
graph->set_color(m_cell.custom_format->bgcolor.blend(::nana::color(0x99, 0xde, 0xfd), 0.8));
else
graph->set_color(m_cell.custom_format->bgcolor);
graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true);
}
@@ -2688,6 +2703,7 @@ namespace nana
void trigger::attached(widget_reference widget, graph_reference graph)
{
essence_->scheme_ptr = static_cast<::nana::listbox::scheme_type*>(API::dev::get_scheme(widget));
essence_->graph = &graph;
typeface_changed(graph);
@@ -2719,7 +2735,7 @@ namespace nana
{
if(essence_->pointer_where.first == essence_t::where_t::header)
{
essence_->ptr_state = essence_t::state_t::grabed;
essence_->ptr_state = essence_t::state_t::grabbed;
nana::point pos = arg.pos;
essence_->widget_to_header(pos);
drawer_header_->grab(pos, true);
@@ -2728,7 +2744,7 @@ namespace nana
}
}
if(essence_->ptr_state == essence_t::state_t::grabed)
if(essence_->ptr_state == essence_t::state_t::grabbed)
{
nana::point pos = arg.pos;
essence_->widget_to_header(pos);
@@ -2756,7 +2772,7 @@ namespace nana
}
}
}
if(set_spliter == false && essence_->ptr_state != essence_t::state_t::grabed)
if(set_spliter == false && essence_->ptr_state != essence_t::state_t::grabbed)
{
if((drawer_header_->item_spliter() != npos) || (essence_->lister.wd_ptr()->cursor() == cursor::size_we))
{
@@ -2783,7 +2799,7 @@ namespace nana
typedef essence_t::state_t state_t;
if((essence_->pointer_where.first != essence_t::where_t::unknown) || (essence_->ptr_state != state_t::normal))
{
if(essence_->ptr_state != state_t::grabed)
if(essence_->ptr_state != state_t::grabbed)
{
essence_->pointer_where.first = essence_t::where_t::unknown;
essence_->ptr_state = state_t::normal;
@@ -2892,7 +2908,7 @@ namespace nana
}
}
}
else if(prev_state == state_t::grabed)
else if(prev_state == state_t::grabbed)
{
nana::point pos = arg.pos;
essence_->widget_to_header(pos);

View File

@@ -108,14 +108,12 @@ namespace nana
case item_renderer::state_highlight:
border = colors::highlight;
body.from_rgb(0xC0, 0xDD, 0xFC);
corner = body;
corner.blend(bground, 0.5);
corner = body.blend(bground, 0.5);
break;
case item_renderer::state_selected:
border = colors::dark_border;
body = colors::white;
corner = body;
corner.blend(bground, 0.5);
corner = body.blend(bground, 0.5);
break;
default: //Don't process other states.
return;
@@ -541,8 +539,8 @@ namespace nana
{
int x = item_pos.x + item_s.width;
int y1 = item_pos.y + 2, y2 = item_pos.y + item_s.height - 1;
graph_->line({ x, y1 }, { x, y2 }, ::nana::color(colors::gray_border).blend(bgcolor, 0.6));
graph_->line({ x + 1, y1 }, { x + 1, y2 }, ::nana::color(colors::button_face_shadow_end).blend(bgcolor, 0.5));
graph_->line({ x, y1 }, { x, y2 }, bgcolor.blend(colors::gray_border, 0.4));
graph_->line({ x + 1, y1 }, { x + 1, y2 }, bgcolor.blend(colors::button_face_shadow_end, 0.5));
}
//Draw text, the text is transformed from orignal for hotkey character

View File

@@ -208,7 +208,8 @@ namespace nana
graph.rectangle(r, false, clr);
graph.set_color(clr.blend(colors::white, 0.5));
clr = clr.blend(colors::white, 0.5);
graph.set_color(clr);
r.pare_off(2);

View File

@@ -1528,7 +1528,7 @@ namespace nana{ namespace widgets
API::caret_visible(window_, visible);
if(visible)
API::caret_pos(window_, pos.x, pos.y);
API::caret_pos(window_, pos);
}
}

View File

@@ -40,9 +40,10 @@ namespace nana
if(bgcolor_ != bgcolor)
{
bgcolor_ = bgcolor;
dark_bgcolor_ = ::nana::color{ colors::black }.blend(bgcolor, 0.1);
blcolor_ = ::nana::color{ colors::black }.blend(bgcolor, 0.5);
ilcolor_ = ::nana::color{ colors::white }.blend(bgcolor, 0.1);
dark_bgcolor_ = bgcolor.blend(colors::black, 0.9);
blcolor_ = bgcolor.blend(colors::black, 0.5);
ilcolor_ = bgcolor.blend(colors::white, 0.9);
}
graph.rectangle(true, bgcolor);
@@ -65,8 +66,8 @@ namespace nana
else
{
bgcolor = m.bgcolor;
blcolor = color{ colors::black }.blend(m.bgcolor, 0.5);
dark_bgcolor = color{ colors::black }.blend(m.bgcolor, 0.1);
blcolor = m.bgcolor.blend(colors::black, 0.5);
dark_bgcolor = m.bgcolor.blend(colors::black, 0.9);
}
auto round_r = r;
@@ -81,12 +82,12 @@ namespace nana
if (m.bgcolor.invisible())
beg = ilcolor_;
else
beg = color{ m.bgcolor }.blend(colors::white, 0.5);
beg = m.bgcolor.blend(colors::white, 0.5);
end = bgcolor;
}
if (sta == item_renderer::highlight)
beg.blend(colors::white, 0.5);
beg = beg.blend(colors::white, 0.5);
graph.gradual_rectangle(round_r.pare_off(2), beg, end, true);
}
@@ -131,9 +132,9 @@ namespace nana
::nana::color rect_clr{0x9d, 0xa3, 0xab};
graph.round_rectangle(r, 1, 1, rect_clr, false, {});
nana::rectangle draw_r(r);
graph.rectangle(draw_r.pare_off(1), false, ::nana::color{ rect_clr }.blend(bgcolor, 0.8));
graph.rectangle(draw_r.pare_off(1), false, ::nana::color{ rect_clr }.blend(bgcolor, 0.4));
graph.rectangle(draw_r.pare_off(1), false, ::nana::color{ rect_clr }.blend(bgcolor, 0.2));
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.8));
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.4));
graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.2));
}
else if (!active)
clr = ::nana::color{ 0x92, 0x99, 0xA4 };

View File

@@ -395,7 +395,7 @@ namespace nana
void drawer::_m_draw_background(const ::nana::color& clr)
{
graph_->gradual_rectangle(graph_->size(), ::nana::color(colors::white).blend(clr, 0.1), ::nana::color(colors::black).blend(clr, 0.05), true);
graph_->gradual_rectangle(graph_->size(), clr.blend(colors::white, 0.9), clr.blend(colors::black, 0.95), true);
}
void drawer::_m_draw()