feat: panel position on screen
This commit is contained in:
parent
215648324a
commit
f1f12b5e21
3 changed files with 56 additions and 14 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -798,7 +798,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-panel-config"
|
name = "cosmic-panel-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-panel#aae46287cdb349381743fe530f281333c7ebfa83"
|
source = "git+https://github.com/pop-os/cosmic-panel#1ef8ca7dd07bbbc6bd86ce8421dc3c759d4a837b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)",
|
"cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic?tag=cosmic-config-derive)",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::widget::horizontal_space,
|
iced::widget::horizontal_space,
|
||||||
iced::Length,
|
iced::Length,
|
||||||
widget::{settings, toggler},
|
iced_widget::pick_list,
|
||||||
|
widget::{settings, text, toggler},
|
||||||
Element,
|
Element,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -11,6 +12,7 @@ use cosmic_panel_config::{AutoHide, CosmicPanelConfig, CosmicPanelOuput, PanelAn
|
||||||
use cosmic_settings_page::Section;
|
use cosmic_settings_page::Section;
|
||||||
use cosmic_settings_page::{self as page, section};
|
use cosmic_settings_page::{self as page, section};
|
||||||
use slotmap::SlotMap;
|
use slotmap::SlotMap;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
pub struct Page {
|
pub struct Page {
|
||||||
config_helper: Option<cosmic_config::Config>,
|
config_helper: Option<cosmic_config::Config>,
|
||||||
|
|
@ -64,7 +66,11 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
||||||
pub fn behavior_and_position() -> Section<crate::pages::Message> {
|
pub fn behavior_and_position() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("panel-behavior-and-position"))
|
.title(fl!("panel-behavior-and-position"))
|
||||||
.descriptions(vec![fl!("panel-behavior-and-position", "autohide")])
|
.descriptions(vec![
|
||||||
|
fl!("panel-behavior-and-position", "autohide"),
|
||||||
|
fl!("panel-behavior-and-position", "position"),
|
||||||
|
fl!("panel-behavior-and-position", "display"),
|
||||||
|
])
|
||||||
.view::<Page>(|_binder, page, section| {
|
.view::<Page>(|_binder, page, section| {
|
||||||
let descriptions = §ion.descriptions;
|
let descriptions = §ion.descriptions;
|
||||||
let panel_config = page.panel_config.as_ref().unwrap();
|
let panel_config = page.panel_config.as_ref().unwrap();
|
||||||
|
|
@ -75,6 +81,20 @@ pub fn behavior_and_position() -> Section<crate::pages::Message> {
|
||||||
Message::AutoHidePanel(value)
|
Message::AutoHidePanel(value)
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
|
.add(settings::item(
|
||||||
|
&descriptions[1],
|
||||||
|
pick_list(
|
||||||
|
Cow::from(vec![
|
||||||
|
Anchor(PanelAnchor::Top),
|
||||||
|
Anchor(PanelAnchor::Bottom),
|
||||||
|
Anchor(PanelAnchor::Left),
|
||||||
|
Anchor(PanelAnchor::Right),
|
||||||
|
]),
|
||||||
|
Some(Anchor(panel_config.anchor)),
|
||||||
|
|a| Message::PanelAnchor(a.0),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.add(settings::item(&descriptions[2], text("todo")))
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::Panel)
|
.map(crate::pages::Message::Panel)
|
||||||
})
|
})
|
||||||
|
|
@ -82,14 +102,15 @@ pub fn behavior_and_position() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
pub fn style() -> Section<crate::pages::Message> {
|
pub fn style() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("hot-corner"))
|
.title(fl!("panel-style"))
|
||||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
.descriptions(vec![
|
||||||
|
fl!("panel-style", "anchor-gap"),
|
||||||
|
fl!("panel-style", "extend"),
|
||||||
|
fl!("panel-style", "appearance"),
|
||||||
|
fl!("panel-style", "size"),
|
||||||
|
fl!("panel-style", "background-opacity"),
|
||||||
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let desktop = binder
|
|
||||||
.page::<super::Page>()
|
|
||||||
.expect("desktop page not found");
|
|
||||||
|
|
||||||
let descriptions = §ion.descriptions;
|
|
||||||
settings::view_section(§ion.title)
|
settings::view_section(§ion.title)
|
||||||
.apply(Element::from)
|
.apply(Element::from)
|
||||||
.map(crate::pages::Message::Desktop)
|
.map(crate::pages::Message::Desktop)
|
||||||
|
|
@ -98,8 +119,8 @@ pub fn style() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
pub fn configuration() -> Section<crate::pages::Message> {
|
pub fn configuration() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("hot-corner"))
|
.title(fl!("panel-applets"))
|
||||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
.descriptions(vec![fl!("panel-applets", "desc")])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let desktop = binder
|
let desktop = binder
|
||||||
.page::<super::Page>()
|
.page::<super::Page>()
|
||||||
|
|
@ -114,8 +135,11 @@ pub fn configuration() -> Section<crate::pages::Message> {
|
||||||
|
|
||||||
pub fn add_panel() -> Section<crate::pages::Message> {
|
pub fn add_panel() -> Section<crate::pages::Message> {
|
||||||
Section::default()
|
Section::default()
|
||||||
.title(fl!("hot-corner"))
|
.title(fl!("panel-missing"))
|
||||||
.descriptions(vec![fl!("hot-corner", "top-left-corner")])
|
.descriptions(vec![
|
||||||
|
fl!("panel-missing", "desc"),
|
||||||
|
fl!("panel-missing", "fix"),
|
||||||
|
])
|
||||||
.view::<Page>(|binder, _page, section| {
|
.view::<Page>(|binder, _page, section| {
|
||||||
let desktop = binder
|
let desktop = binder
|
||||||
.page::<super::Page>()
|
.page::<super::Page>()
|
||||||
|
|
@ -128,6 +152,20 @@ pub fn add_panel() -> Section<crate::pages::Message> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Anchor(PanelAnchor);
|
||||||
|
|
||||||
|
impl ToString for Anchor {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
match self.0 {
|
||||||
|
PanelAnchor::Top => fl!("panel-top"),
|
||||||
|
PanelAnchor::Bottom => fl!("panel-bottom"),
|
||||||
|
PanelAnchor::Left => fl!("panel-left"),
|
||||||
|
PanelAnchor::Right => fl!("panel-right"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Message {
|
pub enum Message {
|
||||||
// panel messages
|
// panel messages
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ panel-behavior-and-position = Behavior and Positions
|
||||||
.autohide = Automatically hide panel
|
.autohide = Automatically hide panel
|
||||||
.position = Position on screen
|
.position = Position on screen
|
||||||
.display = Show on display
|
.display = Show on display
|
||||||
|
panel-top = Top
|
||||||
|
panel-bottom = Bottom
|
||||||
|
panel-left = Left
|
||||||
|
panel-right = Right
|
||||||
|
|
||||||
panel-style = Style
|
panel-style = Style
|
||||||
.anchor-gap = Gap between panel and screen edges
|
.anchor-gap = Gap between panel and screen edges
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue