Skip to content

Commit e19eb34

Browse files
fix(shell): render incorrectly when overlaps
1 parent d95f69f commit e19eb34

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/shell/contextmenu/menu_widget.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ void mb_shell::menu_widget::update(ui::update_context &ctx) {
288288
}
289289
}
290290
void mb_shell::menu_widget::render(ui::nanovg_context ctx) {
291-
render_children(ctx, rendering_submenus);
292-
293291
std::lock_guard lock(data_lock);
294292
if (bg) {
295293
bg->render(ctx);
@@ -298,7 +296,16 @@ void mb_shell::menu_widget::render(ui::nanovg_context ctx) {
298296
if (bg_submenu) {
299297
bg_submenu->render(ctx);
300298
}
299+
300+
ctx.transaction([&]() {
301+
ctx.globalCompositeOperation(NVG_COPY);
302+
auto c = menu_render::current.value()->light_color ? 1 : 0;
303+
ctx.fillColor(nvgRGBAf(c, c, c, 0.3));
304+
ctx.fillRect(*x, *y, *width, *height);
305+
});
301306
super::render(ctx);
307+
308+
render_children(ctx, rendering_submenus);
302309
}
303310
void mb_shell::menu_item_widget::reset_appear_animation(float delay) {
304311
this->opacity->after_animate = [this](float dest) {

src/ui/nanovg_wrapper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ inline auto debugDumpPathCache() { return nvgDebugDumpPathCache(ctx); }
167167
return copy;
168168
}
169169

170+
171+
struct TransactionScope {
172+
nanovg_context &ctx;
173+
TransactionScope(nanovg_context &ctx) : ctx(ctx) { ctx.save(); }
174+
~TransactionScope() { ctx.restore(); }
175+
};
176+
177+
inline TransactionScope transaction() { return TransactionScope(*this); }
178+
170179
inline void transaction(std::function<void()> f) {
171180
save();
172181
f();

0 commit comments

Comments
 (0)