Skip to content

Commit 5b56430

Browse files
authored
refactor(gui): hoist background color onto shared base builder (#131)
Refs #130
1 parent f4651fc commit 5b56430

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/gui/board/render.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use crate::gui::panel::{
1414

1515
impl Render for RopyBoard {
1616
fn render(&mut self, window: &mut Window, cx: &mut Context<'_, Self>) -> impl IntoElement {
17+
let surface_bg = self.main_panel_surface(cx.theme().background);
18+
1719
let base = v_flex()
1820
.id("ropy-board")
1921
.track_focus(&self.focus_handle)
@@ -22,31 +24,23 @@ impl Render for RopyBoard {
2224
.on_action(cx.listener(Self::on_active_action))
2325
.size_full()
2426
.px_4()
25-
.pb_4();
27+
.pb_4()
28+
.bg(surface_bg);
2629

2730
if !self.activated {
28-
return gpui::div()
29-
.size_full()
30-
.child(base.bg(self.main_panel_surface(cx.theme().background)))
31-
.into_any_element();
31+
return gpui::div().size_full().child(base).into_any_element();
3232
}
3333

3434
let body: AnyElement = match self.active_panel {
3535
ActivePanel::Settings => base
36-
.bg(self.main_panel_surface(cx.theme().background))
3736
.on_key_down(cx.listener(Self::on_settings_key_down))
3837
.child(render_settings_content(self, cx))
3938
.into_any_element(),
4039
ActivePanel::About => base
41-
.bg(self.main_panel_surface(cx.theme().background))
4240
.child(render_about_content(self, cx))
4341
.into_any_element(),
44-
ActivePanel::Help => base
45-
.bg(self.main_panel_surface(cx.theme().background))
46-
.child(render_help_content(self, cx))
47-
.into_any_element(),
42+
ActivePanel::Help => base.child(render_help_content(self, cx)).into_any_element(),
4843
ActivePanel::ClipboardList => base
49-
.bg(self.main_panel_surface(cx.theme().background))
5044
.on_action(cx.listener(Self::on_select_left))
5145
.on_action(cx.listener(Self::on_select_right))
5246
.on_action(cx.listener(Self::on_select_prev))

0 commit comments

Comments
 (0)