| 11 | } |
| 12 | |
| 13 | void MenuItem::drawOffset(NVGcontext* vg, float offset) { |
| 14 | BNDwidgetState state = BND_DEFAULT; |
| 15 | |
| 16 | if (APP->event->hoveredWidget == this) |
| 17 | state = BND_HOVER; |
| 18 | |
| 19 | // Set active state if this MenuItem is the Menu's active entry |
| 20 | Menu* parentMenu = dynamic_cast<Menu*>(parent); |
| 21 | if (parentMenu && parentMenu->activeEntry == this) |
| 22 | state = BND_ACTIVE; |
| 23 | |
| 24 | // Main text and background |
| 25 | const BNDtheme* theme = bndGetTheme(); |
| 26 | if (!disabled) { |
| 27 | // bndMenuItem(vg, 0.0, 0.0, box.size.x, box.size.y, state, -1, text.c_str()); |
| 28 | // From bndMenuItem() implementation |
| 29 | if (state != BND_DEFAULT) { |
| 30 | bndInnerBox(vg, 0.0, 0.0, box.size.x, box.size.y, 0, 0, 0, 0, |
| 31 | bndOffsetColor(theme->menuItemTheme.innerSelectedColor, theme->menuItemTheme.shadeTop), |
| 32 | bndOffsetColor(theme->menuItemTheme.innerSelectedColor, theme->menuItemTheme.shadeDown)); |
| 33 | state = BND_ACTIVE; |
| 34 | } |
| 35 | bndIconLabelValue(vg, offset + 0.0, 0.0, box.size.x - offset, box.size.y, -1, |
| 36 | bndTextColor(&theme->menuItemTheme, state), BND_LEFT, |
| 37 | BND_LABEL_FONT_SIZE, text.c_str(), NULL); |
| 38 | } |
| 39 | else { |
| 40 | // bndMenuLabel(vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str()); |
| 41 | // From bndMenuLabel() implementation |
| 42 | bndIconLabelValue(vg, offset + 0.0, 0.0, box.size.x, box.size.y, -1, theme->menuTheme.textColor, BND_LEFT, BND_LABEL_FONT_SIZE, text.c_str(), NULL); |
| 43 | } |
| 44 | |
| 45 | // Right text |
| 46 | float x = box.size.x - bndLabelWidth(vg, -1, rightText.c_str()); |
| 47 | NVGcolor rightColor = (state == BND_DEFAULT && !disabled) ? bndGetTheme()->menuTheme.textColor : bndGetTheme()->menuTheme.textSelectedColor; |
| 48 | bndIconLabelValue(vg, x, 0.0, box.size.x, box.size.y, -1, rightColor, BND_LEFT, BND_LABEL_FONT_SIZE, rightText.c_str(), NULL); |
| 49 | } |
| 50 | |
| 51 | void MenuItem::step() { |
| 52 | // HACK use APP->window->vg from the window. |
nothing calls this directly
no outgoing calls
no test coverage detected