mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-28 16:58:12 +08:00
Improve web frontend performance during zooming and panning (#3337)
* WIP debounce frontend ui updates * Reduce the number of frontend updates performed * Improve menu bar diffing * Cleanup in dispatcher * Fix comment
This commit is contained in:
@@ -484,13 +484,19 @@ impl LayoutGroup {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct WidgetHolder {
|
||||
#[serde(rename = "widgetId")]
|
||||
pub widget_id: WidgetId,
|
||||
pub widget: Widget,
|
||||
}
|
||||
|
||||
impl PartialEq for WidgetHolder {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.widget == other.widget
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetHolder {
|
||||
#[deprecated(since = "0.0.0", note = "Please use the builder pattern, e.g. TextLabel::new(\"hello\").widget_holder()")]
|
||||
pub fn new(widget: Widget) -> Self {
|
||||
@@ -502,6 +508,26 @@ impl WidgetHolder {
|
||||
|
||||
/// Diffing updates self (where self is old) based on new, updating the list of modifications as it does so.
|
||||
pub fn diff(&mut self, new: Self, widget_path: &mut [usize], widget_diffs: &mut Vec<WidgetDiff>) {
|
||||
if let (Widget::PopoverButton(button1), Widget::PopoverButton(button2)) = (&mut self.widget, &new.widget) {
|
||||
if button1.disabled == button2.disabled
|
||||
&& button1.style == button2.style
|
||||
&& button1.menu_direction == button2.menu_direction
|
||||
&& button1.icon == button2.icon
|
||||
&& button1.tooltip == button2.tooltip
|
||||
&& button1.tooltip_shortcut == button2.tooltip_shortcut
|
||||
&& button1.popover_min_width == button2.popover_min_width
|
||||
{
|
||||
let mut new_widget_path = widget_path.to_vec();
|
||||
for (i, (a, b)) in button1.popover_layout.iter_mut().zip(button2.popover_layout.iter()).enumerate() {
|
||||
new_widget_path.push(i);
|
||||
a.diff(b.clone(), &mut new_widget_path, widget_diffs);
|
||||
new_widget_path.pop();
|
||||
}
|
||||
self.widget = new.widget;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If there have been changes to the actual widget (not just the id)
|
||||
if self.widget != new.widget {
|
||||
// We should update to the new widget value as well as a new widget id
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct CheckboxInput {
|
||||
pub tooltip: String,
|
||||
|
||||
#[serde(rename = "forLabel")]
|
||||
#[derivative(Debug = "ignore", PartialEq = "ignore")]
|
||||
pub for_label: CheckboxId,
|
||||
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -36,7 +36,8 @@ pub enum SeparatorType {
|
||||
Section,
|
||||
}
|
||||
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, PartialEq, Eq, Default, WidgetBuilder, specta::Type)]
|
||||
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Eq, Default, WidgetBuilder, specta::Type)]
|
||||
#[derivative(PartialEq)]
|
||||
pub struct TextLabel {
|
||||
pub disabled: bool,
|
||||
|
||||
@@ -62,6 +63,7 @@ pub struct TextLabel {
|
||||
pub tooltip: String,
|
||||
|
||||
#[serde(rename = "forCheckbox")]
|
||||
#[derivative(PartialEq = "ignore")]
|
||||
pub for_checkbox: CheckboxId,
|
||||
|
||||
// Body
|
||||
|
||||
Reference in New Issue
Block a user