code refine

This commit is contained in:
Jinhao 2016-08-17 07:27:41 +08:00
parent eed3ffd5b6
commit d66c4bafce
4 changed files with 25 additions and 44 deletions

View File

@ -287,14 +287,6 @@ namespace nana{ namespace drawerbase
graph.gradual_rectangle(r, from, to, true);
}
void draw_corner_point(::nana::paint::graphics& graph, const rectangle& r)
{
graph.set_pixel(r.x, r.y);
graph.set_pixel(r.right() - 1, r.y);
graph.set_pixel(r.right() - 1, r.bottom() - 1);
graph.set_pixel(r.x, r.bottom() - 1);
}
void trigger::_m_draw_border(graph_reference graph)
{
nana::rectangle r(graph.size());
@ -303,10 +295,13 @@ namespace nana{ namespace drawerbase
graph.frame_rectangle(r, lt, lt, rb, rb);
graph.palette(false, colors::button_face);
draw_corner_point(graph, r);
paint::draw draw(graph);
draw.corner(r, 1);
graph.palette(false, static_cast<color_rgb>(0x919191));
draw_corner_point(graph, r.pare_off(1));
draw.corner(r.pare_off(1), 1);
if (element_state::pressed == attr_.e_state)
graph.rectangle(r, false, static_cast<color_rgb>(0xc3c3c3));

View File

@ -36,28 +36,20 @@ namespace nana
{
if (state == StateHighlighted)
{
::nana::color clr(static_cast<color_rgb>(0xafc7e3));
graph.rectangle(r, false, clr);
graph.rectangle(r, false, static_cast<color_rgb>(0xafc7e3));
auto right = r.right() - 1;
auto bottom = r.bottom() - 1;
graph.palette(false, colors::white);
graph.set_pixel(r.x, r.y);
graph.set_pixel(right, r.y);
graph.set_pixel(r.x, bottom);
graph.set_pixel(right, bottom);
--right;
--bottom;
graph.palette(false, clr);
graph.set_pixel(r.x + 1, r.y + 1);
graph.set_pixel(right, r.y + 1);
graph.set_pixel(r.x + 1, bottom);
graph.set_pixel(right, bottom);
paint::draw draw{ graph };
draw.corner(r, 1);
nana::rectangle po_r(r);
graph.rectangle(po_r.pare_off(1), false, static_cast<color_rgb>(0xEBF4FB));
graph.gradual_rectangle(po_r.pare_off(1), static_cast<color_rgb>(0xDDECFD), static_cast<color_rgb>(0xC2DCFD), true);
graph.palette(false, static_cast<color_rgb>(0xafc7e3));
auto inner_r = r;
draw.corner(inner_r.pare_off(1), 1);
graph.rectangle(inner_r, false, static_cast<color_rgb>(0xEBF4FB));
graph.gradual_rectangle(inner_r.pare_off(1), static_cast<color_rgb>(0xDDECFD), static_cast<color_rgb>(0xC2DCFD), true);
}
else
graph.rectangle(r, true, colors::white);
@ -83,7 +75,9 @@ namespace nana
unsigned item_pixels(graph_reference graph) const
{
return graph.text_extent_size(L"jHWn/?\\{[(0569").height + 4;
unsigned ascent, descent, ileading;
graph.text_metrics(ascent, descent, ileading);
return ascent + descent + 4;
}
};//end class item_renderer

View File

@ -3940,18 +3940,14 @@ namespace nana
void _m_draw_border(int x, int y, unsigned width) const
{
//Draw selecting inner rectangle
auto graph = essence_->graph;
rectangle r{ x, y, width, essence_->scheme_ptr->item_height };
graph->rectangle({ x, y, width, essence_->scheme_ptr->item_height }, false, static_cast<color_rgb>(0x99defd));
graph->rectangle({ x + 1, y + 1, width - 2, essence_->scheme_ptr->item_height - 2 }, false, colors::white);
essence_->graph->rectangle(r, false, static_cast<color_rgb>(0x99defd));
const int right = x + width - 1;
const int bottom = y + essence_->scheme_ptr->item_height - 1;
essence_->graph->palette(false, colors::white);
paint::draw(*essence_->graph).corner(r, 1);
graph->set_pixel(x, y);
graph->set_pixel(x, bottom);
graph->set_pixel(right, y);
graph->set_pixel(right, bottom);
essence_->graph->rectangle(r.pare_off(1), false);
}
private:
essence * const essence_;

View File

@ -112,13 +112,9 @@ namespace nana
nana::rectangle r(pos, size);
graph_.rectangle(r, false, border);
int right = pos.x + static_cast<int>(size.width) - 1;
int bottom = pos.y + static_cast<int>(size.height) - 1;
graph_.palette(false, corner);
graph_.set_pixel(pos.x, pos.y);
graph_.set_pixel(right, pos.y);
graph_.set_pixel(pos.x, bottom);
graph_.set_pixel(right, bottom);
paint::draw{ graph_ }.corner(r, 1);
graph_.rectangle(r.pare_off(1), true, body);
}