libcosmic updates
This commit is contained in:
parent
9c62f19e4b
commit
0491c4baaa
91 changed files with 3550 additions and 2300 deletions
|
|
@ -6,7 +6,7 @@ use cosmic::{
|
|||
iced_core::{id, Alignment, Length, Point},
|
||||
iced_widget::{column, container, scrollable, text, text_input},
|
||||
widget::{button, header_bar},
|
||||
ApplicationExt, Command,
|
||||
ApplicationExt, Task,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
|
@ -42,10 +42,10 @@ impl cosmic::Application for MultiWindow {
|
|||
&mut self.core
|
||||
}
|
||||
|
||||
fn init(core: Core, _input: Self::Flags) -> (Self, cosmic::app::Command<Self::Message>) {
|
||||
fn init(core: Core, _input: Self::Flags) -> (Self, cosmic::app::Task<Self::Message>) {
|
||||
let windows = MultiWindow {
|
||||
windows: HashMap::from([(
|
||||
window::Id::MAIN,
|
||||
self.core.main_window_id().unwrap(),
|
||||
Window {
|
||||
input_id: id::Id::new("main"),
|
||||
input_value: String::new(),
|
||||
|
|
@ -54,12 +54,12 @@ impl cosmic::Application for MultiWindow {
|
|||
core,
|
||||
};
|
||||
|
||||
(windows, cosmic::app::Command::none())
|
||||
(windows, cosmic::app::Task::none())
|
||||
}
|
||||
|
||||
fn subscription(&self) -> cosmic::iced_futures::Subscription<Self::Message> {
|
||||
event::listen_with(|event, _| {
|
||||
if let iced::Event::Window(id, window_event) = event {
|
||||
event::listen_with(|event, _, id| {
|
||||
if let iced::Event::Window(window_event) = event {
|
||||
match window_event {
|
||||
window::Event::CloseRequested => Some(Message::CloseWindow(id)),
|
||||
window::Event::Opened { position, .. } => {
|
||||
|
|
@ -77,18 +77,18 @@ impl cosmic::Application for MultiWindow {
|
|||
fn update(
|
||||
&mut self,
|
||||
message: Self::Message,
|
||||
) -> iced::Command<cosmic::app::Message<Self::Message>> {
|
||||
) -> iced::Task<cosmic::app::Message<Self::Message>> {
|
||||
match message {
|
||||
Message::CloseWindow(id) => window::close(id),
|
||||
Message::WindowClosed(id) => {
|
||||
self.windows.remove(&id);
|
||||
Command::none()
|
||||
Task::none()
|
||||
}
|
||||
Message::WindowOpened(id, ..) => {
|
||||
if let Some(window) = self.windows.get(&id) {
|
||||
text_input::focus(window.input_id.clone())
|
||||
} else {
|
||||
Command::none()
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
Message::NewWindow => {
|
||||
|
|
@ -113,13 +113,13 @@ impl cosmic::Application for MultiWindow {
|
|||
spawn_window
|
||||
}
|
||||
Message::Input(id, value) => {
|
||||
if let Some(w) = self.windows.get_mut(&window::Id::MAIN) {
|
||||
if let Some(w) = self.windows.get_mut(&self.core.main_window_id().unwrap()) {
|
||||
if id == w.input_id {
|
||||
w.input_value = value;
|
||||
}
|
||||
}
|
||||
|
||||
Command::none()
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -142,17 +142,15 @@ impl cosmic::Application for MultiWindow {
|
|||
column![input, new_window_button]
|
||||
.spacing(50)
|
||||
.width(Length::Fill)
|
||||
.align_items(Alignment::Center),
|
||||
.align_x(Alignment::Center),
|
||||
);
|
||||
|
||||
let window_content = container(container(content).width(200).center_x())
|
||||
let window_content = container(container(content).center_x(Length::Fixed(200.)))
|
||||
.style(cosmic::style::Container::Background)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.center_x()
|
||||
.center_y();
|
||||
.center_x(Length::Fill)
|
||||
.center_y(Length::Fill);
|
||||
|
||||
if id == window::Id::MAIN {
|
||||
if id == self.core.main_window_id().unwrap() {
|
||||
window_content.into()
|
||||
} else {
|
||||
column![header_bar().focused(focused), window_content].into()
|
||||
|
|
@ -160,6 +158,6 @@ impl cosmic::Application for MultiWindow {
|
|||
}
|
||||
|
||||
fn view(&self) -> cosmic::prelude::Element<Self::Message> {
|
||||
self.view_window(window::Id::MAIN)
|
||||
self.view_window(self.core.main_window_id().unwrap())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue