refactor drawing of shortkey underline

This commit is contained in:
Jinhao
2017-08-27 10:32:56 +08:00
parent 4e18d81f90
commit ec9ec611b4
5 changed files with 28 additions and 50 deletions

View File

@@ -441,23 +441,9 @@ namespace nana
renderer->item_text(graph, nana::point(item_r.x + 40, item_r.y + text_top_off), text, strpixels, attr);
if (hotkey)
{
item_ptr->hotkey = hotkey;
if (item_ptr->flags.enabled)
{
auto off_px = (hotkey_pos ? graph.text_extent_size(text.c_str(), hotkey_pos).width : 0);
auto hotkey_px = graph.text_extent_size(text.c_str() + hotkey_pos, 1).width;
unsigned ascent, descent, inleading;
graph.text_metrics(ascent, descent, inleading);
int x = item_r.x + 40 + off_px;
int y = item_r.y + text_top_off + ascent + 1;
graph_->line({ x, y }, { x + static_cast<int>(hotkey_px)-1, y }, colors::black);
}
}
item_ptr->hotkey = hotkey;
if (hotkey && item_ptr->flags.enabled)
API::dev::draw_shortkey_underline(*graph_, text, hotkey, hotkey_pos, {item_r.x + 40, item_r.y + text_top_off}, colors::black);
if (item_ptr->linked.menu_ptr)
renderer->sub_arrow(graph, nana::point(graph_->width() - 20, item_r.y), item_h_px, attr);