Move layouts definitions to backend and fix Firefox overlay scrollbars (#647)

* Fix two-axis scrollbars in scrollable regions on Firefox

* Move Document Mode dropdown to the backend; and related code cleanup

* Port the Layer Tree options bar layout to the backend

* Port the tool shelf to the backend

* Clean up initialization and wasm wrapper

* Fix crash

* Fix missing document bar

* Remove unused functions in api.rs

* Code review

* Tool initalisation

* Remove some frontend functions

* Initalise -> Init so en-US/GB doesn't have to matter :)

* Remove blend_mode and opacity from LayerPanelEntry

Co-authored-by: 0hypercube <0hypercube@gmail.com>
This commit is contained in:
Keavon Chambers
2022-05-17 13:12:52 -07:00
co-authored by 0hypercube
parent 95435d8bf1
commit a8f09da5a2
50 changed files with 1034 additions and 978 deletions
+28 -11
View File
@@ -52,8 +52,18 @@ pub type SubLayout = Vec<LayoutRow>;
#[remain::sorted]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum LayoutRow {
Row { widgets: Vec<WidgetHolder> },
Section { name: String, layout: SubLayout },
Column {
#[serde(rename = "columnWidgets")]
widgets: Vec<WidgetHolder>,
},
Row {
#[serde(rename = "rowWidgets")]
widgets: Vec<WidgetHolder>,
},
Section {
name: String,
layout: SubLayout,
},
}
#[derive(Debug, Default)]
@@ -72,6 +82,10 @@ impl<'a> Iterator for WidgetIter<'a> {
}
match self.stack.pop() {
Some(LayoutRow::Column { widgets }) => {
self.current_slice = Some(widgets);
self.next()
}
Some(LayoutRow::Row { widgets }) => {
self.current_slice = Some(widgets);
self.next()
@@ -103,6 +117,10 @@ impl<'a> Iterator for WidgetIterMut<'a> {
};
match self.stack.pop() {
Some(LayoutRow::Column { widgets }) => {
self.current_slice = Some(widgets);
self.next()
}
Some(LayoutRow::Row { widgets }) => {
self.current_slice = Some(widgets);
self.next()
@@ -170,7 +188,7 @@ pub enum Widget {
#[derive(Clone, Serialize, Deserialize, Derivative)]
#[derivative(Debug, PartialEq, Default)]
pub struct NumberInput {
pub value: f64,
pub value: Option<f64>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<NumberInput>,
@@ -285,6 +303,7 @@ pub struct IconButton {
#[serde(rename = "title")]
pub tooltip: String,
pub size: u32,
pub active: bool,
#[serde(rename = "gapAfter")]
pub gap_after: bool,
#[serde(skip)]
@@ -298,12 +317,12 @@ pub struct IconButton {
pub struct TextButton {
pub label: String,
pub emphasized: bool,
pub disabled: bool,
pub min_width: u32,
pub gap_after: bool,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<TextButton>,
pub disabled: bool,
}
#[derive(Clone, Serialize, Deserialize, Derivative, Default)]
@@ -342,16 +361,14 @@ pub struct PopoverButton {
#[derive(Clone, Serialize, Deserialize, Derivative, Default)]
#[derivative(Debug, PartialEq)]
pub struct DropdownInput {
#[serde(rename = "menuEntries")]
pub menu_entries: Vec<Vec<DropdownEntryData>>,
// This uses `u32` instead of `usize` since it will be serialized as a normal JS number
// TODO(mfish33): Replace with usize when using native UI
pub entries: Vec<Vec<DropdownEntryData>>,
// This uses `u32` instead of `usize` since it will be serialized as a normal JS number (replace with usize when we switch to a native UI)
#[serde(rename = "selectedIndex")]
pub selected_index: u32,
pub selected_index: Option<u32>,
#[serde(rename = "drawIcon")]
pub draw_icon: bool,
// `on_update` exists on the `DropdownEntryData`, not this parent `DropdownInput`
pub disabled: bool,
}
#[derive(Clone, Serialize, Deserialize, Derivative, Default)]