mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
draw: one FieldArrangement, Select value bound, named colours per run
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
//! what the fields mean at export is the app's.
|
||||
|
||||
use super::SliceWords;
|
||||
use craft_behavior::Value;
|
||||
use craft_color_ui::ui::{ChosenColor, ColorChoice, NamedColor};
|
||||
use craft_theme::Srgba;
|
||||
use craft_ui::choice::{Checkbox, Radio, RadioGroup};
|
||||
@@ -170,7 +171,7 @@ fn text_row(ui: &mut Ui, label: &Label, value: &mut String) {
|
||||
}
|
||||
|
||||
/// A labelled `Select` over `entries`.
|
||||
fn select_row<T: Copy + Eq + std::hash::Hash + std::fmt::Debug + 'static>(ui: &mut Ui, label: &Label, value: &mut T, entries: &[Entry<T>]) {
|
||||
fn select_row<T: Copy + Value>(ui: &mut Ui, label: &Label, value: &mut T, entries: &[Entry<T>]) {
|
||||
Field::new(label.clone()).show(ui, |ui, _| {
|
||||
if let Some(picked) = Select::new(label.clone(), Bind::given(*value), entries).show(ui).value().copied() {
|
||||
*value = picked;
|
||||
@@ -371,14 +372,14 @@ impl StackDialog for SliceOptionsDialog {
|
||||
SliceBackground::Color(color) if chosen == ChosenColor::Custom => Some(color),
|
||||
_ => None,
|
||||
};
|
||||
let named = SliceBackground::NAMED.iter().zip(background_labels).map(|((id, background), label)| {
|
||||
let swatch = match background {
|
||||
SliceBackground::Color(color) => Some(*color),
|
||||
_ => None,
|
||||
};
|
||||
NamedColor::new(*id, label.clone(), swatch)
|
||||
});
|
||||
Field::new(words.background.clone()).show(ui, |ui, _| {
|
||||
let named = SliceBackground::NAMED.iter().zip(background_labels).map(|((id, background), label)| {
|
||||
let swatch = match background {
|
||||
SliceBackground::Color(color) => Some(*color),
|
||||
_ => None,
|
||||
};
|
||||
NamedColor::new(*id, label.clone(), swatch)
|
||||
});
|
||||
let picked = ColorChoice::new(words.background.clone(), &chosen).named(named).custom(custom).show(ui);
|
||||
if let Some(ChosenColor::Named(id)) = &picked.chosen
|
||||
&& let Some(background) = SliceBackground::named(id)
|
||||
|
||||
@@ -246,19 +246,6 @@ pub struct TransformFields<'a> {
|
||||
enabled: bool,
|
||||
relative: Option<Bind<'a, bool>>,
|
||||
document: Option<craft_behavior::kurbo::Size>,
|
||||
#[allow(dead_code)] // P3(object-panels-w1): op.F12
|
||||
arrangement: FieldArrangement,
|
||||
}
|
||||
|
||||
/// Which fields the strip lists first.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum FieldArrangement {
|
||||
/// Width and height before X and Y.
|
||||
#[default]
|
||||
SizeFirst,
|
||||
/// X and Y before width and height.
|
||||
PositionFirst,
|
||||
}
|
||||
|
||||
impl<'a> TransformFields<'a> {
|
||||
@@ -281,17 +268,9 @@ impl<'a> TransformFields<'a> {
|
||||
enabled: true,
|
||||
relative: None,
|
||||
document: None,
|
||||
arrangement: FieldArrangement::default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Which fields come first: the size (default) or the position.
|
||||
#[must_use]
|
||||
pub fn arrangement(mut self, arrangement: FieldArrangement) -> Self {
|
||||
self.arrangement = arrangement;
|
||||
self
|
||||
}
|
||||
|
||||
/// The rulers X and Y read from: absolute X and Y are measured from the rulers' zero in their units (pixels from the
|
||||
/// origin by default); relative X and Y ignore the zero.
|
||||
#[must_use]
|
||||
|
||||
Reference in New Issue
Block a user