Implement the Properties panel with a transform section for layers (#527)

* initial layout system with tool options

* cargo fmt

* cargo fmt again

* document bar defined on the backend

* cargo fmt

* removed RC<RefCell>

* cargo fmt

* - fix increment behavior
- removed hashmap from layout message handler
- removed no op message from layoutMessage

* cargo fmt

* only send documentBar when zoom or rotation is updated

* ctrl-0 changes zoom properly

* unfinished layer hook in

* fix layerData name

* layer panel options bar

* basic x/y movment

* working transform section

* changed messages from tuples to structs

* hook up text input

* - fixed number input to be more clear
- fixed actions for properties message handler

* Add styling

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mfish33
2022-02-12 08:22:57 -08:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 45d41b1bd7
commit 5a3500d256
19 changed files with 659 additions and 45 deletions
+29 -9
View File
@@ -54,15 +54,6 @@ pub enum LayoutRow {
Section { name: String, layout: SubLayout },
}
impl LayoutRow {
pub fn widgets(&self) -> Vec<WidgetHolder> {
match &self {
Self::Row { name: _, widgets } => widgets.to_vec(),
Self::Section { name: _, layout } => layout.iter().flat_map(|row| row.widgets()).collect(),
}
}
}
#[derive(Debug, Default)]
pub struct WidgetIter<'a> {
pub stack: Vec<&'a LayoutRow>,
@@ -158,11 +149,14 @@ impl<T> Default for WidgetCallback<T> {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Widget {
IconButton(IconButton),
IconLabel(IconLabel),
NumberInput(NumberInput),
OptionalInput(OptionalInput),
PopoverButton(PopoverButton),
RadioInput(RadioInput),
Separator(Separator),
TextInput(TextInput),
TextLabel(TextLabel),
}
#[derive(Clone, Serialize, Deserialize, Derivative)]
@@ -189,6 +183,18 @@ pub struct NumberInput {
pub increment_callback_decrease: WidgetCallback<NumberInput>,
pub label: String,
pub unit: String,
#[serde(rename = "displayDecimalPlaces")]
#[derivative(Default(value = "3"))]
pub display_decimal_places: u32,
}
#[derive(Clone, Serialize, Deserialize, Derivative)]
#[derivative(Debug, PartialEq, Default)]
pub struct TextInput {
pub value: String,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<TextInput>,
}
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
@@ -281,3 +287,17 @@ pub struct RadioEntryData {
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<()>,
}
#[derive(Clone, Serialize, Deserialize, Derivative, Debug, PartialEq)]
pub struct IconLabel {
pub icon: String,
#[serde(rename = "gapAfter")]
pub gap_after: bool,
}
#[derive(Clone, Serialize, Deserialize, Derivative, Debug, PartialEq, Default)]
pub struct TextLabel {
pub value: String,
pub bold: bool,
pub italic: bool,
}