fix: text padding at min list size
This commit is contained in:
parent
23f0a4f942
commit
3529717476
4 changed files with 32 additions and 30 deletions
12
src/app.rs
12
src/app.rs
|
|
@ -1,14 +1,11 @@
|
||||||
// Copyright 2023 System76 <info@system76.com>
|
// Copyright 2023 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic::iced::clipboard::dnd::DndAction;
|
|
||||||
use cosmic::widget::dnd_destination::DragId;
|
|
||||||
use cosmic::widget::menu::action::MenuAction;
|
|
||||||
use cosmic::widget::menu::key_bind::KeyBind;
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
app::{message, Command, Core},
|
app::{message, Command, Core},
|
||||||
cosmic_config, cosmic_theme, executor,
|
cosmic_config, cosmic_theme, executor,
|
||||||
iced::{
|
iced::{
|
||||||
|
clipboard::dnd::DndAction,
|
||||||
event,
|
event,
|
||||||
futures::{self, SinkExt},
|
futures::{self, SinkExt},
|
||||||
keyboard::{Event as KeyEvent, Key, Modifiers},
|
keyboard::{Event as KeyEvent, Key, Modifiers},
|
||||||
|
|
@ -20,6 +17,8 @@ use cosmic::{
|
||||||
style, theme,
|
style, theme,
|
||||||
widget::{
|
widget::{
|
||||||
self,
|
self,
|
||||||
|
dnd_destination::DragId,
|
||||||
|
menu::{action::MenuAction, key_bind::KeyBind},
|
||||||
segmented_button::{self, Entity},
|
segmented_button::{self, Entity},
|
||||||
},
|
},
|
||||||
Application, ApplicationExt, Element,
|
Application, ApplicationExt, Element,
|
||||||
|
|
@ -42,18 +41,17 @@ use std::{
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::localize::LANGUAGE_SORTER;
|
|
||||||
use crate::tab::HOVER_DURATION;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste},
|
clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste},
|
||||||
config::{AppTheme, Config, Favorite, IconSizes, TabConfig, CONFIG_VERSION},
|
config::{AppTheme, Config, Favorite, IconSizes, TabConfig, CONFIG_VERSION},
|
||||||
fl, home_dir,
|
fl, home_dir,
|
||||||
key_bind::key_binds,
|
key_bind::key_binds,
|
||||||
|
localize::LANGUAGE_SORTER,
|
||||||
menu, mime_app,
|
menu, mime_app,
|
||||||
mounter::{mounters, MounterItem, MounterItems, MounterKey, Mounters},
|
mounter::{mounters, MounterItem, MounterItems, MounterKey, Mounters},
|
||||||
operation::{Operation, ReplaceResult},
|
operation::{Operation, ReplaceResult},
|
||||||
spawn_detached::spawn_detached,
|
spawn_detached::spawn_detached,
|
||||||
tab::{self, HeadingOptions, ItemMetadata, Location, Tab},
|
tab::{self, HeadingOptions, ItemMetadata, Location, Tab, HOVER_DURATION},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
use cosmic::widget::menu::key_bind::KeyBind;
|
use cosmic::{
|
||||||
use cosmic::{iced::keyboard::Key, iced_core::keyboard::key::Named};
|
iced::keyboard::Key,
|
||||||
|
iced_core::keyboard::key::Named,
|
||||||
|
widget::menu::key_bind::{KeyBind, Modifier},
|
||||||
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::app::Action;
|
use crate::app::Action;
|
||||||
use cosmic::widget::menu::key_bind::Modifier;
|
|
||||||
|
|
||||||
//TODO: load from config
|
//TODO: load from config
|
||||||
pub fn key_binds() -> HashMap<KeyBind, Action> {
|
pub fn key_binds() -> HashMap<KeyBind, Action> {
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,20 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic::widget::menu::key_bind::KeyBind;
|
|
||||||
use cosmic::widget::menu::{self, ItemHeight, ItemWidth, MenuBar};
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
//TODO: export iced::widget::horizontal_rule in cosmic::widget
|
//TODO: export iced::widget::horizontal_rule in cosmic::widget
|
||||||
iced::{widget::horizontal_rule, Alignment, Background, Border, Length},
|
iced::{widget::horizontal_rule, Alignment, Background, Border, Length},
|
||||||
theme,
|
theme,
|
||||||
widget,
|
widget,
|
||||||
|
widget::menu::{self, key_bind::KeyBind, ItemHeight, ItemWidth, MenuBar},
|
||||||
Element,
|
Element,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::tab::LocationMenuAction;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{Action, Message},
|
app::{Action, Message},
|
||||||
config::TabConfig,
|
config::TabConfig,
|
||||||
fl,
|
fl,
|
||||||
tab::{self, HeadingOptions, Location, Tab},
|
tab::{self, HeadingOptions, Location, LocationMenuAction, Tab},
|
||||||
};
|
};
|
||||||
|
|
||||||
macro_rules! menu_button {
|
macro_rules! menu_button {
|
||||||
|
|
|
||||||
36
src/tab.rs
36
src/tab.rs
|
|
@ -1,9 +1,3 @@
|
||||||
use cosmic::iced::clipboard::dnd::DndAction;
|
|
||||||
use cosmic::iced::Border;
|
|
||||||
use cosmic::iced_core::widget::tree;
|
|
||||||
use cosmic::widget::menu::action::MenuAction;
|
|
||||||
use cosmic::widget::menu::key_bind::KeyBind;
|
|
||||||
use cosmic::widget::{vertical_space, Id, Widget};
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
cosmic_theme, font,
|
cosmic_theme, font,
|
||||||
iced::{
|
iced::{
|
||||||
|
|
@ -12,6 +6,7 @@ use cosmic::{
|
||||||
text::{self, Paragraph},
|
text::{self, Paragraph},
|
||||||
},
|
},
|
||||||
alignment::{Horizontal, Vertical},
|
alignment::{Horizontal, Vertical},
|
||||||
|
clipboard::dnd::DndAction,
|
||||||
futures::SinkExt,
|
futures::SinkExt,
|
||||||
keyboard::Modifiers,
|
keyboard::Modifiers,
|
||||||
subscription::{self, Subscription},
|
subscription::{self, Subscription},
|
||||||
|
|
@ -21,6 +16,7 @@ use cosmic::{
|
||||||
scrollable::{AbsoluteOffset, Viewport},
|
scrollable::{AbsoluteOffset, Viewport},
|
||||||
},
|
},
|
||||||
Alignment,
|
Alignment,
|
||||||
|
Border,
|
||||||
Color,
|
Color,
|
||||||
ContentFit,
|
ContentFit,
|
||||||
Length,
|
Length,
|
||||||
|
|
@ -28,36 +24,42 @@ use cosmic::{
|
||||||
Rectangle,
|
Rectangle,
|
||||||
Size,
|
Size,
|
||||||
},
|
},
|
||||||
theme, widget, Element,
|
iced_core::widget::tree,
|
||||||
|
theme, widget,
|
||||||
|
widget::{
|
||||||
|
menu::{action::MenuAction, key_bind::KeyBind},
|
||||||
|
vertical_space, DndDestination, DndSource, Id, Widget,
|
||||||
|
},
|
||||||
|
Element,
|
||||||
};
|
};
|
||||||
|
|
||||||
use mime_guess::{mime, Mime};
|
use mime_guess::{mime, Mime};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use std::{
|
use std::{
|
||||||
cell::Cell,
|
cell::{Cell, RefCell},
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt,
|
fmt,
|
||||||
fs::{self, Metadata},
|
fs::{self, Metadata},
|
||||||
num::NonZeroU16,
|
num::NonZeroU16,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
|
sync::{Arc, Mutex},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste};
|
|
||||||
use crate::localize::LANGUAGE_SORTER;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{self, Action},
|
app::{self, Action},
|
||||||
|
clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste},
|
||||||
config::{IconSizes, TabConfig, ICON_SCALE_MAX, ICON_SIZE_GRID},
|
config::{IconSizes, TabConfig, ICON_SCALE_MAX, ICON_SIZE_GRID},
|
||||||
dialog::DialogKind,
|
dialog::DialogKind,
|
||||||
fl, menu,
|
fl,
|
||||||
|
localize::LANGUAGE_SORTER,
|
||||||
|
menu,
|
||||||
mime_app::{mime_apps, MimeApp},
|
mime_app::{mime_apps, MimeApp},
|
||||||
mime_icon::{mime_for_path, mime_icon},
|
mime_icon::{mime_for_path, mime_icon},
|
||||||
mouse_area,
|
mouse_area,
|
||||||
};
|
};
|
||||||
use cosmic::widget::{DndDestination, DndSource};
|
|
||||||
|
|
||||||
pub const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500);
|
pub const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500);
|
||||||
pub const HOVER_DURATION: Duration = Duration::from_millis(1600);
|
pub const HOVER_DURATION: Duration = Duration::from_millis(1600);
|
||||||
|
|
@ -1920,7 +1922,9 @@ impl Tab {
|
||||||
} = theme::active().cosmic().spacing;
|
} = theme::active().cosmic().spacing;
|
||||||
let size = self.size_opt.get().unwrap_or(Size::new(0.0, 0.0));
|
let size = self.size_opt.get().unwrap_or(Size::new(0.0, 0.0));
|
||||||
|
|
||||||
let mut row = widget::row::with_capacity(5).align_items(Alignment::Center).padding([0, space_m]);
|
let mut row = widget::row::with_capacity(5)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.padding([0, space_m]);
|
||||||
let mut w = 0.0;
|
let mut w = 0.0;
|
||||||
|
|
||||||
let mut prev_button =
|
let mut prev_button =
|
||||||
|
|
@ -2632,7 +2636,7 @@ impl Tab {
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fixed(row_height as f32))
|
.height(Length::Fixed(row_height as f32))
|
||||||
.id(item.button_id.clone())
|
.id(item.button_id.clone())
|
||||||
.padding(space_xxs)
|
.padding(if icon_size < 24 { 7 } else { space_xxs })
|
||||||
.style(button_style(item.selected, true, false)),
|
.style(button_style(item.selected, true, false)),
|
||||||
)
|
)
|
||||||
.on_press(move |_| Message::Click(Some(i)))
|
.on_press(move |_| Message::Click(Some(i)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue