mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2025-11-17 23:14:23 +00:00
refactor: fallback at default on height
This commit is contained in:
parent
02c00d28cb
commit
eb8e19cb9e
3 changed files with 11 additions and 15 deletions
|
|
@ -135,9 +135,10 @@ impl LayerShika<NeedsComponent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LayerShika<HasComponent> {
|
impl LayerShika<HasComponent> {
|
||||||
pub fn with_height(mut self, height: u32) -> Result<Self> {
|
#[must_use]
|
||||||
self.config.height = WindowHeight::new(height)?;
|
pub fn with_height(mut self, height: u32) -> Self {
|
||||||
Ok(self)
|
self.config.height = WindowHeight::new(height);
|
||||||
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,14 @@
|
||||||
use crate::errors::{DomainError, Result};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct WindowHeight(u32);
|
pub struct WindowHeight(u32);
|
||||||
|
|
||||||
impl WindowHeight {
|
impl WindowHeight {
|
||||||
pub fn new(height: u32) -> Result<Self> {
|
pub fn new(height: u32) -> Self {
|
||||||
if height == 0 {
|
if height == 0 {
|
||||||
return Err(DomainError::InvalidDimensions {
|
Self::default()
|
||||||
width: 0,
|
} else {
|
||||||
height: 0,
|
Self(height)
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Ok(Self(height))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn from_raw(height: u32) -> Self {
|
pub const fn from_raw(height: u32) -> Self {
|
||||||
|
|
@ -29,10 +26,8 @@ impl Default for WindowHeight {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<u32> for WindowHeight {
|
impl From<u32> for WindowHeight {
|
||||||
type Error = DomainError;
|
fn from(height: u32) -> Self {
|
||||||
|
|
||||||
fn try_from(height: u32) -> Result<Self> {
|
|
||||||
Self::new(height)
|
Self::new(height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
//! use layer_shika::prelude::*;
|
//! use layer_shika::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! let (window, system) = LayerShika::from_file("ui/main.slint", "AppWindow")?
|
//! let (window, system) = LayerShika::from_file("ui/main.slint", "AppWindow")?
|
||||||
//! .with_height(42)?
|
//! .with_height(42)
|
||||||
//! .with_anchor(AnchorEdges::top_bar())
|
//! .with_anchor(AnchorEdges::top_bar())
|
||||||
//! .with_exclusive_zone(42)
|
//! .with_exclusive_zone(42)
|
||||||
//! .build()?;
|
//! .build()?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue