Merge branch 'blender-v2.81-release'
[blender.git] / release / scripts / startup / bl_ui / space_info.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 from bpy.types import Header, Menu
21
22
23 class INFO_HT_header(Header):
24     bl_space_type = 'INFO'
25
26     def draw(self, context):
27         layout = self.layout
28         layout.template_header()
29
30         INFO_MT_editor_menus.draw_collapsible(context, layout)
31
32
33 class INFO_MT_editor_menus(Menu):
34     bl_idname = "INFO_MT_editor_menus"
35     bl_label = ""
36
37     def draw(self, _context):
38         layout = self.layout
39         layout.menu("INFO_MT_view")
40         layout.menu("INFO_MT_info")
41
42
43 class INFO_MT_view(Menu):
44     bl_label = "View"
45
46     def draw(self, _context):
47         layout = self.layout
48
49         layout.menu("INFO_MT_area")
50
51
52 class INFO_MT_info(Menu):
53     bl_label = "Info"
54
55     def draw(self, _context):
56         layout = self.layout
57
58         layout.operator("info.select_all", text="Select All").action = 'SELECT'
59         layout.operator("info.select_all", text="Deselect All").action = 'DESELECT'
60         layout.operator("info.select_all", text="Invert Selection").action = 'INVERT'
61         layout.operator("info.select_all", text="Toggle Selection").action = 'TOGGLE'
62
63         layout.separator()
64
65         layout.operator("info.select_box")
66
67         layout.separator()
68
69         # Disabled because users will likely try this and find
70         # it doesn't work all that well in practice.
71         # Mainly because operators needs to run in the right context.
72
73         # layout.operator("info.report_replay")
74         # layout.separator()
75
76         layout.operator("info.report_delete", text="Delete")
77         layout.operator("info.report_copy", text="Copy")
78
79
80 class INFO_MT_area(Menu):
81     bl_label = "Area"
82
83     def draw(self, context):
84         layout = self.layout
85
86         if context.space_data.type == 'VIEW_3D':
87             layout.operator("screen.region_quadview")
88             layout.separator()
89
90         layout.operator("screen.area_split", text="Horizontal Split").direction = 'HORIZONTAL'
91         layout.operator("screen.area_split", text="Vertical Split").direction = 'VERTICAL'
92
93         layout.separator()
94
95         layout.operator("screen.area_dupli", icon='DUPLICATE')
96
97         layout.separator()
98
99         layout.operator("screen.screen_full_area")
100         layout.operator(
101             "screen.screen_full_area",
102             text="Toggle Fullscreen Area",
103             icon='FULLSCREEN_ENTER',
104         ).use_hide_panels = True
105
106
107 class INFO_MT_context_menu(Menu):
108     bl_label = "Info Context Menu"
109
110     def draw(self, _context):
111         layout = self.layout
112
113         layout.operator("info.report_copy", text="Copy")
114         layout.operator("info.report_delete", text="Delete")
115
116
117 classes = (
118     INFO_HT_header,
119     INFO_MT_editor_menus,
120     INFO_MT_area,
121     INFO_MT_view,
122     INFO_MT_info,
123     INFO_MT_context_menu,
124 )
125
126 if __name__ == "__main__":  # only for live edit.
127     from bpy.utils import register_class
128     for cls in classes:
129         register_class(cls)