fix(gallery): center text previews

This commit is contained in:
Vukašin Vojinović 2024-11-11 23:53:25 +01:00 • committed by Jeremy Soller
parent 63126810b1
commit b7ef7f852f
3 changed files with 25 additions and 30 deletions

View file

@ -1198,7 +1198,7 @@ impl App {
children.push(section.into()); children.push(section.into());
*/ */
widget::settings::view_column(children).into() widget::column::with_children(children).into()
} }
fn edit_history(&self) -> Element<Message> { fn edit_history(&self) -> Element<Message> {
@ -1243,7 +1243,7 @@ impl App {
children.push(widget::text::body(fl!("no-history")).into()); children.push(widget::text::body(fl!("no-history")).into());
} }
widget::settings::view_column(children).into() widget::column::with_children(children).into()
} }
fn preview<'a>( fn preview<'a>(
@ -1295,18 +1295,12 @@ impl App {
} }
} }
} }
widget::column::with_children(children).into()
// View column has extra padding not wanted when not showing in context drawer
if context_drawer {
widget::settings::view_column(children).into()
} else {
widget::column::with_children(children).into()
}
} }
fn settings(&self) -> Element<Message> { fn settings(&self) -> Element<Message> {
// TODO: Should dialog be updated here too? // TODO: Should dialog be updated here too?
widget::settings::view_column(vec![widget::settings::section() widget::column::with_children(vec![widget::settings::section()
.title(fl!("appearance")) .title(fl!("appearance"))
.add({ .add({
let app_theme_selected = match self.config.app_theme { let app_theme_selected = match self.config.app_theme {

View file

@ -501,7 +501,7 @@ impl App {
} }
} }
} }
widget::settings::view_column(children).into() widget::column::with_children(children).into()
} }
fn rescan_tab(&self) -> Task<Message> { fn rescan_tab(&self) -> Task<Message> {

View file

@ -30,7 +30,7 @@ use cosmic::{
iced_core::{mouse::ScrollDelta, widget::tree}, iced_core::{mouse::ScrollDelta, widget::tree},
theme, theme,
widget::{ widget::{
self, container, self,
menu::{action::MenuAction, key_bind::KeyBind}, menu::{action::MenuAction, key_bind::KeyBind},
DndDestination, DndSource, Id, Space, Widget, DndDestination, DndSource, Id, Space, Widget,
}, },
@ -1339,16 +1339,14 @@ impl Item {
widget::image(handle.clone()).into() widget::image(handle.clone()).into()
} }
ItemThumbnail::Svg(handle) => widget::svg(handle.clone()).into(), ItemThumbnail::Svg(handle) => widget::svg(handle.clone()).into(),
ItemThumbnail::Text(content) => widget::container( ItemThumbnail::Text(content) => widget::text_editor(content)
widget::text_editor(content) .class(cosmic::theme::iced::TextEditor::Custom(Box::new(
.class(cosmic::theme::iced::TextEditor::Custom(Box::new( text_editor_class,
text_editor_class, )))
))) .width(THUMBNAIL_SIZE as f32)
.padding(spacing.space_xxs), .height(Length::Fixed(THUMBNAIL_SIZE as f32))
) .padding(spacing.space_xxs)
.width(Length::Fixed(THUMBNAIL_SIZE as f32)) .into(),
.height(Length::Fixed(THUMBNAIL_SIZE as f32))
.into(),
} }
} }
@ -3133,12 +3131,15 @@ impl Tab {
} }
ItemThumbnail::Text(text) => { ItemThumbnail::Text(text) => {
element_opt = Some( element_opt = Some(
widget::text_editor(text) widget::container(
.padding(space_xxs) widget::text_editor(text).padding(space_xxs).class(
.class(cosmic::theme::iced::TextEditor::Custom(Box::new( cosmic::theme::iced::TextEditor::Custom(Box::new(
text_editor_class, text_editor_class,
))) )),
.into(), ),
)
.center(Length::Fill)
.into(),
) )
} }
} }
@ -3334,7 +3335,7 @@ impl Tab {
radius: 0.0.into(), radius: 0.0.into(),
fill_mode: rule::FillMode::Full, fill_mode: rule::FillMode::Full,
}))); })));
let heading_rule = container(horizontal_rule(1)) let heading_rule = widget::container(horizontal_rule(1))
.padding([0, theme::active().cosmic().corner_radii.radius_xs[0] as u16]); .padding([0, theme::active().cosmic().corner_radii.radius_xs[0] as u16]);
if let Some(location) = &self.edit_location { if let Some(location) = &self.edit_location {
@ -3898,7 +3899,7 @@ impl Tab {
if count > 0 { if count > 0 {
children.push( children.push(
container(horizontal_rule(1)) widget::container(horizontal_rule(1))
.padding([0, rule_padding]) .padding([0, rule_padding])
.into(), .into(),
); );