1111
1212void mb_shell::menu_item_widget::render (ui::nanovg_context ctx) {
1313 super::render (ctx);
14+
15+ auto c = menu_render::current.value ()->light_color ? 0 : 1 ;
1416 if (item.type == menu_item::type::spacer) {
15- ctx.fillColor (nvgRGBAf (1 , 1 , 1 , 0.1 ));
17+ ctx.fillColor (nvgRGBAf (c, c, c , 0.1 ));
1618 ctx.fillRect (x->dest (), *y, *width, *height);
1719 return ;
1820 }
1921
20- ctx.fillColor (nvgRGBAf (1 , 1 , 1 , *bg_opacity / 255 .f ));
22+ ctx.fillColor (nvgRGBAf (c, c, c , *bg_opacity / 255 .f ));
2123
2224 float roundcorner = 4 ;
2325
@@ -29,10 +31,6 @@ void mb_shell::menu_item_widget::render(ui::nanovg_context ctx) {
2931 ctx.fillRoundedRect (*x + margin, *y, *width - margin * 2 , *height,
3032 roundcorner);
3133
32- ctx.fillColor (nvgRGBAf (1 , 1 , 1 , *opacity / 255 .f ));
33- ctx.fontFace (" Yahei" );
34- ctx.fontSize (14 );
35-
3634 if (item.icon_bitmap .has_value ()) {
3735 auto paintY = floor (*y + (*height - icon_width) / 2 );
3836 if (!icon_img_bmp) {
@@ -50,6 +48,10 @@ void mb_shell::menu_item_widget::render(ui::nanovg_context ctx) {
5048 ctx.fill ();
5149 }
5250
51+ ctx.fillColor (nvgRGBAf (c, c, c, *opacity / 255 .f ));
52+ ctx.fontFace (" Yahei" );
53+ ctx.fontSize (14 );
54+
5355 ctx.text (floor (*x + text_padding + icon_width + icon_padding * 2 ), *y + 16 ,
5456 item.name ->c_str (), nullptr );
5557
@@ -59,7 +61,7 @@ void mb_shell::menu_item_widget::render(ui::nanovg_context ctx) {
5961 ctx.moveTo (*x + *width - 20 , *y + 8 );
6062 ctx.lineTo (*x + *width - 15 , *y + 12 );
6163 ctx.lineTo (*x + *width - 20 , *y + 16 );
62- ctx.strokeColor (nvgRGBAf (1 , 1 , 1 , *opacity * 0.6 / 255 .f ));
64+ ctx.strokeColor (nvgRGBAf (c, c, c , *opacity * 0.6 / 255 .f ));
6365 ctx.strokeWidth (1 );
6466 ctx.stroke ();
6567 }
@@ -70,7 +72,7 @@ void mb_shell::menu_item_widget::render(ui::nanovg_context ctx) {
7072 ctx.moveTo (*x + icon_padding + margin + 2 , *y + 4 + 8 );
7173 ctx.lineTo (*x + icon_padding + margin + 6 , *y + 8 + 8 );
7274 ctx.lineTo (*x + icon_padding + margin + 14 , *y + 0 + 8 );
73- ctx.strokeColor (nvgRGBAf (1 , 1 , 1 , *opacity * 0.6 / 255 .f ));
75+ ctx.strokeColor (nvgRGBAf (c, c, c , *opacity * 0.6 / 255 .f ));
7476 ctx.strokeWidth (2 );
7577 ctx.stroke ();
7678 }
@@ -126,12 +128,11 @@ void mb_shell::menu_item_widget::update(ui::update_context &ctx) {
126128 submenu_wid.get (), ctx, anchor_x, anchor_y, direction);
127129
128130 submenu_wid->direction = direction;
129- submenu_wid->have_overlap = ctx.rt .root ->check_hit (ui::update_context{
130- .mouse_x = x / ctx.rt .dpi_scale ,
131- .mouse_y = y / ctx.rt .dpi_scale ,
132- .screen = ctx.screen ,
133- .rt = ctx.rt
134- });
131+ submenu_wid->have_overlap = ctx.rt .root ->check_hit (
132+ ui::update_context{.mouse_x = x / ctx.rt .dpi_scale ,
133+ .mouse_y = y / ctx.rt .dpi_scale ,
134+ .screen = ctx.screen ,
135+ .rt = ctx.rt });
135136
136137 submenu_wid->x ->reset_to (x / ctx.rt .dpi_scale - ctx.offset_x );
137138 submenu_wid->y ->reset_to (y / ctx.rt .dpi_scale - ctx.offset_y );
@@ -213,6 +214,11 @@ void mb_shell::menu_widget::update(ui::update_context &ctx) {
213214 ctx.hovered_hit (bg.get ());
214215}
215216void mb_shell::menu_widget::render (ui::nanovg_context ctx) {
217+ auto c = menu_render::current.value ()->light_color ? 1 : 0 ;
218+ ctx.fillColor (nvgRGBAf (c, c, c, 0.6 ));
219+ ctx.fillRoundedRect (*x, *y - bg_padding_vertical, *width,
220+ *height + 2 * bg_padding_vertical, 6 );
221+
216222 std::lock_guard lock (data_lock);
217223 bg->render (ctx);
218224 super::render (ctx);
0 commit comments