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); 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) void trigger::_m_draw_border(graph_reference graph)
{ {
nana::rectangle r(graph.size()); nana::rectangle r(graph.size());
@ -303,10 +295,13 @@ namespace nana{ namespace drawerbase
graph.frame_rectangle(r, lt, lt, rb, rb); graph.frame_rectangle(r, lt, lt, rb, rb);
graph.palette(false, colors::button_face); 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)); 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) if (element_state::pressed == attr_.e_state)
graph.rectangle(r, false, static_cast<color_rgb>(0xc3c3c3)); graph.rectangle(r, false, static_cast<color_rgb>(0xc3c3c3));

View File

@ -36,28 +36,20 @@ namespace nana
{ {
if (state == StateHighlighted) if (state == StateHighlighted)
{ {
::nana::color clr(static_cast<color_rgb>(0xafc7e3)); graph.rectangle(r, false, static_cast<color_rgb>(0xafc7e3));
graph.rectangle(r, false, clr);
auto right = r.right() - 1;
auto bottom = r.bottom() - 1;
graph.palette(false, colors::white); 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; paint::draw draw{ graph };
--bottom; draw.corner(r, 1);
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);
nana::rectangle po_r(r); graph.palette(false, static_cast<color_rgb>(0xafc7e3));
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); 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 else
graph.rectangle(r, true, colors::white); graph.rectangle(r, true, colors::white);
@ -83,7 +75,9 @@ namespace nana
unsigned item_pixels(graph_reference graph) const 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 };//end class item_renderer

View File

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

View File

@ -112,13 +112,9 @@ namespace nana
nana::rectangle r(pos, size); nana::rectangle r(pos, size);
graph_.rectangle(r, false, border); 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_.palette(false, corner);
graph_.set_pixel(pos.x, pos.y);
graph_.set_pixel(right, pos.y); paint::draw{ graph_ }.corner(r, 1);
graph_.set_pixel(pos.x, bottom);
graph_.set_pixel(right, bottom);
graph_.rectangle(r.pare_off(1), true, body); graph_.rectangle(r.pare_off(1), true, body);
} }