forked from 1b-agent/opencadstudio-upstream
fix(form): unify style manager field styling
This commit is contained in:
1 parent
ddbfb8f72b
commit
42ba7f12a0
7 files changed
+23
-107
No files matched your search
@@ -4,7 +4,7 @@ use crate::app::{ColorPickTarget, DsField, Message};
|
||||
use crate::scene::convert::tessellate::{arrow_from_block_name, ArrowKind};
|
||||
use crate::t;
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::style::form::hdivider;
|
||||
use crate::ui::style::form::{field_style, hdivider};
|
||||
use iced::widget::{
|
||||
button, canvas, checkbox, column, container, row, scrollable, text, text_input, Space,
|
||||
};
|
||||
@@ -137,26 +137,6 @@ fn tab_btn_style(active: bool) -> impl Fn(&Theme, button::Status) -> button::Sty
|
||||
}
|
||||
}
|
||||
|
||||
fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
let palette = theme.palette();
|
||||
let border = match status {
|
||||
text_input::Status::Focused { .. } => palette.primary.base.color,
|
||||
_ => palette.background.neutral.color,
|
||||
};
|
||||
text_input::Style {
|
||||
background: Background::Color(palette.background.base.color),
|
||||
border: Border {
|
||||
color: border,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
icon: palette.background.base.text,
|
||||
placeholder: palette.background.base.text.scale_alpha(0.48),
|
||||
value: palette.background.base.text,
|
||||
selection: palette.primary.base.color.scale_alpha(0.5),
|
||||
}
|
||||
}
|
||||
|
||||
fn primary_style(theme: &Theme) -> iced::widget::text::Style {
|
||||
iced::widget::text::Style {
|
||||
color: Some(theme.palette().primary.base.color),
|
||||
|
||||
+14
-1
@@ -96,6 +96,19 @@ pub fn button_style(accent: bool) -> impl Fn(&Theme, button::Status) -> button::
|
||||
|
||||
/// Text field: base background, neutral border that turns primary on focus.
|
||||
pub fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
field_style_with_radius(theme, status, 3.0)
|
||||
}
|
||||
|
||||
/// Shared text-field styling with a caller-selected corner radius.
|
||||
///
|
||||
/// The default dialog radius is 3px. A small number of compact dialogs use
|
||||
/// 4px; they can preserve that visual choice without duplicating the palette
|
||||
/// and focus-border logic.
|
||||
pub fn field_style_with_radius(
|
||||
theme: &Theme,
|
||||
status: text_input::Status,
|
||||
radius: f32,
|
||||
) -> text_input::Style {
|
||||
let palette = theme.palette();
|
||||
let border = match status {
|
||||
text_input::Status::Focused { .. } => palette.primary.base.color,
|
||||
@@ -106,7 +119,7 @@ pub fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Sty
|
||||
border: Border {
|
||||
color: border,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
radius: radius.into(),
|
||||
},
|
||||
icon: palette.background.base.text,
|
||||
placeholder: palette.background.base.text.scale_alpha(0.48),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use crate::app::Message;
|
||||
use crate::t;
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::style::form::{hdivider, vsep};
|
||||
use crate::ui::style::form::{field_style, hdivider, vsep};
|
||||
use iced::widget::{button, column, container, row, scrollable, text, text_input, Space};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
use std::borrow::Cow;
|
||||
@@ -62,26 +62,6 @@ fn btn_s(accent: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
}
|
||||
}
|
||||
|
||||
fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
let palette = theme.palette();
|
||||
let border = match status {
|
||||
text_input::Status::Focused { .. } => palette.primary.base.color,
|
||||
_ => palette.background.neutral.color,
|
||||
};
|
||||
text_input::Style {
|
||||
background: Background::Color(palette.background.base.color),
|
||||
border: Border {
|
||||
color: border,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
icon: palette.background.base.text,
|
||||
placeholder: palette.background.base.text.scale_alpha(0.48),
|
||||
value: palette.background.base.text,
|
||||
selection: palette.primary.base.color.scale_alpha(0.5),
|
||||
}
|
||||
}
|
||||
|
||||
/// Layer names bucketed by ACI (AutoCAD Color Index), index = ACI.
|
||||
///
|
||||
/// Pure function of `document.layers`: one entry per layer whose color is
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use crate::app::Message;
|
||||
use crate::t;
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::style::form::{dialog_button, form_radio};
|
||||
use crate::ui::style::form::{dialog_button, field_style_with_radius, 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 std::borrow::Cow;
|
||||
@@ -119,26 +119,6 @@ fn cell<'a>(value: i16, selected: bool) -> Element<'a, Message> {
|
||||
.into()
|
||||
}
|
||||
|
||||
fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
let palette = theme.palette();
|
||||
let border = match status {
|
||||
text_input::Status::Focused { .. } => palette.primary.base.color,
|
||||
_ => palette.background.neutral.color,
|
||||
};
|
||||
text_input::Style {
|
||||
background: Background::Color(palette.background.base.color),
|
||||
border: Border {
|
||||
color: border,
|
||||
width: 1.0,
|
||||
radius: 4.0.into(),
|
||||
},
|
||||
icon: palette.background.base.text,
|
||||
placeholder: palette.background.base.text.scale_alpha(0.48),
|
||||
value: palette.background.base.text,
|
||||
selection: palette.primary.base.color.scale_alpha(0.5),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn view_window<'a>(
|
||||
pdmode: i16,
|
||||
relative: bool,
|
||||
@@ -164,7 +144,7 @@ pub fn view_window<'a>(
|
||||
text_input("0", size_buf)
|
||||
.on_input(Message::PointStyleSizeInput)
|
||||
.on_submit(Message::PointStyleApplySize)
|
||||
.style(field_style)
|
||||
.style(|theme, status| field_style_with_radius(theme, status, 4.0))
|
||||
.size(13)
|
||||
.width(110),
|
||||
Space::new().width(6),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::t;
|
||||
use crate::ui::style::form::field_style_with_radius;
|
||||
use crate::ui::style::style_manager::{hdivider, muted_text_style, tb_button, vsep};
|
||||
use iced::widget::{column, container, mouse_area, row, scrollable, text, text_input, Space};
|
||||
use iced::{Background, Border, Element, Theme};
|
||||
@@ -17,26 +18,6 @@ pub fn rename_input_id() -> iced::widget::Id {
|
||||
iced::widget::Id::new("scale-rename-input")
|
||||
}
|
||||
|
||||
fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
let palette = theme.palette();
|
||||
let border = match status {
|
||||
text_input::Status::Focused { .. } => palette.primary.base.color,
|
||||
_ => palette.background.neutral.color,
|
||||
};
|
||||
text_input::Style {
|
||||
background: Background::Color(palette.background.base.color),
|
||||
border: Border {
|
||||
color: border,
|
||||
width: 1.0,
|
||||
radius: 4.0.into(),
|
||||
},
|
||||
icon: palette.background.base.text,
|
||||
placeholder: palette.background.base.text.scale_alpha(0.48),
|
||||
value: palette.background.base.text,
|
||||
selection: palette.primary.base.color.scale_alpha(0.5),
|
||||
}
|
||||
}
|
||||
|
||||
/// `scales` is (name, "paper:drawing" ratio label). The editor buffers hold the
|
||||
/// name / paper / drawing of the row being added or edited.
|
||||
pub fn view_window<'a, 'b>(
|
||||
@@ -154,7 +135,7 @@ pub fn view_window<'a, 'b>(
|
||||
text(label).size(11).style(muted_text_style).width(96),
|
||||
text_input(ph.as_ref(), value)
|
||||
.on_input(on)
|
||||
.style(field_style)
|
||||
.style(|theme, status| field_style_with_radius(theme, status, 4.0))
|
||||
.size(12)
|
||||
.padding([5, 8])
|
||||
.width(sizing.width),
|
||||
|
||||
@@ -332,6 +332,7 @@ fn input_row<'a>(
|
||||
text(label).size(11).style(muted_style).width(155),
|
||||
text_input(placeholder, value)
|
||||
.on_input(message)
|
||||
.style(crate::ui::style::form::field_style)
|
||||
.size(11)
|
||||
.width(170),
|
||||
]
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
use crate::app::{Message, StyleKind};
|
||||
use crate::t;
|
||||
use crate::ui::style::common::muted_style;
|
||||
use crate::ui::style::form::field_style;
|
||||
use iced::widget::{
|
||||
button, canvas, checkbox, column, container, row, scrollable, text, text_input,
|
||||
};
|
||||
use iced::{mouse, Background, Border, Element, Length, Point, Rectangle, Theme};
|
||||
use iced::{mouse, Background, Element, Length, Point, Rectangle, Theme};
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub struct TextStyleView<'a> {
|
||||
@@ -45,26 +46,6 @@ fn primary_style(theme: &Theme) -> iced::widget::text::Style {
|
||||
}
|
||||
}
|
||||
|
||||
fn field_style(theme: &Theme, status: text_input::Status) -> text_input::Style {
|
||||
let palette = theme.palette();
|
||||
text_input::Style {
|
||||
background: Background::Color(palette.background.base.color),
|
||||
border: Border {
|
||||
color: if matches!(status, text_input::Status::Focused { .. }) {
|
||||
palette.primary.base.color
|
||||
} else {
|
||||
palette.background.neutral.color
|
||||
},
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
icon: palette.background.base.text,
|
||||
placeholder: palette.background.base.text.scale_alpha(0.48),
|
||||
value: palette.background.base.text,
|
||||
selection: palette.primary.base.color.scale_alpha(0.5),
|
||||
}
|
||||
}
|
||||
|
||||
fn list_item(active: bool) -> impl Fn(&Theme, button::Status) -> button::Style {
|
||||
move |theme: &Theme, status| {
|
||||
let palette = theme.palette();
|
||||
|
||||
Reference in new issue
Block a user