making the library collapsable
This commit is contained in:
parent
53b90afbdb
commit
043a90485c
57
src/main.rs
57
src/main.rs
|
@ -16,7 +16,8 @@ use cosmic::widget::nav_bar::nav_bar_style;
|
||||||
use cosmic::widget::segmented_button::Entity;
|
use cosmic::widget::segmented_button::Entity;
|
||||||
use cosmic::widget::tooltip::Position as TPosition;
|
use cosmic::widget::tooltip::Position as TPosition;
|
||||||
use cosmic::widget::{
|
use cosmic::widget::{
|
||||||
button, horizontal_space, nav_bar, tooltip, Space,
|
button, horizontal_space, nav_bar, search_input, text_input,
|
||||||
|
tooltip, Space,
|
||||||
};
|
};
|
||||||
use cosmic::widget::{icon, slider};
|
use cosmic::widget::{icon, slider};
|
||||||
use cosmic::widget::{text, toggler};
|
use cosmic::widget::{text, toggler};
|
||||||
|
@ -121,6 +122,7 @@ enum Message {
|
||||||
WindowOpened(window::Id, Option<Point>),
|
WindowOpened(window::Id, Option<Point>),
|
||||||
WindowClosed(window::Id),
|
WindowClosed(window::Id),
|
||||||
AddLibrary(Library),
|
AddLibrary(Library),
|
||||||
|
LibraryToggle,
|
||||||
Quit,
|
Quit,
|
||||||
Key(Key, Modifiers),
|
Key(Key, Modifiers),
|
||||||
None,
|
None,
|
||||||
|
@ -291,7 +293,11 @@ impl cosmic::Application for App {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
fn header_center(&self) -> Vec<Element<Self::Message>> {
|
fn header_center(&self) -> Vec<Element<Self::Message>> {
|
||||||
vec![]
|
vec![search_input("Search...", "")
|
||||||
|
.on_input(|_| Message::None)
|
||||||
|
.on_submit(|_| Message::None)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into()]
|
||||||
}
|
}
|
||||||
fn header_end(&self) -> Vec<Element<Self::Message>> {
|
fn header_end(&self) -> Vec<Element<Self::Message>> {
|
||||||
let editor_toggle = toggler(self.editor_mode.is_some())
|
let editor_toggle = toggler(self.editor_mode.is_some())
|
||||||
|
@ -302,9 +308,9 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
let presenter_window = self.windows.get(1);
|
let presenter_window = self.windows.get(1);
|
||||||
let text = if self.presentation_open {
|
let text = if self.presentation_open {
|
||||||
text::text("End Presentation")
|
text::body("End Presentation")
|
||||||
} else {
|
} else {
|
||||||
text::text("Present")
|
text::body("Present")
|
||||||
};
|
};
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
|
@ -316,7 +322,7 @@ impl cosmic::Application for App {
|
||||||
Container::new(
|
Container::new(
|
||||||
icon::from_name(
|
icon::from_name(
|
||||||
if self.presentation_open {
|
if self.presentation_open {
|
||||||
"dialog-close"
|
"window-close-symbolic"
|
||||||
} else {
|
} else {
|
||||||
"view-presentation-symbolic"
|
"view-presentation-symbolic"
|
||||||
}
|
}
|
||||||
|
@ -326,7 +332,6 @@ impl cosmic::Application for App {
|
||||||
.center_y(Length::Fill),
|
.center_y(Length::Fill),
|
||||||
text
|
text
|
||||||
)
|
)
|
||||||
.padding(5)
|
|
||||||
.spacing(5),
|
.spacing(5),
|
||||||
)
|
)
|
||||||
.class(cosmic::theme::style::Button::HeaderBar)
|
.class(cosmic::theme::style::Button::HeaderBar)
|
||||||
|
@ -344,6 +349,33 @@ impl cosmic::Application for App {
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
horizontal_space().width(HEADER_SPACE).into(),
|
horizontal_space().width(HEADER_SPACE).into(),
|
||||||
|
tooltip(
|
||||||
|
button::custom(
|
||||||
|
row!(
|
||||||
|
Container::new(
|
||||||
|
icon::from_name(if self.library_open {
|
||||||
|
"arrow-right"
|
||||||
|
} else {
|
||||||
|
"view-list-symbolic"
|
||||||
|
})
|
||||||
|
.scale(3)
|
||||||
|
)
|
||||||
|
.center_y(Length::Fill),
|
||||||
|
text::body(if self.library_open {
|
||||||
|
"Close Library"
|
||||||
|
} else {
|
||||||
|
"Open Library"
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.spacing(5),
|
||||||
|
)
|
||||||
|
.class(cosmic::theme::style::Button::HeaderBar)
|
||||||
|
.on_press(Message::LibraryToggle),
|
||||||
|
"Open Library",
|
||||||
|
TPosition::Bottom,
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
horizontal_space().width(HEADER_SPACE).into(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,6 +593,10 @@ impl cosmic::Application for App {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::LibraryToggle => {
|
||||||
|
self.library_open = !self.library_open;
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
Message::Quit => cosmic::iced::exit(),
|
Message::Quit => cosmic::iced::exit(),
|
||||||
Message::DndEnter(entity, data) => {
|
Message::DndEnter(entity, data) => {
|
||||||
debug!(?entity);
|
debug!(?entity);
|
||||||
|
@ -664,14 +700,17 @@ impl cosmic::Application for App {
|
||||||
]
|
]
|
||||||
.spacing(3);
|
.spacing(3);
|
||||||
|
|
||||||
let library =
|
let library = if self.library_open {
|
||||||
Container::new(if let Some(library) = &self.library {
|
Container::new(if let Some(library) = &self.library {
|
||||||
library.view().map(|m| Message::Library(m))
|
library.view().map(|m| Message::Library(m))
|
||||||
} else {
|
} else {
|
||||||
Space::new(0, 0).into()
|
Space::new(0, 0).into()
|
||||||
})
|
})
|
||||||
.style(nav_bar_style)
|
.style(nav_bar_style)
|
||||||
.center(Length::Fill);
|
.center(Length::FillPortion(2))
|
||||||
|
} else {
|
||||||
|
Container::new(horizontal_space().width(0))
|
||||||
|
};
|
||||||
|
|
||||||
let song_editor =
|
let song_editor =
|
||||||
self.song_editor.view().map(|m| Message::SongEditor(m));
|
self.song_editor.view().map(|m| Message::SongEditor(m));
|
||||||
|
@ -706,7 +745,7 @@ impl cosmic::Application for App {
|
||||||
.center_y(Length::Fill)
|
.center_y(Length::Fill)
|
||||||
.align_left(Length::Fill)
|
.align_left(Length::Fill)
|
||||||
.width(Length::FillPortion(1)),
|
.width(Length::FillPortion(1)),
|
||||||
library.width(Length::FillPortion(2))
|
library
|
||||||
]
|
]
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
|
|
Loading…
Reference in a new issue