mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-06-12 13:34:26 +02:00
feat(wm): allow f32 width % for custom layouts
This commit allows users to provide an f32 value for the WidthPercentage on the primary column of a custom layout.
This commit is contained in:
@@ -72,7 +72,7 @@ impl CustomLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn primary_width_percentage(&self) -> Option<usize> {
|
pub fn primary_width_percentage(&self) -> Option<f32> {
|
||||||
for column in self.iter() {
|
for column in self.iter() {
|
||||||
if let Column::Primary(Option::Some(ColumnWidth::WidthPercentage(percentage))) = column
|
if let Column::Primary(Option::Some(ColumnWidth::WidthPercentage(percentage))) = column
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ impl CustomLayout {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_primary_width_percentage(&mut self, percentage: usize) {
|
pub fn set_primary_width_percentage(&mut self, percentage: f32) {
|
||||||
for column in self.iter_mut() {
|
for column in self.iter_mut() {
|
||||||
if let Column::Primary(Option::Some(ColumnWidth::WidthPercentage(current))) = column {
|
if let Column::Primary(Option::Some(ColumnWidth::WidthPercentage(current))) = column {
|
||||||
*current = percentage;
|
*current = percentage;
|
||||||
@@ -262,7 +262,7 @@ pub enum Column {
|
|||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
pub enum ColumnWidth {
|
pub enum ColumnWidth {
|
||||||
WidthPercentage(usize),
|
WidthPercentage(f32),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]
|
||||||
|
|||||||
@@ -683,15 +683,15 @@ impl WindowManager {
|
|||||||
if matches!(axis, Axis::Horizontal) {
|
if matches!(axis, Axis::Horizontal) {
|
||||||
let percentage = custom
|
let percentage = custom
|
||||||
.primary_width_percentage()
|
.primary_width_percentage()
|
||||||
.unwrap_or(100 / custom.len());
|
.unwrap_or(100.0 / (custom.len() as f32));
|
||||||
|
|
||||||
if no_layout_rules {
|
if no_layout_rules {
|
||||||
match sizing {
|
match sizing {
|
||||||
Sizing::Increase => {
|
Sizing::Increase => {
|
||||||
custom.set_primary_width_percentage(percentage + 5);
|
custom.set_primary_width_percentage(percentage + 5.0);
|
||||||
}
|
}
|
||||||
Sizing::Decrease => {
|
Sizing::Decrease => {
|
||||||
custom.set_primary_width_percentage(percentage - 5);
|
custom.set_primary_width_percentage(percentage - 5.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -700,10 +700,10 @@ impl WindowManager {
|
|||||||
if let Layout::Custom(ref mut custom) = rule.1 {
|
if let Layout::Custom(ref mut custom) = rule.1 {
|
||||||
match sizing {
|
match sizing {
|
||||||
Sizing::Increase => {
|
Sizing::Increase => {
|
||||||
custom.set_primary_width_percentage(percentage + 5);
|
custom.set_primary_width_percentage(percentage + 5.0);
|
||||||
}
|
}
|
||||||
Sizing::Decrease => {
|
Sizing::Decrease => {
|
||||||
custom.set_primary_width_percentage(percentage - 5);
|
custom.set_primary_width_percentage(percentage - 5.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user