forked from 1b-agent/opencadstudio-upstream
refactor(ui): adopt iced color picker
Remove local Pin/PickList wrappers and the ACI grid.\nBlock viewport input behind the picker and load iced_aw glyphs.
This commit is contained in:
1 parent
3ab8dc3ca5
commit
c9c3d3b1bf
25 files changed
+289
-255
No files matched your search
@@ -210,7 +210,8 @@ fn pick_field<'a>(
|
||||
on_select: impl Fn(String) -> Message + 'a,
|
||||
width: Length,
|
||||
) -> Element<'a, Message> {
|
||||
let pl = crate::ui::pick_list(options, selected, on_select)
|
||||
let pl = iced::widget::pick_list(selected, options, |value| value.to_string())
|
||||
.on_select(on_select)
|
||||
.text_size(13)
|
||||
.padding([3, 6])
|
||||
.width(width);
|
||||
@@ -475,9 +476,8 @@ fn properties_tab<'a>(
|
||||
|
||||
let lw_opts = lw_options();
|
||||
let lw_sel = LwItem(r.line_weight);
|
||||
let lw = crate::ui::pick_list(lw_opts, Some(lw_sel), |it: LwItem| {
|
||||
Message::AttrEditorLineweight(it.0)
|
||||
})
|
||||
let lw = iced::widget::pick_list(Some(lw_sel), lw_opts, |value| value.to_string())
|
||||
.on_select(|it: LwItem| Message::AttrEditorLineweight(it.0))
|
||||
.text_size(13)
|
||||
.padding([3, 6])
|
||||
.width(width);
|
||||
|
||||
@@ -413,7 +413,10 @@ fn editor_layer_row<'a>(
|
||||
},
|
||||
move |color| Message::LayerStateEditorLayerColor(index, color),
|
||||
Message::LayerStateEditorLayerColorToggle(index),
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::LayerState(index)),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::LayerState(index),
|
||||
layer.color,
|
||||
),
|
||||
);
|
||||
|
||||
container(
|
||||
@@ -432,13 +435,21 @@ fn editor_layer_row<'a>(
|
||||
54.0
|
||||
),
|
||||
container(color).width(Length::Fixed(135.0)),
|
||||
crate::ui::pick_list(linetypes, current_linetype, move |value| {
|
||||
Message::LayerStateEditorLayerLinetype(index, value)
|
||||
})
|
||||
iced::widget::pick_list(
|
||||
current_linetype,
|
||||
linetypes,
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |value| Message::LayerStateEditorLayerLinetype(index, value))
|
||||
.text_size(11)
|
||||
.padding([3, 5])
|
||||
.width(Length::Fixed(150.0)),
|
||||
crate::ui::pick_list(lw_options(), current_lineweight, move |item: LwItem| {
|
||||
iced::widget::pick_list(
|
||||
current_lineweight,
|
||||
lw_options(),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |item: LwItem| {
|
||||
Message::LayerStateEditorLayerLineweight(index, item.0)
|
||||
})
|
||||
.text_size(11)
|
||||
@@ -449,11 +460,12 @@ fn editor_layer_row<'a>(
|
||||
.size(11)
|
||||
.padding([3, 5])
|
||||
.width(Length::Fixed(135.0)),
|
||||
crate::ui::pick_list(
|
||||
transparency_options(layer.transparency),
|
||||
iced::widget::pick_list(
|
||||
Some(TransparencyItem(layer.transparency)),
|
||||
move |item| Message::LayerStateEditorLayerTransparency(index, item.0),
|
||||
transparency_options(layer.transparency),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |item| Message::LayerStateEditorLayerTransparency(index, item.0))
|
||||
.text_size(11)
|
||||
.padding([3, 5])
|
||||
.width(Length::Fixed(105.0)),
|
||||
@@ -543,11 +555,12 @@ pub fn view_editor<'a>(
|
||||
.style(muted),
|
||||
Space::new().width(sizing.width),
|
||||
text("Current layer").size(10).style(muted),
|
||||
crate::ui::pick_list(
|
||||
layer_names,
|
||||
iced::widget::pick_list(
|
||||
Some(state.current_layer.clone()),
|
||||
Message::LayerStateEditorCurrentLayer,
|
||||
layer_names,
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(Message::LayerStateEditorCurrentLayer)
|
||||
.text_size(11)
|
||||
.padding([3, 6])
|
||||
.width(Length::Fixed(180.0)),
|
||||
|
||||
@@ -780,7 +780,10 @@ fn layer_row<'a>(
|
||||
_ => Message::LayerColorSet(7),
|
||||
},
|
||||
Message::LayerColorPickerToggle(index),
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::Layer(index)),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::Layer(index),
|
||||
acadrust::types::Color::Index(aci),
|
||||
),
|
||||
))
|
||||
.width(Length::Fixed(COL_COLOR))
|
||||
.into();
|
||||
|
||||
@@ -70,11 +70,12 @@ pub fn view_window<'a>(
|
||||
Space::new().height(10),
|
||||
row![
|
||||
text("Default save format:").size(12).width(150),
|
||||
crate::ui::pick_list(
|
||||
crate::io::SAVE_FORMAT_OPTIONS,
|
||||
iced::widget::pick_list(
|
||||
selected_format,
|
||||
|format: &str| Message::DefaultSaveFormatChanged(format.to_string())
|
||||
crate::io::SAVE_FORMAT_OPTIONS,
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(|format: &str| Message::DefaultSaveFormatChanged(format.to_string()))
|
||||
.width(sizing.width),
|
||||
]
|
||||
.spacing(12)
|
||||
@@ -90,11 +91,12 @@ pub fn view_window<'a>(
|
||||
Space::new().height(10),
|
||||
row![
|
||||
text("Iced theme:").size(12).width(150),
|
||||
crate::ui::pick_list(
|
||||
theme_options,
|
||||
iced::widget::pick_list(
|
||||
selected_theme,
|
||||
Message::OptionsThemeChanged,
|
||||
theme_options,
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(Message::OptionsThemeChanged)
|
||||
.width(sizing.width),
|
||||
]
|
||||
.spacing(12)
|
||||
|
||||
+10
-7
@@ -332,7 +332,8 @@ fn drop_row<'a>(
|
||||
ctor: fn(String) -> PlotDlgMsg,
|
||||
width: Length,
|
||||
) -> Element<'a, Message> {
|
||||
let pl = crate::ui::pick_list(options, selected, move |s| Message::PlotDlg(ctor(s)))
|
||||
let pl = iced::widget::pick_list(selected, options, |value| value.to_string())
|
||||
.on_select(move |s| Message::PlotDlg(ctor(s)))
|
||||
.text_size(12)
|
||||
.padding([3, 6])
|
||||
.width(width);
|
||||
@@ -536,11 +537,12 @@ pub fn view_window(
|
||||
section_label("Plot area"),
|
||||
row![
|
||||
container(
|
||||
crate::ui::pick_list(
|
||||
strs(&["Layout", "Extents", "Display", "Window"]),
|
||||
iced::widget::pick_list(
|
||||
Some(s.area.clone()),
|
||||
move |v| Message::PlotDlg(PlotDlgMsg::Area(v)),
|
||||
strs(&["Layout", "Extents", "Display", "Window"]),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |v| Message::PlotDlg(PlotDlgMsg::Area(v)))
|
||||
.text_size(12)
|
||||
.padding([3, 6])
|
||||
.width(width)
|
||||
@@ -608,11 +610,12 @@ pub fn view_window(
|
||||
section_label("Quality"),
|
||||
row![
|
||||
container(
|
||||
crate::ui::pick_list(
|
||||
strs(&["Draft", "Normal", "High", "Maximum"]),
|
||||
iced::widget::pick_list(
|
||||
Some(s.quality.clone()),
|
||||
move |v| Message::PlotDlg(PlotDlgMsg::Quality(v)),
|
||||
strs(&["Draft", "Normal", "High", "Maximum"]),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |v| Message::PlotDlg(PlotDlgMsg::Quality(v)))
|
||||
.text_size(12)
|
||||
.padding([3, 6])
|
||||
.width(width)
|
||||
|
||||
@@ -325,9 +325,8 @@ fn install_controls<'a>(
|
||||
text("no releases").size(11).style(muted_style).into()
|
||||
} else {
|
||||
let r = repo_s.clone();
|
||||
crate::ui::pick_list(tags, selected, move |tag| {
|
||||
Message::PluginReleaseSelect(r.clone(), tag)
|
||||
})
|
||||
iced::widget::pick_list(selected, tags, |value| value.to_string())
|
||||
.on_select(move |tag| Message::PluginReleaseSelect(r.clone(), tag))
|
||||
.text_size(12)
|
||||
.into()
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user