theme: add BarPosition
This commit is contained in:
parent
cbe0165225
commit
b604192bf0
4 changed files with 47 additions and 9 deletions
|
|
@ -1433,14 +1433,18 @@ impl ConfigProxyHandler {
|
|||
});
|
||||
}
|
||||
|
||||
fn handle_set_bar_position(&self, position: BarPosition) {
|
||||
fn handle_set_bar_position(&self, position: BarPosition) -> Result<(), CphError> {
|
||||
let Ok(position) = position.try_into() else {
|
||||
return Err(CphError::UnknownBarPosition(position));
|
||||
};
|
||||
self.state.theme.bar_position.set(position);
|
||||
self.spaces_change();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_get_bar_position(&self) {
|
||||
self.respond(Response::GetBarPosition {
|
||||
position: self.state.theme.bar_position.get(),
|
||||
position: self.state.theme.bar_position.get().into(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -3289,7 +3293,9 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::GetShowBar => self.handle_get_show_bar(),
|
||||
ClientMessage::SetShowTitles { show } => self.handle_set_show_titles(show),
|
||||
ClientMessage::GetShowTitles => self.handle_get_show_titles(),
|
||||
ClientMessage::SetBarPosition { position } => self.handle_set_bar_position(position),
|
||||
ClientMessage::SetBarPosition { position } => self
|
||||
.handle_set_bar_position(position)
|
||||
.wrn("set_bar_position")?,
|
||||
ClientMessage::GetBarPosition => self.handle_get_bar_position(),
|
||||
ClientMessage::SeatFocusHistory { seat, timeline } => self
|
||||
.handle_seat_focus_history(seat, timeline)
|
||||
|
|
@ -3524,6 +3530,8 @@ enum CphError {
|
|||
ModifyConnectorState(#[source] BackendConnectorTransactionError),
|
||||
#[error("Unknown blend space {0:?}")]
|
||||
UnknownBlendSpace(ConfigBlendSpace),
|
||||
#[error("Unknown bar position {0:?}")]
|
||||
UnknownBarPosition(BarPosition),
|
||||
}
|
||||
|
||||
trait WithRequestName {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
theme::BarPosition,
|
||||
tree::NodeVisitor,
|
||||
utils::copyhashmap::CopyHashMap,
|
||||
wire::{JayTrayItemV1Id, XdgPopupId, jay_tray_item_v1::*},
|
||||
},
|
||||
jay_config::theme::BarPosition,
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
|
@ -64,7 +64,7 @@ impl JayTrayItemV1 {
|
|||
fn send_preferred_anchor(&self) {
|
||||
let anchor = match self.data.client.state.theme.bar_position.get() {
|
||||
BarPosition::Bottom => ANCHOR_TOP_RIGHT,
|
||||
BarPosition::Top | _ => ANCHOR_BOTTOM_RIGHT,
|
||||
BarPosition::Top => ANCHOR_BOTTOM_RIGHT,
|
||||
};
|
||||
self.data.client.event(PreferredAnchor {
|
||||
self_id: self.id,
|
||||
|
|
@ -75,7 +75,7 @@ impl JayTrayItemV1 {
|
|||
fn send_preferred_gravity(&self) {
|
||||
let gravity = match self.data.client.state.theme.bar_position.get() {
|
||||
BarPosition::Bottom => ANCHOR_TOP_LEFT,
|
||||
BarPosition::Top | _ => ANCHOR_BOTTOM_LEFT,
|
||||
BarPosition::Top => ANCHOR_BOTTOM_LEFT,
|
||||
};
|
||||
self.data.client.event(PreferredGravity {
|
||||
self_id: self.id,
|
||||
|
|
|
|||
32
src/theme.rs
32
src/theme.rs
|
|
@ -6,7 +6,8 @@ use {
|
|||
gfx_api::AlphaMode,
|
||||
utils::clonecell::CloneCell,
|
||||
},
|
||||
jay_config::theme::BarPosition,
|
||||
jay_config::theme::BarPosition as ConfigBarPosition,
|
||||
linearize::Linearize,
|
||||
num_traits::Float,
|
||||
std::{cell::Cell, cmp::Ordering, ops::Mul, sync::Arc},
|
||||
};
|
||||
|
|
@ -515,6 +516,35 @@ sizes! {
|
|||
|
||||
pub const DEFAULT_FONT: &str = "monospace 8";
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Default, Linearize)]
|
||||
pub enum BarPosition {
|
||||
#[default]
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
impl TryFrom<ConfigBarPosition> for BarPosition {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: ConfigBarPosition) -> Result<Self, Self::Error> {
|
||||
let v = match value {
|
||||
ConfigBarPosition::Top => Self::Top,
|
||||
ConfigBarPosition::Bottom => Self::Bottom,
|
||||
_ => return Err(()),
|
||||
};
|
||||
Ok(v)
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<ConfigBarPosition> for BarPosition {
|
||||
fn into(self) -> ConfigBarPosition {
|
||||
match self {
|
||||
BarPosition::Top => ConfigBarPosition::Top,
|
||||
BarPosition::Bottom => ConfigBarPosition::Bottom,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Theme {
|
||||
pub colors: ThemeColors,
|
||||
pub sizes: ThemeSizes,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ use {
|
|||
scale::Scale,
|
||||
state::State,
|
||||
text::TextTexture,
|
||||
theme::BarPosition,
|
||||
tree::{
|
||||
Direction, FindTreeResult, FindTreeUsecase, FoundNode, Node, NodeId, NodeLayerLink,
|
||||
NodeLocation, PinnedNode, StackedNode, TddType, TileDragDestination,
|
||||
|
|
@ -67,7 +68,6 @@ use {
|
|||
},
|
||||
ahash::AHashMap,
|
||||
jay_config::{
|
||||
theme::BarPosition,
|
||||
video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
|
||||
workspace::WorkspaceDisplayOrder,
|
||||
},
|
||||
|
|
@ -794,7 +794,7 @@ impl OutputNode {
|
|||
Rect::new_sized_saturating(x1, y1 + height - bh - bsw, width, bsw);
|
||||
bar_rect = Rect::new_sized_saturating(x1, y1 + height - bh, width, bh);
|
||||
}
|
||||
BarPosition::Top | _ => {
|
||||
BarPosition::Top => {
|
||||
bar_rect = Rect::new_sized_saturating(x1, y1, width, bh);
|
||||
bar_separator_rect = Rect::new_sized_saturating(x1, y1 + bh, width, bsw);
|
||||
bar_rect_with_separator = Rect::new_sized_saturating(x1, y1, width, bh + bsw);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue