forked from 1b-agent/opencadstudio-upstream
feat(ui): migrate dialogs across application to shared dialog_button and form_radio builders
This commit is contained in:
1 parent
1a6279e841
commit
6b37476687
36 files changed
+214
-197
No files matched your search
+27
-5
@@ -19,14 +19,36 @@ pub fn dialog_button<'a>(
|
||||
on_press: Message,
|
||||
primary: bool,
|
||||
) -> button::Button<'a, Message> {
|
||||
button(text(label).size(12))
|
||||
.on_press(on_press)
|
||||
.padding([6, 18])
|
||||
.style(if primary {
|
||||
dialog_button_styled(
|
||||
label,
|
||||
on_press,
|
||||
if primary {
|
||||
button::primary
|
||||
} else {
|
||||
button::secondary
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// Standard dialog action button with an explicit button style and optional on_press action.
|
||||
pub fn dialog_button_styled_opt<'a>(
|
||||
label: impl text::IntoFragment<'a>,
|
||||
on_press: Option<Message>,
|
||||
style: fn(&Theme, button::Status) -> button::Style,
|
||||
) -> button::Button<'a, Message> {
|
||||
button(text(label).size(12))
|
||||
.on_press_maybe(on_press)
|
||||
.padding([6, 18])
|
||||
.style(style)
|
||||
}
|
||||
|
||||
/// Standard dialog action button with an explicit button style (primary, secondary, danger, warning, etc.).
|
||||
pub fn dialog_button_styled<'a>(
|
||||
label: impl text::IntoFragment<'a>,
|
||||
on_press: Message,
|
||||
style: fn(&Theme, button::Status) -> button::Style,
|
||||
) -> button::Button<'a, Message> {
|
||||
dialog_button_styled_opt(label, Some(on_press), style)
|
||||
}
|
||||
|
||||
/// Unified radio button helper ensuring consistent 16px size for exact pixel-grid concentric alignment.
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
//! does the same without the dialog.
|
||||
|
||||
use crate::app::Message;
|
||||
use iced::widget::{button, canvas, column, container, radio, row, text, text_input, Space};
|
||||
use iced::{mouse, Background, Border, Element, Length, Point, Rectangle, Size, Theme};
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::style::form::{dialog_button, form_radio};
|
||||
use iced::widget::{button, canvas, column, container, row, text, text_input, Space};
|
||||
use iced::{mouse, Background, Border, Element, Length, Point, Rectangle, Size, Theme};
|
||||
use crate::t;
|
||||
use std::borrow::Cow;
|
||||
|
||||
@@ -162,29 +163,22 @@ pub fn view_window<'a>(
|
||||
.align_y(iced::Center);
|
||||
|
||||
let radios = column![
|
||||
radio(
|
||||
form_radio(
|
||||
t!("Set Size Relative to Screen"),
|
||||
true,
|
||||
Some(relative),
|
||||
Message::PointStyleSizeRelative,
|
||||
)
|
||||
.size(16)
|
||||
.text_size(13),
|
||||
radio(
|
||||
),
|
||||
form_radio(
|
||||
t!("Set Size in Absolute Units"),
|
||||
false,
|
||||
Some(relative),
|
||||
Message::PointStyleSizeRelative,
|
||||
)
|
||||
.size(16)
|
||||
.text_size(13),
|
||||
),
|
||||
]
|
||||
.spacing(6);
|
||||
|
||||
let ok = button(text(t!("OK")).size(13))
|
||||
.padding([5, 22])
|
||||
.on_press(Message::PointStyleOk)
|
||||
.style(button::primary);
|
||||
let ok = dialog_button(t!("OK"), Message::PointStyleOk, true);
|
||||
|
||||
container(
|
||||
column![
|
||||
|
||||
Reference in new issue
Block a user