UI: Replace +/- menus with collapsible ones
authorCampbell Barton <ideasman42@gmail.com>
Mon, 27 Jan 2014 07:38:53 +0000 (18:38 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 27 Jan 2014 07:42:11 +0000 (18:42 +1100)
Patch D160, by Scott Petrovic with  own modifications.

29 files changed:
release/datafiles/blender_icons.svg
release/datafiles/blender_icons16/icon16_collapsemenu.dat [new file with mode: 0644]
release/datafiles/blender_icons32/icon32_collapsemenu.dat [new file with mode: 0644]
release/scripts/modules/bpy_types.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_console.py
release/scripts/startup/bl_ui/space_dopesheet.py
release/scripts/startup/bl_ui/space_filebrowser.py
release/scripts/startup/bl_ui/space_graph.py
release/scripts/startup/bl_ui/space_image.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_logic.py
release/scripts/startup/bl_ui/space_nla.py
release/scripts/startup/bl_ui/space_node.py
release/scripts/startup/bl_ui/space_outliner.py
release/scripts/startup/bl_ui/space_properties.py
release/scripts/startup/bl_ui/space_sequencer.py
release/scripts/startup/bl_ui/space_text.py
release/scripts/startup/bl_ui/space_time.py
release/scripts/startup/bl_ui/space_userpref.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/include/ED_screen.h
source/blender/editors/include/UI_icons.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/makesrna/intern/rna_ui_api.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 3f2aa4a856f96a25bc7c2d5eefa297b841ca109f..8d6b9eef29de62f51e7ae5087c95b2d23b439f89 100644 (file)
        id="path18197"
        style="opacity:0.7;fill:url(#linearGradient18212);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.98985863;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
        sodipodi:type="arc" />
+    <g
+       style="display:inline;enable-background:new"
+       id="g24559-2-1"
+       transform="translate(279.8665,506.92392)">
+      <rect
+         y="111"
+         x="103"
+         height="16"
+         width="16"
+         id="rect24489-7-4"
+         style="opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+      <rect
+         style="fill:#ececec;fill-opacity:1;stroke:#141414;stroke-width:0.79452544;stroke-opacity:1"
+         id="rect29842"
+         width="11.816368"
+         height="2.1883197"
+         x="105.18671"
+         y="-116.88043"
+         transform="scale(1,-1)" />
+      <rect
+         style="fill:#ececec;fill-opacity:1;stroke:#141414;stroke-width:0.79452544;stroke-opacity:1;display:inline;enable-background:new"
+         id="rect29842-4"
+         width="11.816368"
+         height="2.1883197"
+         x="105.31538"
+         y="-120.80865"
+         transform="scale(1,-1)" />
+      <rect
+         style="fill:#ececec;fill-opacity:1;stroke:#141414;stroke-width:0.79452544;stroke-opacity:1;display:inline;enable-background:new"
+         id="rect29842-4-5"
+         width="11.816368"
+         height="2.1883197"
+         x="105.41832"
+         y="-124.71391"
+         transform="scale(1,-1)" />
+    </g>
     <g
        inkscape:export-ydpi="90"
        inkscape:export-xdpi="90"
diff --git a/release/datafiles/blender_icons16/icon16_collapsemenu.dat b/release/datafiles/blender_icons16/icon16_collapsemenu.dat
new file mode 100644 (file)
index 0000000..fd16fad
Binary files /dev/null and b/release/datafiles/blender_icons16/icon16_collapsemenu.dat differ
diff --git a/release/datafiles/blender_icons32/icon32_collapsemenu.dat b/release/datafiles/blender_icons32/icon32_collapsemenu.dat
new file mode 100644 (file)
index 0000000..d84dd84
Binary files /dev/null and b/release/datafiles/blender_icons32/icon32_collapsemenu.dat differ
index f7af297a0e0a0021f2be0e648d6052c7ae17202e..0b9893cea514e00098ca43c39660c42318270cbb 100644 (file)
@@ -753,6 +753,17 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
                        self.preset_operator,
                        filter_ext=lambda ext: ext.lower() in {".py", ".xml"})
 
+    @classmethod
+    def draw_collapsible(cls, context, layout):
+        # helper function for (optionally) collapsed header menus
+        # only usable within headers
+        if context.area.show_menus:
+            cls.draw_menus(layout, context)
+        else:
+            layout.separator()
+            layout.menu(cls.__name__, icon='COLLAPSEMENU')
+            layout.separator()
+
 
 class Region(StructRNA):
     __slots__ = ()
