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
+33
-77
@@ -9,7 +9,7 @@ use acadrust::types::Color as AcadColor;
|
||||
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, row, scrollable, text};
|
||||
use iced::widget::{button, column, container, row, text};
|
||||
use iced::{Background, Border, Color, Element, Event, Length, Point, Rectangle, Renderer, Size, Theme, Vector};
|
||||
|
||||
/// Which "logical" entries the colour list offers besides the standard ACI
|
||||
@@ -21,17 +21,47 @@ pub struct ColorExtras {
|
||||
}
|
||||
|
||||
/// Encode a colour as the ACI integer string the style editors store
|
||||
/// (ByBlock=0, ByLayer=256, indexed 1-255; RGB has no ACI slot → ByLayer).
|
||||
/// (ByBlock=0, ByLayer=256, indexed 1-255). True colours are mapped to the
|
||||
/// closest ACI entry because these fields cannot store RGB values.
|
||||
pub fn color_to_aci_string(c: AcadColor) -> String {
|
||||
match c {
|
||||
AcadColor::ByBlock => "0".to_string(),
|
||||
AcadColor::ByLayer => "256".to_string(),
|
||||
AcadColor::None => "257".to_string(),
|
||||
AcadColor::Index(i) => i.to_string(),
|
||||
AcadColor::Rgb { .. } => "256".to_string(),
|
||||
AcadColor::Rgb { r, g, b } => nearest_aci(r, g, b).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert an Iced colour chosen by `iced_aw::ColorPicker` into a DWG true
|
||||
/// colour. ACI-only destinations map it to their closest indexed colour later.
|
||||
pub fn iced_to_acad_color(color: Color) -> AcadColor {
|
||||
let [r, g, b, _] = color.into_rgba8();
|
||||
AcadColor::Rgb { r, g, b }
|
||||
}
|
||||
|
||||
/// Return the closest AutoCAD Color Index for an RGB colour.
|
||||
pub fn nearest_aci(r: u8, g: u8, b: u8) -> u8 {
|
||||
let mut best = 7;
|
||||
let mut best_distance = u32::MAX;
|
||||
|
||||
for index in 1..=255 {
|
||||
let Some((ar, ag, ab)) = acadrust::types::aci_table::aci_to_rgb(index) else {
|
||||
continue;
|
||||
};
|
||||
let dr = i32::from(r) - i32::from(ar);
|
||||
let dg = i32::from(g) - i32::from(ag);
|
||||
let db = i32::from(b) - i32::from(ab);
|
||||
let distance = (dr * dr + dg * dg + db * db) as u32;
|
||||
if distance < best_distance {
|
||||
best = index;
|
||||
best_distance = distance;
|
||||
}
|
||||
}
|
||||
|
||||
best
|
||||
}
|
||||
|
||||
/// Decode an ACI integer string back into an `AcadColor`.
|
||||
pub fn aci_string_to_color(s: &str) -> AcadColor {
|
||||
match s.trim().parse::<i16>().unwrap_or(256) {
|
||||
@@ -197,80 +227,6 @@ pub fn color_list<'a>(
|
||||
list.into()
|
||||
}
|
||||
|
||||
/// Full ACI palette as a standalone window body: ByLayer / ByBlock plus the
|
||||
/// 256-colour grid. `on_pick` is called with the chosen colour.
|
||||
pub fn color_grid_window(on_pick: impl Fn(AcadColor) -> Message) -> Element<'static, Message> {
|
||||
let chip = |color: AcadColor, label: &'static str| -> Element<'static, Message> {
|
||||
let (bg, _) = acad_color_display(color);
|
||||
button(
|
||||
row![swatch(bg), text(label).size(11)]
|
||||
.spacing(5)
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.on_press(on_pick(color))
|
||||
.padding([3, 6])
|
||||
.into()
|
||||
};
|
||||
|
||||
const COLS: u16 = 16;
|
||||
let mut grid = column![].spacing(2);
|
||||
let mut idx: u16 = 1;
|
||||
while idx <= 255 {
|
||||
let mut r = row![].spacing(2);
|
||||
for _ in 0..COLS {
|
||||
if idx > 255 {
|
||||
break;
|
||||
}
|
||||
let ci = idx as u8;
|
||||
let (bg, _) = acad_color_display(AcadColor::Index(ci));
|
||||
r = r.push(
|
||||
button(text("").width(18).height(18))
|
||||
.on_press(on_pick(AcadColor::Index(ci)))
|
||||
.style(move |theme: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(bg)),
|
||||
border: Border {
|
||||
color: if matches!(status, button::Status::Hovered) {
|
||||
theme.palette().primary.base.color
|
||||
} else {
|
||||
theme.palette().background.neutral.color
|
||||
},
|
||||
width: if matches!(status, button::Status::Hovered) {
|
||||
1.5
|
||||
} else {
|
||||
1.0
|
||||
},
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
text_color: theme.palette().background.base.text,
|
||||
..Default::default()
|
||||
})
|
||||
.padding(0),
|
||||
);
|
||||
idx += 1;
|
||||
}
|
||||
grid = grid.push(r);
|
||||
}
|
||||
|
||||
container(
|
||||
column![
|
||||
text("Select Color").size(13),
|
||||
row![chip(AcadColor::ByLayer, "ByLayer"), chip(AcadColor::ByBlock, "ByBlock")].spacing(6),
|
||||
scrollable(grid).height(Length::Fit),
|
||||
]
|
||||
.spacing(8),
|
||||
)
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.palette().background.weak.color
|
||||
)),
|
||||
..Default::default()
|
||||
})
|
||||
.padding(10)
|
||||
.width(Length::Fit)
|
||||
.height(Length::Fit)
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Render `base` inline with `popup` floating just below it — the shared
|
||||
/// dropdown mechanic for the panel's custom dropdowns (colour picker, block
|
||||
/// Name). Unlike iced's menu overlay it always opens downward.
|
||||
|
||||
@@ -2,34 +2,6 @@
|
||||
/// Change this to scale the ribbon, layer manager rows, and property panel rows uniformly.
|
||||
pub const ROW_H: f32 = 26.0;
|
||||
|
||||
/// Iced 0.15 separates pick-list construction from the selection callback.
|
||||
/// Keep the application's established call shape while the rest of the UI
|
||||
/// migrates independently.
|
||||
pub fn pick_list<'a, T, L, V, Message>(
|
||||
options: L,
|
||||
selected: Option<V>,
|
||||
on_select: impl Fn(T) -> Message + 'a,
|
||||
) -> iced::widget::PickList<'a, T, L, V, Message>
|
||||
where
|
||||
T: PartialEq + Clone + ToString + 'a,
|
||||
L: std::borrow::Borrow<[T]> + 'a,
|
||||
V: std::borrow::Borrow<T> + 'a,
|
||||
Message: Clone + 'a,
|
||||
{
|
||||
iced::widget::pick_list(selected, options, |value| value.to_string()).on_select(on_select)
|
||||
}
|
||||
|
||||
/// Place `content` at fixed top-left coordinates inside a fill-sized layer.
|
||||
/// Negative coordinates clamp to the layer edge.
|
||||
pub fn pin_at<'a, Message: 'a>(
|
||||
position: iced::Point,
|
||||
content: impl Into<iced::Element<'a, Message>>,
|
||||
) -> iced::Element<'a, Message> {
|
||||
iced::widget::pin(content)
|
||||
.position(iced::Point::new(position.x.max(0.0), position.y.max(0.0)))
|
||||
.into()
|
||||
}
|
||||
|
||||
pub mod color_select;
|
||||
pub mod command_line;
|
||||
pub mod icons;
|
||||
|
||||
+31
-6
@@ -210,12 +210,6 @@ impl ModalOptions {
|
||||
neutral_close: false,
|
||||
};
|
||||
|
||||
pub const MOVABLE_FIXED: Self = Self {
|
||||
movable: true,
|
||||
resizable: false,
|
||||
neutral_close: false,
|
||||
};
|
||||
|
||||
pub const NOTICE: Self = Self {
|
||||
movable: true,
|
||||
resizable: false,
|
||||
@@ -223,6 +217,37 @@ impl ModalOptions {
|
||||
};
|
||||
}
|
||||
|
||||
/// Dim and block the application beneath an overlay-owned dialog.
|
||||
///
|
||||
/// Some third-party overlays ignore pointer movement outside their interactive
|
||||
/// controls. The shield owns the cursor and pointer presses across the window,
|
||||
/// making such an overlay behave modally.
|
||||
pub fn backdrop<'a>(
|
||||
base: impl Into<Element<'a, Message>>,
|
||||
on_close: Message,
|
||||
) -> Element<'a, Message> {
|
||||
let shield = mouse_area(
|
||||
container(Space::new())
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme
|
||||
.palette()
|
||||
.background
|
||||
.strongest
|
||||
.color
|
||||
.scale_alpha(0.55),
|
||||
)),
|
||||
..Default::default()
|
||||
}),
|
||||
)
|
||||
.on_press(on_close)
|
||||
.interaction(iced::mouse::Interaction::Idle);
|
||||
|
||||
stack![base.into(), opaque(shield)].into()
|
||||
}
|
||||
|
||||
/// Stack `content` over `base` behind a dimmed backdrop, framed with a title bar
|
||||
/// (the ✕ close button at its right end). The backdrop only dims and blocks
|
||||
/// clicks from reaching the view beneath — it does **not** dismiss the dialog;
|
||||
|
||||
@@ -22,7 +22,8 @@ pub fn cycle_popup_overlay(
|
||||
.style(container::bordered_box)
|
||||
.width(Length::Fixed(150.0));
|
||||
|
||||
let positioned = crate::ui::pin_at(anchor, opaque(panel));
|
||||
let positioned = iced::widget::pin(opaque(panel))
|
||||
.position(iced::Point::new(anchor.x.max(0.0), anchor.y.max(0.0)));
|
||||
|
||||
mouse_area(positioned).on_press(Message::CycleCancel).into()
|
||||
}
|
||||
|
||||
@@ -611,7 +611,10 @@ impl PropertiesPanel {
|
||||
// "More Colors…" opens the full palette window targeting the
|
||||
// background colour — this used to just close the picker
|
||||
// (#415).
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::PropertiesBg),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::PropertiesBg,
|
||||
color,
|
||||
),
|
||||
);
|
||||
return prop_row_widget(label, selector);
|
||||
}
|
||||
@@ -655,7 +658,10 @@ impl PropertiesPanel {
|
||||
},
|
||||
Message::PropColorChanged,
|
||||
Message::PropColorPickerToggle,
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::Properties),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::Properties,
|
||||
color,
|
||||
),
|
||||
);
|
||||
prop_row_widget(label, selector)
|
||||
}
|
||||
|
||||
@@ -1108,7 +1108,10 @@ impl Ribbon {
|
||||
by_block: true,
|
||||
},
|
||||
Message::RibbonColorChanged,
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::Ribbon),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::Ribbon,
|
||||
self.active_color,
|
||||
),
|
||||
);
|
||||
|
||||
let panel = container(picker)
|
||||
|
||||
@@ -235,7 +235,8 @@ pub fn view_window<'a>(
|
||||
.unwrap_or_else(|| val.to_string());
|
||||
row![
|
||||
lbl(label),
|
||||
crate::ui::pick_list(labels, Some(cur), move |chosen| {
|
||||
iced::widget::pick_list(Some(cur), labels, |value| value.to_string())
|
||||
.on_select(move |chosen| {
|
||||
let code = opts
|
||||
.iter()
|
||||
.find(|(_, l)| *l == chosen.as_str())
|
||||
@@ -287,7 +288,10 @@ pub fn view_window<'a>(
|
||||
},
|
||||
move |c| Message::DsEdit(f_sel.clone(), crate::ui::color_select::color_to_aci_string(c)),
|
||||
Message::DsColorMore(fld.clone()),
|
||||
Message::OpenColorWindow(ColorPickTarget::DimStyle(fld.clone())),
|
||||
Message::OpenColorWindow(
|
||||
ColorPickTarget::DimStyle(fld.clone()),
|
||||
cur,
|
||||
),
|
||||
);
|
||||
row![lbl(label), container(selector).width(150)]
|
||||
.spacing(8)
|
||||
@@ -304,9 +308,8 @@ pub fn view_window<'a>(
|
||||
-> Element<'a, Message> {
|
||||
row![
|
||||
lbl(label),
|
||||
crate::ui::pick_list(options, Some(selected), move |value| {
|
||||
Message::DsSetHandle { field, value }
|
||||
})
|
||||
iced::widget::pick_list(Some(selected), options, |value| value.to_string())
|
||||
.on_select(move |value| Message::DsSetHandle { field, value })
|
||||
.text_size(11)
|
||||
.width(150),
|
||||
]
|
||||
|
||||
@@ -126,7 +126,10 @@ fn color_row<'a>(
|
||||
value: crate::ui::color_select::color_to_aci_string(c),
|
||||
},
|
||||
Message::MLeaderColorMore(field),
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::MLeader(field)),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::MLeader(field),
|
||||
cur,
|
||||
),
|
||||
);
|
||||
row![text(label).size(11).style(muted_style).width(150), selector]
|
||||
.spacing(8)
|
||||
@@ -142,9 +145,8 @@ fn enum_row<'a>(
|
||||
) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(150),
|
||||
crate::ui::pick_list(options, Some(selected), move |value| {
|
||||
Message::MLeaderStyleSetEnum { field, value }
|
||||
})
|
||||
iced::widget::pick_list(Some(selected), options, |value| value.to_string())
|
||||
.on_select(move |value| Message::MLeaderStyleSetEnum { field, value })
|
||||
.text_size(11)
|
||||
.width(190),
|
||||
]
|
||||
@@ -157,11 +159,12 @@ fn lineweight_row<'a>(selected: acadrust::types::LineWeight) -> Element<'a, Mess
|
||||
let selected = crate::ui::properties::LwItem(selected);
|
||||
row![
|
||||
text("Line weight:").size(11).style(muted_style).width(150),
|
||||
crate::ui::pick_list(
|
||||
crate::ui::properties::lw_options(),
|
||||
iced::widget::pick_list(
|
||||
Some(selected),
|
||||
|item| Message::MLeaderStyleLineWeightChanged(item.0)
|
||||
crate::ui::properties::lw_options(),
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(|item| Message::MLeaderStyleLineWeightChanged(item.0))
|
||||
.text_size(11)
|
||||
.width(190),
|
||||
]
|
||||
@@ -199,9 +202,8 @@ fn handle_row<'a>(
|
||||
) -> Element<'a, Message> {
|
||||
row![
|
||||
text(label).size(11).style(muted_style).width(150),
|
||||
crate::ui::pick_list(options, Some(selected), move |value| {
|
||||
Message::MLeaderStyleSetHandle { field, value }
|
||||
})
|
||||
iced::widget::pick_list(Some(selected), options, |value| value.to_string())
|
||||
.on_select(move |value| Message::MLeaderStyleSetHandle { field, value })
|
||||
.text_size(11)
|
||||
.width(190),
|
||||
]
|
||||
|
||||
+18
-12
@@ -119,7 +119,10 @@ pub fn view_window<'a>(
|
||||
value: crate::ui::color_select::color_to_aci_string(c),
|
||||
},
|
||||
Message::TableColorMore(row, field),
|
||||
Message::OpenColorWindow(crate::app::ColorPickTarget::Table(row, field)),
|
||||
Message::OpenColorWindow(
|
||||
crate::app::ColorPickTarget::Table(row, field),
|
||||
cur,
|
||||
),
|
||||
);
|
||||
row![text(label).size(11).style(muted_style).width(150), selector]
|
||||
.spacing(8)
|
||||
@@ -141,7 +144,8 @@ pub fn view_window<'a>(
|
||||
.push(
|
||||
row![
|
||||
text(" Alignment:").size(11).style(muted_style).width(150),
|
||||
crate::ui::pick_list(
|
||||
iced::widget::pick_list(
|
||||
Some(format!("{:?}", rs.alignment)),
|
||||
[
|
||||
"TopLeft",
|
||||
"TopCenter",
|
||||
@@ -156,9 +160,9 @@ pub fn view_window<'a>(
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
Some(format!("{:?}", rs.alignment)),
|
||||
move |value| Message::TableStyleCellSetAlign { row, value },
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |value| Message::TableStyleCellSetAlign { row, value })
|
||||
.text_size(11)
|
||||
.width(140),
|
||||
]
|
||||
@@ -194,18 +198,19 @@ pub fn view_window<'a>(
|
||||
col = col.push(
|
||||
row![
|
||||
text(format!(" {bname}")).size(11).style(muted_style).width(28),
|
||||
crate::ui::pick_list(
|
||||
iced::widget::pick_list(
|
||||
Some(format!("{:?}", bd.border_type)),
|
||||
["Single", "Double"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
Some(format!("{:?}", bd.border_type)),
|
||||
move |value| Message::TableStyleBorderSetType {
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(move |value| Message::TableStyleBorderSetType {
|
||||
cell: row,
|
||||
border: bu,
|
||||
value
|
||||
},
|
||||
)
|
||||
})
|
||||
.text_size(10)
|
||||
.width(74),
|
||||
text_input("wt", &border_lw[r][b])
|
||||
@@ -274,14 +279,15 @@ pub fn view_window<'a>(
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
text("Flow direction:").size(11).style(muted_style).width(160),
|
||||
crate::ui::pick_list(
|
||||
iced::widget::pick_list(
|
||||
Some(format!("{:?}", s.flow_direction)),
|
||||
["Down", "Up"]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
Some(format!("{:?}", s.flow_direction)),
|
||||
Message::TableStyleSetFlow,
|
||||
|value| value.to_string(),
|
||||
)
|
||||
.on_select(Message::TableStyleSetFlow)
|
||||
.text_size(11)
|
||||
.width(100),
|
||||
]
|
||||
|
||||
@@ -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