Skip to content

Commit fed0008

Browse files
committed
improv: make popover styling consistent
Makes all popovers use the same styling, with hover highlights.
1 parent 8bc944a commit fed0008

File tree

9 files changed

+76
-106
lines changed

9 files changed

+76
-106
lines changed

cosmic-settings/src/pages/bluetooth/mod.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -783,14 +783,13 @@ fn status() -> Section<crate::pages::Message> {
783783
}
784784

785785
fn popup_button(message: Option<Message>, text: &str) -> Element<'_, Message> {
786-
let theme = theme::active();
787-
let theme = theme.cosmic();
786+
let spacing = cosmic::theme::spacing();
788787
widget::text::body(text)
789788
.align_y(Alignment::Center)
790789
.apply(widget::button::custom)
791-
.padding([theme.space_xxxs(), theme.space_xs()])
790+
.padding([spacing.space_xxxs, spacing.space_xs])
792791
.width(Length::Fill)
793-
.class(theme::Button::MenuItem)
792+
.class(cosmic::theme::Button::MenuItem)
794793
.on_press_maybe(message)
795794
.into()
796795
}
@@ -840,22 +839,21 @@ fn connected_devices() -> Section<crate::pages::Message> {
840839
.position(widget::popover::Position::Bottom)
841840
.on_close(Message::PopupDevice(None))
842841
.popup({
843-
widget::container(
844-
widget::column()
845-
.push_maybe(device.is_connected().then(|| {
846-
popup_button(
847-
Some(Message::DisconnectDevice(path.clone())),
848-
&descriptions[device_disconnect],
849-
)
850-
}))
851-
.push(popup_button(
852-
Some(Message::ForgetDevice(path.clone())),
853-
&descriptions[device_forget],
854-
)),
855-
)
856-
.width(Length::Fixed(200.0))
857-
.padding(theme::active().cosmic().space_xxxs())
858-
.class(theme::Container::Dialog)
842+
widget::column()
843+
.push_maybe(device.is_connected().then(|| {
844+
popup_button(
845+
Some(Message::DisconnectDevice(path.clone())),
846+
&descriptions[device_disconnect],
847+
)
848+
}))
849+
.push(popup_button(
850+
Some(Message::ForgetDevice(path.clone())),
851+
&descriptions[device_forget],
852+
))
853+
.width(Length::Fixed(200.0))
854+
.apply(widget::container)
855+
.padding(1)
856+
.class(cosmic::style::Container::Dropdown)
859857
})
860858
.into()
861859
} else {

cosmic-settings/src/pages/desktop/appearance/drawer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ impl Content {
441441
})
442442
),
443443
// Icon theme previews
444-
widget::column::with_children(vec![
444+
widget::column::with_children([
445445
text::heading(&*ICON_THEME).into(),
446446
flex_row(
447447
self.icon_themes

cosmic-settings/src/pages/desktop/appearance/icon_themes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn button(
3535
cosmic::widget::column()
3636
.push(
3737
cosmic::widget::button::custom_image_button(
38-
cosmic::widget::column::with_children(vec![
38+
cosmic::widget::column::with_children([
3939
cosmic::widget::row()
4040
.extend(
4141
handles

cosmic-settings/src/pages/desktop/panel/applets_inner.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ pub fn lists<
439439
return Element::from(text::body(fl!("unknown")));
440440
};
441441

442-
column::with_children(vec![
443-
column::with_children(vec![
442+
column::with_children([
443+
column::with_children([
444444
text::body(fl!("start-segment")).into(),
445445
AppletReorderList::new(
446446
config
@@ -471,7 +471,7 @@ pub fn lists<
471471
])
472472
.spacing(space_xxs)
473473
.into(),
474-
column::with_children(vec![
474+
column::with_children([
475475
text::body(fl!("center-segment")).into(),
476476
AppletReorderList::new(
477477
config
@@ -501,7 +501,7 @@ pub fn lists<
501501
])
502502
.spacing(space_xxs)
503503
.into(),
504-
column::with_children(vec![
504+
column::with_children([
505505
text::body(fl!("end-segment")).into(),
506506
AppletReorderList::new(
507507
config

cosmic-settings/src/pages/input/keyboard/mod.rs

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use cosmic::{
99
Apply, Element, Task,
1010
app::{ContextDrawer, context_drawer},
1111
cosmic_config::{self, ConfigSet},
12-
iced::{Alignment, Color, Length},
13-
iced_core::Border,
12+
iced::{Alignment, Length},
1413
theme,
1514
widget::{self, ListColumn, button, container, icon, radio, row, settings},
1615
};
@@ -166,23 +165,19 @@ fn popover_menu_row(
166165
label: String,
167166
message: impl Fn(DefaultKey) -> SourceContext + 'static,
168167
) -> cosmic::Element<'static, Message> {
168+
let spacing = theme::spacing();
169169
widget::text::body(label)
170-
.apply(widget::container)
171-
.class(cosmic::theme::Container::custom(|theme| {
172-
widget::container::Style {
173-
background: None,
174-
..container::Catalog::style(theme, &cosmic::theme::Container::List)
175-
}
176-
}))
170+
.align_y(Alignment::Center)
177171
.apply(button::custom)
178-
.on_press(())
179-
.class(theme::Button::Transparent)
172+
.padding([spacing.space_xxxs, spacing.space_xs])
173+
.width(Length::Fill)
174+
.class(theme::Button::MenuItem)
175+
.on_press(Message::SourceContext(message(id)))
180176
.apply(Element::from)
181-
.map(move |()| Message::SourceContext(message(id)))
182177
}
183178

184179
fn popover_menu(id: DefaultKey) -> cosmic::Element<'static, Message> {
185-
widget::column::with_children(vec![
180+
widget::column::with_children([
186181
popover_menu_row(
187182
id,
188183
fl!("keyboard-sources", "move-up"),
@@ -193,7 +188,10 @@ fn popover_menu(id: DefaultKey) -> cosmic::Element<'static, Message> {
193188
fl!("keyboard-sources", "move-down"),
194189
SourceContext::MoveDown,
195190
),
196-
cosmic::widget::divider::horizontal::default().into(),
191+
widget::divider::horizontal::default()
192+
.apply(widget::container)
193+
.padding([0, 8])
194+
.into(),
197195
popover_menu_row(
198196
id,
199197
fl!("keyboard-sources", "settings"),
@@ -206,25 +204,10 @@ fn popover_menu(id: DefaultKey) -> cosmic::Element<'static, Message> {
206204
),
207205
popover_menu_row(id, fl!("keyboard-sources", "remove"), SourceContext::Remove),
208206
])
209-
.padding([2, 8])
210-
.width(Length::Shrink)
211-
.height(Length::Shrink)
212-
.apply(cosmic::widget::container)
213-
.class(cosmic::theme::Container::custom(|theme| {
214-
let cosmic = theme.cosmic();
215-
let background = &cosmic.background;
216-
container::Style {
217-
icon_color: Some(background.on.into()),
218-
text_color: Some(background.on.into()),
219-
background: Some(Color::from(background.base).into()),
220-
border: Border {
221-
color: background.component.divider.into(),
222-
width: 1.0,
223-
radius: cosmic.corner_radii.radius_s.into(),
224-
},
225-
shadow: Default::default(),
226-
}
227-
}))
207+
.width(Length::Fixed(200.0))
208+
.apply(widget::container)
209+
.padding(1)
210+
.class(cosmic::style::Container::Dropdown)
228211
.into()
229212
}
230213

@@ -236,8 +219,9 @@ fn popover_button(id: DefaultKey, expanded: bool) -> cosmic::Element<'static, Me
236219
.on_press(on_press);
237220

238221
if expanded {
239-
cosmic::widget::popover(button)
222+
widget::popover(button)
240223
.popup(popover_menu(id))
224+
.position(widget::popover::Position::Bottom)
241225
.on_close(Message::ExpandInputSourcePopover(None))
242226
.into()
243227
} else {

cosmic-settings/src/pages/networking/vpn/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,11 @@ fn devices_view() -> Section<crate::pages::Message> {
937937
}
938938

939939
fn popup_button(message: Message, text: &str) -> Element<'_, Message> {
940-
let theme = cosmic::theme::active();
941-
let theme = theme.cosmic();
940+
let spacing = cosmic::theme::spacing();
942941
widget::text::body(text)
943942
.align_y(Alignment::Center)
944943
.apply(widget::button::custom)
945-
.padding([theme.space_xxxs(), theme.space_xs()])
944+
.padding([spacing.space_xxxs, spacing.space_xs])
946945
.width(Length::Fill)
947946
.class(cosmic::theme::Button::MenuItem)
948947
.on_press(message)

cosmic-settings/src/pages/networking/wifi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,10 @@ fn devices_view() -> Section<crate::pages::Message> {
875875
&section.descriptions[forget_txt],
876876
)
877877
}))
878-
.width(Length::Fixed(170.0))
878+
.width(Length::Fixed(200.0))
879879
.apply(widget::container)
880-
.class(cosmic::style::Container::Dialog)
880+
.padding(1)
881+
.class(cosmic::style::Container::Dropdown)
881882
})
882883
.apply(|e| Some(Element::from(e)))
883884
} else if is_known {
@@ -938,12 +939,11 @@ fn is_connected(state: &NetworkManagerState, network: &AccessPoint) -> bool {
938939
}
939940

940941
fn popup_button(message: Message, text: &str) -> Element<'_, Message> {
941-
let theme = cosmic::theme::active();
942-
let theme = theme.cosmic();
942+
let spacing = cosmic::theme::spacing();
943943
widget::text::body(text)
944944
.align_y(Alignment::Center)
945945
.apply(widget::button::custom)
946-
.padding([theme.space_xxxs(), theme.space_xs()])
946+
.padding([spacing.space_xxxs, spacing.space_xs])
947947
.width(Length::Fill)
948948
.class(cosmic::theme::Button::MenuItem)
949949
.on_press(message)

cosmic-settings/src/pages/networking/wired.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ impl Page {
529529
}))
530530
.width(Length::Fixed(200.0))
531531
.apply(widget::container)
532-
.padding(spacing.space_xxxs)
533-
.class(cosmic::style::Container::Dialog)
532+
.padding(1)
533+
.class(cosmic::style::Container::Dropdown)
534534
})
535535
.apply(|e| Some(Element::from(e)))
536536
} else {
@@ -611,12 +611,11 @@ fn devices_view() -> Section<crate::pages::Message> {
611611
}
612612

613613
fn popup_button(message: Message, text: &str) -> Element<'_, Message> {
614-
let theme = cosmic::theme::active();
615-
let theme = theme.cosmic();
614+
let spacing = cosmic::theme::spacing();
616615
widget::text::body(text)
617616
.align_y(Alignment::Center)
618617
.apply(widget::button::custom)
619-
.padding([theme.space_xxxs(), theme.space_xs()])
618+
.padding([spacing.space_xxxs, spacing.space_xs])
620619
.width(Length::Fill)
621620
.class(cosmic::theme::Button::MenuItem)
622621
.on_press(message)

cosmic-settings/src/pages/time/region.rs

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::rc::Rc;
66
use std::sync::Arc;
77

88
use cosmic::app::{ContextDrawer, context_drawer};
9-
use cosmic::iced::{Alignment, Border, Color, Length};
9+
use cosmic::iced::{Alignment, Length};
1010
use cosmic::iced_core::text::Wrapping;
11-
use cosmic::widget::{self, button, container};
12-
use cosmic::{Apply, Element, theme};
11+
use cosmic::widget::{self, button};
12+
use cosmic::{Apply, Element};
1313
use cosmic_config::{ConfigGet, ConfigSet};
1414
use cosmic_settings_page::Section;
1515
use cosmic_settings_page::{self as page, section};
@@ -818,6 +818,7 @@ fn popover_button(id: usize, expanded: bool) -> Element<'static, Message> {
818818
if expanded {
819819
widget::popover(button)
820820
.popup(popover_menu(id))
821+
.position(widget::popover::Position::Bottom)
821822
.on_close(Message::ExpandLanguagePopover(None))
822823
.into()
823824
} else {
@@ -826,38 +827,31 @@ fn popover_button(id: usize, expanded: bool) -> Element<'static, Message> {
826827
}
827828

828829
fn popover_menu(id: usize) -> Element<'static, Message> {
829-
widget::column::with_children(vec![
830+
widget::column::with_children([
830831
popover_menu_row(
831832
id,
832833
fl!("keyboard-sources", "move-up"),
833834
SourceContext::MoveUp,
834835
),
835-
cosmic::widget::divider::horizontal::default().into(),
836+
widget::divider::horizontal::default()
837+
.apply(widget::container)
838+
.padding([0, 8])
839+
.into(),
836840
popover_menu_row(
837841
id,
838842
fl!("keyboard-sources", "move-down"),
839843
SourceContext::MoveDown,
840844
),
841-
cosmic::widget::divider::horizontal::default().into(),
845+
widget::divider::horizontal::default()
846+
.apply(widget::container)
847+
.padding([0, 8])
848+
.into(),
842849
popover_menu_row(id, fl!("keyboard-sources", "remove"), SourceContext::Remove),
843850
])
844-
.padding(8)
845-
.width(Length::Shrink)
846-
.height(Length::Shrink)
847-
.apply(cosmic::widget::container)
848-
.class(cosmic::theme::Container::custom(|theme| {
849-
let cosmic = theme.cosmic();
850-
container::Style {
851-
icon_color: Some(theme.cosmic().background.on.into()),
852-
text_color: Some(theme.cosmic().background.on.into()),
853-
background: Some(Color::from(theme.cosmic().background.base).into()),
854-
border: Border {
855-
radius: cosmic.corner_radii.radius_m.into(),
856-
..Default::default()
857-
},
858-
shadow: Default::default(),
859-
}
860-
}))
851+
.width(Length::Fixed(200.0))
852+
.apply(widget::container)
853+
.padding(1)
854+
.class(cosmic::style::Container::Dropdown)
861855
.into()
862856
}
863857

@@ -866,19 +860,15 @@ fn popover_menu_row(
866860
label: String,
867861
message: impl Fn(usize) -> SourceContext + 'static,
868862
) -> cosmic::Element<'static, Message> {
863+
let spacing = cosmic::theme::spacing();
869864
widget::text::body(label)
870-
.apply(widget::container)
871-
.class(cosmic::theme::Container::custom(|theme| {
872-
widget::container::Style {
873-
background: None,
874-
..widget::container::Catalog::style(theme, &cosmic::theme::Container::List)
875-
}
876-
}))
865+
.align_y(Alignment::Center)
877866
.apply(button::custom)
878-
.on_press(())
879-
.class(theme::Button::Transparent)
867+
.padding([spacing.space_xxxs, spacing.space_xs])
868+
.width(Length::Fill)
869+
.class(cosmic::theme::Button::MenuItem)
870+
.on_press(Message::SourceContext(message(id)))
880871
.apply(Element::from)
881-
.map(move |()| Message::SourceContext(message(id)))
882872
}
883873

884874
pub async fn set_locale(

0 commit comments

Comments
 (0)