Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
git-f0x committed Nov 24, 2024
1 parent 7e8cb91 commit da1a111
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 466 deletions.
597 changes: 285 additions & 312 deletions Cargo.lock

Large diffs are not rendered by default.

49 changes: 23 additions & 26 deletions src/shell/element/resize_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use crate::{

use calloop::LoopHandle;
use cosmic::{
iced::widget::{column, container, horizontal_space, row, vertical_space},
iced::{
widget::{column, container, horizontal_space, row, vertical_space},
Alignment,
},
iced_core::{Background, Border, Color, Length},
theme,
widget::{icon::from_name, text},
Expand Down Expand Up @@ -66,7 +69,7 @@ impl Program for ResizeIndicatorInternal {
fn view(&self) -> cosmic::Element<'_, Self::Message> {
let edges = self.edges.lock().unwrap();
let icon_container_style = || {
theme::Container::custom(|theme| container::Appearance {
theme::Container::custom(|theme| container::Style {
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
Expand All @@ -90,14 +93,13 @@ impl Program for ResizeIndicatorInternal {
.prefer_svg(true)
.apply(container)
.padding(8)
.style(icon_container_style())
.class(icon_container_style())
.width(Length::Shrink)
.apply(container)
.center_x()
.width(Length::Fill)
.center_x(Length::Fill)
.into()
} else {
vertical_space(36).into()
vertical_space().height(36).into()
},
row(vec![
if edges.contains(ResizeEdge::LEFT) {
Expand All @@ -110,35 +112,32 @@ impl Program for ResizeIndicatorInternal {
.prefer_svg(true)
.apply(container)
.padding(8)
.style(icon_container_style())
.class(icon_container_style())
.width(Length::Shrink)
.apply(container)
.center_y()
.height(Length::Fill)
.center_y(Length::Fill)
.into()
} else {
horizontal_space(36).into()
horizontal_space().width(36).into()
},
row(vec![
text::heading(&self.shortcut1).into(),
text::body(fl!("grow-window")).into(),
horizontal_space(40).into(),
horizontal_space().width(40).into(),
text::heading(&self.shortcut2).into(),
text::body(fl!("shrink-window")).into(),
])
.apply(container)
.center_x()
.center_y()
.align_x(Alignment::Center)
.align_y(Alignment::Center)
.padding(16)
.apply(container)
.style(icon_container_style())
.class(icon_container_style())
.width(Length::Shrink)
.height(Length::Shrink)
.apply(container)
.height(Length::Fill)
.width(Length::Fill)
.center_x()
.center_y()
.center_x(Length::Fill)
.center_y(Length::Fill)
.into(),
if edges.contains(ResizeEdge::RIGHT) {
from_name(if self.direction == ResizeDirection::Outwards {
Expand All @@ -150,14 +149,13 @@ impl Program for ResizeIndicatorInternal {
.prefer_svg(true)
.apply(container)
.padding(8)
.style(icon_container_style())
.class(icon_container_style())
.height(Length::Shrink)
.apply(container)
.center_y()
.height(Length::Fill)
.center_y(Length::Fill)
.into()
} else {
horizontal_space(36).into()
horizontal_space().width(36).into()
},
])
.width(Length::Fill)
Expand All @@ -173,14 +171,13 @@ impl Program for ResizeIndicatorInternal {
.prefer_svg(true)
.apply(container)
.padding(8)
.style(icon_container_style())
.class(icon_container_style())
.width(Length::Shrink)
.apply(container)
.center_x()
.width(Length::Fill)
.center_x(Length::Fill)
.into()
} else {
vertical_space(36).into()
vertical_space().height(36).into()
},
])
.into()
Expand Down
24 changes: 12 additions & 12 deletions src/shell/element/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::{
};
use calloop::LoopHandle;
use cosmic::{
iced::{id::Id, widget as iced_widget},
iced::{id::Id, widget as iced_widget, Alignment},
iced_core::{border::Radius, Background, Border, Color, Length},
iced_runtime::Command,
iced_runtime::Task,
iced_widget::scrollable::AbsoluteOffset,
theme, widget as cosmic_widget, Apply, Element as CosmicElement, Theme,
};
Expand Down Expand Up @@ -712,7 +712,7 @@ impl Program for CosmicStackInternal {
&mut self,
message: Self::Message,
loop_handle: &LoopHandle<'static, crate::state::State>,
) -> Command<Self::Message> {
) -> Task<Self::Message> {
match message {
Message::DragStart => {
if let Some((seat, serial)) = self.last_seat.lock().unwrap().clone() {
Expand Down Expand Up @@ -874,7 +874,7 @@ impl Program for CosmicStackInternal {
}
_ => unreachable!(),
}
Command::none()
Task::none()
}

fn view(&self) -> CosmicElement<'_, Self::Message> {
Expand All @@ -890,8 +890,8 @@ impl Program for CosmicStackInternal {
.size(16)
.prefer_svg(true)
.icon()
.style(if group_focused {
theme::Svg::custom(|theme| iced_widget::svg::Appearance {
.class(if group_focused {
theme::Svg::custom(|theme| iced_widget::svg::Style {
color: Some(if theme.cosmic().is_dark {
Color::BLACK
} else {
Expand All @@ -903,7 +903,7 @@ impl Program for CosmicStackInternal {
})
.apply(iced_widget::container)
.padding([4, 24])
.center_y()
.align_y(Alignment::Center)
.apply(iced_widget::mouse_area)
.on_press(Message::DragStart)
.on_right_press(Message::Menu)
Expand Down Expand Up @@ -935,7 +935,7 @@ impl Program for CosmicStackInternal {
.height(Length::Fill)
.width(Length::Fill),
),
iced_widget::horizontal_space(0)
iced_widget::horizontal_space()
.apply(iced_widget::container)
.padding([64, 24])
.apply(iced_widget::mouse_area)
Expand All @@ -953,10 +953,10 @@ impl Program for CosmicStackInternal {

iced_widget::row(elements)
.height(TAB_HEIGHT as u16)
.width(Length::Fill) //width as u16)
.width(Length::Fill)
.apply(iced_widget::container)
.center_y()
.style(theme::Container::custom(move |theme| {
.align_y(Alignment::Center)
.class(theme::Container::custom(move |theme| {
let background = if group_focused {
Some(Background::Color(theme.cosmic().accent_color().into()))
} else {
Expand All @@ -965,7 +965,7 @@ impl Program for CosmicStackInternal {
)))
};

iced_widget::container::Appearance {
iced_widget::container::Style {
icon_color: Some(Color::from(theme.cosmic().background.on)),
text_color: Some(Color::from(theme.cosmic().background.on)),
background,
Expand Down
39 changes: 17 additions & 22 deletions src/shell/element/stack/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ use cosmic::{
alignment, event,
layout::{Layout, Limits, Node},
mouse, overlay, renderer,
widget::{
operation::{Operation, OperationOutputWrapper},
tree::Tree,
Id, Widget,
},
widget::{operation::Operation, tree::Tree, Id, Widget},
Border, Clipboard, Color, Length, Rectangle, Shell, Size,
},
iced_widget::scrollable::AbsoluteOffset,
Expand Down Expand Up @@ -54,19 +50,19 @@ pub(super) enum TabRuleTheme {
impl From<TabRuleTheme> for theme::Rule {
fn from(theme: TabRuleTheme) -> Self {
match theme {
TabRuleTheme::ActiveActivated => Self::custom(|theme| widget::rule::Appearance {
TabRuleTheme::ActiveActivated => Self::custom(|theme| widget::rule::Style {
color: theme.cosmic().accent_color().into(),
width: 4,
radius: 0.0.into(),
fill_mode: FillMode::Full,
}),
TabRuleTheme::ActiveDeactivated => Self::custom(|theme| widget::rule::Appearance {
TabRuleTheme::ActiveDeactivated => Self::custom(|theme| widget::rule::Style {
color: theme.cosmic().palette.neutral_5.into(),
width: 4,
radius: 0.0.into(),
fill_mode: FillMode::Full,
}),
TabRuleTheme::Default => Self::custom(|theme| widget::rule::Appearance {
TabRuleTheme::Default => Self::custom(|theme| widget::rule::Style {
color: theme.cosmic().palette.neutral_5.into(),
width: 4,
radius: 8.0.into(),
Expand Down Expand Up @@ -96,11 +92,11 @@ impl TabBackgroundTheme {
}
}

impl From<TabBackgroundTheme> for theme::Container {
impl From<TabBackgroundTheme> for theme::Container<'_> {
fn from(background_theme: TabBackgroundTheme) -> Self {
match background_theme {
TabBackgroundTheme::ActiveActivated => {
Self::custom(move |theme| widget::container::Appearance {
Self::custom(move |theme| widget::container::Style {
icon_color: Some(Color::from(theme.cosmic().accent_text_color())),
text_color: Some(Color::from(theme.cosmic().accent_text_color())),
background: Some(background_theme.background_color(theme).into()),
Expand All @@ -113,7 +109,7 @@ impl From<TabBackgroundTheme> for theme::Container {
})
}
TabBackgroundTheme::ActiveDeactivated => {
Self::custom(move |theme| widget::container::Appearance {
Self::custom(move |theme| widget::container::Style {
icon_color: None,
text_color: None,
background: Some(background_theme.background_color(theme).into()),
Expand Down Expand Up @@ -215,20 +211,19 @@ impl<Message: TabMessage + 'static> Tab<Message> {
.icon()
.apply(widget::button)
.padding(0)
.style(theme::iced::Button::Text);
.class(theme::iced::Button::Text);
if let Some(close_message) = self.close_message {
close_button = close_button.on_press(close_message);
}

let items = vec![
widget::vertical_rule(4).style(self.rule_theme).into(),
widget::vertical_rule(4).class(self.rule_theme).into(),
self.app_icon
.clone()
.apply(widget::container)
.height(Length::Fill)
.width(Length::Shrink)
.padding([2, 4])
.center_y()
.center_y(Length::Fill)
.into(),
tab_text(self.title, self.active)
.font(self.font)
Expand All @@ -238,10 +233,9 @@ impl<Message: TabMessage + 'static> Tab<Message> {
.into(),
close_button
.apply(widget::container)
.height(Length::Fill)
.width(Length::Shrink)
.padding([2, 4])
.center_y()
.center_y(Length::Fill)
.align_x(alignment::Horizontal::Right)
.into(),
];
Expand Down Expand Up @@ -269,7 +263,7 @@ pub(super) struct TabInternal<'a, Message: TabMessage> {
id: Id,
idx: usize,
active: bool,
background: theme::Container,
background: theme::Container<'a>,
elements: Vec<cosmic::Element<'a, Message>>,
press_message: Option<Message>,
right_click_message: Option<Message>,
Expand Down Expand Up @@ -347,7 +341,7 @@ where
tree: &mut Tree,
layout: Layout<'_>,
renderer: &cosmic::Renderer,
operation: &mut dyn Operation<OperationOutputWrapper<Message>>,
operation: &mut dyn Operation<()>,
) {
operation.container(None, layout.bounds(), &mut |operation| {
self.elements
Expand Down Expand Up @@ -454,8 +448,8 @@ where
cursor: mouse::Cursor,
viewport: &Rectangle,
) {
use cosmic::widget::container::StyleSheet;
let style = theme.appearance(&self.background);
use cosmic::widget::container::Catalog;
let style = theme.style(&self.background);

draw_background(renderer, &style, layout.bounds());

Expand Down Expand Up @@ -486,7 +480,8 @@ where
tree: &'b mut Tree,
layout: Layout<'_>,
renderer: &cosmic::Renderer,
translation: cosmic::iced::Vector,
) -> Option<overlay::Element<'b, Message, cosmic::Theme, cosmic::Renderer>> {
overlay::from_children(&mut self.elements, tree, layout, renderer)
overlay::from_children(&mut self.elements, tree, layout, renderer, translation)
}
}
2 changes: 1 addition & 1 deletion src/shell/element/stack/tab_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl TabText {
vertical_alignment: alignment::Vertical::Center,
shaping: Shaping::Advanced,
line_height: LineHeight::default(),
wrap: cosmic::iced::advanced::text::Wrap::None,
wrapping: cosmic::iced::advanced::text::Wrapping::None,
})
}
}
Expand Down
Loading

0 comments on commit da1a111

Please sign in to comment.