From 32b630a72dcbe81b216d9ef761e5bc088a2da0d2 Mon Sep 17 00:00:00 2001 From: pml68 Date: Thu, 17 Jul 2025 00:45:18 +0200 Subject: refactor: move `DEFAULT_MAX_{WIDTH,HEIGHT}` constants out of `Dialog` --- src/dialog.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/dialog.rs b/src/dialog.rs index 857fa90..1082ded 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -24,8 +24,6 @@ use iced_widget::{ /// [`max_height`]: Dialog::max_height /// [`width`]: Dialog::width /// [`height`]: Dialog::height -/// [`DEFAULT_MAX_WIDTH`]: Dialog::DEFAULT_MAX_WIDTH -/// [`DEFAULT_MAX_HEIGHT`]: Dialog::DEFAULT_MAX_HEIGHT pub struct Dialog< 'a, Message, @@ -63,16 +61,6 @@ where Theme: 'a + Catalog, Message: 'a + Clone, { - /// The default maximum width of a [`Dialog`]. - /// - /// Check the main documentation of [`Dialog`] to see when this is used. - pub const DEFAULT_MAX_WIDTH: f32 = 400.0; - - /// The default maximum height of a [`Dialog`]. - /// - /// Check the main documentation of [`Dialog`] to see when this is used. - pub const DEFAULT_MAX_HEIGHT: f32 = 260.0; - /// Creates a new [`Dialog`] with the given base and dialog content. pub fn new( is_open: bool, @@ -415,7 +403,7 @@ where let max_width = self.max_width.unwrap_or( if has_buttons && !matches!(self.width, Length::Fixed(_)) { - Self::DEFAULT_MAX_WIDTH + DEFAULT_MAX_WIDTH } else { f32::INFINITY }, @@ -423,7 +411,7 @@ where let max_height = self.max_height.unwrap_or( if has_buttons && !matches!(self.height, Length::Fixed(_)) { - Self::DEFAULT_MAX_HEIGHT + DEFAULT_MAX_HEIGHT } else { f32::INFINITY }, @@ -470,6 +458,16 @@ where } } +/// The default maximum width of a [`Dialog`]. +/// +/// Check the main documentation of [`Dialog`] to see when this is used. +pub const DEFAULT_MAX_WIDTH: f32 = 400.0; + +/// The default maximum height of a [`Dialog`]. +/// +/// Check the main documentation of [`Dialog`] to see when this is used. +pub const DEFAULT_MAX_HEIGHT: f32 = 260.0; + impl<'a, Message, Theme, Renderer> From> for Element<'a, Message, Theme, Renderer> where -- cgit v1.2.3