fix(ui): auto-size modal dialogs

Measure dialog content before fill layout so fields stay visible.\nKeep the MText preview width tied to its toolbar width.\n\nRefs #608
This commit is contained in:
Hakan Seven committed 2026-08-01 18:24:05 +03:00
1 parent 54124dc252
commit 796d7d91d0
11 files changed
+352 -220

No files matched your search

+3 -6
View File
@@ -9,7 +9,7 @@ use crate::app::Message;
use iced::advanced::layout::{self, Layout};
use iced::advanced::widget::{self, Widget};
use iced::advanced::{mouse, overlay, renderer, Shell};
use iced::widget::{button, column, container, mouse_area, opaque, row, stack, Space};
use iced::widget::{button, column, container, mouse_area, opaque, row, sensor, stack, Space};
use iced::{
Background, Border, Element, Event, Length, Padding, Rectangle, Renderer, Size, Theme, Vector,
};
@@ -42,10 +42,6 @@ impl ModalSizing {
width: Length::Fill,
height: Length::Fill,
};
pub fn from_resize(_resize: Vector) -> Self {
Self::FILL
}
}
/// Measure an intrinsic copy of `content`, then lay the fill copy out in the
@@ -326,9 +322,10 @@ pub fn modal<'a>(
// The first stack layer dictates its intrinsic size. Its top spacer reserves
// room for the title, while the actual title bar and resize grip overlay it
// without influencing the modal dimensions.
let measured_content = sensor(content).on_resize(Message::ModalContentResized);
let body_base = column![
Space::new().height(Length::Fixed(24.0)),
content.into(),
measured_content,
]
.spacing(6);
let mut body = stack![body_base, title_bar];
+12 -5
View File
@@ -1,6 +1,6 @@
use crate::app::Message;
use iced::widget::{button, column, row, text, text_input, Space};
use iced::{Element, Fill};
use iced::{Element, Fill, Length, Shrink};
pub const FIND_INPUT_ID: &str = "find-replace-search";
@@ -8,7 +8,13 @@ pub fn view_window<'a>(
search: &'a str,
replacement: &'a str,
status: &'a str,
sizing: crate::ui::modal::ModalSizing,
) -> Element<'a, Message> {
let field_width = if matches!(sizing.width, Length::Fill) {
Fill
} else {
Shrink
};
let find_input = text_input("Text to find", search)
.id(iced::widget::Id::new(FIND_INPUT_ID))
.on_input(Message::FindReplaceSearchChanged)
@@ -33,13 +39,13 @@ pub fn view_window<'a>(
column![
row![
text("Find:").size(12).width(90),
find_input.width(Fill),
find_input.width(field_width),
]
.spacing(8)
.align_y(iced::Center),
row![
text("Replace with:").size(12).width(90),
replacement_input.width(Fill),
replacement_input.width(field_width),
]
.spacing(8)
.align_y(iced::Center),
@@ -47,7 +53,7 @@ pub fn view_window<'a>(
.size(11),
text(status).size(11),
row![
Space::new().width(Fill),
Space::new().width(field_width),
button(text("Close").size(12))
.on_press(Message::CloseModal)
.padding([6, 12])
@@ -61,6 +67,7 @@ pub fn view_window<'a>(
]
.spacing(10)
.padding(12)
.width(Fill)
.width(sizing.width)
.height(sizing.height)
.into()
}