@@ -353,43 +353,7 @@ impl From<Vec<WidgetInstance>> for LayoutGroup {
353353}
354354
355355impl LayoutGroup {
356- /// Applies a tooltip label to all widgets in this row or column without a tooltip.
357- pub fn with_tooltip_label ( self , label : impl Into < String > ) -> Self {
358- let ( is_col, mut widgets) = match self {
359- LayoutGroup :: Column { widgets } => ( true , widgets) ,
360- LayoutGroup :: Row { widgets } => ( false , widgets) ,
361- _ => unimplemented ! ( ) ,
362- } ;
363- let label = label. into ( ) ;
364- for widget in & mut widgets {
365- let val = match & mut widget. widget {
366- Widget :: CheckboxInput ( x) => & mut x. tooltip_label ,
367- Widget :: ColorInput ( x) => & mut x. tooltip_label ,
368- Widget :: CurveInput ( x) => & mut x. tooltip_label ,
369- Widget :: DropdownInput ( x) => & mut x. tooltip_label ,
370- Widget :: FontInput ( x) => & mut x. tooltip_label ,
371- Widget :: IconButton ( x) => & mut x. tooltip_label ,
372- Widget :: IconLabel ( x) => & mut x. tooltip_label ,
373- Widget :: ImageButton ( x) => & mut x. tooltip_label ,
374- Widget :: ImageLabel ( x) => & mut x. tooltip_label ,
375- Widget :: NumberInput ( x) => & mut x. tooltip_label ,
376- Widget :: ParameterExposeButton ( x) => & mut x. tooltip_label ,
377- Widget :: PopoverButton ( x) => & mut x. tooltip_label ,
378- Widget :: TextAreaInput ( x) => & mut x. tooltip_label ,
379- Widget :: TextButton ( x) => & mut x. tooltip_label ,
380- Widget :: TextInput ( x) => & mut x. tooltip_label ,
381- Widget :: TextLabel ( x) => & mut x. tooltip_label ,
382- Widget :: BreadcrumbTrailButtons ( x) => & mut x. tooltip_label ,
383- Widget :: ReferencePointInput ( _) | Widget :: RadioInput ( _) | Widget :: Separator ( _) | Widget :: ShortcutLabel ( _) | Widget :: WorkingColorsInput ( _) | Widget :: NodeCatalog ( _) => continue ,
384- } ;
385- if val. is_empty ( ) {
386- val. clone_from ( & label) ;
387- }
388- }
389- if is_col { Self :: Column { widgets } } else { Self :: Row { widgets } }
390- }
391-
392- /// Applies a tooltip description to all widgets in this row or column without a tooltip.
356+ /// Applies a tooltip description to all widgets without a tooltip in this row or column.
393357 pub fn with_tooltip_description ( self , description : impl Into < String > ) -> Self {
394358 let ( is_col, mut widgets) = match self {
395359 LayoutGroup :: Column { widgets } => ( true , widgets) ,
@@ -403,20 +367,24 @@ impl LayoutGroup {
403367 Widget :: ColorInput ( x) => & mut x. tooltip_description ,
404368 Widget :: CurveInput ( x) => & mut x. tooltip_description ,
405369 Widget :: DropdownInput ( x) => & mut x. tooltip_description ,
406- Widget :: FontInput ( x) => & mut x. tooltip_description ,
407370 Widget :: IconButton ( x) => & mut x. tooltip_description ,
408371 Widget :: IconLabel ( x) => & mut x. tooltip_description ,
409372 Widget :: ImageButton ( x) => & mut x. tooltip_description ,
410373 Widget :: ImageLabel ( x) => & mut x. tooltip_description ,
411374 Widget :: NumberInput ( x) => & mut x. tooltip_description ,
412- Widget :: ParameterExposeButton ( x) => & mut x. tooltip_description ,
413375 Widget :: PopoverButton ( x) => & mut x. tooltip_description ,
414376 Widget :: TextAreaInput ( x) => & mut x. tooltip_description ,
415377 Widget :: TextButton ( x) => & mut x. tooltip_description ,
416378 Widget :: TextInput ( x) => & mut x. tooltip_description ,
417379 Widget :: TextLabel ( x) => & mut x. tooltip_description ,
418380 Widget :: BreadcrumbTrailButtons ( x) => & mut x. tooltip_description ,
419- Widget :: ReferencePointInput ( _) | Widget :: RadioInput ( _) | Widget :: Separator ( _) | Widget :: ShortcutLabel ( _) | Widget :: WorkingColorsInput ( _) | Widget :: NodeCatalog ( _) => continue ,
381+ Widget :: ReferencePointInput ( _)
382+ | Widget :: RadioInput ( _)
383+ | Widget :: Separator ( _)
384+ | Widget :: ShortcutLabel ( _)
385+ | Widget :: WorkingColorsInput ( _)
386+ | Widget :: NodeCatalog ( _)
387+ | Widget :: ParameterExposeButton ( _) => continue ,
420388 } ;
421389 if val. is_empty ( ) {
422390 val. clone_from ( & description) ;
@@ -727,7 +695,6 @@ pub enum Widget {
727695 ColorInput ( ColorInput ) ,
728696 CurveInput ( CurveInput ) ,
729697 DropdownInput ( DropdownInput ) ,
730- FontInput ( FontInput ) ,
731698 IconButton ( IconButton ) ,
732699 IconLabel ( IconLabel ) ,
733700 ImageButton ( ImageButton ) ,
@@ -782,7 +749,6 @@ impl DiffUpdate {
782749 Widget :: CheckboxInput ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
783750 Widget :: ColorInput ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
784751 Widget :: DropdownInput ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
785- Widget :: FontInput ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
786752 Widget :: IconButton ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
787753 Widget :: NumberInput ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
788754 Widget :: ParameterExposeButton ( widget) => widget. tooltip_shortcut . as_mut ( ) ,
@@ -838,10 +804,38 @@ impl DiffUpdate {
838804 ( recursive_wrapper. 0 ) ( entry_sections, & recursive_wrapper)
839805 } ;
840806
807+ // Hash the menu list entry sections for caching purposes
808+ let hash_menu_list_entry_sections = |entry_sections : & MenuListEntrySections | {
809+ struct RecursiveHasher < ' a > {
810+ hasher : DefaultHasher ,
811+ hash_fn : & ' a dyn Fn ( & mut RecursiveHasher , & MenuListEntrySections ) ,
812+ }
813+ let mut recursive_hasher = RecursiveHasher {
814+ hasher : DefaultHasher :: new ( ) ,
815+ hash_fn : & |recursive_hasher, entry_sections| {
816+ for ( index, entries) in entry_sections. iter ( ) . enumerate ( ) {
817+ index. hash ( & mut recursive_hasher. hasher ) ;
818+ for entry in entries {
819+ entry. hash ( & mut recursive_hasher. hasher ) ;
820+ ( recursive_hasher. hash_fn ) ( recursive_hasher, & entry. children ) ;
821+ }
822+ }
823+ } ,
824+ } ;
825+ ( recursive_hasher. hash_fn ) ( & mut recursive_hasher, entry_sections) ;
826+ recursive_hasher. hasher . finish ( )
827+ } ;
828+
841829 // Apply shortcut conversions to all widgets that have menu lists
842830 let convert_menu_lists = |widget_instance : & mut WidgetInstance | match & mut widget_instance. widget {
843- Widget :: DropdownInput ( dropdown_input) => apply_action_shortcut_to_menu_lists ( & mut dropdown_input. entries ) ,
844- Widget :: TextButton ( text_button) => apply_action_shortcut_to_menu_lists ( & mut text_button. menu_list_children ) ,
831+ Widget :: DropdownInput ( dropdown_input) => {
832+ apply_action_shortcut_to_menu_lists ( & mut dropdown_input. entries ) ;
833+ dropdown_input. entries_hash = hash_menu_list_entry_sections ( & dropdown_input. entries ) ;
834+ }
835+ Widget :: TextButton ( text_button) => {
836+ apply_action_shortcut_to_menu_lists ( & mut text_button. menu_list_children ) ;
837+ text_button. menu_list_children_hash = hash_menu_list_entry_sections ( & text_button. menu_list_children ) ;
838+ }
845839 _ => { }
846840 } ;
847841
0 commit comments