index 3a203c77463f3ae400351ef845668dae3b31f552..28d1d52924e9182a2920923524cc722aa09af26a 100644 (file)
@@ -51,18 +51,7 @@ class CLIP_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            sub = row.row(align=True)
-            sub.menu("CLIP_MT_view")
-
-            if sc.view == 'CLIP':
-                if clip:
-                    sub.menu("CLIP_MT_select")
-                    sub.menu("CLIP_MT_clip")
-                    sub.menu("CLIP_MT_track")
-                    sub.menu("CLIP_MT_reconstruction")
-                else:
-                    sub.menu("CLIP_MT_clip")
+        CLIP_MT_tracking_editor_menus.draw_collapsible(context, layout)
 
         row = layout.row()
         row.template_ID(sc, "clip", open="clip.open")
@@ -128,16 +117,7 @@ class CLIP_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            sub = row.row(align=True)
-            sub.menu("CLIP_MT_view")
-
-            if clip:
-                sub.menu("MASK_MT_select")
-                sub.menu("CLIP_MT_clip")  # XXX - remove?
-                sub.menu("MASK_MT_mask")
-            else:
-                sub.menu("CLIP_MT_clip")  # XXX - remove?
+        CLIP_MT_masking_editor_menus.draw_collapsible(context, layout)
 
         row = layout.row()
         row.template_ID(sc, "clip", open="clip.open")
@@ -169,6 +149,52 @@ class CLIP_HT_header(Header):
         layout.template_running_jobs()
 
 
+class CLIP_MT_tracking_editor_menus(Menu):
+    bl_idname = "CLIP_MT_tracking_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        sc = context.space_data
+        clip = sc.clip
+
+        layout.menu("CLIP_MT_view")
+
+        if sc.view == 'CLIP':
+            if clip:
+                layout.menu("CLIP_MT_select")
+                layout.menu("CLIP_MT_clip")
+                layout.menu("CLIP_MT_track")
+                layout.menu("CLIP_MT_reconstruction")
+            else:
+                layout.menu("CLIP_MT_clip")
+
+
+class CLIP_MT_masking_editor_menus(Menu):
+
+    bl_idname = "CLIP_MT_masking_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout = self.layout
+
+        layout.menu("CLIP_MT_view")
+
+        if clip:
+            layout.menu("MASK_MT_select")
+            layout.menu("CLIP_MT_clip")  # XXX - remove?
+            layout.menu("MASK_MT_mask")
+        else:
+            layout.menu("CLIP_MT_clip")  # XXX - remove?
+
+
 class CLIP_PT_clip_view_panel:
 
     @classmethod
index e097dfe802df851f338757ba612b594167c56936..ec16cfd89be90e0256ebc415605fce53ff20dd8b 100644 (file)
@@ -29,12 +29,23 @@ class CONSOLE_HT_header(Header):
 
         layout.template_header()
 
-        if context.area.show_menus:
-            layout.menu("CONSOLE_MT_console")
+        CONSOLE_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.operator("console.autocomplete", text="Autocomplete")
 
 
+class CONSOLE_MT_editor_menus(Menu):
+    bl_idname = "CONSOLE_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout.menu("CONSOLE_MT_console")
+
+
 class CONSOLE_MT_console(Menu):
     bl_label = "Console"
 
index 9d317033bb93a4fd813cf6e0eac04dacb57c48a8..269c960ee7e886f004cc1f71a63f96f50b75ce02 100644 (file)
@@ -107,20 +107,7 @@ class DOPESHEET_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("DOPESHEET_MT_view")
-            row.menu("DOPESHEET_MT_select")
-            row.menu("DOPESHEET_MT_marker")
-
-            if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action is not None):
-                row.menu("DOPESHEET_MT_channel")
-            elif st.mode == 'GPENCIL':
-                row.menu("DOPESHEET_MT_gpencil_channel")
-
-            if st.mode != 'GPENCIL':
-                row.menu("DOPESHEET_MT_key")
-            else:
-                row.menu("DOPESHEET_MT_gpencil_frame")
+        DOPESHEET_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.prop(st, "mode", text="")
         layout.prop(st.dopesheet, "show_summary", text="Summary")
@@ -144,6 +131,32 @@ class DOPESHEET_HT_header(Header):
         row.operator("action.paste", text="", icon='PASTEDOWN')
 
 
+class DOPESHEET_MT_editor_menus(Menu):
+    bl_idname = "DOPESHEET_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        st = context.space_data
+
+        layout.menu("DOPESHEET_MT_view")
+        layout.menu("DOPESHEET_MT_select")
+        layout.menu("DOPESHEET_MT_marker")
+
+        if st.mode == 'DOPESHEET' or (st.mode == 'ACTION' and st.action is not None):
+            layout.menu("DOPESHEET_MT_channel")
+        elif st.mode == 'GPENCIL':
+            layout.menu("DOPESHEET_MT_gpencil_channel")
+
+        if st.mode != 'GPENCIL':
+            layout.menu("DOPESHEET_MT_key")
+        else:
+            layout.menu("DOPESHEET_MT_gpencil_frame")
+
+
 class DOPESHEET_MT_view(Menu):
     bl_label = "View"
 
index 201ac0a72d063520796820b6e96bf4cc1753726b..b90eb7a89c3c468f027cbd76908d89f2bfa19c06 100644 (file)
@@ -29,7 +29,7 @@ class FILEBROWSER_HT_header(Header):
 
         st = context.space_data
 
-        layout.template_header(menus=False)
+        layout.template_header()
 
         row = layout.row()
         row.separator()
index 61e2f10a0570f05b301f4125f21516cc3608817b..775f398bc789dd11606a6fa01e20c5049d3c3eeb 100644 (file)
@@ -35,12 +35,7 @@ class GRAPH_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("GRAPH_MT_view")
-            row.menu("GRAPH_MT_select")
-            row.menu("GRAPH_MT_marker")
-            row.menu("GRAPH_MT_channel")
-            row.menu("GRAPH_MT_key")
+        GRAPH_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.prop(st, "mode", text="")
 
@@ -65,6 +60,22 @@ class GRAPH_HT_header(Header):
             row.operator("graph.ghost_curves_create", text="", icon='GHOST_ENABLED')
 
 
+class GRAPH_MT_editor_menus(Menu):
+    bl_idname = "GRAPH_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout.menu("GRAPH_MT_view")
+        layout.menu("GRAPH_MT_select")
+        layout.menu("GRAPH_MT_marker")
+        layout.menu("GRAPH_MT_channel")
+        layout.menu("GRAPH_MT_key")
+
+
 class GRAPH_MT_view(Menu):
     bl_label = "View"
 
index cb22ee7a580bd6ca8742b6bbf9df5d236f132c43..9b3c2267aba7fa961cdb91cba2e1f2ac4eb82982 100644 (file)
@@ -373,25 +373,7 @@ class IMAGE_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        # menus
-        if context.area.show_menus:
-            sub = row.row(align=True)
-            sub.menu("IMAGE_MT_view")
-
-            if show_uvedit:
-                sub.menu("IMAGE_MT_select")
-            if show_maskedit:
-                sub.menu("MASK_MT_select")
-
-            if ima and ima.is_dirty:
-                sub.menu("IMAGE_MT_image", text="Image*")
-            else:
-                sub.menu("IMAGE_MT_image", text="Image")
-
-            if show_uvedit:
-                sub.menu("IMAGE_MT_uvs")
-            if show_maskedit:
-                sub.menu("MASK_MT_mask")
+        MASK_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.template_ID(sima, "image", new="image.new", open="image.open")
         if not show_render:
@@ -450,6 +432,40 @@ class IMAGE_HT_header(Header):
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
+class MASK_MT_editor_menus(Menu):
+    bl_idname = "MASK_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        sima = context.space_data
+        ima = sima.image
+
+        show_render = sima.show_render
+        show_uvedit = sima.show_uvedit
+        show_maskedit = sima.show_maskedit
+
+        layout.menu("IMAGE_MT_view")
+
+        if show_uvedit:
+            layout.menu("IMAGE_MT_select")
+        if show_maskedit:
+            layout.menu("MASK_MT_select")
+
+        if ima and ima.is_dirty:
+            layout.menu("IMAGE_MT_image", text="Image*")
+        else:
+            layout.menu("IMAGE_MT_image", text="Image")
+
+        if show_uvedit:
+            layout.menu("IMAGE_MT_uvs")
+        if show_maskedit:
+            layout.menu("MASK_MT_mask")
+
+
 class IMAGE_PT_image_properties(Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
index 6457075c9e23b214937f3a3ca417f15e2ffce13b..769cc53d95363fa33265a479db960f9463480e55 100644 (file)
@@ -34,15 +34,7 @@ class INFO_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            sub = row.row(align=True)
-            sub.menu("INFO_MT_file")
-            if rd.use_game_engine:
-                sub.menu("INFO_MT_game")
-            else:
-                sub.menu("INFO_MT_render")
-            sub.menu("INFO_MT_window")
-            sub.menu("INFO_MT_help")
+        INFO_MT_editor_menus.draw_collapsible(context, layout)
 
         if window.screen.show_fullscreen:
             layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
@@ -79,6 +71,29 @@ class INFO_HT_header(Header):
         row.label(text=scene.statistics(), translate=False)
 
 
+class INFO_MT_editor_menus(Menu):
+    bl_idname = "INFO_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        scene = context.scene
+        rd = scene.render
+
+        layout.menu("INFO_MT_file")
+
+        if rd.use_game_engine:
+            layout.menu("INFO_MT_game")
+        else:
+            layout.menu("INFO_MT_render")
+
+        layout.menu("INFO_MT_window")
+        layout.menu("INFO_MT_help")
+
+
 class INFO_MT_file(Menu):
     bl_label = "File"
 
@@ -132,7 +147,7 @@ class INFO_MT_file(Menu):
 
         layout.operator_context = 'EXEC_AREA'
         if bpy.data.is_dirty and context.user_preferences.view.use_quit_dialog:
-            layout.operator_context = 'INVOKE_SCREEN' # quit dialog
+            layout.operator_context = 'INVOKE_SCREEN'  # quit dialog
         layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
 
 
index 730398171d662a8a67cb31c42408f9ea9058700a..9792a26d22470f2a70dd81b8051d39b1fc66ab77 100644 (file)
@@ -93,10 +93,20 @@ class LOGIC_HT_header(Header):
 
         layout.template_header()
 
-        if context.area.show_menus:
-            row = layout.row(align=True)
-            row.menu("LOGIC_MT_view")
-            row.menu("LOGIC_MT_logicbricks_add")
+        LOGIC_MT_editor_menus.draw_collapsible(context, layout)
+
+
+class LOGIC_MT_editor_menus(Menu):
+    bl_idname = "LOGIC_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout.menu("LOGIC_MT_view")
+        layout.menu("LOGIC_MT_logicbricks_add")
 
 
 class LOGIC_MT_view(Menu):
index dd3ec33d56b723cfc60d15315249982d79ddb521..e41086f6da15957dd5591f2e87bbf84c53e36b0d 100644 (file)
@@ -35,18 +35,29 @@ class NLA_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("NLA_MT_view")
-            row.menu("NLA_MT_select")
-            row.menu("NLA_MT_marker")
-            row.menu("NLA_MT_edit")
-            row.menu("NLA_MT_add")
+        NLA_MT_editor_menus.draw_collapsible(context, layout)
 
         dopesheet_filter(layout, context)
 
         layout.prop(st, "auto_snap", text="")
 
 
+class NLA_MT_editor_menus(Menu):
+    bl_idname = "NLA_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout.menu("NLA_MT_view")
+        layout.menu("NLA_MT_select")
+        layout.menu("NLA_MT_marker")
+        layout.menu("NLA_MT_edit")
+        layout.menu("NLA_MT_add")
+
+
 class NLA_MT_view(Menu):
     bl_label = "View"
 
index 3bf2977d778acd35a7ebc8790db0a2d63a231bde..a91c9a317698fa94391a4ace131ca2345dbe66e1 100644 (file)
@@ -36,11 +36,7 @@ class NODE_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("NODE_MT_view")
-            row.menu("NODE_MT_select")
-            row.menu("NODE_MT_add")
-            row.menu("NODE_MT_node")
+        NODE_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.prop(snode, "tree_type", text="", expand=True)
 
@@ -115,6 +111,21 @@ class NODE_HT_header(Header):
         layout.template_running_jobs()
 
 
+class NODE_MT_editor_menus(Menu):
+    bl_idname = "NODE_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout.menu("NODE_MT_view")
+        layout.menu("NODE_MT_select")
+        layout.menu("NODE_MT_add")
+        layout.menu("NODE_MT_node")
+
+
 class NODE_MT_add(bpy.types.Menu):
     bl_space_type = 'NODE_EDITOR'
     bl_label = "Add"
index 16f639eafc41bc3af816dca4cebde438b2a2770e..01165bf288966185e21efc5cc67523fe28874003 100644 (file)
@@ -34,12 +34,7 @@ class OUTLINER_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            sub = row.row(align=True)
-            sub.menu("OUTLINER_MT_view")
-            sub.menu("OUTLINER_MT_search")
-            if space.display_mode == 'DATABLOCKS':
-                sub.menu("OUTLINER_MT_edit_datablocks")
+        OUTLINER_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.prop(space, "display_mode", text="")
 
@@ -64,6 +59,24 @@ class OUTLINER_HT_header(Header):
                 row.label(text="No Keying Set active")
 
 
+class OUTLINER_MT_editor_menus(Menu):
+    bl_idname = "OUTLINER_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        space = context.space_data
+
+        layout.menu("OUTLINER_MT_view")
+        layout.menu("OUTLINER_MT_search")
+
+        if space.display_mode == 'DATABLOCKS':
+            layout.menu("OUTLINER_MT_edit_datablocks")
+
+
 class OUTLINER_MT_view(Menu):
     bl_label = "View"
 
index 758713b5cc44ac3c8c875707f46775381142ed38..f0ca01ec3ba397af7b02cb20020e1680837f6aeb 100644 (file)
@@ -30,7 +30,7 @@ class PROPERTIES_HT_header(Header):
         view = context.space_data
 
         row = layout.row()
-        row.template_header(menus=False)
+        row.template_header()
         row.prop(view, "context", expand=True, icon_only=True)
 
 
index 6f28bcb2225270be6ee5d75b7a1f75813f1543f7..eab4f5ea541738e3e40a0bce84f398592b5d0d1c 100644 (file)
@@ -63,14 +63,7 @@ class SEQUENCER_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("SEQUENCER_MT_view")
-
-            if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
-                row.menu("SEQUENCER_MT_select")
-                row.menu("SEQUENCER_MT_marker")
-                row.menu("SEQUENCER_MT_add")
-                row.menu("SEQUENCER_MT_strip")
+        SEQUENCER_MT_editor_menus.draw_collapsible(context, layout)
 
         layout.prop(st, "view_type", expand=True, text="")
 
@@ -112,6 +105,26 @@ class SEQUENCER_HT_header(Header):
         layout.template_running_jobs()
 
 
+class SEQUENCER_MT_editor_menus(Menu):
+    bl_idname = "SEQUENCER_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        st = context.space_data
+
+        layout.menu("SEQUENCER_MT_view")
+
+        if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
+            layout.menu("SEQUENCER_MT_select")
+            layout.menu("SEQUENCER_MT_marker")
+            layout.menu("SEQUENCER_MT_add")
+            layout.menu("SEQUENCER_MT_strip")
+
+
 class SEQUENCER_MT_view_toggle(Menu):
     bl_label = "View Type"
 
index 32cb1009492ee5e3caa757a37b34d3ee1373ca41..a430fb0916538c308527639806e263a4283b721a 100644 (file)
@@ -34,21 +34,14 @@ class TEXT_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("TEXT_MT_view")
-            row.menu("TEXT_MT_text")
-
-            if text:
-                row.menu("TEXT_MT_edit")
-                row.menu("TEXT_MT_format")
-
-            row.menu("TEXT_MT_templates")
+        TEXT_MT_editor_menus.draw_collapsible(context, layout)
 
         if text and text.is_modified:
             sub = row.row(align=True)
             sub.alert = True
             sub.operator("text.resolve_conflict", text="", icon='HELP')
 
+        row = layout.row(align=True)
         row.template_ID(st, "text", new="text.new", unlink="text.unlink", open="text.open")
 
         row = layout.row(align=True)
@@ -84,6 +77,28 @@ class TEXT_HT_header(Header):
                           else "Text: Internal")
 
 
+class TEXT_MT_editor_menus(Menu):
+    bl_idname = "TEXT_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        st = context.space_data
+        text = st.text
+
+        layout.menu("TEXT_MT_view")
+        layout.menu("TEXT_MT_text")
+
+        if text:
+            layout.menu("TEXT_MT_edit")
+            layout.menu("TEXT_MT_format")
+
+        layout.menu("TEXT_MT_templates")
+
+
 class TEXT_PT_properties(Panel):
     bl_space_type = 'TEXT_EDITOR'
     bl_region_type = 'UI'
index 4cb67181fdbdc180d0df7eee4e09c24cd728cbef..c0d5553699151da0ec47049a9432a387bba5b156 100644 (file)
@@ -34,11 +34,7 @@ class TIME_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        if context.area.show_menus:
-            row.menu("TIME_MT_view")
-            row.menu("TIME_MT_marker")
-            row.menu("TIME_MT_frame")
-            row.menu("TIME_MT_playback")
+        TIME_MT_editor_menus.draw_collapsible(context, layout)
 
         row = layout.row(align=True)
         row.prop(scene, "use_preview_range", text="", toggle=True)
@@ -96,6 +92,21 @@ class TIME_HT_header(Header):
         row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')
 
 
+class TIME_MT_editor_menus(Menu):
+    bl_idname = "TIME_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        layout.menu("TIME_MT_view")
+        layout.menu("TIME_MT_marker")
+        layout.menu("TIME_MT_frame")
+        layout.menu("TIME_MT_playback")
+
+
 class TIME_MT_marker(Menu):
     bl_label = "Marker"
 
index 8d4fd47508c82c10f4cec309c7e5bc9977693f0e..72785fc2c15f023d11fa0448985e81c777a6ea1a 100644 (file)
@@ -48,7 +48,7 @@ class USERPREF_HT_header(Header):
     def draw(self, context):
         layout = self.layout
 
-        layout.template_header(menus=False)
+        layout.template_header()
 
         userpref = context.user_preferences
 
@@ -432,12 +432,12 @@ class USERPREF_PT_system(Panel):
             col.label(text="Might fail for Mesh editing selection!")
             col.separator()
         col.prop(system, "use_region_overlap")
-        
+
         col.separator()
 
         col.label(text="Text Draw Options:")
         col.prop(system, "use_text_antialiasing")
-        
+
         col.separator()
 
         col.label(text="Textures:")
@@ -917,7 +917,7 @@ class USERPREF_PT_file(Panel):
         col.prop(paths, "save_version")
         col.prop(paths, "recent_files")
         col.prop(paths, "use_save_preview_images")
-        
+
         col.separator()
 
         col.label(text="Auto Save:")
@@ -1047,7 +1047,7 @@ class USERPREF_PT_input(Panel):
         sub.row().prop(inputs, "view_rotate_method", expand=True)
 
         sub.separator()
-        
+
         sub.label(text="Zoom Style:")
         sub.row().prop(inputs, "view_zoom_method", text="")
         if inputs.view_zoom_method in {'DOLLY', 'CONTINUE'}:
index cc264eabafda5ac7926ea2739360a95afa7a5d57..062345103ef66c4481e1e63728afee30e46d14a6 100644 (file)
@@ -37,47 +37,9 @@ class VIEW3D_HT_header(Header):
 
         row = layout.row(align=True)
         row.template_header()
+        sub = row.row(align=True)
 
-        # Menus
-        if context.area.show_menus:
-            sub = row.row(align=True)
-
-            sub.menu("VIEW3D_MT_view")
-
-            # Select Menu
-            if mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
-                mesh = obj.data
-                if mesh.use_paint_mask:
-                    sub.menu("VIEW3D_MT_select_paint_mask")
-                elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
-                    sub.menu("VIEW3D_MT_select_paint_mask_vertex")
-            elif mode_string not in {'SCULPT'}:
-                sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
-
-            if mode_string == 'OBJECT':
-                sub.menu("INFO_MT_add", text="Add")
-            elif mode_string == 'EDIT_MESH':
-                sub.menu("INFO_MT_mesh_add", text="Add")
-            elif mode_string == 'EDIT_CURVE':
-                sub.menu("INFO_MT_curve_add", text="Add")
-            elif mode_string == 'EDIT_SURFACE':
-                sub.menu("INFO_MT_surface_add", text="Add")
-            elif mode_string == 'EDIT_METABALL':
-                sub.menu("INFO_MT_metaball_add", text="Add")
-            elif mode_string == 'EDIT_ARMATURE':
-                sub.menu("INFO_MT_edit_armature_add", text="Add")
-
-            if edit_object:
-                sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
-            elif obj:
-                if mode_string not in {'PAINT_TEXTURE'}:
-                    sub.menu("VIEW3D_MT_%s" % mode_string.lower())
-                if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
-                    sub.menu("VIEW3D_MT_brush")
-                if mode_string == 'SCULPT':
-                    sub.menu("VIEW3D_MT_hide_mask")
-            else:
-                sub.menu("VIEW3D_MT_object")
+        VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
 
         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
         row = layout
@@ -143,6 +105,57 @@ class VIEW3D_HT_header(Header):
             row.operator("pose.paste", text="", icon='PASTEFLIPDOWN').flipped = 1
 
 
+class VIEW3D_MT_editor_menus(Menu):
+    bl_space_type = 'VIEW3D_MT_editor_menus'
+    bl_label = ""
+
+    def draw(self, context):
+        self.draw_menus(self.layout, context)
+
+    @staticmethod
+    def draw_menus(layout, context):
+        obj = context.active_object
+        mode_string = context.mode
+        edit_object = context.edit_object
+
+        layout.menu("VIEW3D_MT_view")
+
+        # Select Menu
+        if mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
+            mesh = obj.data
+            if mesh.use_paint_mask:
+                layout.menu("VIEW3D_MT_select_paint_mask")
+            elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
+                layout.menu("VIEW3D_MT_select_paint_mask_vertex")
+        elif mode_string not in {'EDIT_TEXT', 'SCULPT'}:
+            layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
+
+        if mode_string == 'OBJECT':
+            layout.menu("INFO_MT_add", text="Add")
+        elif mode_string == 'EDIT_MESH':
+            layout.menu("INFO_MT_mesh_add", text="Add")
+        elif mode_string == 'EDIT_CURVE':
+            layout.menu("INFO_MT_curve_add", text="Add")
+        elif mode_string == 'EDIT_SURFACE':
+            layout.menu("INFO_MT_surface_add", text="Add")
+        elif mode_string == 'EDIT_METABALL':
+            layout.menu("INFO_MT_metaball_add", text="Add")
+        elif mode_string == 'EDIT_ARMATURE':
+            layout.menu("INFO_MT_edit_armature_add", text="Add")
+
+        if edit_object:
+            layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
+        elif obj:
+            if mode_string not in {'PAINT_TEXTURE'}:
+                layout.menu("VIEW3D_MT_%s" % mode_string.lower())
+            if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
+                layout.menu("VIEW3D_MT_brush")
+            if mode_string == 'SCULPT':
+                layout.menu("VIEW3D_MT_hide_mask")
+        else:
+            layout.menu("VIEW3D_MT_object")
+
+
 # ********** Menu **********
 
 
index d80e40d245599fbf844d859b8835c149f8a135f8..b432e611c56733ef601b2957c757b7a0ca9b9a7f 100644 (file)
@@ -73,7 +73,6 @@ void  ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
 /* spaces */
 void    ED_spacetypes_keymap(struct wmKeyConfig *keyconf);
 int     ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco);
-int     ED_area_header_standardbuttons(const struct bContext *C, struct uiBlock *block, int yco);
 
 
 /* areas */
index 27205771d1a3240d8a3c160fa90351b50d8a1af4..dcc526b81d2aa217bcad95ef7dbaedbc77035d4d 100644 (file)
@@ -51,9 +51,7 @@ DEF_ICON(MENU_PANEL)
 DEF_ICON(BLENDER)
 DEF_ICON(GRIP)
 DEF_ICON(DOT)
-#ifndef DEF_ICON_BLANK_SKIP
-       DEF_ICON(BLANK004)
-#endif
+DEF_ICON(COLLAPSEMENU)
 DEF_ICON(X)
 #ifndef DEF_ICON_BLANK_SKIP
        DEF_ICON(BLANK005)
index 3a48e943da2dad869576b5ff0eb4a5af282947e8..65811b7c009611719cfd41120d143145a7b335c3 100644 (file)
@@ -820,7 +820,7 @@ uiLayout *uiLayoutOverlap(uiLayout *layout);
 uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
 
 /* templates */
-void uiTemplateHeader(uiLayout *layout, struct bContext *C, int menus);
+void uiTemplateHeader(uiLayout *layout, struct bContext *C);
 void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
                   const char *newop, const char *openop, const char *unlinkop);
 void uiTemplateIDBrowse(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
index 14ec4d5e0f06a237ca42a9562259547d22d533a1..0aa9368fc5fd86466f4b36ca884de8cc9d33c6ee 100644 (file)
@@ -91,13 +91,12 @@ void UI_template_fix_linking(void)
 
 /********************** Header Template *************************/
 
-void uiTemplateHeader(uiLayout *layout, bContext *C, int menus)
+void uiTemplateHeader(uiLayout *layout, bContext *C)
 {
        uiBlock *block;
 
        block = uiLayoutAbsoluteBlock(layout);
-       if (menus) ED_area_header_standardbuttons(C, block, 0);
-       else ED_area_header_switchbutton(C, block, 0);
+       ED_area_header_switchbutton(C, block, 0);
 }
 
 /********************** Search Callbacks *************************/
index 2c69150587776b513be4da14d88e90e4cba85e1e..25b6f241d9b45abc9f3f973115915738d6e78869 100644 (file)
@@ -1533,39 +1533,6 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
        return xco + 1.7 * U.widget_unit;
 }
 
-int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
-{
-       ScrArea *sa = CTX_wm_area(C);
-       int xco = 0.4 * U.widget_unit;
-       uiBut *but;
-       
-       if (!sa->full)
-               xco = ED_area_header_switchbutton(C, block, yco);
-
-       uiBlockSetEmboss(block, UI_EMBOSSN);
-
-       if (sa->flag & HEADER_NO_PULLDOWN) {
-               but = uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
-                                      ICON_DISCLOSURE_TRI_RIGHT,
-                                      xco, yco, U.widget_unit, U.widget_unit * 0.9f,
-                                      &(sa->flag), 0, 0, 0, 0,
-                                      TIP_("Show pulldown menus"));
-       }
-       else {
-               but = uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
-                                      ICON_DISCLOSURE_TRI_DOWN,
-                                      xco, yco, U.widget_unit, U.widget_unit * 0.9f,
-                                      &(sa->flag), 0, 0, 0, 0,
-                                      TIP_("Hide pulldown menus"));
-       }
-
-       uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
-
-       uiBlockSetEmboss(block, UI_EMBOSS);
-       
-       return xco + U.widget_unit;
-}
-
 /************************ standard UI regions ************************/
 
 void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr)
index f9e366a26460d54de0d03dca8c2e914ea89d8103..8b7246b4b907fdd6564ba058bca4faa267ef3145 100644 (file)
@@ -3046,9 +3046,9 @@ static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op))
 static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Show/Hide Header Menus";
+       ot->name = "Expand/Collapse Header Menus";
        ot->idname = "SCREEN_OT_header_toggle_menus";
-       ot->description = "Show or hide the header pulldown menus";
+       ot->description = "Expand or collapse the header pulldown menus";
        
        /* api callbacks */
        ot->exec = header_toggle_menus_exec;
@@ -3069,10 +3069,9 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
        else
                uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip");
 
-       if (sa->flag & HEADER_NO_PULLDOWN)
-               uiItemO(layout, IFACE_("Show Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus");
-       else
-               uiItemO(layout, IFACE_("Hide Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus");
+       uiItemO(layout, IFACE_("Collapse Menus"),
+               (sa->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT,
+               "SCREEN_OT_header_toggle_menus");
 
        uiItemS(layout);
 
index f3f31b5dd6602c589bcc537b69318b5ed26b23c2..adabc1dd7614976bf7d5dec2151c37e183916259 100644 (file)
@@ -631,7 +631,6 @@ void RNA_api_ui_layout(StructRNA *srna)
        /* templates */
        func = RNA_def_function(srna, "template_header", "uiTemplateHeader");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
-       RNA_def_boolean(func, "menus", true, "", "The header has menus, and should show menu expander");
 
        func = RNA_def_function(srna, "template_ID", "uiTemplateID");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
index 18422554dced2ca9c69a054014d4b7aff3f6999f..45b03198a1fa2713f88ecea7dd737ebed9ef461b 100644 (file)
@@ -465,7 +465,7 @@ struct bTheme *UI_GetTheme(void) {STUB_ASSERT(0); return (struct bTheme *) NULL;
 /* rna template */
 void uiTemplateAnyID(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *text) {STUB_ASSERT(0);}
 void uiTemplatePathBuilder(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *root_ptr, char *text) {STUB_ASSERT(0);}
-void uiTemplateHeader(struct uiLayout *layout, struct bContext *C, int menus) {STUB_ASSERT(0);}
+void uiTemplateHeader(struct uiLayout *layout, struct bContext *C) {STUB_ASSERT(0);}
 void uiTemplateID(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *newop, char *unlinkop) {STUB_ASSERT(0);}
 struct uiLayout *uiTemplateModifier(struct uiLayout *layout, struct PointerRNA *ptr) {STUB_ASSERT(0); return (struct uiLayout *) NULL;}
 struct uiLayout *uiTemplateConstraint(struct uiLayout *layout, struct PointerRNA *ptr) {STUB_ASSERT(0); return (struct uiLayout *) NULL;}