@@ -231,31 +231,42 @@ impl ToolData {
231231 }
232232}
233233
234- impl LayoutHolder for ToolData {
235- fn layout ( & self ) -> Layout {
234+ impl ToolData {
235+ pub fn send_layout ( & self , responses : & mut VecDeque < Message > , layout_target : LayoutTarget , brush_tool : bool ) {
236+ responses. add ( LayoutMessage :: SendLayout {
237+ layout : self . layout ( brush_tool) ,
238+ layout_target,
239+ } ) ;
240+ }
241+
242+ fn layout ( & self , brush_tool : bool ) -> Layout {
236243 let active_tool = self . active_shape_type . unwrap_or ( self . active_tool_type ) ;
237244
238245 let tool_groups_layout = list_tools_in_groups ( )
239246 . iter ( )
240247 . map ( |tool_group|
241248 tool_group
242249 . iter ( )
243- . map ( |tool_availability| {
244- match tool_availability {
245- ToolAvailability :: Available ( tool) =>
250+ . filter_map ( |tool_availability| {
251+ if !brush_tool && let ToolRole :: Normal ( tool) = tool_availability && tool. tool_type ( ) == ToolType :: Brush {
252+ return None ;
253+ }
254+
255+ Some ( match tool_availability {
256+ ToolRole :: Normal ( tool) =>
246257 ToolEntry :: new ( tool. tool_type ( ) , tool. icon_name ( ) )
247258 . tooltip_label ( tool. tooltip_label ( ) )
248259 . tooltip_shortcut ( action_shortcut ! ( tool_type_to_activate_tool_message( tool. tool_type( ) ) ) ) ,
249- ToolAvailability :: AvailableAsShape ( shape) =>
260+ ToolRole :: Shape ( shape) =>
250261 ToolEntry :: new ( shape. tool_type ( ) , shape. icon_name ( ) )
251262 . tooltip_label ( shape. tooltip_label ( ) )
252263 . tooltip_description ( shape. tooltip_description ( ) )
253264 . tooltip_shortcut ( action_shortcut ! ( tool_type_to_activate_tool_message( shape. tool_type( ) ) ) ) ,
254- // ToolAvailability::ComingSoon(tool) => tool.clone(),
255- }
265+ } )
256266 } )
257267 . collect :: < Vec < _ > > ( )
258268 )
269+ . filter ( |group| !group. is_empty ( ) )
259270 . flat_map ( |group| {
260271 let separator = std:: iter:: once ( Separator :: new ( SeparatorType :: Section ) . direction ( SeparatorDirection :: Vertical ) . widget_instance ( ) ) ;
261272 let buttons = group. into_iter ( ) . map ( |ToolEntry { tooltip_label, tooltip_description, tooltip_shortcut, tool_type, icon_name } | {
@@ -319,9 +330,8 @@ impl Default for ToolFsmState {
319330 . into_iter ( )
320331 . flatten ( )
321332 . filter_map ( |tool| match tool {
322- ToolAvailability :: Available ( tool) => Some ( ( tool. tool_type ( ) , tool) ) ,
323- ToolAvailability :: AvailableAsShape ( _) => None ,
324- // ToolAvailability::ComingSoon(_) => None,
333+ ToolRole :: Normal ( tool) => Some ( ( tool. tool_type ( ) , tool) ) ,
334+ ToolRole :: Shape ( _) => None ,
325335 } )
326336 . collect ( ) ,
327337 } ,
@@ -369,7 +379,6 @@ pub enum ToolType {
369379 Patch ,
370380 Detail ,
371381 Relight ,
372- Frame ,
373382}
374383
375384impl ToolType {
@@ -385,58 +394,57 @@ impl ToolType {
385394 }
386395}
387396
388- enum ToolAvailability {
389- Available ( Box < Tool > ) ,
390- AvailableAsShape ( ShapeType ) ,
391- // ComingSoon(ToolEntry),
397+ enum ToolRole {
398+ Normal ( Box < Tool > ) ,
399+ Shape ( ShapeType ) ,
392400}
393401
394402/// List of all the tools in their conventional ordering and grouping.
395- fn list_tools_in_groups ( ) -> Vec < Vec < ToolAvailability > > {
403+ fn list_tools_in_groups ( ) -> Vec < Vec < ToolRole > > {
396404 vec ! [
397405 vec![
398406 // General tool group
399- ToolAvailability :: Available ( Box :: <select_tool:: SelectTool >:: default ( ) ) ,
400- ToolAvailability :: Available ( Box :: <artboard_tool:: ArtboardTool >:: default ( ) ) ,
401- ToolAvailability :: Available ( Box :: <navigate_tool:: NavigateTool >:: default ( ) ) ,
402- ToolAvailability :: Available ( Box :: <eyedropper_tool:: EyedropperTool >:: default ( ) ) ,
403- ToolAvailability :: Available ( Box :: <fill_tool:: FillTool >:: default ( ) ) ,
404- ToolAvailability :: Available ( Box :: <gradient_tool:: GradientTool >:: default ( ) ) ,
407+ ToolRole :: Normal ( Box :: <select_tool:: SelectTool >:: default ( ) ) ,
408+ ToolRole :: Normal ( Box :: <artboard_tool:: ArtboardTool >:: default ( ) ) ,
409+ ToolRole :: Normal ( Box :: <navigate_tool:: NavigateTool >:: default ( ) ) ,
410+ ToolRole :: Normal ( Box :: <eyedropper_tool:: EyedropperTool >:: default ( ) ) ,
411+ ToolRole :: Normal ( Box :: <fill_tool:: FillTool >:: default ( ) ) ,
412+ ToolRole :: Normal ( Box :: <gradient_tool:: GradientTool >:: default ( ) ) ,
405413 ] ,
406414 vec![
407415 // Vector tool group
408- ToolAvailability :: Available ( Box :: <path_tool:: PathTool >:: default ( ) ) ,
409- ToolAvailability :: Available ( Box :: <pen_tool:: PenTool >:: default ( ) ) ,
410- ToolAvailability :: Available ( Box :: <freehand_tool:: FreehandTool >:: default ( ) ) ,
411- ToolAvailability :: Available ( Box :: <spline_tool:: SplineTool >:: default ( ) ) ,
412- ToolAvailability :: AvailableAsShape ( ShapeType :: Line ) ,
413- ToolAvailability :: AvailableAsShape ( ShapeType :: Rectangle ) ,
414- ToolAvailability :: AvailableAsShape ( ShapeType :: Ellipse ) ,
415- ToolAvailability :: Available ( Box :: <shape_tool:: ShapeTool >:: default ( ) ) ,
416- ToolAvailability :: Available ( Box :: <text_tool:: TextTool >:: default ( ) ) ,
416+ ToolRole :: Normal ( Box :: <path_tool:: PathTool >:: default ( ) ) ,
417+ ToolRole :: Normal ( Box :: <pen_tool:: PenTool >:: default ( ) ) ,
418+ ToolRole :: Normal ( Box :: <freehand_tool:: FreehandTool >:: default ( ) ) ,
419+ ToolRole :: Normal ( Box :: <spline_tool:: SplineTool >:: default ( ) ) ,
420+ ToolRole :: Shape ( ShapeType :: Line ) ,
421+ ToolRole :: Shape ( ShapeType :: Rectangle ) ,
422+ ToolRole :: Shape ( ShapeType :: Ellipse ) ,
423+ ToolRole :: Normal ( Box :: <shape_tool:: ShapeTool >:: default ( ) ) ,
424+ ToolRole :: Normal ( Box :: <text_tool:: TextTool >:: default ( ) ) ,
417425 ] ,
418426 vec![
419427 // Raster tool group
420- ToolAvailability :: Available ( Box :: <brush_tool:: BrushTool >:: default ( ) ) ,
421- // ToolAvailability::ComingSoon (
428+ ToolRole :: Normal ( Box :: <brush_tool:: BrushTool >:: default ( ) ) ,
429+ // ToolRole::Normal (
422430 // ToolEntry::new(ToolType::Heal, "RasterHealTool")
423431 // .tooltip_label("Heal Tool")
424432 // .tooltip_shortcut(action_shortcut_manual!(Key::KeyJ)),
425433 // ),
426- // ToolAvailability::ComingSoon (
434+ // ToolRole::Normal (
427435 // ToolEntry::new(ToolType::Clone, "RasterCloneTool")
428436 // .tooltip_label("Clone Tool")
429437 // .tooltip_shortcut(action_shortcut_manual!(Key::KeyC)),
430438 // ),
431- // ToolAvailability::ComingSoon (ToolEntry::new(ToolType::Patch, "RasterPatchTool")
439+ // ToolRole::Normal (ToolEntry::new(ToolType::Patch, "RasterPatchTool")
432440 // .tooltip_label("Patch Tool"),
433441 // ),
434- // ToolAvailability::ComingSoon (
442+ // ToolRole::Normal (
435443 // ToolEntry::new(ToolType::Detail, "RasterDetailTool")
436444 // .tooltip_label("Detail Tool")
437445 // .tooltip_shortcut(action_shortcut_manual!(Key::KeyD)),
438446 // ),
439- // ToolAvailability::ComingSoon (
447+ // ToolRole::Normal (
440448 // ToolEntry::new(ToolType::Relight, "RasterRelightTool")
441449 // .tooltip_label("Relight Tool")
442450 // .tooltip_shortcut(action_shortcut_manual!(Key::KeyO)),
0 commit comments