Skip to content

Commit

Permalink
added more styles for pane grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Redhawk18 committed Aug 29, 2023
1 parent b19ffae commit 1a6dbdb
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum Message {
TabSelected(usize),
TabClosed(usize),

PaneClick(pane_grid::Pane),
PaneDragged(pane_grid::DragEvent),
PaneResized(pane_grid::ResizeEvent),

Expand Down Expand Up @@ -176,18 +177,17 @@ impl Application for Blaze {
}
Message::PaneDragged(_) => {}
Message::PaneResized(_) => todo!(),

Message::PaneClick(pane) => self.panes.active = Some(pane),
}

Command::none()
}

fn view(&self) -> Element<Message> {
column!(
menu_bar(),
pane_grid(&self.panes, &self.tabs)
)
.padding(8)
.into()
column!(menu_bar(), pane_grid(&self.panes, &self.tabs))
.padding(8)
.into()
}

fn theme(&self) -> Theme {
Expand Down
30 changes: 22 additions & 8 deletions src/gui/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub enum Container {
#[default]
Primary,
PaneGridTitleBar(bool),
PaneGridContent,
PaneGridContent(bool),
}

impl container::StyleSheet for Theme {
Expand All @@ -113,14 +113,28 @@ impl container::StyleSheet for Theme {
Container::Primary => container::Appearance {
..Default::default()
},
Container::PaneGridTitleBar(_) => container::Appearance {
text_color: Some(self.colors.accent.default),
border_color: self.colors.text.default,
background: Some(Background::Color(self.colors.accent.default)),
border_width: 4.0,
border_radius: 4.0.into(),
Container::PaneGridTitleBar(active) => container::Appearance {
text_color: Some(self.colors.text.default),
border_color: if *active {
self.colors.accent.default
} else {
self.colors.primary.default
},
background: Some(Background::Color(self.colors.background.default)),
border_width: 1.0,
border_radius: [4.0, 4.0, 0.0, 0.0].into(),
},
Container::PaneGridContent(active) => container::Appearance {
text_color: Some(self.colors.text.default),
border_color: if *active {
self.colors.accent.default
} else {
self.colors.primary.default
},
background: Some(Background::Color(self.colors.background.default)),
border_width: 1.0,
border_radius: [0.0, 0.0, 4.0, 4.0].into(),
},
Container::PaneGridContent => todo!(),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/gui/theme/shades.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use iced::Color;
use palette::rgb::Rgb;
use palette::{DarkenAssign, FromColor, LightenAssign, Okhsl, Srgb};
use palette::{rgb::Rgb, DarkenAssign, FromColor, LightenAssign, Okhsl, Srgb};

/// provides post-processing to Pigment's raw colors
#[derive(Clone)]
Expand Down
3 changes: 1 addition & 2 deletions src/gui/widgets/menu_bar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::gui::theme::Renderer;
use crate::gui::{FileTab, Message, Tab};
use crate::gui::{theme::Renderer, FileTab, Message, Tab};

use iced::widget::button;
use iced_aw::{MenuBar, MenuTree};
Expand Down
16 changes: 7 additions & 9 deletions src/gui/widgets/pane_grid.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
use crate::gui::theme::Renderer;
use crate::gui::{Tabs, Panes};
use crate::gui::{theme::Renderer, widgets::tab_bar::tab_bar, Message, PaneState, Panes, Tabs};

use crate::gui::{Message, PaneState, Tab};

use iced::widget::pane_grid::{Content, PaneGrid, State, TitleBar};

use super::tab_bar::tab_bar;
use iced::widget::pane_grid::{Content, PaneGrid, TitleBar};

pub fn pane_grid<'a>(panes: &'a Panes, tabs: &'a Tabs) -> PaneGrid<'a, Message, Renderer> {
PaneGrid::new(&panes.data, |pane, state, _is_maximized| {
let is_focused = panes.active == Some(pane);
Content::new(match state {
PaneState::Tab => tab_bar(tabs.active, &tabs.data),
})
.style(crate::gui::theme::Container::PaneGridTitleBar(true))
.style(crate::gui::theme::Container::PaneGridContent(is_focused))
.title_bar(
TitleBar::new("content").style(crate::gui::theme::Container::PaneGridTitleBar(true)),
TitleBar::new("content")
.style(crate::gui::theme::Container::PaneGridTitleBar(is_focused)),
)
})
.on_click(Message::PaneClick)
.on_drag(Message::PaneDragged)
.on_resize(10, Message::PaneResized)
}
6 changes: 4 additions & 2 deletions src/gui/widgets/tab_bar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::gui::theme::{Element, Renderer};
use crate::gui::{Message, Tab};
use crate::gui::{
theme::{Element, Renderer},
Message, Tab,
};

use iced::widget::{column, text_input, Column};
use iced_aw::{TabBar, TabLabel};
Expand Down

0 comments on commit 1a6dbdb

Please sign in to comment.