improv: reduce padding when condensed
This commit is contained in:
parent
1cbd563d64
commit
dec705e0fe
6 changed files with 87 additions and 85 deletions
|
|
@ -314,7 +314,7 @@ impl cosmic::Application for SettingsApp {
|
|||
|
||||
crate::pages::Message::DesktopWallpaper(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<desktop::wallpaper::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -324,19 +324,19 @@ impl cosmic::Application for SettingsApp {
|
|||
|
||||
crate::pages::Message::Displays(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<display::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
crate::pages::Message::Keyboard(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<input::keyboard::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
crate::pages::Message::Input(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<input::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ impl cosmic::Application for SettingsApp {
|
|||
|
||||
crate::pages::Message::PanelApplet(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<applets_inner::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -364,18 +364,18 @@ impl cosmic::Application for SettingsApp {
|
|||
|
||||
crate::pages::Message::DockApplet(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<dock::applets::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
crate::pages::Message::Appearance(message) => {
|
||||
if let Some(page) = self.pages.page_mut::<appearance::Page>() {
|
||||
return page.update(message).map(cosmic::app::Message::App);
|
||||
return page.update(message).map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
crate::pages::Message::Power(message) => {
|
||||
page::update!(self.pages, message, power::Page)
|
||||
page::update!(self.pages, message, power::Page);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ impl cosmic::Application for SettingsApp {
|
|||
if let Some(page) = self.pages.page_mut::<applets_inner::Page>() {
|
||||
return page
|
||||
.update(applets_inner::Message::PanelConfig(config))
|
||||
.map(cosmic::app::Message::App);
|
||||
.map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +421,7 @@ impl cosmic::Application for SettingsApp {
|
|||
if let Some(page) = self.pages.page_mut::<applets_inner::Page>() {
|
||||
return page
|
||||
.update(applets_inner::Message::Applets(info_list))
|
||||
.map(cosmic::app::Message::App);
|
||||
.map(Into::into);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -554,9 +554,7 @@ impl SettingsApp {
|
|||
let current_page = self.active_page;
|
||||
self.active_page = page;
|
||||
|
||||
let mut leave_command = iced::Command::none()
|
||||
.map(Message::PageMessage)
|
||||
.map(cosmic::app::Message::App);
|
||||
let mut leave_command = iced::Command::none();
|
||||
|
||||
if current_page != page {
|
||||
leave_command = self
|
||||
|
|
@ -564,7 +562,7 @@ impl SettingsApp {
|
|||
.on_leave(current_page)
|
||||
.unwrap_or(iced::Command::none())
|
||||
.map(Message::PageMessage)
|
||||
.map(cosmic::app::Message::App);
|
||||
.map(Into::into);
|
||||
self.config.active_page = Box::from(&*self.pages.info[page].id);
|
||||
self.config
|
||||
.set_active_page(Box::from(&*self.pages.info[page].id));
|
||||
|
|
@ -583,13 +581,12 @@ impl SettingsApp {
|
|||
.pages
|
||||
.on_enter(page, sender)
|
||||
.map(Message::PageMessage)
|
||||
.map(cosmic::app::Message::App);
|
||||
.map(Into::into);
|
||||
|
||||
Command::batch(vec![
|
||||
leave_command,
|
||||
page_command,
|
||||
cosmic::command::future(async { Message::SetWindowTitle })
|
||||
.map(cosmic::app::Message::App),
|
||||
cosmic::command::future(async { Message::SetWindowTitle }),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
@ -681,7 +678,7 @@ impl SettingsApp {
|
|||
}
|
||||
}
|
||||
|
||||
settings::view_column(column_widgets).into()
|
||||
settings::view_column(column_widgets).padding(0).into()
|
||||
}
|
||||
|
||||
fn search_changed(&mut self, phrase: String) {
|
||||
|
|
@ -746,28 +743,37 @@ impl SettingsApp {
|
|||
}
|
||||
}
|
||||
|
||||
settings::view_column(sections).into()
|
||||
settings::view_column(sections).padding(0).into()
|
||||
}
|
||||
|
||||
/// Displays the sub-pages view of a page.
|
||||
fn sub_page_view(&self, sub_pages: &[page::Entity]) -> cosmic::Element<Message> {
|
||||
let theme = cosmic::theme::active();
|
||||
let mut page_list =
|
||||
column::with_capacity(sub_pages.len()).spacing(theme.cosmic().space_s());
|
||||
|
||||
for entity in sub_pages.iter().copied() {
|
||||
let sub_page = &self.pages.info[entity];
|
||||
page_list = page_list.push(crate::widget::page_list_item(
|
||||
sub_page.title.as_str(),
|
||||
sub_page.description.as_str(),
|
||||
&sub_page.icon_name,
|
||||
entity,
|
||||
));
|
||||
}
|
||||
let page_list = sub_pages
|
||||
.iter()
|
||||
.copied()
|
||||
.fold(
|
||||
column::with_capacity(sub_pages.len()),
|
||||
|page_list, entity| {
|
||||
let sub_page = &self.pages.info[entity];
|
||||
|
||||
page_list.push(crate::widget::page_list_item(
|
||||
sub_page.title.as_str(),
|
||||
sub_page.description.as_str(),
|
||||
&sub_page.icon_name,
|
||||
entity,
|
||||
))
|
||||
},
|
||||
)
|
||||
.spacing(theme.cosmic().space_s())
|
||||
.padding(0)
|
||||
.apply(cosmic::Element::from)
|
||||
.map(Message::Page);
|
||||
|
||||
column::with_capacity(2)
|
||||
.push(page_title(&self.pages.info[self.active_page]))
|
||||
.push(Element::from(page_list).map(Message::Page))
|
||||
.push(page_list)
|
||||
.spacing(theme.cosmic().space_m())
|
||||
.padding(0)
|
||||
.into()
|
||||
|
|
|
|||
|
|
@ -86,32 +86,29 @@ pub fn color_image<'a, M: 'a>(
|
|||
}
|
||||
|
||||
/// Color selection list
|
||||
///
|
||||
/// Begin with removable custom colors, and chain with non-removable default colors.
|
||||
#[must_use]
|
||||
pub fn color_select_options(
|
||||
context: &super::Context,
|
||||
selected: Option<&wallpaper::Color>,
|
||||
) -> Element<'static, Message> {
|
||||
let mut vec = Vec::with_capacity(wallpaper::DEFAULT_COLORS.len());
|
||||
|
||||
// Place removable custom colors first
|
||||
for color in context.custom_colors.iter().rev() {
|
||||
vec.push(color_button(
|
||||
color.clone(),
|
||||
true,
|
||||
selected.map_or(false, |selection| selection == color),
|
||||
));
|
||||
}
|
||||
|
||||
// Then non-removable default colors
|
||||
for color in wallpaper::DEFAULT_COLORS {
|
||||
vec.push(color_button(
|
||||
color.clone(),
|
||||
false,
|
||||
selected.map_or(false, |selection| selection == color),
|
||||
));
|
||||
}
|
||||
|
||||
flex_select_row(vec)
|
||||
flex_select_row(
|
||||
context
|
||||
.custom_colors
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|color| (color, true))
|
||||
.chain(wallpaper::DEFAULT_COLORS.iter().map(|color| (color, false)))
|
||||
.map(|(color, removable)| {
|
||||
color_button(
|
||||
color.clone(),
|
||||
removable,
|
||||
selected.map_or(false, |selection| selection == color),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Background selection list
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use cosmic::{
|
|||
iced::{self, Length},
|
||||
iced_core::Border,
|
||||
iced_style, theme,
|
||||
widget::{self, button, container, icon, radio, row, settings},
|
||||
widget::{self, button, container, icon, radio, row, settings, ListColumn},
|
||||
Apply, Command, Element,
|
||||
};
|
||||
use cosmic_comp_config::XkbConfig;
|
||||
|
|
@ -220,8 +220,6 @@ fn input_source(
|
|||
settings::flex_item(description, popover_button(id, expanded)).into()
|
||||
}
|
||||
|
||||
pub mod shortcuts;
|
||||
|
||||
fn special_char_radio_row<'a>(
|
||||
desc: &'a str,
|
||||
value: Option<&'static str>,
|
||||
|
|
@ -526,11 +524,13 @@ impl Page {
|
|||
|
||||
// TODO description, layout default
|
||||
|
||||
let mut list = cosmic::widget::list_column();
|
||||
list = list.add(special_char_radio_row("None", None, current));
|
||||
for (desc, id) in options {
|
||||
list = list.add(special_char_radio_row(desc, Some(id), current));
|
||||
}
|
||||
let mut list =
|
||||
cosmic::widget::list_column().add(special_char_radio_row("None", None, current));
|
||||
|
||||
list = options
|
||||
.iter()
|
||||
.map(|(desc, id)| special_char_radio_row(desc, Some(id), current))
|
||||
.fold(list, ListColumn::add);
|
||||
|
||||
cosmic::widget::container(list).padding(24).into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ pub enum Message {
|
|||
DockApplet(desktop::dock::applets::Message),
|
||||
External { id: String, message: Vec<u8> },
|
||||
Keyboard(input::keyboard::Message),
|
||||
KeyboardShortcuts(input::keyboard::shortcuts::Message),
|
||||
Input(input::Message),
|
||||
Page(Entity),
|
||||
Panel(desktop::panel::Message),
|
||||
|
|
|
|||
|
|
@ -67,27 +67,24 @@ fn profiles() -> Section<crate::pages::Message> {
|
|||
|
||||
let current_profile = runtime.block_on(b.get_current_power_profile());
|
||||
|
||||
let mut widgets = Vec::new();
|
||||
section = profiles
|
||||
.into_iter()
|
||||
.map(|profile| {
|
||||
let selected = if current_profile == profile {
|
||||
Some(true)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
for profile in profiles {
|
||||
let selected = if current_profile == profile {
|
||||
Some(true)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let widget = widget::Radio::new("", true, selected, |_| {
|
||||
Message::PowerProfileChange(profile.clone())
|
||||
});
|
||||
|
||||
let widget = widget::Radio::new("", true, selected, |_| {
|
||||
Message::PowerProfileChange(profile.clone())
|
||||
});
|
||||
let item = settings::item::builder(profile.title())
|
||||
.description(profile.description())
|
||||
.control(widget);
|
||||
widgets.push(item);
|
||||
}
|
||||
|
||||
for item in widgets {
|
||||
section = section.add(item);
|
||||
}
|
||||
settings::item::builder(profile.title())
|
||||
.description(profile.description())
|
||||
.control(widget)
|
||||
})
|
||||
.fold(section, settings::Section::add);
|
||||
} else {
|
||||
let item = widget::text::body(fl!("power-mode", "nobackend"));
|
||||
section = section.add(item);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ fn hardware() -> Section<crate::pages::Message> {
|
|||
.view::<Page>(move |_binder, page, section| {
|
||||
let desc = §ion.descriptions;
|
||||
|
||||
let mut sections = settings::view_section(§ion.title)
|
||||
let sections = settings::view_section(§ion.title)
|
||||
.add(settings::flex_item(
|
||||
&*desc[model],
|
||||
text(&page.info.hardware_model),
|
||||
|
|
@ -161,11 +161,12 @@ fn hardware() -> Section<crate::pages::Message> {
|
|||
text(&page.info.processor),
|
||||
));
|
||||
|
||||
for card in &page.info.graphics {
|
||||
sections = sections.add(settings::flex_item(&*desc[graphics], text(card.as_str())));
|
||||
}
|
||||
|
||||
sections
|
||||
page.info
|
||||
.graphics
|
||||
.iter()
|
||||
.fold(sections, |sections, card| {
|
||||
sections.add(settings::flex_item(&*desc[graphics], text(card.as_str())))
|
||||
})
|
||||
.add(settings::flex_item(
|
||||
&*desc[disk_capacity],
|
||||
text(&page.info.disk_capacity),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue