Skip to content

Commit

Permalink
Add height margin to all windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Sep 7, 2024
1 parent ad6baef commit fd2947c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
15 changes: 12 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use data::config::{self, Config};
use data::version::Version;
use data::{environment, history, server, version, Url, User};
use iced::widget::{column, container};
use iced::{Length, Subscription, Task};
use iced::{padding, Length, Subscription, Task};
use screen::{dashboard, help, migration, welcome};

use self::event::{events, Event};
Expand Down Expand Up @@ -789,7 +789,7 @@ impl Halloy {
}

fn view(&self, id: window::Id) -> Element<Message> {
if id == self.main_window.id {
let content = if id == self.main_window.id {
let now = Instant::now();

let screen = match &self.screen {
Expand Down Expand Up @@ -821,7 +821,16 @@ impl Halloy {
.map(Message::Dashboard)
} else {
column![].into()
}
};

// The height margin varies across different operating systems due to design differences.
// For instance, on macOS, the menubar is hidden, resulting in a need for additional padding to accommodate the
// space occupied by the traffic light buttons.
let height_margin = if cfg!(target_os = "macos") { 20 } else { 0 };

container(content)
.padding(padding::top(height_margin))
.into()
}

fn theme(&self, _window: window::Id) -> Theme {
Expand Down
9 changes: 1 addition & 8 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use data::user::Nick;
use data::{client, environment, history, Config, Server, User, Version};
use iced::widget::pane_grid::{self, PaneGrid};
use iced::widget::{column, container, row, Space};
use iced::{clipboard, padding, Length, Task};
use iced::{clipboard, Length, Task};

use self::command_bar::CommandBar;
use self::pane::Pane;
Expand Down Expand Up @@ -707,11 +707,6 @@ impl Dashboard {
)
.map(|e| e.map(Message::Sidebar));

// The height margin varies across different operating systems due to design differences.
// For instance, on macOS, the menubar is hidden, resulting in a need for additional padding to accommodate the
// space occupied by the traffic light buttons.
let height_margin = if cfg!(target_os = "macos") { 20 } else { 0 };

let content = match config.sidebar.position {
data::config::sidebar::Position::Left | data::config::sidebar::Position::Top => {
vec![side_menu.unwrap_or_else(|| row![].into()), pane_grid.into()]
Expand All @@ -725,13 +720,11 @@ impl Dashboard {
Column::with_children(content)
.width(Length::Fill)
.height(Length::Fill)
.padding(padding::top(height_margin))
.into()
} else {
Row::with_children(content)
.width(Length::Fill)
.height(Length::Fill)
.padding(padding::top(height_margin))
.into()
};

Expand Down

0 comments on commit fd2947c

Please sign in to comment.