UI: move image paint panels into the image side-bar
authorCampbell Barton <ideasman42@gmail.com>
Wed, 1 May 2019 02:35:00 +0000 (12:35 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 1 May 2019 02:35:00 +0000 (12:35 +1000)
- Move painting brush panels into the image side-bar.
- Add active tool panel to the image side-bar.

release/scripts/startup/bl_ui/space_image.py
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/space_image.c
source/blender/editors/uvedit/uvedit_buttons.c

index ef87cae..2786e14 100644 (file)
@@ -41,13 +41,13 @@ from bpy.app.translations import pgettext_iface as iface_
 
 
 class ImagePaintPanel(UnifiedPaintPanel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'UI'
 
 
 class BrushButtonsPanel(UnifiedPaintPanel):
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'UI'
 
     @classmethod
     def poll(cls, context):
@@ -55,6 +55,25 @@ class BrushButtonsPanel(UnifiedPaintPanel):
         return tool_settings.brush
 
 
+class IMAGE_PT_active_tool(Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'UI'
+    bl_label = "Active Tool"
+    bl_category = "Tool"
+
+    def draw(self, context):
+        layout = self.layout
+
+        # Panel display of topbar tool settings.
+        # currently displays in tool settings, keep here since the same functionality is used for the topbar.
+
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        from .space_toolsystem_common import ToolSelectPanelHelper
+        ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True)
+
+
 class IMAGE_MT_view(Menu):
     bl_label = "View"
 
@@ -677,12 +696,6 @@ class IMAGE_HT_header(Header):
             mesh = context.edit_object.data
             layout.prop_search(mesh.uv_layers, "active", mesh, "uv_layers", text="")
 
-        row = layout.row()
-        row.popover(
-            panel="IMAGE_PT_view_display",
-            text="Display"
-        )
-
         if ima:
             if ima.is_stereo_3d:
                 row = layout.row()
@@ -804,8 +817,9 @@ class IMAGE_PT_image_properties(Panel):
 
 class IMAGE_PT_view_display(Panel):
     bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'HEADER'
+    bl_region_type = 'UI'
     bl_label = "Display"
+    bl_category = "View"
 
     @classmethod
     def poll(cls, context):
@@ -834,9 +848,10 @@ class IMAGE_PT_view_display(Panel):
 
 class IMAGE_PT_view_display_uv_edit_overlays(Panel):
     bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'HEADER'
+    bl_region_type = 'UI'
     bl_label = "Overlays"
     bl_parent_id = 'IMAGE_PT_view_display'
+    bl_category = "View"
     bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
@@ -847,15 +862,15 @@ class IMAGE_PT_view_display_uv_edit_overlays(Panel):
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
+        layout.use_property_decorate = False
 
         sima = context.space_data
         uvedit = sima.uv_editor
 
         col = layout.column()
 
-        split = col.split(factor=0.6)
-        split.prop(uvedit, "show_edges", text="Edges")
-        split.prop(uvedit, "edge_display_type", text="")
+        col.prop(uvedit, "show_edges", text="Edges")
+        col.prop(uvedit, "edge_display_type", text="Draw Type")
 
         col.prop(uvedit, "show_faces", text="Faces")
 
@@ -866,9 +881,10 @@ class IMAGE_PT_view_display_uv_edit_overlays(Panel):
 
 class IMAGE_PT_view_display_uv_edit_overlays_advanced(Panel):
     bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'HEADER'
+    bl_region_type = 'UI'
     bl_label = "Advanced"
     bl_parent_id = 'IMAGE_PT_view_display_uv_edit_overlays'
+    bl_category = "View"
     bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
@@ -934,7 +950,7 @@ class IMAGE_PT_render_slots(Panel):
 class IMAGE_PT_paint(Panel, ImagePaintPanel):
     bl_label = "Brush"
     bl_context = ".paint_common_2d"
-    bl_category = "Tools"
+    bl_category = "Tool"
 
     def draw(self, context):
         layout = self.layout
@@ -953,6 +969,7 @@ class IMAGE_PT_paint(Panel, ImagePaintPanel):
 
 
 class IMAGE_PT_paint_color(Panel, ImagePaintPanel):
+    bl_category = "Tool"
     bl_context = ".paint_common_2d"
     bl_parent_id = "IMAGE_PT_paint"
     bl_label = "Color Picker"
@@ -976,6 +993,7 @@ class IMAGE_PT_paint_color(Panel, ImagePaintPanel):
 
 
 class IMAGE_PT_paint_swatches(Panel, ImagePaintPanel):
+    bl_category = "Tool"
     bl_context = ".paint_common_2d"
     bl_parent_id = "IMAGE_PT_paint"
     bl_label = "Color Palette"
@@ -999,6 +1017,7 @@ class IMAGE_PT_paint_swatches(Panel, ImagePaintPanel):
 
 
 class IMAGE_PT_paint_gradient(Panel, ImagePaintPanel):
+    bl_category = "Tool"
     bl_context = ".paint_common_2d"
     bl_parent_id = "IMAGE_PT_paint"
     bl_label = "Gradient"
@@ -1030,6 +1049,7 @@ class IMAGE_PT_paint_gradient(Panel, ImagePaintPanel):
 
 
 class IMAGE_PT_paint_clone(Panel, ImagePaintPanel):
+    bl_category = "Tool"
     bl_context = ".paint_common_2d"
     bl_parent_id = "IMAGE_PT_paint"
     bl_label = "Clone from Image/UV Map"
@@ -1057,6 +1077,7 @@ class IMAGE_PT_paint_clone(Panel, ImagePaintPanel):
 
 
 class IMAGE_PT_paint_options(Panel, ImagePaintPanel):
+    bl_category = "Tool"
     bl_context = ".paint_common_2d"
     bl_parent_id = "IMAGE_PT_paint"
     bl_label = "Options"
@@ -1085,7 +1106,7 @@ class IMAGE_PT_tools_brush_display(BrushButtonsPanel, Panel):
     bl_label = "Display"
     bl_context = ".paint_common_2d"
     bl_options = {'DEFAULT_CLOSED'}
-    bl_category = "Options"
+    bl_category = "Tool"
 
     def draw(self, context):
         layout = self.layout
@@ -1139,6 +1160,7 @@ class IMAGE_PT_tools_brush_display_show_brush(BrushButtonsPanel, Panel):
     bl_context = ".paint_common_2d"  # dot on purpose (access from topbar)
     bl_label = "Show Brush"
     bl_parent_id = "IMAGE_PT_tools_brush_display"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw_header(self, context):
@@ -1172,6 +1194,7 @@ class IMAGE_PT_tools_brush_display_custom_icon(BrushButtonsPanel, Panel):
     bl_context = ".paint_common_2d"  # dot on purpose (access from topbar)
     bl_label = "Custom Icon"
     bl_parent_id = "IMAGE_PT_tools_brush_display"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw_header(self, context):
@@ -1197,8 +1220,8 @@ class IMAGE_PT_tools_brush_display_custom_icon(BrushButtonsPanel, Panel):
 class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
     bl_label = "Texture"
     bl_context = ".paint_common_2d"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
-    bl_category = "Tools"
 
     def draw(self, context):
         layout = self.layout
@@ -1215,8 +1238,8 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
 class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
     bl_label = "Texture Mask"
     bl_context = ".paint_common_2d"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
-    bl_category = "Tools"
 
     def draw(self, context):
         layout = self.layout
@@ -1233,8 +1256,8 @@ class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
 class IMAGE_PT_paint_stroke(BrushButtonsPanel, Panel):
     bl_label = "Stroke"
     bl_context = ".paint_common_2d"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
-    bl_category = "Tools"
 
     def draw(self, context):
         layout = self.layout
@@ -1283,6 +1306,7 @@ class IMAGE_PT_paint_stroke_smooth_stroke(BrushButtonsPanel, Panel):
     bl_context = ".paint_common_2d"  # dot on purpose (access from topbar)
     bl_label = "Smooth Stroke"
     bl_parent_id = "IMAGE_PT_paint_stroke"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
@@ -1315,8 +1339,8 @@ class IMAGE_PT_paint_stroke_smooth_stroke(BrushButtonsPanel, Panel):
 class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
     bl_label = "Falloff"
     bl_context = ".paint_common_2d"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
-    bl_category = "Tools"
 
     def draw(self, context):
         layout = self.layout
@@ -1337,9 +1361,9 @@ class IMAGE_PT_paint_curve(BrushButtonsPanel, Panel):
 
 
 class IMAGE_PT_tools_imagepaint_symmetry(BrushButtonsPanel, Panel):
-    bl_category = "Tools"
     bl_context = ".imagepaint_2d"
     bl_label = "Tiling"
+    bl_category = "Tool"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
@@ -1358,7 +1382,7 @@ class IMAGE_PT_uv_sculpt_curve(Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = ".uv_sculpt"  # dot on purpose (access from topbar)
-    bl_category = "Options"
+    bl_category = "Tool"
     bl_label = "UV Sculpt Curve"
     bl_options = {'DEFAULT_CLOSED'}
 
@@ -1388,7 +1412,7 @@ class IMAGE_PT_uv_sculpt(Panel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
     bl_context = ".uv_sculpt"  # dot on purpose (access from topbar)
-    bl_category = "Options"
+    bl_category = "Tool"
     bl_label = "UV Sculpt"
 
     @classmethod
@@ -1543,7 +1567,7 @@ class IMAGE_PT_scope_sample(ImageScopesPanel, Panel):
 class IMAGE_PT_uv_cursor(Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
-    bl_category = "Image"
+    bl_category = "View"
     bl_label = "2D Cursor"
 
     @classmethod
@@ -1567,7 +1591,7 @@ class IMAGE_PT_uv_cursor(Panel):
 class IMAGE_PT_grease_pencil(AnnotationDataPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
-    bl_category = "Image"
+    bl_category = "View"
 
     # NOTE: this is just a wrapper around the generic GP Panel.
 
@@ -1594,6 +1618,7 @@ classes = (
     IMAGE_HT_tool_header,
     IMAGE_HT_header,
     MASK_MT_editor_menus,
+    IMAGE_PT_active_tool,
     IMAGE_PT_mask,
     IMAGE_PT_mask_layers,
     IMAGE_PT_mask_display,
index 1b1c3bf..f924404 100644 (file)
@@ -203,14 +203,14 @@ static void buttons_main_region_layout_properties(const bContext *C,
 
 static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
 {
-  const WorkSpace *workspace = CTX_wm_workspace(C);
   const enum eContextObjectMode mode = CTX_data_mode_enum(C);
 
   const char *contexts_base[5] = {NULL};
   contexts_base[0] = ".active_tool";
   const char **contexts = &contexts_base[1];
 
-  if (workspace->tools_space_type == SPACE_VIEW3D) {
+  /* Hard coded to 3D view. */
+  {
     switch (mode) {
       case CTX_MODE_EDIT_MESH:
         ARRAY_SET_ITEMS(contexts, ".mesh_edit");
@@ -267,22 +267,6 @@ static void buttons_main_region_layout_tool(const bContext *C, ARegion *ar)
         break;
     }
   }
-  else if (workspace->tools_space_type == SPACE_IMAGE) {
-    switch (workspace->tools_mode) {
-      case SI_MODE_VIEW:
-        break;
-      case SI_MODE_PAINT:
-        ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
-        break;
-      case SI_MODE_MASK:
-        break;
-      case SI_MODE_UV:
-        if (mode == CTX_MODE_EDIT_MESH) {
-          ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
-        }
-        break;
-    }
-  }
 
   /* for grease pencil we don't use tool system yet, so we need check outside
    * workspace->tools_space_type because this value is not available
index f5dd0c4..752eede 100644 (file)
@@ -1371,6 +1371,7 @@ void image_buttons_register(ARegionType *art)
   pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata");
   strcpy(pt->idname, "IMAGE_PT_metadata");
   strcpy(pt->label, N_("Metadata"));
+  strcpy(pt->category, "Image");
   strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
   pt->poll = metadata_panel_context_poll;
   pt->draw = metadata_panel_context_draw;
index ae26201..248497a 100644 (file)
@@ -743,6 +743,33 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar)
   WM_event_add_keymap_handler(&ar->handlers, keymap);
 }
 
+static void image_buttons_region_layout(const bContext *C, ARegion *ar)
+{
+  const enum eContextObjectMode mode = CTX_data_mode_enum(C);
+  const char *contexts_base[3] = {NULL};
+
+  const char **contexts = contexts_base;
+
+  SpaceImage *sima = CTX_wm_space_image(C);
+  switch (sima->mode) {
+    case SI_MODE_VIEW:
+      break;
+    case SI_MODE_PAINT:
+      ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
+      break;
+    case SI_MODE_MASK:
+      break;
+    case SI_MODE_UV:
+      if (mode == CTX_MODE_EDIT_MESH) {
+        ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
+      }
+      break;
+  }
+
+  const bool vertical = true;
+  ED_region_panels_layout_ex(C, ar, contexts_base, -1, vertical);
+}
+
 static void image_buttons_region_draw(const bContext *C, ARegion *ar)
 {
   SpaceImage *sima = CTX_wm_space_image(C);
@@ -769,7 +796,8 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar)
   }
   ED_space_image_release_buffer(sima, ibuf, lock);
 
-  ED_region_panels(C, ar);
+  /* Layout handles details. */
+  ED_region_panels_draw(C, ar);
 }
 
 static void image_buttons_region_listener(wmWindow *UNUSED(win),
@@ -1014,6 +1042,7 @@ void ED_spacetype_image(void)
   art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
   art->listener = image_buttons_region_listener;
   art->init = image_buttons_region_init;
+  art->layout = image_buttons_region_layout;
   art->draw = image_buttons_region_draw;
   BLI_addhead(&st->regiontypes, art);
 
index 3983cce..1482fea 100644 (file)
@@ -258,6 +258,8 @@ void ED_uvedit_buttons_register(ARegionType *art)
   pt = MEM_callocN(sizeof(PanelType), "spacetype image panel uv");
   strcpy(pt->idname, "IMAGE_PT_uv");
   strcpy(pt->label, N_("UV Vertex")); /* XXX C panels unavailable through RNA bpy.types! */
+  /* Could be 'Item' matching 3D view, avoid new tab for two buttons. */
+  strcpy(pt->category, "Image");
   pt->draw = image_panel_uv;
   pt->poll = image_panel_uv_poll;
   BLI_addtail(&art->paneltypes, pt);