wip: update to use cosmic-advanced-text
This commit is contained in:
parent
98ec1bbd48
commit
5da0bef35e
36 changed files with 367 additions and 282 deletions
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio"] }
|
||||
libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio", "tiny_skia", "a11y", "lazy"] }
|
||||
|
|
|
|||
|
|
@ -2,14 +2,12 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use cosmic::{
|
||||
iced::{self, wayland::window::set_mode_window, Alignment, Application, Command, Length},
|
||||
iced::{self, wayland::window::set_mode_window, Application, Command, Length},
|
||||
iced::{
|
||||
wayland::window::{start_drag_window, toggle_maximize},
|
||||
widget::{
|
||||
column, container, horizontal_space, pick_list, progress_bar, radio, row, slider,
|
||||
},
|
||||
widget::{column, container, horizontal_space, pick_list, progress_bar, row, slider},
|
||||
window,
|
||||
},
|
||||
iced_native::window,
|
||||
theme::{self, Theme},
|
||||
widget::{
|
||||
button, header_bar, nav_bar, nav_bar_toggle,
|
||||
|
|
@ -176,6 +174,7 @@ pub enum Message {
|
|||
InputChanged,
|
||||
Rectangle(RectangleUpdate<u32>),
|
||||
NavBar(segmented_button::Entity),
|
||||
Ignore,
|
||||
}
|
||||
|
||||
impl Application for Window {
|
||||
|
|
@ -240,9 +239,9 @@ impl Application for Window {
|
|||
Message::ToggleNavBarCondensed => {
|
||||
self.nav_bar_toggled_condensed = !self.nav_bar_toggled_condensed
|
||||
}
|
||||
Message::Drag => return start_drag_window(window::Id::new(0)),
|
||||
Message::Minimize => return set_mode_window(window::Id::new(0), window::Mode::Hidden),
|
||||
Message::Maximize => return toggle_maximize(window::Id::new(0)),
|
||||
Message::Drag => return start_drag_window(window::Id(0)),
|
||||
Message::Minimize => return set_mode_window(window::Id(0), window::Mode::Hidden),
|
||||
Message::Maximize => return toggle_maximize(window::Id(0)),
|
||||
Message::RowSelected(row) => println!("Selected row {row}"),
|
||||
Message::InputChanged => {}
|
||||
Message::Rectangle(r) => match r {
|
||||
|
|
@ -253,6 +252,7 @@ impl Application for Window {
|
|||
self.rectangle_tracker.replace(t);
|
||||
}
|
||||
},
|
||||
Message::Ignore => {}
|
||||
}
|
||||
|
||||
Command::none()
|
||||
|
|
@ -363,13 +363,13 @@ impl Application for Window {
|
|||
.add(settings::item(
|
||||
"Slider",
|
||||
slider(0.0..=100.0, self.slider_value, Message::SliderChanged)
|
||||
.width(Length::Units(250)),
|
||||
.width(Length::Fixed(250.0)),
|
||||
))
|
||||
.add(settings::item(
|
||||
"Progress",
|
||||
progress_bar(0.0..=100.0, self.slider_value)
|
||||
.width(Length::Units(250))
|
||||
.height(Length::Units(4)),
|
||||
.width(Length::Fixed(250.0))
|
||||
.height(Length::Fixed(4.0)),
|
||||
))
|
||||
.into(),
|
||||
])
|
||||
|
|
@ -408,6 +408,12 @@ impl Application for Window {
|
|||
Message::Close
|
||||
}
|
||||
fn subscription(&self) -> iced::Subscription<Self::Message> {
|
||||
rectangle_tracker_subscription(0).map(|(i, e)| Message::Rectangle(e))
|
||||
rectangle_tracker_subscription(0).map(|m| {
|
||||
if let Some((_, e)) = m {
|
||||
Message::Rectangle(e)
|
||||
} else {
|
||||
Message::Ignore
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ publish = false
|
|||
[dependencies]
|
||||
apply = "0.3.0"
|
||||
fraction = "0.13.0"
|
||||
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_softbuffer"] }
|
||||
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_tiny_skia", "a11y", "lazy"] }
|
||||
once_cell = "1.15"
|
||||
slotmap = "1.0.6"
|
||||
slotmap = "1.0.6"
|
||||
env_logger = "0.10"
|
||||
|
|
|
|||
|
|
@ -4,9 +4,15 @@
|
|||
use cosmic::{iced::Application, settings};
|
||||
|
||||
mod window;
|
||||
use env_logger::Env;
|
||||
pub use window::*;
|
||||
|
||||
pub fn main() -> cosmic::iced::Result {
|
||||
let env = Env::default()
|
||||
.filter_or("MY_LOG_LEVEL", "debug")
|
||||
.write_style_or("MY_LOG_STYLE", "always");
|
||||
|
||||
env_logger::init_from_env(env);
|
||||
settings::set_default_icon_theme("Pop");
|
||||
let mut settings = settings();
|
||||
settings.window.min_size = Some((600, 300));
|
||||
|
|
|
|||
|
|
@ -1,25 +1,27 @@
|
|||
/// Copyright 2022 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
use cosmic::{
|
||||
iced::widget::{self, button, column, container, horizontal_space, row, text},
|
||||
iced::{self, Application, Command, Length, Subscription},
|
||||
iced_native::{subscription, window},
|
||||
iced_winit::window::{close, drag, minimize, toggle_maximize},
|
||||
iced::{
|
||||
subscription,
|
||||
widget::{self, column, container, horizontal_space, row, text},
|
||||
window::{self, close, drag, minimize, toggle_maximize},
|
||||
},
|
||||
keyboard_nav,
|
||||
theme::{self, Theme, COSMIC_DARK, COSMIC_LIGHT},
|
||||
theme::{self, Theme},
|
||||
widget::{
|
||||
header_bar, icon, list, nav_bar, nav_bar_toggle, scrollable, segmented_button, settings,
|
||||
warning, IconSource,
|
||||
},
|
||||
Element, ElementExt,
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::{
|
||||
sync::atomic::{AtomicU32, Ordering},
|
||||
vec,
|
||||
};
|
||||
|
||||
static BTN: Lazy<button::Id> = Lazy::new(button::Id::unique);
|
||||
// XXX The use of button is removed because it assigns the same ID to multiple buttons, causing a crash when a11y is enabled...
|
||||
// static BTN: Lazy<id::Id> = Lazy::new(|| id::Id::new("BTN"));
|
||||
|
||||
mod bluetooth;
|
||||
|
||||
|
|
@ -237,7 +239,7 @@ impl Window {
|
|||
))
|
||||
.padding(0)
|
||||
.style(theme::Button::Link)
|
||||
.id(BTN.clone())
|
||||
// .id(BTN.clone())
|
||||
.on_press(Message::from(page)),
|
||||
row!(
|
||||
text(sub_page.title()).size(30),
|
||||
|
|
@ -282,7 +284,7 @@ impl Window {
|
|||
.padding(0)
|
||||
.style(theme::Button::Transparent)
|
||||
.on_press(Message::from(sub_page.into_page()))
|
||||
.id(BTN.clone())
|
||||
// .id(BTN.clone())
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -405,10 +407,10 @@ impl Application for Window {
|
|||
Message::ToggleNavBarCondensed => {
|
||||
self.nav_bar_toggled_condensed = !self.nav_bar_toggled_condensed
|
||||
}
|
||||
Message::Drag => return drag(window::Id::new(0)),
|
||||
Message::Close => return close(window::Id::new(0)),
|
||||
Message::Minimize => return minimize(window::Id::new(0), true),
|
||||
Message::Maximize => return toggle_maximize(window::Id::new(0)),
|
||||
Message::Drag => return drag(),
|
||||
Message::Close => return close(),
|
||||
Message::Minimize => return minimize(true),
|
||||
Message::Maximize => return toggle_maximize(),
|
||||
|
||||
Message::InputChanged => {}
|
||||
|
||||
|
|
@ -553,7 +555,7 @@ impl Application for Window {
|
|||
column(vec![
|
||||
header,
|
||||
warning,
|
||||
iced::widget::vertical_space(Length::Units(12)).into(),
|
||||
iced::widget::vertical_space(Length::Fixed(12.0)).into(),
|
||||
content,
|
||||
])
|
||||
.into()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use apply::Apply;
|
|||
use cosmic::{
|
||||
cosmic_theme,
|
||||
iced::widget::{checkbox, pick_list, progress_bar, radio, row, slider, text, text_input},
|
||||
iced::{Alignment, Length},
|
||||
iced::{id, Alignment, Length},
|
||||
theme::{self, Button as ButtonTheme, Theme},
|
||||
widget::{
|
||||
button, container, icon, segmented_button, segmented_selection, settings, spin_button,
|
||||
|
|
@ -29,7 +29,7 @@ pub enum MultiOption {
|
|||
OptionD,
|
||||
OptionE,
|
||||
}
|
||||
static INPUT_ID: Lazy<text_input::Id> = Lazy::new(text_input::Id::unique);
|
||||
static INPUT_ID: Lazy<id::Id> = Lazy::new(id::Id::unique);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
|
|
@ -253,13 +253,13 @@ impl State {
|
|||
.add(settings::item(
|
||||
"Slider",
|
||||
slider(0.0..=100.0, self.slider_value, Message::SliderChanged)
|
||||
.width(Length::Units(250)),
|
||||
.width(Length::Fixed(250.0)),
|
||||
))
|
||||
.add(settings::item(
|
||||
"Progress",
|
||||
progress_bar(0.0..=100.0, self.slider_value)
|
||||
.width(Length::Units(250))
|
||||
.height(Length::Units(4)),
|
||||
.width(Length::Fixed(250.0))
|
||||
.height(Length::Fixed(4.0)),
|
||||
))
|
||||
.add(settings::item_row(vec![checkbox(
|
||||
"Checkbox",
|
||||
|
|
@ -401,8 +401,8 @@ impl State {
|
|||
text_input(
|
||||
"Type to search apps or type “?” for more options...",
|
||||
&self.entry_value,
|
||||
Message::InputChanged,
|
||||
)
|
||||
.on_input(Message::InputChanged)
|
||||
// .on_submit(Message::Activate(None))
|
||||
.padding(8)
|
||||
.size(20)
|
||||
|
|
|
|||
|
|
@ -219,10 +219,10 @@ impl State {
|
|||
for image_path in chunk.iter() {
|
||||
image_row.push(if image_path.ends_with(".svg") {
|
||||
svg(svg::Handle::from_path(image_path))
|
||||
.width(Length::Units(150))
|
||||
.width(Length::Fixed(150.0))
|
||||
.into()
|
||||
} else {
|
||||
image(image_path).width(Length::Units(150)).into()
|
||||
image(image_path).width(Length::Fixed(150.0)).into()
|
||||
});
|
||||
}
|
||||
image_column.push(row(image_row).spacing(16).into());
|
||||
|
|
@ -234,7 +234,7 @@ impl State {
|
|||
horizontal_space(Length::Fill),
|
||||
container(
|
||||
image("/usr/share/backgrounds/pop/kate-hazen-COSMIC-desktop-wallpaper.png")
|
||||
.width(Length::Units(300))
|
||||
.width(Length::Fixed(300.0))
|
||||
)
|
||||
.padding(4)
|
||||
.style(theme::Container::Background),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use apply::Apply;
|
||||
use cosmic::iced::widget::{horizontal_space, row, scrollable};
|
||||
use cosmic::iced::Length;
|
||||
use cosmic::iced_winit::Alignment;
|
||||
use cosmic::iced::{Alignment, Length};
|
||||
use cosmic::widget::{button, segmented_button, view_switcher};
|
||||
use cosmic::{theme, Element};
|
||||
use slotmap::Key;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue