Skip to content

Commit

Permalink
Style consistency and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavidmackenzie committed Feb 4, 2025
1 parent e8c2b53 commit cd92eba
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/views/config_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ pub fn view<'a>(
button = button.on_press(Message::MenuBarButtonClicked); // Needed for highlighting

// Increased width to 145 as Linux needs a little more width
Item::with_menu(button, Menu::new(menu_items).width(180.0).offset(10.0))
Item::with_menu(button, Menu::new(menu_items).width(180.0))
}
2 changes: 1 addition & 1 deletion src/views/connection_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ pub fn view<'a>(hardware_view: &'a HardwareView) -> Item<'a, Message, Theme, Ren
button(text(model_string))
.on_press(Message::MenuBarButtonClicked) // Needed for highlighting
.style(menu_bar_button),
Menu::new(menu_items).width(215.0).offset(10.0),
Menu::new(menu_items).width(215.0),
)
}
24 changes: 10 additions & 14 deletions src/views/devices_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,16 @@ fn device_menu_items<'a>(
// for a [HardwareConnection] type currently used to connect to the device
for hardware_connection in hardware_connections.values() {
if !matches!(hardware_connection, NoConnection) {
// avoid re-offering the current connection method if connected
let connect_button = if current_connection != hardware_connection {
let mut connect_button =
button(text(format!("Connect via {}", hardware_connection.name())))
.on_press(Message::ConnectRequest(hardware_connection.clone()))
.width(Length::Fill)
.style(menu_button_style)
} else {
button(text("Connected to Device"))
.width(Length::Fill)
.style(menu_button_style)
};
.style(menu_button_style);

// avoid re-offering the current connection method if connected
if current_connection != hardware_connection {
connect_button = connect_button
.on_press(Message::ConnectRequest(hardware_connection.clone()));
}
device_menu_items.push(Item::new(connect_button));
}
}
Expand Down Expand Up @@ -108,7 +107,7 @@ fn device_menu_items<'a>(

device_items.push(Item::with_menu(
device_button,
Menu::new(device_menu_items).width(280.0).offset(10.0),
Menu::new(device_menu_items).width(200.0),
));
}

Expand All @@ -126,9 +125,6 @@ pub fn view<'a>(
button(text(format!("devices ({})", device_menu_items.len())))
.on_press(Message::MenuBarButtonClicked) // Needed for highlighting
.style(menu_button_style),
Menu::new(device_menu_items)
.width(380.0)
.max_width(400.0)
.offset(10.0),
Menu::new(device_menu_items).width(380.0).max_width(400.0),
)
}
16 changes: 10 additions & 6 deletions src/views/hardware_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use iced::widget::{
};
use iced::widget::{container, Tooltip};
use iced::Alignment::{End, Start};
use iced::{Alignment, Center, Element, Fill, Length, Size, Task};
use iced::{alignment, Alignment, Center, Element, Fill, Length, Size, Task};
use iced::{Renderer, Theme};
use iced_aw::menu::Item;
use iced_aw::{Menu, MenuBar};
Expand Down Expand Up @@ -712,10 +712,14 @@ fn pin_button_menu<'a>(
}
pullup_items.push(Item::new(pullup_button));
}
let input_button = button("Input")
.width(Fill)
.on_press(HardwareViewMessage::MenuBarButtonClicked) // Needed for highlighting
.style(menu_button_style);
let input_button = button(row!(
text("Input"),
horizontal_space(),
text(" >").align_y(alignment::Vertical::Center),
))
.width(100.0)
.on_press(HardwareViewMessage::MenuBarButtonClicked) // Needed for highlighting
.style(menu_button_style);
pin_menu_items.push(Item::with_menu(
input_button,
Menu::new(pullup_items).width(80.0),
Expand Down Expand Up @@ -751,7 +755,7 @@ fn pin_button_menu<'a>(

Item::with_menu(
pin_button(pin_description).on_press(HardwareViewMessage::MenuBarButtonClicked), // Needed for highlighting
Menu::new(pin_menu_items).width(70.0),
Menu::new(pin_menu_items).width(80.0),
)
}

Expand Down
29 changes: 20 additions & 9 deletions src/views/info_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ const BLACK_SHADOW: Shadow = Shadow {

const HOVERED_COLOR: Color = Color::WHITE;
const UNHOVERED_COLOR: Color = Color::from_rgba(0.7, 0.7, 0.7, 1.0);
const MENU_BAR_BORDER: Border = Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: MENU_RADIUS,
};

const MENU_BORDER: Border = Border {
color: Color::WHITE,
width: 1.0,
radius: MENU_RADIUS,
};

const MENU_BUTTON_BORDER: Border = Border {
color: Color::TRANSPARENT,
width: 0.0,
radius: MENU_RADIUS,
Expand All @@ -54,55 +65,55 @@ const MENU_SHADOW: Shadow = Shadow {
const MENU_BAR_BUTTON_STYLE: Style = Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: UNHOVERED_COLOR,
border: MENU_BORDER,
border: MENU_BUTTON_BORDER,
shadow: MENU_SHADOW,
};

const MENU_BAR_BUTTON_HOVER_STYLE: Style = Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: HOVERED_COLOR,
border: MENU_BORDER,
border: MENU_BAR_BORDER,
shadow: MENU_SHADOW,
};

const MENU_BAR_BUTTON_HIGHLIGHT_STYLE: Style = Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: Color::from_rgba(1.0, 0.647, 0.0, 0.7),
border: MENU_BORDER,
border: MENU_BAR_BORDER,
shadow: MENU_SHADOW,
};

const MENU_BUTTON_STYLE: Style = Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: UNHOVERED_COLOR,
border: MENU_BORDER,
border: MENU_BUTTON_BORDER,
shadow: MENU_SHADOW,
};

const MENU_BUTTON_HOVER_STYLE: Style = Style {
background: Some(Background::Color(Color::TRANSPARENT)),
text_color: HOVERED_COLOR,
border: MENU_BORDER,
border: MENU_BUTTON_BORDER,
shadow: MENU_SHADOW,
};

pub const MENU_BAR_STYLE: menu_bar::Style = menu_bar::Style {
bar_background: Background::Color(Color::TRANSPARENT),
bar_border: MENU_BORDER,
bar_border: MENU_BAR_BORDER,
bar_shadow: MENU_SHADOW,
bar_background_expand: Padding::new(2.0),
bar_background_expand: Padding::new(0.0),
menu_background: Background::Color(MENU_BACKGROUND_COLOR),
menu_border: MENU_BORDER,
menu_shadow: BLACK_SHADOW,
menu_background_expand: Padding::new(5.0),
menu_background_expand: Padding::new(0.0),
path: Background::Color(Color::TRANSPARENT),
path_border: MENU_BORDER,
};

const INFO_BAR_STYLE: container::Style = container::Style {
text_color: Some(Color::WHITE),
background: Some(Background::Color(MENU_BACKGROUND_COLOR)),
border: MENU_BORDER,
border: MENU_BAR_BORDER,
shadow: MENU_SHADOW,
};

Expand Down
2 changes: 1 addition & 1 deletion src/views/layout_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ impl LayoutSelector {
.style(menu_bar_button)
.on_press(Message::MenuBarButtonClicked); // Needed for highlighting;

Item::with_menu(button, Menu::new(menu_items).width(135.0).offset(10.0))
Item::with_menu(button, Menu::new(menu_items).width(135.0))
}
}

0 comments on commit cd92eba

Please sign in to comment.