UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users * Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars. * Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector. * Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here. * Individual sections of the topbar are individually scrollable. * Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting. * Top-bar should scale nicely with DPI. * The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes). * Info editors at the top of the window and using the full window width with be replaced by the top-bar. * In fullscreen modes, no more info editor is added on top, the top-bar replaces it. == Technical Features/Changes * Adds initial support for global areas A global area is part of the window, not part of the regular screen-layout. I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas. * Adds a TOPBAR editor type The editor type is hidden in the UI editor type menu. * Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY) * Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar. * Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds. The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved. * Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code. Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being. NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility. == ToDo's It's a bit hard to predict all the ToDo's here are the known main ones: * Add options for the new active-tool system and for operator redo to the topbar. * Automatically hide the top-bar in fullscreen modes. * General visual polish. * Top-bar drag & drop support (WIP in temp-tab_drag_drop). * Improve dynamic regions (should also fix some layout glitches). * Make internal terminology consistent. * Enable topbar file writing once design is more advanced. * Address TODO's and XXX's in code :) Thanks @brecht for the review! And @sergey for the complaining ;) Differential Revision: D2758
This commit is contained in:
@@ -583,6 +583,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
|
||||
bf_editor_space_sequencer
|
||||
bf_editor_space_text
|
||||
bf_editor_space_time
|
||||
bf_editor_space_topbar
|
||||
bf_editor_space_userpref
|
||||
bf_editor_space_view3d
|
||||
bf_editor_space_clip
|
||||
|
||||
@@ -84,6 +84,7 @@ _modules = [
|
||||
"space_sequencer",
|
||||
"space_text",
|
||||
"space_time",
|
||||
"space_topbar",
|
||||
"space_userpref",
|
||||
"space_view3d",
|
||||
"space_view3d_toolbar",
|
||||
|
||||
401
release/scripts/startup/bl_ui/space_topbar.py
Normal file
401
release/scripts/startup/bl_ui/space_topbar.py
Normal file
@@ -0,0 +1,401 @@
|
||||
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8 compliant>
|
||||
import bpy
|
||||
from bpy.types import Header, Menu, Panel
|
||||
|
||||
|
||||
class TOPBAR_HT_upper_bar(Header):
|
||||
bl_space_type = 'TOPBAR'
|
||||
|
||||
def draw(self, context):
|
||||
region = context.region
|
||||
|
||||
if region.alignment == 'RIGHT':
|
||||
self.draw_right(context)
|
||||
else:
|
||||
self.draw_left(context)
|
||||
|
||||
def draw_left(self, context):
|
||||
layout = self.layout
|
||||
|
||||
window = context.window
|
||||
screen = context.screen
|
||||
|
||||
layout.operator("wm.splash", text="", icon='BLENDER', emboss=False)
|
||||
|
||||
TOPBAR_MT_editor_menus.draw_collapsible(context, layout)
|
||||
|
||||
layout.separator()
|
||||
|
||||
if not screen.show_fullscreen:
|
||||
layout.template_ID_tabs(window, "workspace", new="workspace.workspace_add_menu", unlink="workspace.workspace_delete")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.template_running_jobs()
|
||||
|
||||
layout.template_reports_banner()
|
||||
|
||||
row = layout.row(align=True)
|
||||
|
||||
if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False:
|
||||
row.label("Auto-run disabled", icon='ERROR')
|
||||
if bpy.data.is_saved:
|
||||
props = row.operator("wm.revert_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
|
||||
props.use_scripts = True
|
||||
|
||||
row.operator("script.autoexec_warn_clear", text="Ignore")
|
||||
|
||||
# include last so text doesn't push buttons out of the header
|
||||
row.label(bpy.app.autoexec_fail_message)
|
||||
return
|
||||
|
||||
def draw_right(self, context):
|
||||
layout = self.layout
|
||||
|
||||
window = context.window
|
||||
|
||||
layout.template_ID(window, "scene", new="scene.new", unlink="scene.delete")
|
||||
|
||||
|
||||
class TOPBAR_HT_lower_bar(Header):
|
||||
bl_space_type = 'TOPBAR'
|
||||
bl_region_type = 'WINDOW'
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
region = context.region
|
||||
|
||||
if region.alignment == 'LEFT':
|
||||
self.draw_left(context)
|
||||
elif region.alignment == 'RIGHT':
|
||||
self.draw_right(context)
|
||||
else:
|
||||
# WITH_REDO_REGION_REMOVAL:
|
||||
# layout.template_operator_redo_props()
|
||||
pass
|
||||
|
||||
def draw_left(self, context):
|
||||
layout = self.layout
|
||||
layer = context.view_layer
|
||||
|
||||
act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[layer.objects.active.mode]
|
||||
layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
|
||||
|
||||
|
||||
def draw_right(self, context):
|
||||
layout = self.layout
|
||||
|
||||
window = context.window
|
||||
workspace = context.workspace
|
||||
scene = context.scene
|
||||
screen = context.screen
|
||||
|
||||
if screen.show_fullscreen:
|
||||
layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
|
||||
else:
|
||||
layout.template_search_preview(window, "screen", workspace, "screens", new="screen.new", unlink="screen.delete", rows=2, cols=6)
|
||||
# Active workspace view-layer is retrieved through window, not through workspace.
|
||||
layout.template_search(window, "view_layer", scene, "view_layers")
|
||||
|
||||
|
||||
class TOPBAR_MT_editor_menus(Menu):
|
||||
bl_idname = "TOPBAR_MT_editor_menus"
|
||||
bl_label = ""
|
||||
|
||||
def draw(self, context):
|
||||
self.draw_menus(self.layout, context)
|
||||
|
||||
@staticmethod
|
||||
def draw_menus(layout, context):
|
||||
layout.menu("TOPBAR_MT_file")
|
||||
|
||||
layout.menu("TOPBAR_MT_render")
|
||||
|
||||
layout.menu("TOPBAR_MT_window")
|
||||
layout.menu("TOPBAR_MT_help")
|
||||
|
||||
|
||||
class TOPBAR_MT_file(Menu):
|
||||
bl_label = "File"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.operator("wm.read_homefile", text="New", icon='NEW')
|
||||
layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
|
||||
layout.menu("TOPBAR_MT_file_open_recent", icon='OPEN_RECENT')
|
||||
layout.operator("wm.revert_mainfile", icon='FILE_REFRESH')
|
||||
layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
|
||||
layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA'
|
||||
layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
|
||||
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.operator("wm.save_as_mainfile", text="Save Copy...", icon='SAVE_COPY').copy = True
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
|
||||
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.operator("wm.save_homefile", icon='SAVE_PREFS')
|
||||
layout.operator("wm.read_factory_settings", icon='LOAD_FACTORY')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.operator("wm.link", text="Link", icon='LINK_BLEND')
|
||||
layout.operator("wm.append", text="Append", icon='APPEND_BLEND')
|
||||
layout.menu("TOPBAR_MT_file_previews")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("TOPBAR_MT_file_import", icon='IMPORT')
|
||||
layout.menu("TOPBAR_MT_file_export", icon='EXPORT')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("TOPBAR_MT_file_external_data", icon='EXTERNAL_DATA')
|
||||
|
||||
layout.separator()
|
||||
|
||||
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("wm.quit_blender", text="Quit", icon='QUIT')
|
||||
|
||||
|
||||
class TOPBAR_MT_file_import(Menu):
|
||||
bl_idname = "TOPBAR_MT_file_import"
|
||||
bl_label = "Import"
|
||||
|
||||
def draw(self, context):
|
||||
if bpy.app.build_options.collada:
|
||||
self.layout.operator("wm.collada_import", text="Collada (Default) (.dae)")
|
||||
if bpy.app.build_options.alembic:
|
||||
self.layout.operator("wm.alembic_import", text="Alembic (.abc)")
|
||||
|
||||
|
||||
class TOPBAR_MT_file_export(Menu):
|
||||
bl_idname = "TOPBAR_MT_file_export"
|
||||
bl_label = "Export"
|
||||
|
||||
def draw(self, context):
|
||||
if bpy.app.build_options.collada:
|
||||
self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)")
|
||||
if bpy.app.build_options.alembic:
|
||||
self.layout.operator("wm.alembic_export", text="Alembic (.abc)")
|
||||
|
||||
|
||||
class TOPBAR_MT_file_external_data(Menu):
|
||||
bl_label = "External Data"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
icon = 'CHECKBOX_HLT' if bpy.data.use_autopack else 'CHECKBOX_DEHLT'
|
||||
layout.operator("file.autopack_toggle", icon=icon)
|
||||
|
||||
layout.separator()
|
||||
|
||||
pack_all = layout.row()
|
||||
pack_all.operator("file.pack_all")
|
||||
pack_all.active = not bpy.data.use_autopack
|
||||
|
||||
unpack_all = layout.row()
|
||||
unpack_all.operator("file.unpack_all")
|
||||
unpack_all.active = not bpy.data.use_autopack
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("file.make_paths_relative")
|
||||
layout.operator("file.make_paths_absolute")
|
||||
layout.operator("file.report_missing_files")
|
||||
layout.operator("file.find_missing_files")
|
||||
|
||||
|
||||
class TOPBAR_MT_file_previews(Menu):
|
||||
bl_label = "Data Previews"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("wm.previews_ensure")
|
||||
layout.operator("wm.previews_batch_generate")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("wm.previews_clear")
|
||||
layout.operator("wm.previews_batch_clear")
|
||||
|
||||
|
||||
class TOPBAR_MT_game(Menu):
|
||||
bl_label = "Game"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
gs = context.scene.game_settings
|
||||
|
||||
layout.operator("view3d.game_start")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.prop(gs, "show_debug_properties")
|
||||
layout.prop(gs, "show_framerate_profile")
|
||||
layout.prop(gs, "show_physics_visualization")
|
||||
layout.prop(gs, "use_deprecation_warnings")
|
||||
layout.prop(gs, "use_animation_record")
|
||||
layout.separator()
|
||||
layout.prop(gs, "use_auto_start")
|
||||
|
||||
|
||||
class TOPBAR_MT_render(Menu):
|
||||
bl_label = "Render"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("render.render", text="Render Image", icon='RENDER_STILL').use_viewport = True
|
||||
props = layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION')
|
||||
props.animation = True
|
||||
props.use_viewport = True
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("render.opengl", text="OpenGL Render Image")
|
||||
layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
|
||||
layout.menu("TOPBAR_MT_opengl_render")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("render.view_show")
|
||||
layout.operator("render.play_rendered_anim", icon='PLAY')
|
||||
|
||||
|
||||
class TOPBAR_MT_opengl_render(Menu):
|
||||
bl_label = "OpenGL Render Options"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
rd = context.scene.render
|
||||
layout.prop(rd, "use_antialiasing")
|
||||
layout.prop(rd, "use_full_sample")
|
||||
|
||||
layout.prop_menu_enum(rd, "antialiasing_samples")
|
||||
layout.prop_menu_enum(rd, "alpha_mode")
|
||||
|
||||
|
||||
class TOPBAR_MT_window(Menu):
|
||||
bl_label = "Window"
|
||||
|
||||
def draw(self, context):
|
||||
import sys
|
||||
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("wm.window_new")
|
||||
layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("screen.screenshot")
|
||||
layout.operator("screen.screencast")
|
||||
|
||||
if sys.platform[:3] == "win":
|
||||
layout.separator()
|
||||
layout.operator("wm.console_toggle", icon='CONSOLE')
|
||||
|
||||
if context.scene.render.use_multiview:
|
||||
layout.separator()
|
||||
layout.operator("wm.set_stereo_3d", icon='CAMERA_STEREO')
|
||||
|
||||
|
||||
class TOPBAR_MT_help(Menu):
|
||||
bl_label = "Help"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="Manual", icon='HELP',
|
||||
).url = "https://docs.blender.org/manual/en/dev/"
|
||||
layout.operator(
|
||||
"wm.url_open", text="Release Log", icon='URL',
|
||||
).url = "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/%d.%d" % bpy.app.version[:2]
|
||||
layout.separator()
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="Blender Website", icon='URL',
|
||||
).url = "https://www.blender.org"
|
||||
layout.operator(
|
||||
"wm.url_open", text="Blender Store", icon='URL',
|
||||
).url = "https://store.blender.org"
|
||||
layout.operator(
|
||||
"wm.url_open", text="Developer Community", icon='URL',
|
||||
).url = "https://www.blender.org/get-involved/"
|
||||
layout.operator(
|
||||
"wm.url_open", text="User Community", icon='URL',
|
||||
).url = "https://www.blender.org/support/user-community"
|
||||
layout.separator()
|
||||
layout.operator(
|
||||
"wm.url_open", text="Report a Bug", icon='URL',
|
||||
).url = "https://developer.blender.org/maniphest/task/edit/form/1"
|
||||
layout.separator()
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="Python API Reference", icon='URL',
|
||||
).url = bpy.types.WM_OT_doc_view._prefix
|
||||
|
||||
layout.operator("wm.operator_cheat_sheet", icon='TEXT')
|
||||
layout.operator("wm.sysinfo", icon='TEXT')
|
||||
layout.separator()
|
||||
|
||||
layout.operator("wm.splash", icon='BLENDER')
|
||||
|
||||
|
||||
classes = (
|
||||
TOPBAR_HT_upper_bar,
|
||||
TOPBAR_HT_lower_bar,
|
||||
TOPBAR_MT_editor_menus,
|
||||
TOPBAR_MT_file,
|
||||
TOPBAR_MT_file_import,
|
||||
TOPBAR_MT_file_export,
|
||||
TOPBAR_MT_file_external_data,
|
||||
TOPBAR_MT_file_previews,
|
||||
TOPBAR_MT_game,
|
||||
TOPBAR_MT_render,
|
||||
TOPBAR_MT_opengl_render,
|
||||
TOPBAR_MT_window,
|
||||
TOPBAR_MT_help,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
@@ -853,6 +853,9 @@ class USERPREF_PT_theme(Panel):
|
||||
col.label(text="List Item:")
|
||||
self._theme_widget_style(col, ui.wcol_list_item)
|
||||
|
||||
col.label(text="Tab:")
|
||||
self._theme_widget_style(col, ui.wcol_tab)
|
||||
|
||||
ui_state = theme.user_interface.wcol_state
|
||||
col.label(text="State:")
|
||||
|
||||
|
||||
@@ -178,6 +178,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C);
|
||||
struct SpaceInfo *CTX_wm_space_info(const bContext *C);
|
||||
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C);
|
||||
struct SpaceClip *CTX_wm_space_clip(const bContext *C);
|
||||
struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C);
|
||||
|
||||
void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
|
||||
void CTX_wm_window_set(bContext *C, struct wmWindow *win);
|
||||
|
||||
@@ -58,6 +58,7 @@ struct wmWindowManager;
|
||||
struct WorkSpace;
|
||||
struct GPUFXSettings;
|
||||
struct wmMsgBus;
|
||||
struct ScrAreaMap;
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
@@ -244,6 +245,7 @@ typedef struct HeaderType {
|
||||
|
||||
char idname[BKE_ST_MAXNAME]; /* unique name */
|
||||
int space_type;
|
||||
int region_type;
|
||||
|
||||
/* draw entirely, view changes should be handled here */
|
||||
void (*draw)(const struct bContext *, struct Header *);
|
||||
@@ -334,6 +336,7 @@ float BKE_screen_view3d_zoom_from_fac(float zoomfac);
|
||||
|
||||
/* screen */
|
||||
void BKE_screen_free(struct bScreen *sc);
|
||||
void BKE_screen_area_map_free(struct ScrAreaMap *area_map) ATTR_NONNULL();
|
||||
unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
|
||||
|
||||
struct ScrEdge *BKE_screen_find_edge(struct bScreen *sc, struct ScrVert *v1, struct ScrVert *v2);
|
||||
|
||||
@@ -831,6 +831,14 @@ struct SpaceClip *CTX_wm_space_clip(const bContext *C)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (sa && sa->spacetype == SPACE_TOPBAR)
|
||||
return sa->spacedata.first;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
|
||||
{
|
||||
C->wm.manager = wm;
|
||||
|
||||
@@ -397,6 +397,7 @@ void BKE_screen_area_free(ScrArea *sa)
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
BKE_area_region_free(st, ar);
|
||||
|
||||
MEM_SAFE_FREE(sa->global);
|
||||
BLI_freelistN(&sa->regionbase);
|
||||
|
||||
BKE_spacedata_freelist(&sa->spacedata);
|
||||
@@ -404,10 +405,21 @@ void BKE_screen_area_free(ScrArea *sa)
|
||||
BLI_freelistN(&sa->actionzones);
|
||||
}
|
||||
|
||||
void BKE_screen_area_map_free(ScrAreaMap *area_map)
|
||||
{
|
||||
for (ScrArea *area = area_map->areabase.first, *area_next; area; area = area_next) {
|
||||
area_next = area->next;
|
||||
BKE_screen_area_free(area);
|
||||
}
|
||||
|
||||
BLI_freelistN(&area_map->vertbase);
|
||||
BLI_freelistN(&area_map->edgebase);
|
||||
BLI_freelistN(&area_map->areabase);
|
||||
}
|
||||
|
||||
/** Free (or release) any data used by this screen (does not free the screen itself). */
|
||||
void BKE_screen_free(bScreen *sc)
|
||||
{
|
||||
ScrArea *sa, *san;
|
||||
ARegion *ar;
|
||||
|
||||
/* No animdata here. */
|
||||
@@ -417,14 +429,7 @@ void BKE_screen_free(bScreen *sc)
|
||||
|
||||
BLI_freelistN(&sc->regionbase);
|
||||
|
||||
for (sa = sc->areabase.first; sa; sa = san) {
|
||||
san = sa->next;
|
||||
BKE_screen_area_free(sa);
|
||||
}
|
||||
|
||||
BLI_freelistN(&sc->vertbase);
|
||||
BLI_freelistN(&sc->edgebase);
|
||||
BLI_freelistN(&sc->areabase);
|
||||
BKE_screen_area_map_free(AREAMAP_FROM_SCREEN(sc));
|
||||
|
||||
BKE_previewimg_free(&sc->preview);
|
||||
|
||||
|
||||
@@ -6396,6 +6396,8 @@ static void direct_link_area(FileData *fd, ScrArea *area)
|
||||
area->type = NULL; /* spacetype callbacks */
|
||||
area->region_active_win = -1;
|
||||
|
||||
area->global = newdataadr(fd, area->global);
|
||||
|
||||
/* if we do not have the spacetype registered we cannot
|
||||
* free it, so don't allocate any new memory for such spacetypes. */
|
||||
if (!BKE_spacetype_exists(area->spacetype)) {
|
||||
@@ -6630,9 +6632,9 @@ static void direct_link_area(FileData *fd, ScrArea *area)
|
||||
area->v4 = newdataadr(fd, area->v4);
|
||||
}
|
||||
|
||||
static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
|
||||
{
|
||||
area->full = newlibadr(fd, sc->id.lib, area->full);
|
||||
area->full = newlibadr(fd, parent_id->lib, area->full);
|
||||
|
||||
for (SpaceLink *sl = area->spacedata.first; sl; sl= sl->next) {
|
||||
switch (sl->spacetype) {
|
||||
@@ -6640,11 +6642,11 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
{
|
||||
View3D *v3d = (View3D*) sl;
|
||||
|
||||
v3d->camera= newlibadr(fd, sc->id.lib, v3d->camera);
|
||||
v3d->ob_centre= newlibadr(fd, sc->id.lib, v3d->ob_centre);
|
||||
v3d->camera= newlibadr(fd, parent_id->lib, v3d->camera);
|
||||
v3d->ob_centre= newlibadr(fd, parent_id->lib, v3d->ob_centre);
|
||||
|
||||
if (v3d->localvd) {
|
||||
v3d->localvd->camera = newlibadr(fd, sc->id.lib, v3d->localvd->camera);
|
||||
v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -6654,15 +6656,15 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
bDopeSheet *ads = sipo->ads;
|
||||
|
||||
if (ads) {
|
||||
ads->source = newlibadr(fd, sc->id.lib, ads->source);
|
||||
ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
|
||||
ads->source = newlibadr(fd, parent_id->lib, ads->source);
|
||||
ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPACE_BUTS:
|
||||
{
|
||||
SpaceButs *sbuts = (SpaceButs *)sl;
|
||||
sbuts->pinid = newlibadr(fd, sc->id.lib, sbuts->pinid);
|
||||
sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid);
|
||||
if (sbuts->pinid == NULL) {
|
||||
sbuts->flag &= ~SB_PIN_CONTEXT;
|
||||
}
|
||||
@@ -6676,24 +6678,24 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
bDopeSheet *ads = &saction->ads;
|
||||
|
||||
if (ads) {
|
||||
ads->source = newlibadr(fd, sc->id.lib, ads->source);
|
||||
ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
|
||||
ads->source = newlibadr(fd, parent_id->lib, ads->source);
|
||||
ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
|
||||
}
|
||||
|
||||
saction->action = newlibadr(fd, sc->id.lib, saction->action);
|
||||
saction->action = newlibadr(fd, parent_id->lib, saction->action);
|
||||
break;
|
||||
}
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
sima->image = newlibadr_real_us(fd, sc->id.lib, sima->image);
|
||||
sima->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sima->mask_info.mask);
|
||||
sima->image = newlibadr_real_us(fd, parent_id->lib, sima->image);
|
||||
sima->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sima->mask_info.mask);
|
||||
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd);
|
||||
sima->gpd = newlibadr_us(fd, parent_id->lib, sima->gpd);
|
||||
break;
|
||||
}
|
||||
case SPACE_SEQ:
|
||||
@@ -6703,7 +6705,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
|
||||
* so fingers crossed this works fine!
|
||||
*/
|
||||
sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd);
|
||||
sseq->gpd = newlibadr_us(fd, parent_id->lib, sseq->gpd);
|
||||
break;
|
||||
}
|
||||
case SPACE_NLA:
|
||||
@@ -6712,8 +6714,8 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
bDopeSheet *ads= snla->ads;
|
||||
|
||||
if (ads) {
|
||||
ads->source = newlibadr(fd, sc->id.lib, ads->source);
|
||||
ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp);
|
||||
ads->source = newlibadr(fd, parent_id->lib, ads->source);
|
||||
ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -6721,7 +6723,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
{
|
||||
SpaceText *st= (SpaceText *)sl;
|
||||
|
||||
st->text= newlibadr(fd, sc->id.lib, st->text);
|
||||
st->text= newlibadr(fd, parent_id->lib, st->text);
|
||||
break;
|
||||
}
|
||||
case SPACE_SCRIPT:
|
||||
@@ -6729,7 +6731,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
SpaceScript *scpt = (SpaceScript *)sl;
|
||||
/*scpt->script = NULL; - 2.45 set to null, better re-run the script */
|
||||
if (scpt->script) {
|
||||
scpt->script = newlibadr(fd, sc->id.lib, scpt->script);
|
||||
scpt->script = newlibadr(fd, parent_id->lib, scpt->script);
|
||||
if (scpt->script) {
|
||||
SCRIPT_SET_NULL(scpt->script);
|
||||
}
|
||||
@@ -6763,11 +6765,11 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
bNodeTree *ntree;
|
||||
|
||||
/* node tree can be stored locally in id too, link this first */
|
||||
snode->id = newlibadr(fd, sc->id.lib, snode->id);
|
||||
snode->from = newlibadr(fd, sc->id.lib, snode->from);
|
||||
snode->id = newlibadr(fd, parent_id->lib, snode->id);
|
||||
snode->from = newlibadr(fd, parent_id->lib, snode->from);
|
||||
|
||||
ntree = snode->id ? ntreeFromID(snode->id) : NULL;
|
||||
snode->nodetree = ntree ? ntree : newlibadr_us(fd, sc->id.lib, snode->nodetree);
|
||||
snode->nodetree = ntree ? ntree : newlibadr_us(fd, parent_id->lib, snode->nodetree);
|
||||
|
||||
for (path = snode->treepath.first; path; path = path->next) {
|
||||
if (path == snode->treepath.first) {
|
||||
@@ -6775,7 +6777,7 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
path->nodetree = snode->nodetree;
|
||||
}
|
||||
else
|
||||
path->nodetree = newlibadr_us(fd, sc->id.lib, path->nodetree);
|
||||
path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree);
|
||||
|
||||
if (!path->nodetree)
|
||||
break;
|
||||
@@ -6803,9 +6805,8 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
case SPACE_CLIP:
|
||||
{
|
||||
SpaceClip *sclip = (SpaceClip *)sl;
|
||||
|
||||
sclip->clip = newlibadr_real_us(fd, sc->id.lib, sclip->clip);
|
||||
sclip->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sclip->mask_info.mask);
|
||||
sclip->clip = newlibadr_real_us(fd, parent_id->lib, sclip->clip);
|
||||
sclip->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sclip->mask_info.mask);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -6814,6 +6815,34 @@ static void lib_link_area(FileData *fd, bScreen *sc, ScrArea *area)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \return false on error.
|
||||
*/
|
||||
static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map)
|
||||
{
|
||||
link_list(fd, &area_map->vertbase);
|
||||
link_list(fd, &area_map->edgebase);
|
||||
link_list(fd, &area_map->areabase);
|
||||
for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
|
||||
direct_link_area(fd, area);
|
||||
}
|
||||
|
||||
/* edges */
|
||||
for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
|
||||
se->v1 = newdataadr(fd, se->v1);
|
||||
se->v2 = newdataadr(fd, se->v2);
|
||||
BKE_screen_sort_scrvert(&se->v1, &se->v2);
|
||||
|
||||
if (se->v1 == NULL) {
|
||||
BLI_remlink(&area_map->edgebase, se);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ************ READ WM ***************** */
|
||||
|
||||
static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
|
||||
@@ -6830,6 +6859,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
|
||||
/* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */
|
||||
oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0);
|
||||
|
||||
direct_link_area_map(fd, &win->global_areas);
|
||||
|
||||
win->ghostwin = NULL;
|
||||
win->gwnctx = NULL;
|
||||
win->eventstate = NULL;
|
||||
@@ -6901,6 +6932,10 @@ static void lib_link_windowmanager(FileData *fd, Main *main)
|
||||
win->scene = newlibadr(fd, wm->id.lib, win->scene);
|
||||
/* deprecated, but needed for versioning (will be NULL'ed then) */
|
||||
win->screen = newlibadr(fd, NULL, win->screen);
|
||||
|
||||
for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
|
||||
lib_link_area(fd, &wm->id, area);
|
||||
}
|
||||
}
|
||||
|
||||
wm->id.tag &= ~LIB_TAG_NEED_LINK;
|
||||
@@ -6927,7 +6962,7 @@ static void lib_link_screen(FileData *fd, Main *main)
|
||||
sc->scrubbing = false;
|
||||
|
||||
for (ScrArea *area = sc->areabase.first; area; area = area->next) {
|
||||
lib_link_area(fd, sc, area);
|
||||
lib_link_area(fd, &sc->id, area);
|
||||
}
|
||||
sc->id.tag &= ~LIB_TAG_NEED_LINK;
|
||||
}
|
||||
@@ -7353,14 +7388,8 @@ void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions)
|
||||
|
||||
static bool direct_link_screen(FileData *fd, bScreen *sc)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ScrVert *sv;
|
||||
ScrEdge *se;
|
||||
bool wrong_id = false;
|
||||
|
||||
link_list(fd, &(sc->vertbase));
|
||||
link_list(fd, &(sc->edgebase));
|
||||
link_list(fd, &(sc->areabase));
|
||||
sc->regionbase.first = sc->regionbase.last= NULL;
|
||||
sc->context = NULL;
|
||||
sc->active_region = NULL;
|
||||
@@ -7368,27 +7397,10 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
|
||||
|
||||
sc->preview = direct_link_preview_image(fd, sc->preview);
|
||||
|
||||
/* edges */
|
||||
for (se = sc->edgebase.first; se; se = se->next) {
|
||||
se->v1 = newdataadr(fd, se->v1);
|
||||
se->v2 = newdataadr(fd, se->v2);
|
||||
if ((intptr_t)se->v1 > (intptr_t)se->v2) {
|
||||
sv = se->v1;
|
||||
se->v1 = se->v2;
|
||||
se->v2 = sv;
|
||||
}
|
||||
|
||||
if (se->v1 == NULL) {
|
||||
if (!direct_link_area_map(fd, AREAMAP_FROM_SCREEN(sc))) {
|
||||
printf("Error reading Screen %s... removing it.\n", sc->id.name + 2);
|
||||
BLI_remlink(&sc->edgebase, se);
|
||||
wrong_id = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* areas */
|
||||
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
direct_link_area(fd, sa);
|
||||
}
|
||||
|
||||
return wrong_id;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_workspace.h"
|
||||
|
||||
#include "BLO_readfile.h"
|
||||
@@ -945,4 +946,60 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!DNA_struct_find(fd->filesdna, "SpaceTopBar")) {
|
||||
/* Remove info editor, but only if at the top of the window. */
|
||||
for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
|
||||
/* Calculate window width/height from screen vertices */
|
||||
int win_width = 0, win_height = 0;
|
||||
for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
|
||||
win_width = MAX2(win_width, vert->vec.x);
|
||||
win_height = MAX2(win_height, vert->vec.y);
|
||||
}
|
||||
|
||||
for (ScrArea *area = screen->areabase.first, *area_next; area; area = area_next) {
|
||||
area_next = area->next;
|
||||
|
||||
if (area->spacetype == SPACE_INFO) {
|
||||
if ((area->v2->vec.y == win_height) && (area->v1->vec.x == 0) && (area->v4->vec.x == win_width)) {
|
||||
BKE_screen_area_free(area);
|
||||
|
||||
BLI_remlink(&screen->areabase, area);
|
||||
|
||||
BKE_screen_remove_double_scredges(screen);
|
||||
BKE_screen_remove_unused_scredges(screen);
|
||||
BKE_screen_remove_unused_scrverts(screen);
|
||||
|
||||
MEM_freeN(area);
|
||||
}
|
||||
}
|
||||
/* AREA_TEMP_INFO is deprecated from now on, it should only be set for info areas
|
||||
* which are deleted above, so don't need to unset it. Its slot/bit can be reused */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
if (!MAIN_VERSION_ATLEAST(main, 280, TO_BE_DETERMINED)) {
|
||||
/* Remove tool property regions. */
|
||||
for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
if (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
|
||||
ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
|
||||
|
||||
for (ARegion *region = regionbase->first, *region_next; region; region = region_next) {
|
||||
region_next = region->next;
|
||||
|
||||
if (region->regiontype == RGN_TYPE_TOOL_PROPS) {
|
||||
BKE_area_region_free(NULL, region);
|
||||
BLI_freelinkN(regionbase, region);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2878,8 +2878,12 @@ static void write_area_regions(WriteData *wd, ScrArea *area)
|
||||
writedata(wd, DATA, cl->len + 1, cl->line);
|
||||
}
|
||||
writestruct(wd, DATA, SpaceConsole, 1, sl);
|
||||
|
||||
}
|
||||
#ifdef WITH_TOPBAR_WRITING
|
||||
else if (sl->spacetype == SPACE_TOPBAR) {
|
||||
writestruct(wd, DATA, SpaceTopBar, 1, sl);
|
||||
}
|
||||
#endif
|
||||
else if (sl->spacetype == SPACE_USERPREF) {
|
||||
writestruct(wd, DATA, SpaceUserPref, 1, sl);
|
||||
}
|
||||
@@ -2890,7 +2894,21 @@ static void write_area_regions(WriteData *wd, ScrArea *area)
|
||||
writestruct(wd, DATA, SpaceInfo, 1, sl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_area_map(WriteData *wd, ScrAreaMap *area_map)
|
||||
{
|
||||
writelist(wd, DATA, ScrVert, &area_map->vertbase);
|
||||
writelist(wd, DATA, ScrEdge, &area_map->edgebase);
|
||||
for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
|
||||
writestruct(wd, DATA, ScrArea, 1, area);
|
||||
|
||||
#ifdef WITH_TOPBAR_WRITING
|
||||
writestruct(wd, DATA, ScrGlobalAreaData, 1, area->global);
|
||||
#endif
|
||||
|
||||
write_area_regions(wd, area);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_windowmanager(WriteData *wd, wmWindowManager *wm)
|
||||
@@ -2899,6 +2917,11 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm)
|
||||
write_iddata(wd, &wm->id);
|
||||
|
||||
for (wmWindow *win = wm->windows.first; win; win = win->next) {
|
||||
#ifndef WITH_TOPBAR_WRITING
|
||||
/* Don't write global areas yet, while we make changes to them. */
|
||||
ScrAreaMap global_areas = win->global_areas;
|
||||
memset(&win->global_areas, 0, sizeof(win->global_areas));
|
||||
#endif
|
||||
|
||||
/* update deprecated screen member (for so loading in 2.7x uses the correct screen) */
|
||||
win->screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
||||
@@ -2907,6 +2930,12 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm)
|
||||
writestruct(wd, DATA, WorkSpaceInstanceHook, 1, win->workspace_hook);
|
||||
writestruct(wd, DATA, Stereo3dFormat, 1, win->stereo3d_format);
|
||||
|
||||
#ifdef WITH_TOPBAR_WRITING
|
||||
write_area_map(wd, &win->global_areas);
|
||||
#else
|
||||
win->global_areas = global_areas;
|
||||
#endif
|
||||
|
||||
/* data is written, clear deprecated data again */
|
||||
win->screen = NULL;
|
||||
}
|
||||
@@ -2922,19 +2951,7 @@ static void write_screen(WriteData *wd, bScreen *sc)
|
||||
write_previews(wd, sc->preview);
|
||||
|
||||
/* direct data */
|
||||
for (ScrVert *sv = sc->vertbase.first; sv; sv = sv->next) {
|
||||
writestruct(wd, DATA, ScrVert, 1, sv);
|
||||
}
|
||||
|
||||
for (ScrEdge *se = sc->edgebase.first; se; se = se->next) {
|
||||
writestruct(wd, DATA, ScrEdge, 1, se);
|
||||
}
|
||||
|
||||
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
writestruct(wd, DATA, ScrArea, 1, sa);
|
||||
|
||||
write_area_regions(wd, sa);
|
||||
}
|
||||
write_area_map(wd, AREAMAP_FROM_SCREEN(sc));
|
||||
}
|
||||
|
||||
static void write_bone(WriteData *wd, Bone *bone)
|
||||
|
||||
@@ -56,6 +56,7 @@ if(WITH_BLENDER)
|
||||
add_subdirectory(space_sequencer)
|
||||
add_subdirectory(space_text)
|
||||
add_subdirectory(space_time)
|
||||
add_subdirectory(space_topbar)
|
||||
add_subdirectory(space_userpref)
|
||||
add_subdirectory(space_view3d)
|
||||
add_subdirectory(transform)
|
||||
|
||||
@@ -1450,7 +1450,7 @@ static void gp_convert_ui(bContext *C, wmOperator *op)
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
/* Main auto-draw call */
|
||||
uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
}
|
||||
|
||||
void GPENCIL_OT_convert(wmOperatorType *ot)
|
||||
|
||||
@@ -111,6 +111,11 @@ int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *bl
|
||||
void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
|
||||
void ED_area_exit(struct bContext *C, struct ScrArea *sa);
|
||||
int ED_screen_area_active(const struct bContext *C);
|
||||
void ED_screen_global_topbar_area_create(
|
||||
struct wmWindow *win,
|
||||
const struct bScreen *screen);
|
||||
void ED_screen_global_areas_create(
|
||||
struct wmWindow *win);
|
||||
void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene,
|
||||
struct WorkSpace *workspace);
|
||||
void ED_area_tag_redraw(ScrArea *sa);
|
||||
@@ -123,6 +128,23 @@ void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool s
|
||||
void ED_area_prevspace(struct bContext *C, ScrArea *sa);
|
||||
void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
|
||||
int ED_area_headersize(void);
|
||||
int ED_area_global_size_y(const ScrArea *area);
|
||||
bool ED_area_is_global(const ScrArea *area);
|
||||
int ED_region_global_size_y(void);
|
||||
|
||||
/** Iterate over all areas visible in the screen (screen as in everything visible in the window, not just bScreen) */
|
||||
#define ED_screen_areas_iter(win, screen, area_name) \
|
||||
for (ScrArea *area_name = (win)->global_areas.areabase.first ? \
|
||||
(win)->global_areas.areabase.first : \
|
||||
screen->areabase.first; \
|
||||
area_name != NULL; \
|
||||
area_name = (area_name == (win)->global_areas.areabase.last) ? (screen)->areabase.first : area_name->next)
|
||||
#define ED_screen_verts_iter(win, screen, vert_name) \
|
||||
for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \
|
||||
(win)->global_areas.vertbase.first : \
|
||||
screen->vertbase.first; \
|
||||
vert_name != NULL; \
|
||||
vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : vert_name->next)
|
||||
|
||||
/* screens */
|
||||
void ED_screens_initialize(struct wmWindowManager *wm);
|
||||
@@ -130,6 +152,7 @@ void ED_screen_draw_edges(struct wmWindow *win);
|
||||
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
|
||||
void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
|
||||
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
|
||||
void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen);
|
||||
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
|
||||
bool ED_screen_change(struct bContext *C, struct bScreen *sc);
|
||||
void ED_screen_update_after_scene_change(
|
||||
|
||||
@@ -58,6 +58,7 @@ void ED_spacetype_logic(void);
|
||||
void ED_spacetype_console(void);
|
||||
void ED_spacetype_userpref(void);
|
||||
void ED_spacetype_clip(void);
|
||||
void ED_spacetype_topbar(void);
|
||||
|
||||
/* calls for instancing and freeing spacetype static data
|
||||
* called in WM_init_exit */
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __ED_UNDO_H__
|
||||
#define __ED_UNDO_H__
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
struct bContext;
|
||||
struct CLG_LogRef;
|
||||
struct wmOperator;
|
||||
@@ -50,6 +52,16 @@ int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op);
|
||||
void ED_undo_operator_repeat_cb(struct bContext *C, void *arg_op, void *arg_unused);
|
||||
void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg_unused);
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
/* Context sanity helpers for operator repeat. */
|
||||
typedef struct OperatorRepeatContextHandle OperatorRepeatContextHandle;
|
||||
|
||||
const OperatorRepeatContextHandle *ED_operator_repeat_prepare_context(
|
||||
struct bContext *C, struct wmOperator *op) ATTR_WARN_UNUSED_RESULT;
|
||||
void ED_operator_repeat_reset_context(
|
||||
struct bContext *C, const OperatorRepeatContextHandle *context_info);
|
||||
#endif
|
||||
|
||||
bool ED_undo_is_valid(const struct bContext *C, const char *undoname);
|
||||
|
||||
struct UndoStack *ED_undo_stack_get(void);
|
||||
|
||||
@@ -31,11 +31,10 @@
|
||||
#ifndef __ED_UTIL_H__
|
||||
#define __ED_UTIL_H__
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
struct bContext;
|
||||
struct wmOperatorType;
|
||||
struct ScrArea;
|
||||
struct SpaceLink;
|
||||
struct PackedFile;
|
||||
|
||||
/* ed_util.c */
|
||||
|
||||
|
||||
@@ -699,8 +699,30 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDP
|
||||
void *arg, int retval, int icon, int maxlen, int x, int y,
|
||||
short width, short height, float a1, float a2, const char *tip);
|
||||
|
||||
|
||||
/* For uiDefAutoButsRNA */
|
||||
typedef enum {
|
||||
/* Keep current layout for aligning label with property button. */
|
||||
UI_BUT_LABEL_ALIGN_NONE,
|
||||
/* Align label and property button vertically. */
|
||||
UI_BUT_LABEL_ALIGN_COLUMN,
|
||||
/* Split layout into a column for the label and one for property button. */
|
||||
UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
|
||||
} eButLabelAlign;
|
||||
|
||||
/* Return info for uiDefAutoButsRNA */
|
||||
typedef enum {
|
||||
/* Returns when no buttons were added */
|
||||
UI_PROP_BUTS_NONE_ADDED = (1 << 0),
|
||||
/* Returned when any property failed the custom check callback (check_prop) */
|
||||
UI_PROP_BUTS_ANY_FAILED_CHECK = (1 << 1),
|
||||
} eAutoPropButsReturn;
|
||||
|
||||
uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2);
|
||||
int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align);
|
||||
eAutoPropButsReturn uiDefAutoButsRNA(
|
||||
uiLayout *layout, struct PointerRNA *ptr,
|
||||
bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
|
||||
eButLabelAlign label_align, const bool compact);
|
||||
|
||||
/* use inside searchfunc to add items */
|
||||
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid);
|
||||
@@ -836,6 +858,7 @@ void UI_exit(void);
|
||||
#define UI_LAYOUT_ALIGN_CENTER 2
|
||||
#define UI_LAYOUT_ALIGN_RIGHT 3
|
||||
|
||||
#define UI_ITEM_O_RETURN_PROPS (1 << 0)
|
||||
#define UI_ITEM_R_EXPAND (1 << 1)
|
||||
#define UI_ITEM_R_SLIDER (1 << 2)
|
||||
#define UI_ITEM_R_TOGGLE (1 << 3)
|
||||
@@ -845,10 +868,15 @@ void UI_exit(void);
|
||||
#define UI_ITEM_R_NO_BG (1 << 7)
|
||||
#define UI_ITEM_R_IMMEDIATE (1 << 8)
|
||||
#define UI_ITEM_O_DEPRESS (1 << 9)
|
||||
#define UI_ITEM_R_COMPACT (1 << 10)
|
||||
|
||||
/* uiTemplateOperatorPropertyButs flags */
|
||||
#define UI_TEMPLATE_OP_PROPS_SHOW_TITLE 1
|
||||
#define UI_TEMPLATE_OP_PROPS_SHOW_EMPTY 2
|
||||
|
||||
/* uiLayoutOperatorButs flags */
|
||||
enum {
|
||||
UI_TEMPLATE_OP_PROPS_SHOW_TITLE = (1 << 0),
|
||||
UI_TEMPLATE_OP_PROPS_SHOW_EMPTY = (1 << 1),
|
||||
UI_TEMPLATE_OP_PROPS_COMPACT = (1 << 2),
|
||||
};
|
||||
|
||||
/* used for transp checkers */
|
||||
#define UI_ALPHA_CHECKER_DARK 100
|
||||
@@ -931,6 +959,11 @@ void uiTemplateIDBrowse(
|
||||
void uiTemplateIDPreview(
|
||||
uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
|
||||
const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter);
|
||||
void uiTemplateIDTabs(
|
||||
uiLayout *layout, struct bContext *C,
|
||||
PointerRNA *ptr, const char *propname,
|
||||
const char *newop, const char *openop, const char *unlinkop,
|
||||
int filter);
|
||||
void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
|
||||
const char *proptypename, const char *text);
|
||||
void uiTemplateSearch(
|
||||
@@ -947,6 +980,9 @@ void uiTemplateSearchPreview(
|
||||
void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
|
||||
struct PointerRNA *root_ptr, const char *text);
|
||||
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
void uiTemplateOperatorRedoProperties(uiLayout *layout, struct bContext *C);
|
||||
#endif
|
||||
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
|
||||
void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
|
||||
struct MTex *slot, const char *preview_id);
|
||||
@@ -971,9 +1007,10 @@ void uiTemplateImageInfo(uiLayout *layout, struct bContext *C, struct Image *ima
|
||||
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
|
||||
void UI_but_func_operator_search(uiBut *but);
|
||||
void uiTemplateOperatorSearch(uiLayout *layout);
|
||||
void uiTemplateOperatorPropertyButs(const struct bContext *C, uiLayout *layout, struct wmOperator *op,
|
||||
eAutoPropButsReturn uiTemplateOperatorPropertyButs(
|
||||
const struct bContext *C, uiLayout *layout, struct wmOperator *op,
|
||||
bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
|
||||
const char label_align, const short flag);
|
||||
const eButLabelAlign label_align, const short flag);
|
||||
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
|
||||
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
|
||||
|
||||
@@ -51,7 +51,7 @@ typedef enum {
|
||||
/* use to denote intentionally unset theme color */
|
||||
#define TH_UNDEFINED -1
|
||||
|
||||
enum {
|
||||
typedef enum ThemeColorID {
|
||||
TH_REDALERT,
|
||||
|
||||
TH_THEMEUI,
|
||||
@@ -308,7 +308,7 @@ enum {
|
||||
|
||||
TH_EDGE_BEVEL,
|
||||
TH_VERTEX_BEVEL
|
||||
};
|
||||
} ThemeColorID;
|
||||
|
||||
/* specific defines per space should have higher define values */
|
||||
|
||||
|
||||
@@ -1193,7 +1193,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
|
||||
if (block->layouts.first) {
|
||||
UI_block_layout_resolve(block, NULL, NULL);
|
||||
}
|
||||
ui_block_align_calc(block);
|
||||
ui_block_align_calc(block, CTX_wm_region(C));
|
||||
if ((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) {
|
||||
ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
|
||||
}
|
||||
@@ -1420,7 +1420,6 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
|
||||
break;
|
||||
case UI_BTYPE_ROW:
|
||||
case UI_BTYPE_LISTROW:
|
||||
case UI_BTYPE_TAB:
|
||||
UI_GET_BUT_VALUE_INIT(but, *value);
|
||||
/* support for rna enum buts */
|
||||
if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
|
||||
@@ -1430,6 +1429,18 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
|
||||
if (*value == (double)but->hardmax) is_push = true;
|
||||
}
|
||||
break;
|
||||
case UI_BTYPE_TAB:
|
||||
if (but->rnaprop && but->custom_data) {
|
||||
/* uiBut.custom_data points to data this tab represents (e.g. workspace).
|
||||
* uiBut.rnapoin/prop store an active value (e.g. active workspace). */
|
||||
if (RNA_property_type(but->rnaprop) == PROP_POINTER) {
|
||||
PointerRNA active_ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
|
||||
if (active_ptr.data == but->custom_data) {
|
||||
is_push = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
is_push = -1;
|
||||
break;
|
||||
@@ -1915,7 +1926,7 @@ static bool ui_but_icon_extra_is_visible_text_clear(const uiBut *but)
|
||||
|
||||
static bool ui_but_icon_extra_is_visible_search_unlink(const uiBut *but)
|
||||
{
|
||||
BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
|
||||
BLI_assert(ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB));
|
||||
return ((but->editstr == NULL) &&
|
||||
(but->drawstr[0] != '\0') &&
|
||||
(but->flag & UI_BUT_VALUE_CLEAR));
|
||||
@@ -1958,6 +1969,11 @@ uiButExtraIconType ui_but_icon_extra_get(uiBut *but)
|
||||
return UI_BUT_ICONEXTRA_EYEDROPPER;
|
||||
}
|
||||
break;
|
||||
case UI_BTYPE_TAB:
|
||||
if (ui_but_icon_extra_is_visible_search_unlink(but)) {
|
||||
return UI_BUT_ICONEXTRA_CLEAR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2071,14 +2087,23 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
|
||||
*r_use_exp_float = false;
|
||||
}
|
||||
|
||||
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
||||
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB)) {
|
||||
PropertyType type;
|
||||
const char *buf = NULL;
|
||||
int buf_len;
|
||||
|
||||
type = RNA_property_type(but->rnaprop);
|
||||
|
||||
if (type == PROP_STRING) {
|
||||
if ((but->type == UI_BTYPE_TAB) && (but->custom_data)) {
|
||||
StructRNA *ptr_type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
|
||||
PointerRNA ptr;
|
||||
|
||||
/* uiBut.custom_data points to data this tab represents (e.g. workspace).
|
||||
* uiBut.rnapoin/prop store an active value (e.g. active workspace). */
|
||||
RNA_pointer_create(but->rnapoin.id.data, ptr_type, but->custom_data, &ptr);
|
||||
buf = RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
|
||||
}
|
||||
else if (type == PROP_STRING) {
|
||||
/* RNA string */
|
||||
buf = RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
|
||||
}
|
||||
@@ -2114,12 +2139,7 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
|
||||
MEM_freeN((void *)buf);
|
||||
}
|
||||
}
|
||||
else if (but->type == UI_BTYPE_TEXT) {
|
||||
/* string */
|
||||
BLI_strncpy(str, but->poin, maxlen);
|
||||
return;
|
||||
}
|
||||
else if (but->type == UI_BTYPE_SEARCH_MENU) {
|
||||
else if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
||||
/* string */
|
||||
BLI_strncpy(str, but->poin, maxlen);
|
||||
return;
|
||||
@@ -2329,17 +2349,15 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
||||
return true;
|
||||
}
|
||||
else if (type == PROP_POINTER) {
|
||||
/* RNA pointer */
|
||||
PointerRNA ptr, rptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
if (str[0] == '\0') {
|
||||
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
ptr = but->rnasearchpoin;
|
||||
prop = but->rnasearchprop;
|
||||
/* RNA pointer */
|
||||
PointerRNA rptr;
|
||||
PointerRNA ptr = but->rnasearchpoin;
|
||||
PropertyRNA *prop = but->rnasearchprop;
|
||||
|
||||
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr))
|
||||
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
|
||||
@@ -2362,6 +2380,21 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (but->type == UI_BTYPE_TAB) {
|
||||
if (but->rnaprop && but->custom_data) {
|
||||
StructRNA *ptr_type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* uiBut.custom_data points to data this tab represents (e.g. workspace).
|
||||
* uiBut.rnapoin/prop store an active value (e.g. active workspace). */
|
||||
RNA_pointer_create(but->rnapoin.id.data, ptr_type, but->custom_data, &ptr);
|
||||
prop = RNA_struct_name_property(ptr_type);
|
||||
if (RNA_property_editable(&ptr, prop)) {
|
||||
RNA_property_string_set(&ptr, prop, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (but->type == UI_BTYPE_TEXT) {
|
||||
/* string */
|
||||
if (!but->poin || (str[0] == '\0')) {
|
||||
@@ -2907,6 +2940,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
|
||||
|
||||
case UI_BTYPE_TEXT:
|
||||
case UI_BTYPE_SEARCH_MENU:
|
||||
case UI_BTYPE_TAB:
|
||||
if (!but->editstr) {
|
||||
char str[UI_MAX_DRAW_STR];
|
||||
|
||||
@@ -3030,6 +3064,16 @@ void ui_block_cm_to_display_space_range(uiBlock *block, float *min, float *max)
|
||||
*max = max_fff(UNPACK3(pixel));
|
||||
}
|
||||
|
||||
static uiBut *ui_but_alloc(const eButType type)
|
||||
{
|
||||
switch (type) {
|
||||
case UI_BTYPE_TAB:
|
||||
return MEM_callocN(sizeof(uiButTab), "uiButTab");
|
||||
default:
|
||||
return MEM_callocN(sizeof(uiBut), "uiBut");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief ui_def_but is the function that draws many button types
|
||||
*
|
||||
@@ -3063,7 +3107,7 @@ static uiBut *ui_def_but(
|
||||
}
|
||||
}
|
||||
|
||||
but = MEM_callocN(sizeof(uiBut), "uiBut");
|
||||
but = ui_but_alloc(type & BUTTYPE);
|
||||
|
||||
but->type = type & BUTTYPE;
|
||||
but->pointype = type & UI_BUT_POIN_TYPES;
|
||||
|
||||
@@ -320,13 +320,43 @@ static int ui_block_align_butal_cmp(const void *a, const void *b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ui_block_align_but_to_region(uiBut *but, const ARegion *region)
|
||||
{
|
||||
rctf *rect = &but->rect;
|
||||
const float but_width = BLI_rctf_size_x(rect);
|
||||
const float but_height = BLI_rctf_size_y(rect);
|
||||
const float px = U.pixelsize;
|
||||
|
||||
switch (but->drawflag & UI_BUT_ALIGN) {
|
||||
case UI_BUT_ALIGN_TOP:
|
||||
rect->ymax = region->winy + px;
|
||||
rect->ymin = but->rect.ymax - but_height;
|
||||
break;
|
||||
case UI_BUT_ALIGN_DOWN:
|
||||
rect->ymin = -px;
|
||||
rect->ymax = rect->ymin + but_height;
|
||||
break;
|
||||
case UI_BUT_ALIGN_LEFT:
|
||||
rect->xmin = -px;
|
||||
rect->xmax = rect->xmin + but_width;
|
||||
break;
|
||||
case UI_BUT_ALIGN_RIGHT:
|
||||
rect->xmax = region->winx + px;
|
||||
rect->xmin = rect->xmax - but_width;
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the alignment of all 'align groups' of buttons in given block.
|
||||
*
|
||||
* This is using an order-independent algorithm, i.e. alignment of buttons should be OK regardless of order in which
|
||||
* they are added to the block.
|
||||
*/
|
||||
void ui_block_align_calc(uiBlock *block)
|
||||
void ui_block_align_calc(uiBlock *block, const ARegion *region)
|
||||
{
|
||||
uiBut *but;
|
||||
int num_buttons = 0;
|
||||
@@ -338,10 +368,17 @@ void ui_block_align_calc(uiBlock *block)
|
||||
int side;
|
||||
int i, j;
|
||||
|
||||
/* First loop: we count number of buttons belonging to an align group, and clear their align flag. */
|
||||
/* First loop: we count number of buttons belonging to an align group, and clear their align flag.
|
||||
* Tabs get some special treatment here, they get aligned to region border. */
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
/* special case: tabs need to be aligned to a region border, drawflag tells which one */
|
||||
if (but->type == UI_BTYPE_TAB) {
|
||||
ui_block_align_but_to_region(but, region);
|
||||
}
|
||||
else {
|
||||
/* Clear old align flags. */
|
||||
but->drawflag &= ~UI_BUT_ALIGN_ALL;
|
||||
}
|
||||
|
||||
if (but->alignnr != 0) {
|
||||
num_buttons++;
|
||||
|
||||
@@ -931,6 +931,20 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
data->applied = true;
|
||||
}
|
||||
|
||||
static void ui_apply_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
{
|
||||
if (data->str) {
|
||||
ui_but_string_set(C, but, data->str);
|
||||
ui_but_update_edited(but);
|
||||
}
|
||||
else {
|
||||
ui_apply_but_func(C, but);
|
||||
}
|
||||
|
||||
data->retval = but->retval;
|
||||
data->applied = true;
|
||||
}
|
||||
|
||||
static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
{
|
||||
if (data->str) {
|
||||
@@ -1892,9 +1906,11 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
|
||||
break;
|
||||
case UI_BTYPE_ROW:
|
||||
case UI_BTYPE_LISTROW:
|
||||
case UI_BTYPE_TAB:
|
||||
ui_apply_but_ROW(C, block, but, data);
|
||||
break;
|
||||
case UI_BTYPE_TAB:
|
||||
ui_apply_but_TAB(C, but, data);
|
||||
break;
|
||||
case UI_BTYPE_SCROLL:
|
||||
case UI_BTYPE_GRIP:
|
||||
case UI_BTYPE_NUM:
|
||||
@@ -3649,18 +3665,6 @@ static int ui_do_but_KEYEVT(
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
static int ui_do_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
|
||||
{
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, const int mouse_xy[2])
|
||||
{
|
||||
int x = mouse_xy[0], y = mouse_xy[1];
|
||||
@@ -3676,6 +3680,43 @@ static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, c
|
||||
return BLI_rcti_isect_pt(&icon_rect, x, y);
|
||||
}
|
||||
|
||||
static int ui_do_but_TAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
|
||||
{
|
||||
if (data->state == BUTTON_STATE_HIGHLIGHT) {
|
||||
if ((event->type == LEFTMOUSE) &&
|
||||
((event->val == KM_DBL_CLICK) || event->ctrl))
|
||||
{
|
||||
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
else if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && (event->val == KM_CLICK)) {
|
||||
const bool has_icon_extra = ui_but_icon_extra_get(but) == UI_BUT_ICONEXTRA_CLEAR;
|
||||
|
||||
if (has_icon_extra && ui_but_is_mouse_over_icon_extra(data->region, but, &event->x)) {
|
||||
uiButTab *tab = (uiButTab *)but;
|
||||
wmOperatorType *ot_backup = but->optype;
|
||||
|
||||
but->optype = tab->unlink_ot;
|
||||
/* Force calling unlink/delete operator. */
|
||||
ui_apply_but(C, block, but, data, true);
|
||||
but->optype = ot_backup;
|
||||
}
|
||||
button_activate_state(C, but, BUTTON_STATE_EXIT);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
}
|
||||
else if (data->state == BUTTON_STATE_TEXT_EDITING) {
|
||||
ui_do_but_textedit(C, block, but, data, event);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
|
||||
ui_do_but_textedit_select(C, block, but, data, event);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
return WM_UI_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
static int ui_do_but_TEX(
|
||||
bContext *C, uiBlock *block, uiBut *but,
|
||||
uiHandleButtonData *data, const wmEvent *event)
|
||||
@@ -6946,7 +6987,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
|
||||
retval = ui_do_but_HOTKEYEVT(C, but, data, event);
|
||||
break;
|
||||
case UI_BTYPE_TAB:
|
||||
retval = ui_do_but_TAB(C, but, data, event);
|
||||
retval = ui_do_but_TAB(C, block, but, data, event);
|
||||
break;
|
||||
case UI_BTYPE_BUT_TOGGLE:
|
||||
case UI_BTYPE_TOGGLE:
|
||||
@@ -7216,12 +7257,11 @@ bool ui_but_is_active(ARegion *ar)
|
||||
/* is called by notifier */
|
||||
void UI_screen_free_active_but(const bContext *C, bScreen *screen)
|
||||
{
|
||||
ScrArea *sa = screen->areabase.first;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
for (; sa; sa = sa->next) {
|
||||
ARegion *ar = sa->regionbase.first;
|
||||
for (; ar; ar = ar->next) {
|
||||
uiBut *but = ui_but_find_active_in_region(ar);
|
||||
ED_screen_areas_iter(win, screen, area) {
|
||||
for (ARegion *region = area->regionbase.first; region; region = region->next) {
|
||||
uiBut *but = ui_but_find_active_in_region(region);
|
||||
if (but) {
|
||||
uiHandleButtonData *data = but->active;
|
||||
|
||||
|
||||
@@ -330,6 +330,11 @@ struct uiBut {
|
||||
uiBlock *block;
|
||||
};
|
||||
|
||||
typedef struct uiButTab {
|
||||
uiBut but;
|
||||
struct wmOperatorType *unlink_ot;
|
||||
} uiButTab;
|
||||
|
||||
typedef struct ColorPicker {
|
||||
struct ColorPicker *next, *prev;
|
||||
float color_data[3]; /* colr data may be HSV or HSL for now */
|
||||
@@ -773,7 +778,7 @@ void ui_layout_list_set_labels_active(uiLayout *layout);
|
||||
|
||||
/* interface_align.c */
|
||||
bool ui_but_can_align(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
void ui_block_align_calc(uiBlock *block);
|
||||
void ui_block_align_calc(uiBlock *block, const ARegion *region);
|
||||
|
||||
/* interface_anim.c */
|
||||
void ui_but_anim_flag(uiBut *but, float cfra);
|
||||
|
||||
@@ -392,7 +392,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
|
||||
static void ui_item_array(
|
||||
uiLayout *layout, uiBlock *block, const char *name, int icon,
|
||||
PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h),
|
||||
bool expand, bool slider, bool toggle, bool icon_only)
|
||||
bool expand, bool slider, bool toggle, bool icon_only, bool compact)
|
||||
{
|
||||
uiStyle *style = layout->root->style;
|
||||
uiBut *but;
|
||||
@@ -541,9 +541,18 @@ static void ui_item_array(
|
||||
}
|
||||
|
||||
for (a = 0; a < len; a++) {
|
||||
if (!icon_only) str[0] = RNA_property_array_item_char(prop, a);
|
||||
if (boolarr) icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
||||
but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y);
|
||||
int width_item;
|
||||
|
||||
if (!icon_only) {
|
||||
str[0] = RNA_property_array_item_char(prop, a);
|
||||
}
|
||||
if (boolarr) {
|
||||
icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
||||
}
|
||||
width_item = (compact && type == PROP_BOOLEAN) ?
|
||||
min_ii(w, ui_text_icon_width(layout, str, icon, false)) : w;
|
||||
|
||||
but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, width_item, UI_UNIT_Y);
|
||||
if (slider && but->type == UI_BTYPE_NUM)
|
||||
but->type = UI_BTYPE_NUM_SLIDER;
|
||||
if (toggle && but->type == UI_BTYPE_CHECKBOX)
|
||||
@@ -669,27 +678,38 @@ static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_
|
||||
RNA_boolean_set(&but->rnapoin, "oskey", (but->modifier_key & KM_OSKEY) != 0);
|
||||
}
|
||||
|
||||
/* create label + button for RNA property */
|
||||
static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag)
|
||||
/**
|
||||
* Create label + button for RNA property
|
||||
*
|
||||
* \param w_hint: For varying width layout, this becomes the label width.
|
||||
* Otherwise it's used to fit both items into it.
|
||||
**/
|
||||
static uiBut *ui_item_with_label(
|
||||
uiLayout *layout, uiBlock *block, const char *name, int icon,
|
||||
PointerRNA *ptr, PropertyRNA *prop, int index,
|
||||
int x, int y, int w_hint, int h, int flag)
|
||||
{
|
||||
uiLayout *sub;
|
||||
uiBut *but = NULL;
|
||||
PropertyType type;
|
||||
PropertySubType subtype;
|
||||
int labelw;
|
||||
int prop_but_width = w_hint;
|
||||
|
||||
sub = uiLayoutRow(layout, layout->align);
|
||||
UI_block_layout_set_current(block, sub);
|
||||
|
||||
if (name[0]) {
|
||||
/* XXX UI_fontstyle_string_width is not accurate */
|
||||
#if 0
|
||||
labelw = UI_fontstyle_string_width(fstyle, name);
|
||||
CLAMP(labelw, w / 4, 3 * w / 4);
|
||||
#endif
|
||||
labelw = w / 3;
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, "");
|
||||
w = w - labelw;
|
||||
int w_label;
|
||||
|
||||
if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
|
||||
/* w_hint is width for label in this case. Use a default width for property button(s) */
|
||||
prop_but_width = UI_UNIT_X * 5;
|
||||
w_label = w_hint;
|
||||
}
|
||||
else {
|
||||
w_label = w_hint / 3;
|
||||
}
|
||||
uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
|
||||
}
|
||||
|
||||
type = RNA_property_type(prop);
|
||||
@@ -697,14 +717,14 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
|
||||
|
||||
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
|
||||
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
|
||||
but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h);
|
||||
but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
|
||||
|
||||
/* BUTTONS_OT_file_browse calls UI_context_active_but_prop_get_filebrowser */
|
||||
uiDefIconButO(block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse",
|
||||
WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
|
||||
}
|
||||
else if (flag & UI_ITEM_R_EVENT) {
|
||||
but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL);
|
||||
but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, prop_but_width, h, ptr, prop, index, 0, 0, -1, -1, NULL);
|
||||
}
|
||||
else if (flag & UI_ITEM_R_FULL_EVENT) {
|
||||
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
|
||||
@@ -712,14 +732,17 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
|
||||
|
||||
WM_keymap_item_to_string(ptr->data, false, buf, sizeof(buf));
|
||||
|
||||
but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
|
||||
but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, prop_but_width, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
|
||||
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
|
||||
if (flag & UI_ITEM_R_IMMEDIATE)
|
||||
UI_but_flag_enable(but, UI_BUT_IMMEDIATE);
|
||||
}
|
||||
}
|
||||
else
|
||||
but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "", icon, x, y, w, h);
|
||||
else {
|
||||
const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "";
|
||||
but = uiDefAutoButR(block, ptr, prop, index, str, icon,
|
||||
x, y, prop_but_width, h);
|
||||
}
|
||||
|
||||
UI_block_layout_set_current(block, layout);
|
||||
return but;
|
||||
@@ -1302,8 +1325,10 @@ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
|
||||
/* RNA property items */
|
||||
|
||||
static void ui_item_rna_size(
|
||||
uiLayout *layout, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop,
|
||||
int index, bool icon_only, int *r_w, int *r_h)
|
||||
uiLayout *layout, const char *name, int icon,
|
||||
PointerRNA *ptr, PropertyRNA *prop,
|
||||
int index, bool icon_only, bool compact,
|
||||
int *r_w, int *r_h)
|
||||
{
|
||||
PropertyType type;
|
||||
PropertySubType subtype;
|
||||
@@ -1329,7 +1354,7 @@ static void ui_item_rna_size(
|
||||
RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
|
||||
for (item = item_array; item->identifier; item++) {
|
||||
if (item->identifier[0]) {
|
||||
w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, 0));
|
||||
w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, compact));
|
||||
}
|
||||
}
|
||||
if (free) {
|
||||
@@ -1340,12 +1365,13 @@ static void ui_item_rna_size(
|
||||
|
||||
if (!w) {
|
||||
if (type == PROP_ENUM && icon_only) {
|
||||
w = ui_text_icon_width(layout, "", ICON_BLANK1, 0);
|
||||
w = ui_text_icon_width(layout, "", ICON_BLANK1, compact);
|
||||
if (index != RNA_ENUM_VALUE)
|
||||
w += 0.6f * UI_UNIT_X;
|
||||
}
|
||||
else {
|
||||
w = ui_text_icon_width(layout, name, icon, 0);
|
||||
/* not compact for float/int buttons, looks too squashed */
|
||||
w = ui_text_icon_width(layout, name, icon, ELEM(type, PROP_FLOAT, PROP_INT) ? false : compact);
|
||||
}
|
||||
}
|
||||
h = UI_UNIT_Y;
|
||||
@@ -1382,7 +1408,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
PropertyType type;
|
||||
char namestr[UI_MAX_NAME_STR];
|
||||
int len, w, h;
|
||||
bool slider, toggle, expand, icon_only, no_bg;
|
||||
bool slider, toggle, expand, icon_only, no_bg, compact;
|
||||
bool is_array;
|
||||
|
||||
UI_block_layout_set_current(block, layout);
|
||||
@@ -1415,8 +1441,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
name = ui_item_name_add_colon(name, namestr);
|
||||
}
|
||||
else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) {
|
||||
if (flag & UI_ITEM_R_COMPACT) {
|
||||
name = "";
|
||||
}
|
||||
else {
|
||||
name = ui_item_name_add_colon(name, namestr);
|
||||
}
|
||||
}
|
||||
|
||||
/* menus and pie-menus don't show checkbox without this */
|
||||
if ((layout->root->type == UI_LAYOUT_MENU) ||
|
||||
@@ -1443,16 +1474,19 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
|
||||
expand = (flag & UI_ITEM_R_EXPAND) != 0;
|
||||
icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
|
||||
no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
|
||||
compact = (flag & UI_ITEM_R_COMPACT) != 0;
|
||||
|
||||
/* get size */
|
||||
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
|
||||
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
|
||||
|
||||
if (no_bg)
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
|
||||
/* array property */
|
||||
if (index == RNA_NO_INDEX && is_array)
|
||||
ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
|
||||
ui_item_array(
|
||||
layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
|
||||
expand, slider, toggle, icon_only, compact);
|
||||
/* enum item */
|
||||
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
|
||||
if (icon && name[0] && !icon_only)
|
||||
@@ -1641,6 +1675,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
|
||||
|
||||
/* Pointer RNA button with search */
|
||||
|
||||
|
||||
static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@@ -1771,7 +1806,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
|
||||
/* create button */
|
||||
block = uiLayoutGetBlock(layout);
|
||||
|
||||
ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, &w, &h);
|
||||
ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, false, &w, &h);
|
||||
w += UI_UNIT_X; /* X icon needs more space */
|
||||
but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
|
||||
|
||||
|
||||
@@ -120,7 +120,9 @@ static void template_add_button_search_menu(
|
||||
|
||||
if (use_previews) {
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
const bool use_big_size = (region->regiontype != RGN_TYPE_HEADER); /* silly check, could be more generic */
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
/* XXX ugly top-bar exception */
|
||||
const bool use_big_size = (region->regiontype != RGN_TYPE_HEADER) && (area->spacetype != SPACE_TOPBAR); /* silly check, could be more generic */
|
||||
/* Ugly exception for screens here, drawing their preview in icon size looks ugly/useless */
|
||||
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
|
||||
const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f);
|
||||
@@ -238,7 +240,7 @@ typedef struct TemplateID {
|
||||
} TemplateID;
|
||||
|
||||
/* Search browse menu, assign */
|
||||
static void id_search_call_cb(bContext *C, void *arg_template, void *item)
|
||||
static void template_ID_set_property_cb(bContext *C, void *arg_template, void *item)
|
||||
{
|
||||
TemplateID *template_ui = (TemplateID *)arg_template;
|
||||
|
||||
@@ -379,7 +381,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
||||
}
|
||||
|
||||
return template_common_search_menu(
|
||||
C, ar, id_search_cb_p, &template_ui, id_search_call_cb, active_item_ptr.data,
|
||||
C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data,
|
||||
template_ui.prv_rows, template_ui.prv_cols);
|
||||
}
|
||||
|
||||
@@ -570,6 +572,67 @@ static const char *template_id_context(StructRNA *type)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uiBut *template_id_def_new_but(
|
||||
uiBlock *block, const ID *id, const TemplateID *template_ui, StructRNA *type,
|
||||
const char * const newop, const bool editable, const bool id_open, const bool use_tab_but)
|
||||
{
|
||||
ID *idfrom = template_ui->ptr.id.data;
|
||||
uiBut *but;
|
||||
const int w = id ? UI_UNIT_X : id_open ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
|
||||
const int but_type = use_tab_but ? UI_BTYPE_TAB : UI_BTYPE_BUT;
|
||||
|
||||
/* i18n markup, does nothing! */
|
||||
BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
|
||||
BLT_I18NCONTEXT_ID_SCENE,
|
||||
BLT_I18NCONTEXT_ID_OBJECT,
|
||||
BLT_I18NCONTEXT_ID_MESH,
|
||||
BLT_I18NCONTEXT_ID_CURVE,
|
||||
BLT_I18NCONTEXT_ID_METABALL,
|
||||
BLT_I18NCONTEXT_ID_MATERIAL,
|
||||
BLT_I18NCONTEXT_ID_TEXTURE,
|
||||
BLT_I18NCONTEXT_ID_IMAGE,
|
||||
BLT_I18NCONTEXT_ID_LATTICE,
|
||||
BLT_I18NCONTEXT_ID_LAMP,
|
||||
BLT_I18NCONTEXT_ID_CAMERA,
|
||||
BLT_I18NCONTEXT_ID_WORLD,
|
||||
BLT_I18NCONTEXT_ID_SCREEN,
|
||||
BLT_I18NCONTEXT_ID_TEXT,
|
||||
);
|
||||
BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER,
|
||||
BLT_I18NCONTEXT_ID_SOUND,
|
||||
BLT_I18NCONTEXT_ID_ARMATURE,
|
||||
BLT_I18NCONTEXT_ID_ACTION,
|
||||
BLT_I18NCONTEXT_ID_NODETREE,
|
||||
BLT_I18NCONTEXT_ID_BRUSH,
|
||||
BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
|
||||
BLT_I18NCONTEXT_ID_GPENCIL,
|
||||
BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
|
||||
BLT_I18NCONTEXT_ID_WORKSPACE,
|
||||
BLT_I18NCONTEXT_ID_LIGHTPROBE,
|
||||
);
|
||||
|
||||
if (newop) {
|
||||
but = uiDefIconTextButO(block, but_type, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
|
||||
(id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
|
||||
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
||||
}
|
||||
else {
|
||||
but = uiDefIconTextBut(block, but_type, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
|
||||
0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
||||
}
|
||||
|
||||
if ((idfrom && idfrom->lib) || !editable) {
|
||||
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
||||
}
|
||||
|
||||
#ifndef WITH_INTERNATIONAL
|
||||
UNUSED_VARS(type);
|
||||
#endif
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
static void template_ID(
|
||||
bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag,
|
||||
const char *newop, const char *openop, const char *unlinkop)
|
||||
@@ -672,51 +735,7 @@ static void template_ID(
|
||||
}
|
||||
|
||||
if (flag & UI_ID_ADD_NEW) {
|
||||
int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
|
||||
|
||||
/* i18n markup, does nothing! */
|
||||
BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
|
||||
BLT_I18NCONTEXT_ID_SCENE,
|
||||
BLT_I18NCONTEXT_ID_OBJECT,
|
||||
BLT_I18NCONTEXT_ID_MESH,
|
||||
BLT_I18NCONTEXT_ID_CURVE,
|
||||
BLT_I18NCONTEXT_ID_METABALL,
|
||||
BLT_I18NCONTEXT_ID_MATERIAL,
|
||||
BLT_I18NCONTEXT_ID_TEXTURE,
|
||||
BLT_I18NCONTEXT_ID_IMAGE,
|
||||
BLT_I18NCONTEXT_ID_LATTICE,
|
||||
BLT_I18NCONTEXT_ID_LAMP,
|
||||
BLT_I18NCONTEXT_ID_CAMERA,
|
||||
BLT_I18NCONTEXT_ID_WORLD,
|
||||
BLT_I18NCONTEXT_ID_SCREEN,
|
||||
BLT_I18NCONTEXT_ID_TEXT,
|
||||
);
|
||||
BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER,
|
||||
BLT_I18NCONTEXT_ID_SOUND,
|
||||
BLT_I18NCONTEXT_ID_ARMATURE,
|
||||
BLT_I18NCONTEXT_ID_ACTION,
|
||||
BLT_I18NCONTEXT_ID_NODETREE,
|
||||
BLT_I18NCONTEXT_ID_BRUSH,
|
||||
BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
|
||||
BLT_I18NCONTEXT_ID_GPENCIL,
|
||||
BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
|
||||
BLT_I18NCONTEXT_ID_WORKSPACE,
|
||||
BLT_I18NCONTEXT_ID_LIGHTPROBE,
|
||||
);
|
||||
|
||||
if (newop) {
|
||||
but = uiDefIconTextButO(block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
|
||||
(id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
|
||||
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
||||
}
|
||||
else {
|
||||
but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
|
||||
0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
||||
}
|
||||
|
||||
if ((idfrom && idfrom->lib) || !editable)
|
||||
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
||||
template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false);
|
||||
}
|
||||
|
||||
/* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
|
||||
@@ -785,9 +804,57 @@ static void template_ID(
|
||||
UI_block_align_end(block);
|
||||
}
|
||||
|
||||
static void template_ID_tabs(
|
||||
bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag,
|
||||
const char *newop, const char *UNUSED(openop), const char *unlinkop)
|
||||
{
|
||||
const ARegion *region = CTX_wm_region(C);
|
||||
const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop);
|
||||
const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;
|
||||
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
uiStyle *style = UI_style_get_dpi();
|
||||
|
||||
|
||||
for (ID *id = template->idlb->first; id; id = id->next) {
|
||||
wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false);
|
||||
const bool is_active = active_ptr.data == id;
|
||||
const unsigned int but_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X +
|
||||
(is_active ? ICON_DEFAULT_WIDTH_SCALE : 0);
|
||||
uiButTab *tab;
|
||||
|
||||
tab = (uiButTab *)uiDefButR_prop(
|
||||
block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y,
|
||||
&template->ptr, template->prop, 0, 0.0f,
|
||||
sizeof(id->name) - 2, 0.0f, 0.0f, "");
|
||||
UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(template), id);
|
||||
tab->but.custom_data = (void *)id;
|
||||
tab->unlink_ot = unlink_ot;
|
||||
|
||||
if (is_active) {
|
||||
UI_but_flag_enable(&tab->but, UI_BUT_VALUE_CLEAR);
|
||||
}
|
||||
UI_but_drawflag_enable(&tab->but, but_align);
|
||||
}
|
||||
|
||||
if (flag & UI_ID_ADD_NEW) {
|
||||
const bool editable = RNA_property_editable(&template->ptr, template->prop);
|
||||
uiBut *but;
|
||||
|
||||
if (active_ptr.type) {
|
||||
type = active_ptr.type;
|
||||
}
|
||||
|
||||
but = template_id_def_new_but(block, active_ptr.data, template, type, newop, editable, flag & UI_ID_OPEN, true);
|
||||
UI_but_drawflag_enable(but, but_align);
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_template_id(
|
||||
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
||||
const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols, int filter)
|
||||
uiLayout *layout, bContext *C,
|
||||
PointerRNA *ptr, const char *propname,
|
||||
const char *newop, const char *openop, const char *unlinkop,
|
||||
int flag, int prv_rows, int prv_cols, int filter, bool use_tabs)
|
||||
{
|
||||
TemplateID *template_ui;
|
||||
PropertyRNA *prop;
|
||||
@@ -828,9 +895,15 @@ static void ui_template_id(
|
||||
* - template_ID makes a copy of the template data and assigns it to the relevant buttons
|
||||
*/
|
||||
if (template_ui->idlb) {
|
||||
if (use_tabs) {
|
||||
uiLayoutRow(layout, false);
|
||||
template_ID_tabs(C, layout, template_ui, type, flag, newop, openop, unlinkop);
|
||||
}
|
||||
else {
|
||||
uiLayoutRow(layout, true);
|
||||
template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(template_ui);
|
||||
}
|
||||
@@ -839,23 +912,49 @@ void uiTemplateID(
|
||||
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
||||
const char *openop, const char *unlinkop, int filter)
|
||||
{
|
||||
ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
|
||||
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0, filter);
|
||||
ui_template_id(
|
||||
layout, C, ptr, propname,
|
||||
newop, openop, unlinkop,
|
||||
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
|
||||
0, 0, filter, false);
|
||||
}
|
||||
|
||||
void uiTemplateIDBrowse(
|
||||
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
||||
const char *openop, const char *unlinkop, int filter)
|
||||
{
|
||||
ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, 0, 0, filter);
|
||||
ui_template_id(
|
||||
layout, C, ptr, propname,
|
||||
newop, openop, unlinkop,
|
||||
UI_ID_BROWSE | UI_ID_RENAME,
|
||||
0, 0, filter, false);
|
||||
}
|
||||
|
||||
void uiTemplateIDPreview(
|
||||
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
||||
const char *openop, const char *unlinkop, int rows, int cols, int filter)
|
||||
{
|
||||
ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
|
||||
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols, filter);
|
||||
ui_template_id(
|
||||
layout, C, ptr, propname,
|
||||
newop, openop, unlinkop,
|
||||
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS,
|
||||
rows, cols, filter, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of #uiTemplateID using tabs.
|
||||
*/
|
||||
void uiTemplateIDTabs(
|
||||
uiLayout *layout, bContext *C,
|
||||
PointerRNA *ptr, const char *propname,
|
||||
const char *newop, const char *openop, const char *unlinkop,
|
||||
int filter)
|
||||
{
|
||||
ui_template_id(
|
||||
layout, C, ptr, propname,
|
||||
newop, openop, unlinkop,
|
||||
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
|
||||
0, 0, filter, true);
|
||||
}
|
||||
|
||||
/************************ ID Chooser Template ***************************/
|
||||
@@ -1429,6 +1528,63 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/************************ Redo Buttons Template *************************/
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
static bool template_operator_redo_property_buts_poll(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
|
||||
{
|
||||
return (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED) == 0;
|
||||
}
|
||||
|
||||
static void template_operator_redo_property_buts_draw(
|
||||
const bContext *C, wmOperator *op,
|
||||
uiLayout *layout, int layout_flags,
|
||||
bool *r_has_advanced)
|
||||
{
|
||||
if (op->type->flag & OPTYPE_MACRO) {
|
||||
for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) {
|
||||
template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Might want to make label_align adjustable somehow. */
|
||||
eAutoPropButsReturn return_info = uiTemplateOperatorPropertyButs(
|
||||
C, layout, op, template_operator_redo_property_buts_poll,
|
||||
UI_BUT_LABEL_ALIGN_NONE, layout_flags);
|
||||
if (return_info & UI_PROP_BUTS_ANY_FAILED_CHECK) {
|
||||
*r_has_advanced = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uiTemplateOperatorRedoProperties(uiLayout *layout, bContext *C)
|
||||
{
|
||||
wmOperator *op = WM_operator_last_redo(C);
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
|
||||
if (op == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Repeat button with operator name as text. */
|
||||
uiItemFullO(layout, "SCREEN_OT_repeat_last", RNA_struct_ui_name(op->type->srna),
|
||||
ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
|
||||
|
||||
if (WM_operator_repeat_check(C, op)) {
|
||||
bool has_advanced = false;
|
||||
|
||||
UI_block_func_set(block, ED_undo_operator_repeat_cb, op, NULL);
|
||||
template_operator_redo_property_buts_draw(C, op, layout, UI_TEMPLATE_OP_PROPS_COMPACT, &has_advanced);
|
||||
UI_block_func_set(block, NULL, NULL, NULL); /* may want to reset to old state instead of NULLing all */
|
||||
|
||||
if (has_advanced) {
|
||||
uiItemO(layout, IFACE_("More..."), ICON_NONE, "SCREEN_OT_redo_last");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************ Constraint Template *************************/
|
||||
|
||||
#include "DNA_constraint_types.h"
|
||||
@@ -3716,11 +3872,14 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt,
|
||||
* Draw Operator property buttons for redoing execution with different settings.
|
||||
* This function does not initialize the layout, functions can be called on the layout before and after.
|
||||
*/
|
||||
void uiTemplateOperatorPropertyButs(
|
||||
eAutoPropButsReturn uiTemplateOperatorPropertyButs(
|
||||
const bContext *C, uiLayout *layout, wmOperator *op,
|
||||
bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
|
||||
const char label_align, const short flag)
|
||||
const eButLabelAlign label_align, const short flag)
|
||||
{
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
eAutoPropButsReturn return_info = 0;
|
||||
|
||||
if (!op->properties) {
|
||||
IDPropertyTemplate val = {0};
|
||||
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
|
||||
@@ -3733,14 +3892,14 @@ void uiTemplateOperatorPropertyButs(
|
||||
/* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
|
||||
* just fails silently */
|
||||
if (!WM_operator_repeat_check(C, op)) {
|
||||
UI_block_lock_set(uiLayoutGetBlock(layout), true, "Operator can't' redo");
|
||||
UI_block_lock_set(block, true, "Operator can't' redo");
|
||||
|
||||
/* XXX, could give some nicer feedback or not show redo panel at all? */
|
||||
uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE);
|
||||
}
|
||||
else {
|
||||
/* useful for macros where only one of the steps can't be re-done */
|
||||
UI_block_lock_clear(uiLayoutGetBlock(layout));
|
||||
UI_block_lock_clear(block);
|
||||
}
|
||||
|
||||
/* menu */
|
||||
@@ -3749,7 +3908,7 @@ void uiTemplateOperatorPropertyButs(
|
||||
PointerRNA op_ptr;
|
||||
uiLayout *row;
|
||||
|
||||
uiLayoutGetBlock(layout)->ui_operator = op;
|
||||
block->ui_operator = op;
|
||||
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE);
|
||||
@@ -3768,19 +3927,19 @@ void uiTemplateOperatorPropertyButs(
|
||||
op->type->ui((bContext *)C, op);
|
||||
op->layout = NULL;
|
||||
|
||||
/* UI_LAYOUT_OP_SHOW_EMPTY ignored */
|
||||
/* UI_LAYOUT_OP_SHOW_EMPTY ignored. return_info is ignored too. We could
|
||||
* allow ot.ui callback to return this, but not needed right now. */
|
||||
}
|
||||
else {
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
PointerRNA ptr;
|
||||
int empty;
|
||||
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
/* main draw call */
|
||||
empty = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
|
||||
return_info = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT));
|
||||
|
||||
if (empty && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
|
||||
if ((return_info & UI_PROP_BUTS_NONE_ADDED) && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
|
||||
uiItemL(layout, IFACE_("No Properties"), ICON_NONE);
|
||||
}
|
||||
}
|
||||
@@ -3790,7 +3949,6 @@ void uiTemplateOperatorPropertyButs(
|
||||
* but this is not so important if this button is drawn in those cases
|
||||
* (which isn't all that likely anyway) - campbell */
|
||||
if (op->properties->len) {
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
uiLayout *col; /* needed to avoid alignment errors with previous buttons */
|
||||
|
||||
@@ -3804,7 +3962,6 @@ void uiTemplateOperatorPropertyButs(
|
||||
|
||||
/* set various special settings for buttons */
|
||||
{
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0;
|
||||
uiBut *but;
|
||||
|
||||
@@ -3824,6 +3981,8 @@ void uiTemplateOperatorPropertyButs(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return return_info;
|
||||
}
|
||||
|
||||
/************************* Running Jobs Template **************************/
|
||||
|
||||
@@ -157,38 +157,45 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
|
||||
* \a check_prop callback filters functions to avoid drawing certain properties,
|
||||
* in cases where PROP_HIDDEN flag can't be used for a property.
|
||||
*/
|
||||
int uiDefAutoButsRNA(
|
||||
eAutoPropButsReturn uiDefAutoButsRNA(
|
||||
uiLayout *layout, PointerRNA *ptr,
|
||||
bool (*check_prop)(PointerRNA *, PropertyRNA *),
|
||||
const char label_align)
|
||||
const eButLabelAlign label_align, const bool compact)
|
||||
{
|
||||
eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED;
|
||||
uiLayout *split, *col;
|
||||
int flag;
|
||||
const char *name;
|
||||
int tot = 0;
|
||||
|
||||
assert(ELEM(label_align, '\0', 'H', 'V'));
|
||||
|
||||
RNA_STRUCT_BEGIN (ptr, prop)
|
||||
{
|
||||
flag = RNA_property_flag(prop);
|
||||
if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop) == 0))
|
||||
continue;
|
||||
|
||||
if (label_align != '\0') {
|
||||
if (flag & PROP_HIDDEN) {
|
||||
continue;
|
||||
}
|
||||
if (check_prop && check_prop(ptr, prop) == 0) {
|
||||
return_info |= UI_PROP_BUTS_ANY_FAILED_CHECK;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (label_align) {
|
||||
case UI_BUT_LABEL_ALIGN_COLUMN:
|
||||
case UI_BUT_LABEL_ALIGN_SPLIT_COLUMN:
|
||||
{
|
||||
PropertyType type = RNA_property_type(prop);
|
||||
const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
|
||||
|
||||
name = RNA_property_ui_name(prop);
|
||||
|
||||
if (label_align == 'V') {
|
||||
if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) {
|
||||
col = uiLayoutColumn(layout, true);
|
||||
|
||||
if (!is_boolean)
|
||||
uiItemL(col, name, ICON_NONE);
|
||||
}
|
||||
else { /* (label_align == 'H') */
|
||||
BLI_assert(label_align == 'H');
|
||||
else {
|
||||
BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN);
|
||||
split = uiLayoutSplit(layout, 0.5f, false);
|
||||
|
||||
col = uiLayoutColumn(split, false);
|
||||
@@ -201,18 +208,21 @@ int uiDefAutoButsRNA(
|
||||
|
||||
/* name is shown above, empty name for button below */
|
||||
name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
|
||||
|
||||
break;
|
||||
}
|
||||
else {
|
||||
case UI_BUT_LABEL_ALIGN_NONE:
|
||||
col = layout;
|
||||
name = NULL; /* no smart label alignment, show default name with button */
|
||||
break;
|
||||
}
|
||||
|
||||
uiItemFullR(col, ptr, prop, -1, 0, 0, name, ICON_NONE);
|
||||
tot++;
|
||||
uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
|
||||
return_info &= ~UI_PROP_BUTS_NONE_ADDED;
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
|
||||
return tot;
|
||||
return return_info;
|
||||
}
|
||||
|
||||
/* *** RNA collection search menu *** */
|
||||
|
||||
@@ -2289,7 +2289,7 @@ static struct uiWidgetColors wcol_list_item = {
|
||||
};
|
||||
|
||||
struct uiWidgetColors wcol_tab = {
|
||||
{255, 255, 255, 255},
|
||||
{60, 60, 60, 255},
|
||||
{83, 83, 83, 255},
|
||||
{114, 114, 114, 255},
|
||||
{90, 90, 90, 255},
|
||||
@@ -3832,16 +3832,20 @@ static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, in
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
||||
static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
{
|
||||
const uiStyle *style = UI_style_get();
|
||||
const float rad = 0.15f * U.widget_unit;
|
||||
const float rad = 0.25f * U.widget_unit;
|
||||
const int fontid = style->widget.uifont_id;
|
||||
const bool is_active = (but->flag & UI_SELECT);
|
||||
const bool is_active = (state & UI_SELECT);
|
||||
|
||||
/* Draw shaded outline - Disabled for now, seems incorrect and also looks nicer without it imho ;) */
|
||||
//#define USE_TAB_SHADED_HIGHLIGHT
|
||||
|
||||
uiWidgetBase wtb;
|
||||
unsigned char theme_col_tab_highlight[3];
|
||||
|
||||
#ifdef USE_TAB_SHADED_HIGHLIGHT
|
||||
/* create outline highlight colors */
|
||||
if (is_active) {
|
||||
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner_sel,
|
||||
@@ -3851,6 +3855,7 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
|
||||
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner,
|
||||
(unsigned char *)wcol->outline, 0.12f);
|
||||
}
|
||||
#endif
|
||||
|
||||
widget_init(&wtb);
|
||||
|
||||
@@ -3858,7 +3863,9 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
/* draw inner */
|
||||
#ifdef USE_TAB_SHADED_HIGHLIGHT
|
||||
wtb.draw_outline = 0;
|
||||
#endif
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
/* We are drawing on top of widget bases. Flush cache. */
|
||||
@@ -3866,13 +3873,19 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
|
||||
UI_widgetbase_draw_cache_flush();
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
#ifdef USE_TAB_SHADED_HIGHLIGHT
|
||||
/* draw outline (3d look) */
|
||||
ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (unsigned char *)wcol->inner);
|
||||
#endif
|
||||
|
||||
/* text shadow */
|
||||
BLF_enable(fontid, BLF_SHADOW);
|
||||
BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
|
||||
BLF_shadow_offset(fontid, 0, -1);
|
||||
|
||||
#ifndef USE_TAB_SHADED_HIGHLIGHT
|
||||
UNUSED_VARS(is_active, theme_col_tab_highlight);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
|
||||
@@ -3963,8 +3976,8 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
break;
|
||||
|
||||
case UI_WTYPE_TAB:
|
||||
wt.custom = widget_tab;
|
||||
wt.wcol_theme = &btheme->tui.wcol_tab;
|
||||
wt.draw = widget_tab;
|
||||
break;
|
||||
|
||||
case UI_WTYPE_TOOLTIP:
|
||||
|
||||
@@ -165,6 +165,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
||||
case SPACE_CLIP:
|
||||
ts = &btheme->tclip;
|
||||
break;
|
||||
case SPACE_TOPBAR:
|
||||
ts = &btheme->ttopbar;
|
||||
break;
|
||||
default:
|
||||
ts = &btheme->tv3d;
|
||||
break;
|
||||
@@ -1225,6 +1228,14 @@ void ui_theme_init_default(void)
|
||||
rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
|
||||
btheme->tclip.handle_vertex_size = 5;
|
||||
ui_theme_space_init_handles_color(&btheme->tclip);
|
||||
|
||||
/* space topbar */
|
||||
char tmp[4];
|
||||
btheme->ttopbar = btheme->tv3d;
|
||||
/* swap colors */
|
||||
copy_v4_v4_char(tmp, btheme->ttopbar.header);
|
||||
copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
|
||||
copy_v4_v4_char(btheme->ttopbar.back, tmp);
|
||||
}
|
||||
|
||||
void ui_style_init_default(void)
|
||||
@@ -2914,10 +2925,10 @@ void init_userdef_do_versions(void)
|
||||
U.uiflag |= USER_LOCK_CURSOR_ADJUST;
|
||||
}
|
||||
|
||||
if (!USER_VERSION_ATLEAST(280, 1)) {
|
||||
if (!USER_VERSION_ATLEAST(280, 9)) {
|
||||
/* interface_widgets.c */
|
||||
struct uiWidgetColors wcol_tab = {
|
||||
{255, 255, 255, 255},
|
||||
{60, 60, 60, 255},
|
||||
{83, 83, 83, 255},
|
||||
{114, 114, 114, 255},
|
||||
{90, 90, 90, 255},
|
||||
@@ -2930,7 +2941,14 @@ void init_userdef_do_versions(void)
|
||||
};
|
||||
|
||||
for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
char tmp[4];
|
||||
|
||||
btheme->tui.wcol_tab = wcol_tab;
|
||||
btheme->ttopbar = btheme->tv3d;
|
||||
/* swap colors */
|
||||
copy_v4_v4_char(tmp, btheme->ttopbar.header);
|
||||
copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
|
||||
copy_v4_v4_char(btheme->ttopbar.back, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5584,7 +5584,7 @@ static void edbm_sort_elements_ui(bContext *C, wmOperator *op)
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
/* Main auto-draw call. */
|
||||
uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
}
|
||||
|
||||
void MESH_OT_sort_elements(wmOperatorType *ot)
|
||||
|
||||
@@ -528,7 +528,7 @@ static void data_transfer_ui(bContext *C, wmOperator *op)
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
/* Main auto-draw call */
|
||||
uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
}
|
||||
|
||||
/* transfers weight from active to selected */
|
||||
|
||||
@@ -972,7 +972,7 @@ static void parent_set_ui(bContext *C, wmOperator *op)
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
/* Main auto-draw call. */
|
||||
uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
}
|
||||
|
||||
void OBJECT_OT_parent_set(wmOperatorType *ot)
|
||||
|
||||
@@ -1168,7 +1168,7 @@ static bool region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
|
||||
static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad, bool add_azones)
|
||||
{
|
||||
rcti *remainder_prev = remainder;
|
||||
int prefsizex, prefsizey;
|
||||
@@ -1197,11 +1197,15 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
|
||||
alignment = RGN_ALIGN_NONE;
|
||||
|
||||
/* prefsize, for header we stick to exception (prevent dpi rounding error) */
|
||||
prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex);
|
||||
const float sizex_dpi_fac = (ar->flag & RGN_SIZEX_DPI_APPLIED) ? 1.0f : UI_DPI_FAC;
|
||||
prefsizex = sizex_dpi_fac * ((ar->sizex > 1) ? ar->sizex + 0.5f : ar->type->prefsizex);
|
||||
|
||||
if (ar->regiontype == RGN_TYPE_HEADER) {
|
||||
prefsizey = ED_area_headersize();
|
||||
}
|
||||
else if (ED_area_is_global(sa)) {
|
||||
prefsizey = ED_region_global_size_y();
|
||||
}
|
||||
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
|
||||
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
|
||||
}
|
||||
@@ -1397,7 +1401,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
|
||||
* but accounts for small common rounding problems when scaling the UI,
|
||||
* must be minimum '4' */
|
||||
}
|
||||
else {
|
||||
else if (add_azones) {
|
||||
const bScreen *screen = WM_window_get_active_screen(win);
|
||||
|
||||
if (ELEM(screen->state, SCREENNORMAL, SCREENMAXIMIZED)) {
|
||||
@@ -1409,22 +1413,35 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
|
||||
}
|
||||
}
|
||||
|
||||
region_rect_recursive(win, sa, ar->next, remainder, quad);
|
||||
region_rect_recursive(win, sa, ar->next, remainder, quad, add_azones);
|
||||
}
|
||||
|
||||
static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
|
||||
static void area_calc_totrct(ScrArea *sa, int window_size_x, int window_size_y)
|
||||
{
|
||||
short rt = (short) U.pixelsize;
|
||||
short px = (short)U.pixelsize;
|
||||
|
||||
if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + rt;
|
||||
else sa->totrct.xmin = sa->v1->vec.x;
|
||||
if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - rt;
|
||||
else sa->totrct.xmax = sa->v4->vec.x;
|
||||
sa->totrct.xmin = sa->v1->vec.x;
|
||||
sa->totrct.xmax = sa->v4->vec.x;
|
||||
sa->totrct.ymin = sa->v1->vec.y;
|
||||
sa->totrct.ymax = sa->v2->vec.y;
|
||||
|
||||
if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + rt;
|
||||
else sa->totrct.ymin = sa->v1->vec.y;
|
||||
if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - rt;
|
||||
else sa->totrct.ymax = sa->v2->vec.y;
|
||||
/* scale down totrct by 1 pixel on all sides not matching window borders */
|
||||
if (sa->totrct.xmin > 0) {
|
||||
sa->totrct.xmin += px;
|
||||
}
|
||||
if (sa->totrct.xmax < (window_size_x - 1)) {
|
||||
sa->totrct.xmax -= px;
|
||||
}
|
||||
if (sa->totrct.ymin > 0) {
|
||||
sa->totrct.ymin += px;
|
||||
}
|
||||
if (sa->totrct.ymax < (window_size_y - 1)) {
|
||||
sa->totrct.ymax -= px;
|
||||
}
|
||||
BLI_assert(sa->totrct.xmin >= 0);
|
||||
BLI_assert(sa->totrct.xmax >= 0);
|
||||
BLI_assert(sa->totrct.ymin >= 0);
|
||||
BLI_assert(sa->totrct.ymax >= 0);
|
||||
|
||||
/* for speedup */
|
||||
sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
|
||||
@@ -1510,11 +1527,36 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
|
||||
}
|
||||
}
|
||||
|
||||
void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
|
||||
{
|
||||
const int size_x = WM_window_pixels_x(win);
|
||||
const int size_y = WM_window_pixels_y(win);
|
||||
rcti rect;
|
||||
|
||||
area_calc_totrct(area, size_x, size_y);
|
||||
|
||||
/* region rect sizes */
|
||||
rect = area->totrct;
|
||||
region_rect_recursive(win, area, area->regionbase.first, &rect, 0, false);
|
||||
|
||||
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
|
||||
region_subwindow(ar);
|
||||
|
||||
/* region size may have changed, init does necessary adjustments */
|
||||
if (ar->type->init) {
|
||||
ar->type->init(wm, ar);
|
||||
}
|
||||
}
|
||||
|
||||
area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
|
||||
}
|
||||
|
||||
/* called in screen_refresh, or screens_init, also area size changes */
|
||||
void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
|
||||
{
|
||||
const bScreen *screen = WM_window_get_active_screen(win);
|
||||
const int window_size_x = WM_window_pixels_x(win);
|
||||
const int window_size_y = WM_window_pixels_y(win);
|
||||
ARegion *ar;
|
||||
rcti rect;
|
||||
|
||||
@@ -1530,14 +1572,15 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
|
||||
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
|
||||
|
||||
/* area sizes */
|
||||
area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
|
||||
area_calc_totrct(sa, window_size_x, window_size_y);
|
||||
|
||||
/* clear all azones, add the area triange widgets */
|
||||
area_azone_initialize(win, screen, sa);
|
||||
|
||||
/* region rect sizes */
|
||||
rect = sa->totrct;
|
||||
region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
|
||||
region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0, true);
|
||||
sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
|
||||
|
||||
/* default area handlers */
|
||||
ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
|
||||
@@ -1832,6 +1875,18 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
|
||||
|
||||
/************************ standard UI regions ************************/
|
||||
|
||||
static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
|
||||
{
|
||||
switch (region->regiontype) {
|
||||
case RGN_TYPE_HEADER:
|
||||
return ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL;
|
||||
case RGN_TYPE_PREVIEW:
|
||||
return TH_PREVIEW_BACK;
|
||||
default:
|
||||
return TH_BACK;
|
||||
}
|
||||
}
|
||||
|
||||
void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int contextnr, const bool vertical)
|
||||
{
|
||||
const WorkSpace *workspace = CTX_wm_workspace(C);
|
||||
@@ -2117,17 +2172,25 @@ void ED_region_header(const bContext *C, ARegion *ar)
|
||||
Header header = {NULL};
|
||||
int maxco, xco, yco;
|
||||
int headery = ED_area_headersize();
|
||||
const int start_ofs = 0.4f * UI_UNIT_X;
|
||||
bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
|
||||
|
||||
/* clear */
|
||||
UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL);
|
||||
UI_ThemeClearColor(region_background_color_id(C, ar));
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* set view2d view matrix for scrolling (without scrollers) */
|
||||
UI_view2d_view_ortho(&ar->v2d);
|
||||
|
||||
xco = maxco = 0.4f * UI_UNIT_X;
|
||||
xco = maxco = start_ofs;
|
||||
yco = headery - floor(0.2f * UI_UNIT_Y);
|
||||
|
||||
/* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
|
||||
if (CTX_wm_area(C)->spacetype == SPACE_TOPBAR) {
|
||||
xco += 1;
|
||||
yco += 1;
|
||||
}
|
||||
|
||||
/* draw all headers types */
|
||||
for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
|
||||
block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS);
|
||||
@@ -2150,12 +2213,22 @@ void ED_region_header(const bContext *C, ARegion *ar)
|
||||
if (xco > maxco)
|
||||
maxco = xco;
|
||||
|
||||
if (region_layout_based && (ar->sizex != (maxco + start_ofs))) {
|
||||
/* region size is layout based and needs to be updated */
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
ar->sizex = maxco + start_ofs;
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->sizex, ar->winy);
|
||||
|
||||
sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
|
||||
ar->flag |= RGN_SIZEX_DPI_APPLIED;
|
||||
}
|
||||
UI_block_end(C, block);
|
||||
UI_block_draw(C, block);
|
||||
}
|
||||
|
||||
/* always as last */
|
||||
UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery);
|
||||
UI_view2d_totRect_set(&ar->v2d, maxco + (region_layout_based ? 0 : UI_UNIT_X + 80), headery);
|
||||
|
||||
/* restore view matrix? */
|
||||
UI_view2d_view_restore(C);
|
||||
@@ -2172,6 +2245,31 @@ int ED_area_headersize(void)
|
||||
return (int)(HEADERY * UI_DPI_FAC);
|
||||
}
|
||||
|
||||
/**
|
||||
* \return the final height of a global \a area, accounting for DPI.
|
||||
*/
|
||||
int ED_area_global_size_y(const ScrArea *area)
|
||||
{
|
||||
BLI_assert(ED_area_is_global(area));
|
||||
return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC);
|
||||
}
|
||||
|
||||
bool ED_area_is_global(const ScrArea *area)
|
||||
{
|
||||
return area->global != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* For now we just assume all global areas are made up out of horizontal bars
|
||||
* with the same size. A fixed size could be stored in ARegion instead if needed.
|
||||
*
|
||||
* \return the DPI aware height of a single bar/region in global areas.
|
||||
*/
|
||||
int ED_region_global_size_y(void)
|
||||
{
|
||||
return ED_area_headersize(); /* same size as header */
|
||||
}
|
||||
|
||||
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw)
|
||||
{
|
||||
const int header_height = UI_UNIT_Y;
|
||||
|
||||
@@ -76,17 +76,21 @@
|
||||
|
||||
/* ******************* screen vert, edge, area managing *********************** */
|
||||
|
||||
static ScrVert *screen_addvert(bScreen *sc, short x, short y)
|
||||
static ScrVert *screen_addvert_ex(ScrAreaMap *area_map, short x, short y)
|
||||
{
|
||||
ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert");
|
||||
sv->vec.x = x;
|
||||
sv->vec.y = y;
|
||||
|
||||
BLI_addtail(&sc->vertbase, sv);
|
||||
BLI_addtail(&area_map->vertbase, sv);
|
||||
return sv;
|
||||
}
|
||||
static ScrVert *screen_addvert(bScreen *sc, short x, short y)
|
||||
{
|
||||
return screen_addvert_ex(AREAMAP_FROM_SCREEN(sc), x, y);
|
||||
}
|
||||
|
||||
static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
|
||||
static ScrEdge *screen_addedge_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
|
||||
{
|
||||
ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge");
|
||||
|
||||
@@ -94,10 +98,13 @@ static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
|
||||
se->v1 = v1;
|
||||
se->v2 = v2;
|
||||
|
||||
BLI_addtail(&sc->edgebase, se);
|
||||
BLI_addtail(&area_map->edgebase, se);
|
||||
return se;
|
||||
}
|
||||
|
||||
static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
|
||||
{
|
||||
return screen_addedge_ex(AREAMAP_FROM_SCREEN(sc), v1, v2);
|
||||
}
|
||||
|
||||
bool scredge_is_horizontal(ScrEdge *se)
|
||||
{
|
||||
@@ -105,16 +112,16 @@ bool scredge_is_horizontal(ScrEdge *se)
|
||||
}
|
||||
|
||||
/* need win size to make sure not to include edges along screen edge */
|
||||
ScrEdge *screen_find_active_scredge(const bScreen *sc,
|
||||
ScrEdge *screen_area_map_find_active_scredge(
|
||||
const ScrAreaMap *area_map,
|
||||
const int winsize_x, const int winsize_y,
|
||||
const int mx, const int my)
|
||||
{
|
||||
ScrEdge *se;
|
||||
int safety = U.widget_unit / 10;
|
||||
|
||||
if (safety < 2) safety = 2;
|
||||
CLAMP_MIN(safety, 2);
|
||||
|
||||
for (se = sc->edgebase.first; se; se = se->next) {
|
||||
for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
|
||||
if (scredge_is_horizontal(se)) {
|
||||
if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) {
|
||||
short min, max;
|
||||
@@ -140,23 +147,52 @@ ScrEdge *screen_find_active_scredge(const bScreen *sc,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* need win size to make sure not to include edges along screen edge */
|
||||
ScrEdge *screen_find_active_scredge(
|
||||
const wmWindow *win, const bScreen *screen,
|
||||
const int mx, const int my)
|
||||
{
|
||||
/* Use layout size (screen excluding global areas) for screen-layout area edges */
|
||||
const int screen_x = WM_window_screen_pixels_x(win), screen_y = WM_window_screen_pixels_y(win);
|
||||
ScrEdge *se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), screen_x, screen_y, mx, my);
|
||||
|
||||
if (!se) {
|
||||
/* Use entire window size (screen including global areas) for global area edges */
|
||||
const int win_x = WM_window_pixels_x(win), win_y = WM_window_pixels_y(win);
|
||||
se = screen_area_map_find_active_scredge(&win->global_areas, win_x, win_y, mx, my);
|
||||
}
|
||||
return se;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* adds no space data */
|
||||
static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype)
|
||||
static ScrArea *screen_addarea_ex(
|
||||
ScrAreaMap *area_map,
|
||||
ScrVert *bottom_left, ScrVert *top_left, ScrVert *top_right, ScrVert *bottom_right,
|
||||
short headertype, short spacetype)
|
||||
{
|
||||
ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea");
|
||||
sa->v1 = v1;
|
||||
sa->v2 = v2;
|
||||
sa->v3 = v3;
|
||||
sa->v4 = v4;
|
||||
|
||||
sa->v1 = bottom_left;
|
||||
sa->v2 = top_left;
|
||||
sa->v3 = top_right;
|
||||
sa->v4 = bottom_right;
|
||||
sa->headertype = headertype;
|
||||
sa->spacetype = sa->butspacetype = spacetype;
|
||||
|
||||
BLI_addtail(&sc->areabase, sa);
|
||||
BLI_addtail(&area_map->areabase, sa);
|
||||
|
||||
return sa;
|
||||
}
|
||||
static ScrArea *screen_addarea(
|
||||
bScreen *sc,
|
||||
ScrVert *left_bottom, ScrVert *left_top, ScrVert *right_top, ScrVert *right_bottom,
|
||||
short headertype, short spacetype)
|
||||
{
|
||||
return screen_addarea_ex(AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom,
|
||||
headertype, spacetype);
|
||||
}
|
||||
|
||||
static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
|
||||
{
|
||||
@@ -462,10 +498,10 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void select_connected_scredge(bScreen *sc, ScrEdge *edge)
|
||||
void select_connected_scredge(const wmWindow *win, ScrEdge *edge)
|
||||
{
|
||||
bScreen *sc = WM_window_get_active_screen(win);
|
||||
ScrEdge *se;
|
||||
ScrVert *sv;
|
||||
int oneselected;
|
||||
char dir;
|
||||
|
||||
@@ -475,10 +511,8 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
|
||||
if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v';
|
||||
else dir = 'h';
|
||||
|
||||
sv = sc->vertbase.first;
|
||||
while (sv) {
|
||||
ED_screen_verts_iter(win, sc, sv) {
|
||||
sv->flag = 0;
|
||||
sv = sv->next;
|
||||
}
|
||||
|
||||
edge->v1->flag = 1;
|
||||
@@ -508,8 +542,13 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
|
||||
}
|
||||
}
|
||||
|
||||
/* test if screen vertices should be scaled */
|
||||
static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
/**
|
||||
* Test if screen vertices should be scaled and do if needed.
|
||||
*/
|
||||
static void screen_vertices_scale(
|
||||
const wmWindow *win, bScreen *sc,
|
||||
int window_size_x, int window_size_y,
|
||||
int screen_size_x, int screen_size_y)
|
||||
{
|
||||
/* clamp Y size of header sized areas when expanding windows
|
||||
* avoids annoying empty space around file menu */
|
||||
@@ -518,7 +557,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
const int headery_init = ED_area_headersize();
|
||||
ScrVert *sv = NULL;
|
||||
ScrArea *sa;
|
||||
int winsize_x_prev, winsize_y_prev;
|
||||
int screen_size_x_prev, screen_size_y_prev;
|
||||
float facx, facy, tempf, min[2], max[2];
|
||||
|
||||
/* calculate size */
|
||||
@@ -536,8 +575,8 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
sv->vec.y -= min[1];
|
||||
}
|
||||
|
||||
winsize_x_prev = (max[0] - min[0]) + 1;
|
||||
winsize_y_prev = (max[1] - min[1]) + 1;
|
||||
screen_size_x_prev = (max[0] - min[0]) + 1;
|
||||
screen_size_y_prev = (max[1] - min[1]) + 1;
|
||||
|
||||
|
||||
#ifdef USE_HEADER_SIZE_CLAMP
|
||||
@@ -545,14 +584,14 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
#define TEMP_TOP 2
|
||||
|
||||
/* if the window's Y axis grows, clamp header sized areas */
|
||||
if (winsize_y_prev < winsize_y) { /* growing? */
|
||||
if (screen_size_y_prev < screen_size_y) { /* growing? */
|
||||
const int headery_margin_max = headery_init + 4;
|
||||
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
||||
sa->temp = 0;
|
||||
|
||||
if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
|
||||
if (sa->v2->vec.y == winsize_y_prev - 1) {
|
||||
if (sa->v2->vec.y == screen_size_y_prev) {
|
||||
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
|
||||
sa->temp = TEMP_TOP;
|
||||
}
|
||||
@@ -568,9 +607,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
#endif
|
||||
|
||||
|
||||
if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) {
|
||||
facx = ((float)winsize_x - 1) / ((float)winsize_x_prev - 1);
|
||||
facy = ((float)winsize_y - 1) / ((float)winsize_y_prev - 1);
|
||||
if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
|
||||
facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
|
||||
facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
|
||||
|
||||
/* make sure it fits! */
|
||||
for (sv = sc->vertbase.first; sv; sv = sv->next) {
|
||||
@@ -581,20 +620,20 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
//sv->vec.x += AREAGRID - 1;
|
||||
//sv->vec.x -= (sv->vec.x % AREAGRID);
|
||||
|
||||
CLAMP(sv->vec.x, 0, winsize_x - 1);
|
||||
CLAMP(sv->vec.x, 0, screen_size_x - 1);
|
||||
|
||||
tempf = ((float)sv->vec.y) * facy;
|
||||
sv->vec.y = (short)(tempf + 0.5f);
|
||||
//sv->vec.y += AREAGRID - 1;
|
||||
//sv->vec.y -= (sv->vec.y % AREAGRID);
|
||||
|
||||
CLAMP(sv->vec.y, 0, winsize_y - 1);
|
||||
CLAMP(sv->vec.y, 0, screen_size_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_HEADER_SIZE_CLAMP
|
||||
if (winsize_y_prev < winsize_y) { /* growing? */
|
||||
if (screen_size_y_prev < screen_size_y) { /* growing? */
|
||||
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
ScrEdge *se = NULL;
|
||||
|
||||
@@ -610,7 +649,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
const int yval = sa->v2->vec.y - headery_init;
|
||||
se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
|
||||
if (se != NULL) {
|
||||
select_connected_scredge(sc, se);
|
||||
select_connected_scredge(win, se);
|
||||
}
|
||||
for (sv = sc->vertbase.first; sv; sv = sv->next) {
|
||||
if (sv != sa->v2 && sv != sa->v3) {
|
||||
@@ -625,7 +664,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
const int yval = sa->v1->vec.y + headery_init;
|
||||
se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
|
||||
if (se != NULL) {
|
||||
select_connected_scredge(sc, se);
|
||||
select_connected_scredge(win, se);
|
||||
}
|
||||
for (sv = sc->vertbase.first; sv; sv = sv->next) {
|
||||
if (sv != sa->v1 && sv != sa->v4) {
|
||||
@@ -654,7 +693,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
/* adjust headery if verts are along the edge of window */
|
||||
if (sa->v1->vec.y > 0)
|
||||
headery += U.pixelsize;
|
||||
if (sa->v2->vec.y < winsize_y - 1)
|
||||
if (sa->v2->vec.y < screen_size_y)
|
||||
headery += U.pixelsize;
|
||||
|
||||
if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) {
|
||||
@@ -663,7 +702,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
if (se && sa->v1 != sa->v2) {
|
||||
int yval;
|
||||
|
||||
select_connected_scredge(sc, se);
|
||||
select_connected_scredge(win, se);
|
||||
|
||||
/* all selected vertices get the right offset */
|
||||
yval = sa->v2->vec.y - headery + 1;
|
||||
@@ -679,6 +718,16 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
|
||||
}
|
||||
}
|
||||
|
||||
/* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set.
|
||||
* TODO Assumes global area to be top-aligned. Should be made more generic */
|
||||
for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
|
||||
/* width */
|
||||
area->v1->vec.x = area->v2->vec.x = 0;
|
||||
area->v3->vec.x = area->v4->vec.x = window_size_x - 1;
|
||||
/* height */
|
||||
area->v2->vec.y = area->v3->vec.y = window_size_y - 1;
|
||||
area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -689,7 +738,7 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
|
||||
{
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar == screen->active_region) {
|
||||
if (swin_changed || (ar->type && ar->type->event_cursor)) {
|
||||
@@ -751,20 +800,21 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
|
||||
|
||||
/* exception for bg mode, we only need the screen context */
|
||||
if (!G.background) {
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
ScrArea *sa;
|
||||
const int window_size_x = WM_window_pixels_x(win);
|
||||
const int window_size_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
|
||||
/* header size depends on DPI, let's verify */
|
||||
WM_window_set_dpi(win);
|
||||
screen_refresh_headersizes();
|
||||
|
||||
screen_test_scale(screen, winsize_x, winsize_y);
|
||||
screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, area) {
|
||||
/* set spacetype and region callbacks, calls init() */
|
||||
/* sets subwindows for regions, adds handlers */
|
||||
ED_area_initialize(wm, win, sa);
|
||||
ED_area_initialize(wm, win, area);
|
||||
}
|
||||
|
||||
/* wake up animtimer */
|
||||
@@ -782,6 +832,36 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
|
||||
screen->context = ed_screen_context;
|
||||
}
|
||||
|
||||
static bool screen_regions_need_size_refresh(
|
||||
const wmWindow *win, const bScreen *screen)
|
||||
{
|
||||
ED_screen_areas_iter(win, screen, area) {
|
||||
if (area->flag & AREA_FLAG_REGION_SIZE_UPDATE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void screen_refresh_region_sizes_only(
|
||||
wmWindowManager *wm, wmWindow *win,
|
||||
bScreen *screen)
|
||||
{
|
||||
const int window_size_x = WM_window_pixels_x(win);
|
||||
const int window_size_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
|
||||
screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
|
||||
|
||||
ED_screen_areas_iter(win, screen, area) {
|
||||
screen_area_update_region_sizes(wm, win, area);
|
||||
/* XXX hack to force drawing */
|
||||
ED_area_tag_redraw(area);
|
||||
}
|
||||
}
|
||||
|
||||
/* file read, set all screens, ... */
|
||||
void ED_screens_initialize(wmWindowManager *wm)
|
||||
{
|
||||
@@ -792,10 +872,23 @@ void ED_screens_initialize(wmWindowManager *wm)
|
||||
WM_window_set_active_workspace(win, G.main->workspaces.first);
|
||||
}
|
||||
|
||||
if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
|
||||
ED_screen_global_areas_create(win);
|
||||
}
|
||||
ED_screen_refresh(wm, win);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *screen)
|
||||
{
|
||||
if (screen->do_refresh) {
|
||||
ED_screen_refresh(wm, win);
|
||||
}
|
||||
else if (screen_regions_need_size_refresh(win, screen)) {
|
||||
screen_refresh_region_sizes_only(wm, win, screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* *********** exit calls are for closing running stuff ******** */
|
||||
|
||||
@@ -872,6 +965,9 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_area_exit(C, sa);
|
||||
}
|
||||
for (sa = window->global_areas.areabase.first; sa; sa = sa->next) {
|
||||
ED_area_exit(C, sa);
|
||||
}
|
||||
|
||||
/* mark it available for use for other windows */
|
||||
screen->winid = 0;
|
||||
@@ -893,9 +989,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
|
||||
static void screen_cursor_set(wmWindow *win, const wmEvent *event)
|
||||
{
|
||||
const bScreen *screen = WM_window_get_active_screen(win);
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
|
||||
AZone *az = NULL;
|
||||
ScrArea *sa;
|
||||
|
||||
@@ -914,7 +1007,7 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event)
|
||||
}
|
||||
}
|
||||
else {
|
||||
ScrEdge *actedge = screen_find_active_scredge(screen, winsize_x, winsize_y, event->x, event->y);
|
||||
ScrEdge *actedge = screen_find_active_scredge(win, screen, event->x, event->y);
|
||||
|
||||
if (actedge) {
|
||||
if (scredge_is_horizontal(actedge))
|
||||
@@ -936,16 +1029,20 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
|
||||
bScreen *scr = WM_window_get_active_screen(win);
|
||||
|
||||
if (scr) {
|
||||
ScrArea *sa;
|
||||
ScrArea *sa = NULL;
|
||||
ARegion *ar;
|
||||
ARegion *old_ar = scr->active_region;
|
||||
|
||||
for (sa = scr->areabase.first; sa; sa = sa->next) {
|
||||
if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax)
|
||||
if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax)
|
||||
if (NULL == is_in_area_actionzone(sa, &event->x))
|
||||
ED_screen_areas_iter(win, scr, area_iter) {
|
||||
if (event->x > area_iter->totrct.xmin && event->x < area_iter->totrct.xmax) {
|
||||
if (event->y > area_iter->totrct.ymin && event->y < area_iter->totrct.ymax) {
|
||||
if (is_in_area_actionzone(area_iter, &event->x) == NULL) {
|
||||
sa = area_iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sa) {
|
||||
/* make overlap active when mouse over */
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
@@ -961,20 +1058,24 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
|
||||
/* check for redraw headers */
|
||||
if (old_ar != scr->active_region) {
|
||||
|
||||
for (sa = scr->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, scr, area_iter) {
|
||||
bool do_draw = false;
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
if (ar == old_ar || ar == scr->active_region)
|
||||
for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar == old_ar || ar == scr->active_region) {
|
||||
do_draw = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_draw) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
if (ar->regiontype == RGN_TYPE_HEADER)
|
||||
for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_HEADER) {
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* cursors, for time being set always on edges, otherwise aregion doesnt switch */
|
||||
if (scr->active_region == NULL) {
|
||||
@@ -1016,6 +1117,47 @@ int ED_screen_area_active(const bContext *C)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
|
||||
{
|
||||
if (screen->temp == 0) {
|
||||
SpaceType *st = BKE_spacetype_from_id(SPACE_TOPBAR);
|
||||
SpaceLink *sl = st->new(NULL);
|
||||
ScrArea *sa;
|
||||
const short size_y = 2 * HEADERY;
|
||||
const int minx = 0, maxx = WM_window_pixels_x(win) - 1;
|
||||
const int maxy = WM_window_pixels_y(win) - 1, miny = maxy - size_y;
|
||||
|
||||
ScrVert *bottom_left = screen_addvert_ex(&win->global_areas, minx, miny);
|
||||
ScrVert *top_left = screen_addvert_ex(&win->global_areas, minx, maxy);
|
||||
ScrVert *top_right = screen_addvert_ex(&win->global_areas, maxx, maxy);
|
||||
ScrVert *bottom_right = screen_addvert_ex(&win->global_areas, maxx, miny);
|
||||
screen_addedge_ex(&win->global_areas, bottom_left, top_left);
|
||||
screen_addedge_ex(&win->global_areas, top_left, top_right);
|
||||
screen_addedge_ex(&win->global_areas, top_right, bottom_right);
|
||||
screen_addedge_ex(&win->global_areas, bottom_right, bottom_left);
|
||||
|
||||
sa = screen_addarea_ex(&win->global_areas, bottom_left, top_left, top_right, bottom_right,
|
||||
HEADERTOP, SPACE_TOPBAR);
|
||||
sa->regionbase = sl->regionbase;
|
||||
|
||||
/* Data specific to global areas. */
|
||||
sa->global = MEM_callocN(sizeof(*sa->global), __func__);
|
||||
sa->global->cur_fixed_height = size_y;
|
||||
sa->global->size_max = size_y;
|
||||
sa->global->size_min = HEADERY;
|
||||
|
||||
BLI_addhead(&sa->spacedata, sl);
|
||||
BLI_listbase_clear(&sl->regionbase);
|
||||
}
|
||||
/* Do not create more area types here! Function is called on file load (wm_window_ghostwindows_ensure). TODO */
|
||||
}
|
||||
|
||||
void ED_screen_global_areas_create(wmWindow *win)
|
||||
{
|
||||
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
||||
ED_screen_global_topbar_area_create(win, screen);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Screen changing */
|
||||
@@ -1168,7 +1310,6 @@ void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new
|
||||
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
ScrArea *newsa = NULL;
|
||||
|
||||
if (!sa || sa->full == NULL) {
|
||||
@@ -1176,19 +1317,8 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
}
|
||||
|
||||
if (!newsa) {
|
||||
if (sa->full && (screen->state == SCREENMAXIMIZED)) {
|
||||
/* if this has been called from the temporary info header generated in
|
||||
* temp fullscreen layouts, find the correct fullscreen area to change
|
||||
* to create a new space inside */
|
||||
for (newsa = screen->areabase.first; newsa; newsa = newsa->next) {
|
||||
if (!(sa->flag & AREA_TEMP_INFO))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
newsa = sa;
|
||||
}
|
||||
}
|
||||
|
||||
BLI_assert(newsa);
|
||||
|
||||
@@ -1308,10 +1438,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
|
||||
|
||||
/* clear full screen state */
|
||||
old->full = NULL;
|
||||
old->flag &= ~AREA_TEMP_INFO;
|
||||
}
|
||||
|
||||
sa->flag &= ~AREA_TEMP_INFO;
|
||||
sa->full = NULL;
|
||||
|
||||
if (fullsa == NULL) {
|
||||
@@ -1349,6 +1477,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
|
||||
ScrArea *newa;
|
||||
char newname[MAX_ID_NAME - 2];
|
||||
|
||||
BLI_assert(ELEM(state, SCREENMAXIMIZED, SCREENFULL));
|
||||
|
||||
oldscreen = WM_window_get_active_screen(win);
|
||||
|
||||
oldscreen->state = state;
|
||||
@@ -1367,49 +1497,29 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
|
||||
|
||||
/* use random area when we have no active one, e.g. when the
|
||||
* mouse is outside of the window and we open a file browser */
|
||||
if (!sa)
|
||||
if (!sa) {
|
||||
sa = oldscreen->areabase.first;
|
||||
|
||||
if (state == SCREENMAXIMIZED) {
|
||||
/* returns the top small area */
|
||||
newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1);
|
||||
ED_area_newspace(C, newa, SPACE_INFO, false);
|
||||
|
||||
/* copy area */
|
||||
newa = newa->prev;
|
||||
ED_area_data_swap(newa, sa);
|
||||
sa->flag |= AREA_TEMP_INFO;
|
||||
|
||||
sa->full = oldscreen;
|
||||
newa->full = oldscreen;
|
||||
newa->next->full = oldscreen; // XXX
|
||||
}
|
||||
else if (state == SCREENFULL) {
|
||||
|
||||
newa = (ScrArea *)sc->areabase.first;
|
||||
|
||||
/* copy area */
|
||||
ED_area_data_swap(newa, sa);
|
||||
newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
|
||||
|
||||
if (state == SCREENFULL) {
|
||||
/* temporarily hide the side panels/header */
|
||||
for (ar = newa->regionbase.first; ar; ar = ar->next) {
|
||||
ar->flagfullscreen = ar->flag;
|
||||
|
||||
if (ELEM(ar->regiontype,
|
||||
RGN_TYPE_UI,
|
||||
RGN_TYPE_HEADER,
|
||||
RGN_TYPE_TOOLS))
|
||||
{
|
||||
if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, RGN_TYPE_TOOLS)){
|
||||
ar->flag |= RGN_FLAG_HIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sa->full = oldscreen;
|
||||
newa->full = oldscreen;
|
||||
}
|
||||
else {
|
||||
BLI_assert(false);
|
||||
}
|
||||
|
||||
ED_screen_change(C, sc);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ struct Main;
|
||||
/* area.c */
|
||||
void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free);
|
||||
void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2);
|
||||
void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area);
|
||||
void region_toggle_hidden(struct bContext *C, ARegion *ar, const bool do_fade);
|
||||
|
||||
/* screen_edit.c */
|
||||
@@ -55,12 +56,16 @@ bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, stru
|
||||
ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
|
||||
int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2);
|
||||
int area_getorientation(ScrArea *sa, ScrArea *sb);
|
||||
void select_connected_scredge(bScreen *sc, ScrEdge *edge);
|
||||
void select_connected_scredge(const wmWindow *win, ScrEdge *edge);
|
||||
|
||||
bool scredge_is_horizontal(ScrEdge *se);
|
||||
ScrEdge *screen_find_active_scredge(const bScreen *sc,
|
||||
ScrEdge *screen_area_map_find_active_scredge(
|
||||
const struct ScrAreaMap *area_map,
|
||||
const int winsize_x, const int winsize_y,
|
||||
const int mx, const int my);
|
||||
ScrEdge *screen_find_active_scredge(
|
||||
const wmWindow *win, const bScreen *screen,
|
||||
const int mx, const int my);
|
||||
|
||||
struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]);
|
||||
|
||||
|
||||
@@ -791,8 +791,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *sc = CTX_wm_screen(C);
|
||||
sActionzoneData *sad = op->customdata;
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE:
|
||||
@@ -816,7 +816,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
/* once we drag outside the actionzone, register a gesture
|
||||
* check we're not on an edge so join finds the other area */
|
||||
is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) &&
|
||||
(screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y) == NULL));
|
||||
(screen_area_map_find_active_scredge(
|
||||
AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y) == NULL));
|
||||
}
|
||||
else {
|
||||
const int delta_min = 1;
|
||||
@@ -1049,6 +1050,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
|
||||
newsc = BKE_workspace_layout_screen_get(layout_new);
|
||||
WM_window_set_active_layout(newwin, workspace, layout_new);
|
||||
ED_screen_global_areas_create(newwin);
|
||||
|
||||
/* copy area to new screen */
|
||||
ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
|
||||
@@ -1116,25 +1118,73 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot)
|
||||
*/
|
||||
|
||||
typedef struct sAreaMoveData {
|
||||
int bigger, smaller, origval;
|
||||
int bigger, smaller, origval, step;
|
||||
char dir;
|
||||
bool do_snap;
|
||||
enum AreaMoveSnapType {
|
||||
/* Snapping disabled */
|
||||
SNAP_NONE = 0,
|
||||
/* Snap to mid-point and adjacent edges. */
|
||||
SNAP_MIDPOINT_AND_ADJACENT,
|
||||
/* Snap to either bigger or smaller, nothing in-between (used for
|
||||
* global areas). This has priority over other snap types, if it is
|
||||
* used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */
|
||||
SNAP_BIGGER_SMALLER_ONLY,
|
||||
} snap_type;
|
||||
} sAreaMoveData;
|
||||
|
||||
/* helper call to move area-edge, sets limits
|
||||
* need window size in order to get correct limits */
|
||||
static void area_move_set_limits(bScreen *sc, int dir,
|
||||
static void area_move_set_limits(
|
||||
wmWindow *win, bScreen *sc, int dir,
|
||||
const int winsize_x, const int winsize_y,
|
||||
int *bigger, int *smaller)
|
||||
int *bigger, int *smaller,
|
||||
bool *use_bigger_smaller_snap)
|
||||
{
|
||||
ScrArea *sa;
|
||||
int areaminy = ED_area_headersize();
|
||||
int areamin;
|
||||
|
||||
/* we check all areas and test for free space with MINSIZE */
|
||||
*bigger = *smaller = 100000;
|
||||
|
||||
for (sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
if (use_bigger_smaller_snap != NULL) {
|
||||
*use_bigger_smaller_snap = false;
|
||||
for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
|
||||
const int size_min = round_fl_to_int(area->global->size_min * UI_DPI_FAC);
|
||||
const int size_max = round_fl_to_int(area->global->size_max * UI_DPI_FAC);
|
||||
|
||||
/* logic here is only tested for lower edge :) */
|
||||
/* left edge */
|
||||
if ((area->v1->editflag && area->v2->editflag)) {
|
||||
*smaller = area->v4->vec.x - size_max;
|
||||
*bigger = area->v4->vec.x - size_min;
|
||||
*use_bigger_smaller_snap = true;
|
||||
return;
|
||||
}
|
||||
/* top edge */
|
||||
else if ((area->v2->editflag && area->v3->editflag)) {
|
||||
*smaller = area->v1->vec.y + size_min;
|
||||
*bigger = area->v1->vec.y + size_max;
|
||||
*use_bigger_smaller_snap = true;
|
||||
return;
|
||||
}
|
||||
/* right edge */
|
||||
else if ((area->v3->editflag && area->v4->editflag)) {
|
||||
*smaller = area->v1->vec.x + size_min;
|
||||
*bigger = area->v1->vec.x + size_max;
|
||||
*use_bigger_smaller_snap = true;
|
||||
return;
|
||||
}
|
||||
/* lower edge */
|
||||
else if ((area->v4->editflag && area->v1->editflag)) {
|
||||
*smaller = area->v2->vec.y - size_max;
|
||||
*bigger = area->v2->vec.y - size_min;
|
||||
*use_bigger_smaller_snap = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
if (dir == 'h') {
|
||||
int y1;
|
||||
areamin = areaminy;
|
||||
@@ -1180,9 +1230,8 @@ static int area_move_init(bContext *C, wmOperator *op)
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
ScrEdge *actedge;
|
||||
sAreaMoveData *md;
|
||||
ScrVert *v1;
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
int x, y;
|
||||
|
||||
/* required properties */
|
||||
@@ -1190,7 +1239,7 @@ static int area_move_init(bContext *C, wmOperator *op)
|
||||
y = RNA_int_get(op->ptr, "y");
|
||||
|
||||
/* setup */
|
||||
actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
|
||||
actedge = screen_find_active_scredge(win, sc, x, y);
|
||||
if (actedge == NULL) return 0;
|
||||
|
||||
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
|
||||
@@ -1200,23 +1249,33 @@ static int area_move_init(bContext *C, wmOperator *op)
|
||||
if (md->dir == 'h') md->origval = actedge->v1->vec.y;
|
||||
else md->origval = actedge->v1->vec.x;
|
||||
|
||||
select_connected_scredge(sc, actedge);
|
||||
select_connected_scredge(win, actedge);
|
||||
/* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
|
||||
for (v1 = sc->vertbase.first; v1; v1 = v1->next)
|
||||
ED_screen_verts_iter(win, sc, v1) {
|
||||
v1->editflag = v1->flag;
|
||||
}
|
||||
|
||||
area_move_set_limits(sc, md->dir, winsize_x, winsize_y, &md->bigger, &md->smaller);
|
||||
bool use_bigger_smaller_snap = false;
|
||||
area_move_set_limits(win, sc, md->dir, screen_size_x, screen_size_y,
|
||||
&md->bigger, &md->smaller,
|
||||
&use_bigger_smaller_snap);
|
||||
|
||||
md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_NONE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int area_snap_calc_location(
|
||||
const bScreen *sc, const int delta,
|
||||
const int origval, const int dir,
|
||||
const bScreen *sc, const enum AreaMoveSnapType snap_type,
|
||||
const int delta, const int origval, const int dir,
|
||||
const int bigger, const int smaller)
|
||||
{
|
||||
int final_loc = -1;
|
||||
BLI_assert(snap_type != SNAP_NONE);
|
||||
if (snap_type == SNAP_BIGGER_SMALLER_ONLY) {
|
||||
return ((origval + delta) >= bigger) ? bigger : smaller;
|
||||
}
|
||||
|
||||
int final_loc = -1;
|
||||
const int m_loc = origval + delta;
|
||||
const int axis = (dir == 'v') ? 0 : 1;
|
||||
int snap_dist;
|
||||
@@ -1260,29 +1319,29 @@ static void area_move_apply_do(
|
||||
const bContext *C, int delta,
|
||||
const int origval, const int dir,
|
||||
const int bigger, const int smaller,
|
||||
const bool do_snap)
|
||||
const enum AreaMoveSnapType snap_type)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *sc = CTX_wm_screen(C);
|
||||
ScrVert *v1;
|
||||
bool doredraw = false;
|
||||
CLAMP(delta, -smaller, bigger);
|
||||
|
||||
short final_loc = -1;
|
||||
|
||||
if (do_snap) {
|
||||
final_loc = area_snap_calc_location(sc, delta, origval, dir, bigger, smaller);
|
||||
}
|
||||
else {
|
||||
if (snap_type == SNAP_NONE) {
|
||||
final_loc = origval + delta;
|
||||
if (delta != bigger && delta != -smaller) {
|
||||
final_loc -= (final_loc % AREAGRID);
|
||||
}
|
||||
}
|
||||
else {
|
||||
final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller);
|
||||
}
|
||||
|
||||
BLI_assert(final_loc != -1);
|
||||
short axis = (dir == 'v') ? 0 : 1;
|
||||
|
||||
for (v1 = sc->vertbase.first; v1; v1 = v1->next) {
|
||||
ED_screen_verts_iter(win, sc, v1) {
|
||||
if (v1->editflag) {
|
||||
short oldval = (&v1->vec.x)[axis];
|
||||
(&v1->vec.x)[axis] = final_loc;
|
||||
@@ -1297,11 +1356,23 @@ static void area_move_apply_do(
|
||||
|
||||
/* only redraw if we actually moved a screen vert, for AREAGRID */
|
||||
if (doredraw) {
|
||||
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
bool redraw_all = false;
|
||||
ED_screen_areas_iter(win, sc, sa) {
|
||||
if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) {
|
||||
if (ED_area_is_global(sa)) {
|
||||
sa->global->cur_fixed_height = round_fl_to_int((sa->v2->vec.y - sa->v1->vec.y) / UI_DPI_FAC);
|
||||
sc->do_refresh = true;
|
||||
redraw_all = true;
|
||||
}
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
}
|
||||
if (redraw_all) {
|
||||
ED_screen_areas_iter(win, sc, sa) {
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
|
||||
/* Update preview thumbnail */
|
||||
BKE_icon_changed(sc->id.icon_id);
|
||||
@@ -1313,7 +1384,7 @@ static void area_move_apply(bContext *C, wmOperator *op)
|
||||
sAreaMoveData *md = op->customdata;
|
||||
int delta = RNA_int_get(op->ptr, "delta");
|
||||
|
||||
area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->do_snap);
|
||||
area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->snap_type);
|
||||
}
|
||||
|
||||
static void area_move_exit(bContext *C, wmOperator *op)
|
||||
@@ -1392,10 +1463,14 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
case KM_MODAL_SNAP_ON:
|
||||
md->do_snap = true;
|
||||
if (md->snap_type == SNAP_NONE) {
|
||||
md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
|
||||
}
|
||||
break;
|
||||
case KM_MODAL_SNAP_OFF:
|
||||
md->do_snap = false;
|
||||
if (md->snap_type == SNAP_MIDPOINT_AND_ADJACENT) {
|
||||
md->snap_type = SNAP_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1644,8 +1719,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *sc = CTX_wm_screen(C);
|
||||
sAreaSplitData *sd;
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
int dir;
|
||||
|
||||
/* no full window splitting allowed */
|
||||
@@ -1698,7 +1773,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
else
|
||||
y = event->x;
|
||||
|
||||
actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
|
||||
actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, x, y);
|
||||
if (actedge == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
@@ -1718,7 +1793,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
/* do the split */
|
||||
if (area_split_apply(C, op)) {
|
||||
area_move_set_limits(sc, dir, winsize_x, winsize_y, &sd->bigger, &sd->smaller);
|
||||
area_move_set_limits(win, sc, dir, screen_size_x, screen_size_y, &sd->bigger, &sd->smaller, NULL);
|
||||
|
||||
/* add temp handler for edge move or cancel */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
@@ -1836,10 +1911,11 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
if (sd->previewmode == 0) {
|
||||
if (sd->do_snap) {
|
||||
const int snap_loc = area_snap_calc_location(
|
||||
CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->bigger, sd->smaller);
|
||||
CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
|
||||
sd->bigger, sd->smaller);
|
||||
sd->delta = snap_loc - sd->origval;
|
||||
}
|
||||
area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, false);
|
||||
area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, SNAP_NONE);
|
||||
}
|
||||
else {
|
||||
if (sd->sarea) {
|
||||
@@ -1863,7 +1939,8 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
|
||||
|
||||
const int snap_loc = area_snap_calc_location(
|
||||
CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin);
|
||||
CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
|
||||
sd->origmin + sd->origsize, -sd->origmin);
|
||||
|
||||
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
|
||||
sd->delta = snap_loc - sd->origval;
|
||||
@@ -2579,6 +2656,14 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int screen_maximize_area_poll(bContext *C)
|
||||
{
|
||||
const bScreen *screen = CTX_wm_screen(C);
|
||||
const ScrArea *area = CTX_wm_area(C);
|
||||
return ED_operator_areaactive(C) &&
|
||||
((screen->state != SCREENNORMAL) || (area->spacetype != SPACE_TOPBAR));
|
||||
}
|
||||
|
||||
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
@@ -2588,7 +2673,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
|
||||
ot->idname = "SCREEN_OT_screen_full_area";
|
||||
|
||||
ot->exec = screen_maximize_area_exec;
|
||||
ot->poll = ED_operator_areaactive;
|
||||
ot->poll = screen_maximize_area_poll;
|
||||
ot->flag = 0;
|
||||
|
||||
prop = RNA_def_boolean(ot->srna, "use_hide_panels", false, "Hide Panels", "Hide all the panels");
|
||||
@@ -2898,10 +2983,11 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
uiLayout *layout;
|
||||
PointerRNA ptr;
|
||||
ScrEdge *actedge;
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
|
||||
actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y);
|
||||
actedge = screen_area_map_find_active_scredge(
|
||||
AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y);
|
||||
|
||||
if (actedge == NULL) return OPERATOR_CANCELLED;
|
||||
|
||||
@@ -3305,6 +3391,18 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int region_flip_poll(bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
|
||||
/* don't flip anything around in topbar */
|
||||
if (area->spacetype == SPACE_TOPBAR) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Flipping regions in the Top-bar is not allowed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ED_operator_areaactive(C);
|
||||
}
|
||||
|
||||
static void SCREEN_OT_region_flip(wmOperatorType *ot)
|
||||
{
|
||||
@@ -3315,7 +3413,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = region_flip_exec;
|
||||
ot->poll = ED_operator_areaactive;
|
||||
ot->poll = region_flip_poll;
|
||||
ot->flag = 0;
|
||||
}
|
||||
|
||||
@@ -3408,12 +3506,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
/* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
|
||||
if (sa->spacetype != SPACE_FILE) {
|
||||
if (sa->full)
|
||||
uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
|
||||
else
|
||||
uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
|
||||
/* file browser should be fullscreen all the time, topbar should
|
||||
* never be. But other regions can be maximized/restored... */
|
||||
if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
|
||||
const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
|
||||
uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
|
||||
/* main draw call */
|
||||
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
|
||||
uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
}
|
||||
|
||||
static int screenshot_poll(bContext *C)
|
||||
|
||||
@@ -313,11 +313,9 @@ static void WORKSPACE_OT_workspace_duplicate(wmOperatorType *ot)
|
||||
|
||||
static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
ED_workspace_delete(WM_window_get_active_workspace(win), bmain, C, wm);
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_DELETE, WM_window_get_active_workspace(win));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ WorkSpaceLayout *ED_workspace_layout_add(
|
||||
wmWindow *win,
|
||||
const char *name)
|
||||
{
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
const int screen_size_x = WM_window_screen_pixels_x(win);
|
||||
const int screen_size_y = WM_window_screen_pixels_y(win);
|
||||
|
||||
bScreen *screen = screen_add(name, winsize_x, winsize_y);
|
||||
bScreen *screen = screen_add(name, screen_size_x, screen_size_y);
|
||||
WorkSpaceLayout *layout = BKE_workspace_layout_add(workspace, screen, name);
|
||||
|
||||
return layout;
|
||||
|
||||
@@ -635,7 +635,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
|
||||
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
|
||||
|
||||
/* main draw call */
|
||||
uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
}
|
||||
#endif // WITH_AUDASPACE
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ void ED_spacetypes_init(void)
|
||||
ED_spacetype_console();
|
||||
ED_spacetype_userpref();
|
||||
ED_spacetype_clip();
|
||||
ED_spacetype_topbar();
|
||||
// ...
|
||||
|
||||
/* register operator types for screen and all spaces */
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "DNA_windowmanager_types.h"
|
||||
#include "DNA_workspace_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -118,19 +119,30 @@ void CLIP_OT_properties(wmOperatorType *ot)
|
||||
|
||||
static ARegion *clip_has_tools_region(ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
|
||||
ARegion *ar, *artool = NULL, *arhead;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
ARegion *arprops = NULL;
|
||||
#endif
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_TOOLS)
|
||||
artool = ar;
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
|
||||
arprops = ar;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* tool region hide/unhide also hides props */
|
||||
if (arprops && artool)
|
||||
if (artool
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
&& arprops
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return artool;
|
||||
}
|
||||
|
||||
if (artool == NULL) {
|
||||
/* add subdiv level; after header */
|
||||
@@ -149,6 +161,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa)
|
||||
artool->flag = RGN_FLAG_HIDDEN;
|
||||
}
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
if (arprops == NULL) {
|
||||
/* add extra subdivided region for tool properties */
|
||||
arprops = MEM_callocN(sizeof(ARegion), "tool props for clip");
|
||||
@@ -157,6 +170,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa)
|
||||
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
}
|
||||
#endif
|
||||
|
||||
return artool;
|
||||
}
|
||||
@@ -189,11 +203,13 @@ void CLIP_OT_tools(wmOperatorType *ot)
|
||||
ot->poll = tools_poll;
|
||||
}
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
|
||||
/************************** redo panel ******************************/
|
||||
|
||||
static void clip_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op)
|
||||
{
|
||||
uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, 'V', 0);
|
||||
uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
|
||||
}
|
||||
|
||||
static void clip_panel_operator_redo_header(const bContext *C, Panel *pa)
|
||||
@@ -263,3 +279,4 @@ void ED_clip_tool_props_register(ARegionType *art)
|
||||
pt->draw = clip_panel_operator_redo;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -256,12 +256,14 @@ static SpaceLink *clip_new(const bContext *C)
|
||||
ar->regiontype = RGN_TYPE_TOOLS;
|
||||
ar->alignment = RGN_ALIGN_LEFT;
|
||||
|
||||
/* tool properties */
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
/* tools view */
|
||||
ar = MEM_callocN(sizeof(ARegion), "tool properties for clip");
|
||||
|
||||
BLI_addtail(&sc->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
#endif
|
||||
|
||||
/* properties view */
|
||||
ar = MEM_callocN(sizeof(ARegion), "properties for clip");
|
||||
@@ -889,20 +891,25 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
|
||||
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
|
||||
ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
|
||||
ARegion *ar_preview = ED_clip_has_preview_region(C, sa);
|
||||
ARegion *ar_properties = ED_clip_has_properties_region(sa);
|
||||
ARegion *ar_channels = ED_clip_has_channels_region(sa);
|
||||
bool main_visible = false, preview_visible = false, tools_visible = false;
|
||||
bool tool_props_visible = false, properties_visible = false, channels_visible = false;
|
||||
bool properties_visible = false, channels_visible = false;
|
||||
bool view_changed = false;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
|
||||
bool tool_props_visible = false;
|
||||
#endif
|
||||
|
||||
switch (sc->view) {
|
||||
case SC_VIEW_CLIP:
|
||||
main_visible = true;
|
||||
preview_visible = false;
|
||||
tools_visible = true;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
tool_props_visible = true;
|
||||
#endif
|
||||
properties_visible = true;
|
||||
channels_visible = false;
|
||||
break;
|
||||
@@ -910,7 +917,9 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
main_visible = false;
|
||||
preview_visible = true;
|
||||
tools_visible = false;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
tool_props_visible = false;
|
||||
#endif
|
||||
properties_visible = false;
|
||||
channels_visible = false;
|
||||
|
||||
@@ -920,7 +929,9 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
main_visible = false;
|
||||
preview_visible = true;
|
||||
tools_visible = false;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
tool_props_visible = false;
|
||||
#endif
|
||||
properties_visible = false;
|
||||
channels_visible = true;
|
||||
|
||||
@@ -1001,6 +1012,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
if (tool_props_visible) {
|
||||
if (ar_tool_props && (ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
|
||||
ar_tool_props->flag &= ~RGN_FLAG_HIDDEN;
|
||||
@@ -1024,6 +1036,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
|
||||
view_changed = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (preview_visible) {
|
||||
if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
|
||||
@@ -1607,6 +1620,7 @@ void ED_spacetype_clip(void)
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
/* tool properties */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region");
|
||||
art->regionid = RGN_TYPE_TOOL_PROPS;
|
||||
@@ -1619,6 +1633,7 @@ void ED_spacetype_clip(void)
|
||||
ED_clip_tool_props_register(art);
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
#endif
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
|
||||
|
||||
@@ -88,7 +88,8 @@ static void file_panel_operator(const bContext *C, Panel *pa)
|
||||
|
||||
UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
|
||||
|
||||
uiTemplateOperatorPropertyButs(C, pa->layout, op, file_panel_check_prop, '\0', UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
|
||||
uiTemplateOperatorPropertyButs(C, pa->layout, op, file_panel_check_prop, UI_BUT_LABEL_ALIGN_NONE,
|
||||
UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
|
||||
|
||||
UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -1431,7 +1431,7 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
|
||||
/* main draw call */
|
||||
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
|
||||
uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
|
||||
/* image template */
|
||||
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
|
||||
@@ -2147,7 +2147,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
|
||||
/* main draw call */
|
||||
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
|
||||
uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
|
||||
/* multiview template */
|
||||
if (is_multiview)
|
||||
|
||||
@@ -690,7 +690,7 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
|
||||
|
||||
/* main draw call */
|
||||
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
|
||||
uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, '\0');
|
||||
uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
|
||||
|
||||
/* image template */
|
||||
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
|
||||
|
||||
45
source/blender/editors/space_topbar/CMakeLists.txt
Normal file
45
source/blender/editors/space_topbar/CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# Contributor(s): Jacques Beaurain.
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../gpu
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
../../../../intern/glew-mx
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
${GLEW_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
set(SRC
|
||||
space_topbar.c
|
||||
)
|
||||
|
||||
add_definitions(${GL_DEFINITIONS})
|
||||
|
||||
blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}")
|
||||
265
source/blender/editors/space_topbar/space_topbar.c
Normal file
265
source/blender/editors/space_topbar/space_topbar.c
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2017 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributor(s): Blender Foundation
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file blender/editors/space_topbar/space_topbar.c
|
||||
* \ingroup sptopbar
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLO_readfile.h"
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_space_api.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
|
||||
/* ******************** default callbacks for topbar space ***************** */
|
||||
|
||||
static SpaceLink *topbar_new(const bContext *UNUSED(C))
|
||||
{
|
||||
ARegion *ar;
|
||||
SpaceTopBar *stopbar;
|
||||
|
||||
stopbar = MEM_callocN(sizeof(*stopbar), "init topbar");
|
||||
stopbar->spacetype = SPACE_TOPBAR;
|
||||
|
||||
/* header */
|
||||
ar = MEM_callocN(sizeof(ARegion), "left aligned header for topbar");
|
||||
BLI_addtail(&stopbar->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_HEADER;
|
||||
ar->alignment = RGN_ALIGN_TOP;
|
||||
ar = MEM_callocN(sizeof(ARegion), "right aligned header for topbar");
|
||||
BLI_addtail(&stopbar->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_HEADER;
|
||||
ar->alignment = RGN_ALIGN_RIGHT | RGN_SPLIT_PREV;
|
||||
|
||||
/* main regions */
|
||||
ar = MEM_callocN(sizeof(ARegion), "left aligned main region for topbar");
|
||||
BLI_addtail(&stopbar->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_WINDOW;
|
||||
ar->alignment = RGN_ALIGN_LEFT;
|
||||
ar = MEM_callocN(sizeof(ARegion), "right aligned main region for topbar");
|
||||
BLI_addtail(&stopbar->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_WINDOW;
|
||||
ar->alignment = RGN_ALIGN_RIGHT;
|
||||
ar = MEM_callocN(sizeof(ARegion), "center main region for topbar");
|
||||
BLI_addtail(&stopbar->regionbase, ar);
|
||||
ar->regiontype = RGN_TYPE_WINDOW;
|
||||
|
||||
return (SpaceLink *)stopbar;
|
||||
}
|
||||
|
||||
/* not spacelink itself */
|
||||
static void topbar_free(SpaceLink *UNUSED(sl))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* spacetype; init callback */
|
||||
static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static SpaceLink *topbar_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceTopBar *stopbarn = MEM_dupallocN(sl);
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
|
||||
return (SpaceLink *)stopbarn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void topbar_main_region_init(wmWindowManager *wm, ARegion *region)
|
||||
{
|
||||
wmKeyMap *keymap;
|
||||
|
||||
/* force delayed UI_view2d_region_reinit call */
|
||||
if (ELEM(region->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
|
||||
region->flag |= RGN_FLAG_DYNAMIC_SIZE;
|
||||
}
|
||||
UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_HEADER, region->winx, region->winy);
|
||||
|
||||
keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0);
|
||||
WM_event_add_keymap_handler(®ion->handlers, keymap);
|
||||
}
|
||||
|
||||
static void topbar_main_region_draw(const bContext *C, ARegion *region)
|
||||
{
|
||||
ED_region_header(C, region);
|
||||
}
|
||||
|
||||
static void topbar_operatortypes(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void topbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
|
||||
{
|
||||
if ((ar->alignment & ~RGN_SPLIT_PREV) == RGN_ALIGN_RIGHT) {
|
||||
ar->flag |= RGN_FLAG_DYNAMIC_SIZE;
|
||||
}
|
||||
ED_region_header_init(ar);
|
||||
}
|
||||
|
||||
static void topbar_header_region_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
ED_region_header(C, ar);
|
||||
}
|
||||
|
||||
static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
|
||||
wmNotifier *wmn, const Scene *UNUSED(scene))
|
||||
{
|
||||
/* context changes */
|
||||
switch (wmn->category) {
|
||||
case NC_WM:
|
||||
if (wmn->data == ND_HISTORY)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
case NC_SCENE:
|
||||
if (wmn->data == ND_MODE)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
case NC_SPACE:
|
||||
if (wmn->data == ND_SPACE_VIEW3D)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void topbar_header_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
|
||||
wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
|
||||
{
|
||||
/* context changes */
|
||||
#if 0
|
||||
switch (wmn->category) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
|
||||
{
|
||||
struct RecentFile *recent;
|
||||
uiLayout *layout = menu->layout;
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
|
||||
if (!BLI_listbase_is_empty(&G.recent_files)) {
|
||||
for (recent = G.recent_files.first; (recent); recent = recent->next) {
|
||||
const char *file = BLI_path_basename(recent->filepath);
|
||||
const int icon = BLO_has_bfile_extension(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP;
|
||||
uiItemStringO(layout, file, icon, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void recent_files_menu_register(void)
|
||||
{
|
||||
MenuType *mt;
|
||||
|
||||
mt = MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
|
||||
strcpy(mt->idname, "TOPBAR_MT_file_open_recent");
|
||||
strcpy(mt->label, N_("Open Recent..."));
|
||||
strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
mt->draw = recent_files_menu_draw;
|
||||
WM_menutype_add(mt);
|
||||
}
|
||||
|
||||
|
||||
/* only called once, from space/spacetypes.c */
|
||||
void ED_spacetype_topbar(void)
|
||||
{
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype topbar");
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid = SPACE_TOPBAR;
|
||||
strncpy(st->name, "Top Bar", BKE_ST_MAXNAME);
|
||||
|
||||
st->new = topbar_new;
|
||||
st->free = topbar_free;
|
||||
st->init = topbar_init;
|
||||
st->duplicate = topbar_duplicate;
|
||||
st->operatortypes = topbar_operatortypes;
|
||||
st->keymap = topbar_keymap;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype topbar main region");
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->init = topbar_main_region_init;
|
||||
art->draw = topbar_main_region_draw;
|
||||
art->listener = topbar_main_region_listener;
|
||||
art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype topbar header region");
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
||||
art->listener = topbar_header_listener;
|
||||
art->init = topbar_header_region_init;
|
||||
art->draw = topbar_header_region_draw;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
recent_files_menu_register();
|
||||
|
||||
BKE_spacetype_register(st);
|
||||
}
|
||||
@@ -113,17 +113,29 @@ ARegion *view3d_has_buttons_region(ScrArea *sa)
|
||||
|
||||
ARegion *view3d_has_tools_region(ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
|
||||
ARegion *ar, *artool = NULL, *arhead;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
ARegion *arprops = NULL;
|
||||
#endif
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_TOOLS)
|
||||
artool = ar;
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
|
||||
arprops = ar;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* tool region hide/unhide also hides props */
|
||||
if (arprops && artool) return artool;
|
||||
if (artool
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
&& arprops
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return artool;
|
||||
}
|
||||
|
||||
if (artool == NULL) {
|
||||
/* add subdiv level; after header */
|
||||
@@ -142,6 +154,7 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
|
||||
artool->flag = RGN_FLAG_HIDDEN;
|
||||
}
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
if (arprops == NULL) {
|
||||
/* add extra subdivided region for tool properties */
|
||||
arprops = MEM_callocN(sizeof(ARegion), "tool props for view3d");
|
||||
@@ -150,6 +163,7 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
|
||||
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
}
|
||||
#endif
|
||||
|
||||
return artool;
|
||||
}
|
||||
@@ -370,6 +384,7 @@ static SpaceLink *view3d_new(const bContext *C)
|
||||
ar->alignment = RGN_ALIGN_LEFT;
|
||||
ar->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
/* tool properties */
|
||||
ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
|
||||
|
||||
@@ -377,6 +392,7 @@ static SpaceLink *view3d_new(const bContext *C)
|
||||
ar->regiontype = RGN_TYPE_TOOL_PROPS;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
|
||||
ar->flag = RGN_FLAG_HIDDEN;
|
||||
#endif
|
||||
|
||||
/* buttons/list view */
|
||||
ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
|
||||
@@ -1312,6 +1328,7 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *ar)
|
||||
ED_region_panels(C, ar, CTX_data_mode_string(C), -1, true);
|
||||
}
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
static void view3d_props_region_listener(
|
||||
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
|
||||
wmNotifier *wmn, const Scene *UNUSED(scene))
|
||||
@@ -1332,6 +1349,7 @@ static void view3d_props_region_listener(
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* area (not region) level listener */
|
||||
static void space_view3d_listener(
|
||||
@@ -1523,6 +1541,7 @@ void ED_spacetype_view3d(void)
|
||||
view3d_toolshelf_register(art);
|
||||
#endif
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
/* regions: tool properties */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region");
|
||||
art->regionid = RGN_TYPE_TOOL_PROPS;
|
||||
@@ -1535,7 +1554,7 @@ void ED_spacetype_view3d(void)
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
view3d_tool_props_register(art);
|
||||
|
||||
#endif
|
||||
|
||||
/* regions: header */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region");
|
||||
|
||||
@@ -63,11 +63,12 @@
|
||||
#include "view3d_intern.h" /* own include */
|
||||
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
/* ******************* view3d space & buttons ************** */
|
||||
|
||||
static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op)
|
||||
{
|
||||
uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, 'V', 0);
|
||||
uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
|
||||
}
|
||||
|
||||
static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa)
|
||||
@@ -126,6 +127,8 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
|
||||
CTX_wm_region_set((bContext *)C, ar);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ******************* */
|
||||
|
||||
typedef struct CustomTool {
|
||||
@@ -239,6 +242,7 @@ void view3d_toolshelf_register(ARegionType *art)
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
|
||||
#ifndef WITH_REDO_REGION_REMOVAL
|
||||
void view3d_tool_props_register(ARegionType *art)
|
||||
{
|
||||
PanelType *pt;
|
||||
@@ -251,6 +255,7 @@ void view3d_tool_props_register(ARegionType *art)
|
||||
pt->draw = view3d_panel_operator_redo;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ********** operator to open/close toolshelf region */
|
||||
|
||||
|
||||
@@ -304,12 +304,44 @@ void ED_OT_undo_redo(wmOperatorType *ot)
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
struct OperatorRepeatContextHandle {
|
||||
ScrArea *restore_area;
|
||||
ARegion *restore_region;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the context to the state \a op was executed in (or at least, was in when registering).
|
||||
* #ED_operator_repeat_reset_context should be called when done repeating!
|
||||
*/
|
||||
const OperatorRepeatContextHandle *ED_operator_repeat_prepare_context(bContext *C, wmOperator *op)
|
||||
{
|
||||
static OperatorRepeatContextHandle context_info;
|
||||
|
||||
context_info.restore_area = CTX_wm_area(C);
|
||||
context_info.restore_region = CTX_wm_region(C);
|
||||
|
||||
CTX_wm_area_set(C, op->execution_area);
|
||||
CTX_wm_region_set(C, op->execution_region);
|
||||
|
||||
return &context_info;
|
||||
}
|
||||
/**
|
||||
* Resets context to the old state from before #ED_operator_repeat_prepare_context was called.
|
||||
*/
|
||||
void ED_operator_repeat_reset_context(bContext *C, const OperatorRepeatContextHandle *context_info)
|
||||
{
|
||||
CTX_wm_area_set(C, context_info->restore_area);
|
||||
CTX_wm_region_set(C, context_info->restore_region);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Operator Repeat
|
||||
* \{ */
|
||||
|
||||
/* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
|
||||
int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
|
||||
int ED_undo_operator_repeat(bContext *C, wmOperator *op)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -318,12 +350,17 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
struct Scene *scene = CTX_data_scene(C);
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
const OperatorRepeatContextHandle *context_info;
|
||||
context_info = ED_operator_repeat_prepare_context(C, op);
|
||||
#else
|
||||
/* keep in sync with logic in view3d_panel_operator_redo() */
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
|
||||
|
||||
if (ar1)
|
||||
CTX_wm_region_set(C, ar1);
|
||||
#endif
|
||||
|
||||
if ((WM_operator_repeat_check(C, op)) &&
|
||||
(WM_operator_poll(C, op->type)) &&
|
||||
@@ -369,8 +406,12 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
ED_operator_repeat_reset_context(C, context_info);
|
||||
#else
|
||||
/* set region back */
|
||||
CTX_wm_region_set(C, ar);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
CLOG_WARN(&LOG, "called with NULL 'op'");
|
||||
|
||||
@@ -48,12 +48,19 @@ struct wmTimer;
|
||||
struct wmTooltipState;
|
||||
|
||||
|
||||
/* TODO Doing this is quite ugly :)
|
||||
* Once the top-bar is merged bScreen should be refactored to use ScrAreaMap. */
|
||||
#define AREAMAP_FROM_SCREEN(screen) ((ScrAreaMap *)&(screen)->vertbase)
|
||||
|
||||
typedef struct bScreen {
|
||||
ID id;
|
||||
|
||||
/* TODO Should become ScrAreaMap now.
|
||||
* ** NOTE: KEEP ORDER IN SYNC WITH ScrAreaMap! (see AREAMAP_FROM_SCREEN macro above) ** */
|
||||
ListBase vertbase; /* screens have vertices/edges to define areas */
|
||||
ListBase edgebase;
|
||||
ListBase areabase;
|
||||
|
||||
ListBase regionbase; /* screen level regions (menus), runtime only */
|
||||
|
||||
struct Scene *scene DNA_DEPRECATED;
|
||||
@@ -98,6 +105,14 @@ typedef struct ScrEdge {
|
||||
int pad;
|
||||
} ScrEdge;
|
||||
|
||||
typedef struct ScrAreaMap {
|
||||
/* ** NOTE: KEEP ORDER IN SYNC WITH LISTBASES IN bScreen! ** */
|
||||
|
||||
ListBase vertbase; /* ScrVert - screens have vertices/edges to define areas */
|
||||
ListBase edgebase; /* ScrEdge */
|
||||
ListBase areabase; /* ScrArea */
|
||||
} ScrAreaMap;
|
||||
|
||||
typedef struct Panel { /* the part from uiBlock that needs saved in file */
|
||||
struct Panel *next, *prev;
|
||||
|
||||
@@ -211,6 +226,23 @@ typedef struct uiPreview { /* some preview UI data need to be saved in
|
||||
short pad1[3];
|
||||
} uiPreview;
|
||||
|
||||
/* These two lines with # tell makesdna this struct can be excluded.
|
||||
* Should be: #ifndef WITH_TOPBAR_WRITING */
|
||||
#
|
||||
#
|
||||
typedef struct ScrGlobalAreaData {
|
||||
/* Global areas have a non-dynamic size. That means, changing the window
|
||||
* size doesn't affect their size at all. However, they can still be
|
||||
* 'collapsed', by changing this value. Ignores DPI (ED_area_global_size_y
|
||||
* and winx/winy don't) */
|
||||
short cur_fixed_height;
|
||||
/* For global areas, this is the min and max size they can use depending on
|
||||
* if they are 'collapsed' or not. Value is set on area creation and not
|
||||
* touched afterwards. */
|
||||
short size_min, size_max;
|
||||
short pad;
|
||||
} ScrGlobalAreaData;
|
||||
|
||||
typedef struct ScrArea {
|
||||
struct ScrArea *next, *prev;
|
||||
|
||||
@@ -231,6 +263,9 @@ typedef struct ScrArea {
|
||||
|
||||
struct SpaceType *type; /* callbacks for this space type */
|
||||
|
||||
/* Non-NULL if this area is global. */
|
||||
ScrGlobalAreaData *global;
|
||||
|
||||
/* A list of space links (editors) that were open in this area before. When
|
||||
* changing the editor type, we try to reuse old editor data from this list.
|
||||
* The first item is the active/visible one.
|
||||
@@ -295,7 +330,11 @@ enum {
|
||||
HEADER_NO_PULLDOWN = (1 << 0),
|
||||
// AREA_FLAG_DEPRECATED_1 = (1 << 1),
|
||||
// AREA_FLAG_DEPRECATED_2 = (1 << 2),
|
||||
AREA_TEMP_INFO = (1 << 3),
|
||||
#ifdef DNA_DEPRECATED_ALLOW
|
||||
AREA_TEMP_INFO = (1 << 3), /* versioned to make slot reusable */
|
||||
#endif
|
||||
/* update size of regions within the area */
|
||||
AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3),
|
||||
// AREA_FLAG_DEPRECATED_4 = (1 << 4),
|
||||
// AREA_FLAG_DEPRECATED_5 = (1 << 5),
|
||||
/* used to check if we should switch back to prevspace (of a different type) */
|
||||
@@ -413,8 +452,19 @@ enum {
|
||||
#define RGN_SPLIT_PREV 32
|
||||
|
||||
/* region flag */
|
||||
#define RGN_FLAG_HIDDEN 1
|
||||
#define RGN_FLAG_TOO_SMALL 2
|
||||
enum {
|
||||
RGN_FLAG_HIDDEN = (1 << 0),
|
||||
RGN_FLAG_TOO_SMALL = (1 << 1),
|
||||
/* Force delayed reinit of region size data, so that region size is calculated
|
||||
* just big enough to show all its content (if enough space is available).
|
||||
* Note that only ED_region_header supports this right now. */
|
||||
RGN_FLAG_DYNAMIC_SIZE = (1 << 2),
|
||||
/* The region width stored in ARegion.sizex already has the DPI
|
||||
* factor applied, skip applying it again (in region_rect_recursive).
|
||||
* XXX Not nice at all. Leaving for now as temporary solution, but
|
||||
* it might cause issues if we change how ARegion.sizex is used... */
|
||||
RGN_SIZEX_DPI_APPLIED = (1 << 3),
|
||||
};
|
||||
|
||||
/* region do_draw */
|
||||
#define RGN_DRAW 1
|
||||
|
||||
@@ -67,6 +67,14 @@ struct MovieClipScopes;
|
||||
struct Mask;
|
||||
struct BLI_mempool;
|
||||
|
||||
/* TODO 2.8: Remove the operator redo panel/region from the 3D View and Clip
|
||||
* Editor toolshelf. Leaving this ifdef'ed out for until new tool system and
|
||||
* topbar design is more clear. */
|
||||
//#define WITH_REDO_REGION_REMOVAL
|
||||
/* TODO 2.8: We don't write the topbar to files currently. Uncomment this
|
||||
* define to enable writing (should become the default in a bit). */
|
||||
//#define WITH_TOPBAR_WRITING
|
||||
|
||||
|
||||
/* SpaceLink (Base) ==================================== */
|
||||
|
||||
@@ -1330,6 +1338,7 @@ typedef struct SpaceClip {
|
||||
MaskSpaceInfo mask_info;
|
||||
} SpaceClip;
|
||||
|
||||
|
||||
/* SpaceClip->flag */
|
||||
typedef enum eSpaceClip_Flag {
|
||||
SC_SHOW_MARKER_PATTERN = (1 << 0),
|
||||
@@ -1378,6 +1387,22 @@ typedef enum eSpaceClip_GPencil_Source {
|
||||
SC_GPENCIL_SRC_TRACK = 1,
|
||||
} eSpaceClip_GPencil_Source;
|
||||
|
||||
|
||||
/* Top Bar ======================================= */
|
||||
|
||||
/* These two lines with # tell makesdna this struct can be excluded.
|
||||
* Should be: #ifndef WITH_TOPBAR_WRITING */
|
||||
#
|
||||
#
|
||||
typedef struct SpaceTopBar {
|
||||
SpaceLink *next, *prev;
|
||||
ListBase regionbase; /* storage of regions for inactive spaces */
|
||||
int spacetype;
|
||||
|
||||
int pad;
|
||||
} SpaceTopBar;
|
||||
|
||||
|
||||
/* **************** SPACE DEFINES ********************* */
|
||||
|
||||
/* space types, moved from DNA_screen_types.h */
|
||||
@@ -1407,8 +1432,9 @@ typedef enum eSpace_Type {
|
||||
SPACE_CONSOLE = 18,
|
||||
SPACE_USERPREF = 19,
|
||||
SPACE_CLIP = 20,
|
||||
SPACE_TOPBAR = 21,
|
||||
|
||||
SPACEICONMAX = SPACE_CLIP
|
||||
SPACEICONMAX = SPACE_TOPBAR
|
||||
} eSpace_Type;
|
||||
|
||||
/* use for function args */
|
||||
|
||||
@@ -400,6 +400,7 @@ typedef struct bTheme {
|
||||
ThemeSpace tuserpref;
|
||||
ThemeSpace tconsole;
|
||||
ThemeSpace tclip;
|
||||
ThemeSpace ttopbar;
|
||||
|
||||
/* 20 sets of bone colors for this theme */
|
||||
ThemeWireColor tarm[20];
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define __DNA_WINDOWMANAGER_TYPES_H__
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_vec_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
@@ -190,6 +191,10 @@ typedef struct wmWindow {
|
||||
|
||||
struct WorkSpaceInstanceHook *workspace_hook;
|
||||
|
||||
/** Global areas aren't part of the screen, but part of the window directly.
|
||||
* \note Code assumes global areas with fixed height, fixed width not supported yet */
|
||||
ScrAreaMap global_areas;
|
||||
|
||||
struct bScreen *screen DNA_DEPRECATED;
|
||||
|
||||
short posx, posy, sizex, sizey; /* window coords */
|
||||
@@ -376,6 +381,10 @@ typedef struct wmOperator {
|
||||
struct uiLayout *layout; /* runtime for drawing */
|
||||
short flag, pad[3];
|
||||
|
||||
/* Screen context the operator was finished in. It gets temporarily
|
||||
* restored during operator repeat. Only set for registered operators. */
|
||||
struct ScrArea *execution_area;
|
||||
struct ARegion *execution_region;
|
||||
} wmOperator;
|
||||
|
||||
/* operator type return flags: exec(), invoke() modal(), return values */
|
||||
|
||||
@@ -83,6 +83,12 @@ static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
|
||||
return wm ? (ED_screen_animation_playing(wm) != NULL) : 0;
|
||||
}
|
||||
|
||||
static int rna_region_alignment_get(PointerRNA *ptr)
|
||||
{
|
||||
ARegion *region = ptr->data;
|
||||
return (region->alignment & ~RGN_SPLIT_PREV);
|
||||
}
|
||||
|
||||
static void rna_Screen_layout_name_get(PointerRNA *ptr, char *value)
|
||||
{
|
||||
const bScreen *screen = ptr->data;
|
||||
@@ -130,10 +136,22 @@ static int rna_Screen_fullscreen_get(PointerRNA *ptr)
|
||||
/* UI compatible list: should not be needed, but for now we need to keep EMPTY
|
||||
* at least in the static version of this enum for python scripts. */
|
||||
static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
|
||||
PropertyRNA *UNUSED(prop), bool *r_free)
|
||||
{
|
||||
EnumPropertyItem *item = NULL;
|
||||
int totitem = 0;
|
||||
|
||||
/* +1 to skip SPACE_EMPTY */
|
||||
return rna_enum_space_type_items + 1;
|
||||
for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
|
||||
if (ELEM(item_from->value, SPACE_TOPBAR)) {
|
||||
continue;
|
||||
}
|
||||
RNA_enum_item_add(&item, &totitem, item_from);
|
||||
}
|
||||
RNA_enum_item_end(&item, &totitem);
|
||||
*r_free = true;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
static int rna_Area_type_get(PointerRNA *ptr)
|
||||
@@ -145,6 +163,13 @@ static int rna_Area_type_get(PointerRNA *ptr)
|
||||
|
||||
static void rna_Area_type_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
if (ELEM(value, SPACE_TOPBAR)) {
|
||||
/* Special case: An area can not be set to show the top-bar editor (or
|
||||
* other global areas). However it should still be possible to identify
|
||||
* its type from Python. */
|
||||
return;
|
||||
}
|
||||
|
||||
ScrArea *sa = (ScrArea *)ptr->data;
|
||||
sa->butspacetype = value;
|
||||
}
|
||||
@@ -329,6 +354,19 @@ static void rna_def_region(BlenderRNA *brna)
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
static const EnumPropertyItem alignment_types[] = {
|
||||
{RGN_ALIGN_NONE, "NONE", 0, "None", "Don't use any fixed alignment, fill available space"},
|
||||
{RGN_ALIGN_TOP, "TOP", 0, "Top", ""},
|
||||
{RGN_ALIGN_BOTTOM, "BOTTOM", 0, "Bottom", ""},
|
||||
{RGN_ALIGN_LEFT, "LEFT", 0, "Left", ""},
|
||||
{RGN_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
|
||||
{RGN_ALIGN_HSPLIT, "HORIZONTAL_SPLIT", 0, "Horizontal Split", ""},
|
||||
{RGN_ALIGN_VSPLIT, "VERTICAL_SPLIT", 0, "Vertical Split", ""},
|
||||
{RGN_ALIGN_FLOAT, "FLOAT", 0, "Float", "Region floats on screen, doesn't use any fixed alignment"},
|
||||
{RGN_ALIGN_QSPLIT, "QUAD_SPLIT", 0, "Quad Split", "Region is split horizontally and vertically"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "Region", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area");
|
||||
RNA_def_struct_sdna(srna, "ARegion");
|
||||
@@ -365,6 +403,12 @@ static void rna_def_region(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_ui_text(prop, "View2D", "2D view of the region");
|
||||
|
||||
prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_enum_items(prop, alignment_types);
|
||||
RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area");
|
||||
|
||||
RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
|
||||
"advanced editing and script development"},
|
||||
{SPACE_INFO, "INFO", ICON_INFO, "Info", "Main menu bar and list of error messages "
|
||||
"(drag down to expand and display)"},
|
||||
/* Special case: Top-bar isn't supposed to be a regular editor for the user. */
|
||||
{SPACE_TOPBAR, "TOPBAR", ICON_NONE, "Top Bar", "Global bar at the top of the screen for global per-window settings"},
|
||||
|
||||
/* Data */
|
||||
{0, "", ICON_NONE, "Data", ""},
|
||||
@@ -1806,6 +1808,7 @@ static void rna_def_space(BlenderRNA *brna)
|
||||
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "spacetype");
|
||||
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
|
||||
/* When making this editable, take care for the special case of global areas (see rna_Area_type_set). */
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Type", "Space data type");
|
||||
|
||||
|
||||
@@ -568,7 +568,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
|
||||
|
||||
if (!ht)
|
||||
return;
|
||||
if (!(art = region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER)))
|
||||
if (!(art = region_type_find(NULL, ht->space_type, ht->region_type)))
|
||||
return;
|
||||
|
||||
RNA_struct_free_extension(type, &ht->ext);
|
||||
@@ -592,6 +592,7 @@ static StructRNA *rna_Header_register(
|
||||
|
||||
/* setup dummy header & header type to store static properties in */
|
||||
dummyheader.type = &dummyht;
|
||||
dummyht.region_type = RGN_TYPE_HEADER; /* RGN_TYPE_HEADER by default, may be overridden */
|
||||
RNA_pointer_create(NULL, &RNA_Header, &dummyheader, &dummyhtr);
|
||||
|
||||
/* validate the python class */
|
||||
@@ -604,7 +605,7 @@ static StructRNA *rna_Header_register(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(art = region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER)))
|
||||
if (!(art = region_type_find(reports, dummyht.space_type, dummyht.region_type)))
|
||||
return NULL;
|
||||
|
||||
/* check if we have registered this header type before, and remove it */
|
||||
@@ -1240,6 +1241,14 @@ static void rna_def_header(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_REGISTER);
|
||||
RNA_def_property_ui_text(prop, "Space type", "The space where the header is going to be used in");
|
||||
|
||||
prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
|
||||
RNA_def_property_enum_default(prop, RGN_TYPE_HEADER);
|
||||
RNA_def_property_enum_items(prop, rna_enum_region_type_items);
|
||||
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
||||
RNA_def_property_ui_text(prop, "Region Type", "The region where the header is going to be used in "
|
||||
"(defaults to header region)");
|
||||
|
||||
RNA_define_verify_sdna(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -715,6 +715,15 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
api_ui_item_common_text(func);
|
||||
|
||||
func = RNA_def_function(srna, "template_ID_tabs", "uiTemplateIDTabs");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
api_ui_item_rna_common(func);
|
||||
RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new ID block");
|
||||
RNA_def_string(func, "open", NULL, 0, "", "Operator identifier to open a file for creating a new ID block");
|
||||
RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink the ID block");
|
||||
RNA_def_enum(func, "filter", id_template_filter_items, UI_TEMPLATE_ID_FILTER_ALL,
|
||||
"", "Optionally limit the items which can be selected");
|
||||
|
||||
func = RNA_def_function(srna, "template_search", "uiTemplateSearch");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
api_ui_item_rna_common(func);
|
||||
@@ -756,6 +765,12 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
func = RNA_def_function(srna, "template_operator_redo_props", "uiTemplateOperatorRedoProperties");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
||||
RNA_def_function_ui_description(func, "Adds properties of the last executed operator using redo");
|
||||
#endif
|
||||
|
||||
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
|
||||
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
|
||||
parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
|
||||
|
||||
@@ -1030,6 +1030,11 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "State Colors", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
|
||||
prop = RNA_def_property(srna, "wcol_tab", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_ui_text(prop, "Tab Colors", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
|
||||
prop = RNA_def_property(srna, "menu_shadow_fac", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_ui_text(prop, "Menu Shadow Strength", "Blending factor for menu shadows");
|
||||
RNA_def_property_range(prop, 0.01f, 1.0f);
|
||||
@@ -2960,6 +2965,20 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
|
||||
rna_def_userdef_theme_spaces_curves(srna, false, false, false, true);
|
||||
}
|
||||
|
||||
static void rna_def_userdef_theme_space_topbar(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
|
||||
/* space_topbar */
|
||||
|
||||
srna = RNA_def_struct(brna, "ThemeTopBar", NULL);
|
||||
RNA_def_struct_sdna(srna, "ThemeSpace");
|
||||
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
|
||||
RNA_def_struct_ui_text(srna, "Theme Top Bar", "Theme settings for the Top Bar");
|
||||
|
||||
rna_def_userdef_theme_spaces_main(srna);
|
||||
}
|
||||
|
||||
static void rna_def_userdef_themes(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
@@ -2985,6 +3004,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
|
||||
{16, "FILE_BROWSER", ICON_FILESEL, "File Browser", ""},
|
||||
{17, "CONSOLE", ICON_CONSOLE, "Python Console", ""},
|
||||
{20, "CLIP_EDITOR", ICON_CLIP, "Movie Clip Editor", ""},
|
||||
{21, "TOPBAR", ICON_NONE, "Top Bar", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -3112,6 +3132,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "tclip");
|
||||
RNA_def_property_struct_type(prop, "ThemeClipEditor");
|
||||
RNA_def_property_ui_text(prop, "Clip Editor", "");
|
||||
|
||||
prop = RNA_def_property(srna, "topbar", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "ttopbar");
|
||||
RNA_def_property_struct_type(prop, "ThemeTopBar");
|
||||
RNA_def_property_ui_text(prop, "Top Bar", "");
|
||||
}
|
||||
|
||||
static void rna_def_userdef_addon(BlenderRNA *brna)
|
||||
@@ -3202,6 +3228,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna)
|
||||
rna_def_userdef_theme_space_userpref(brna);
|
||||
rna_def_userdef_theme_space_console(brna);
|
||||
rna_def_userdef_theme_space_clip(brna);
|
||||
rna_def_userdef_theme_space_topbar(brna);
|
||||
rna_def_userdef_theme_colorset(brna);
|
||||
rna_def_userdef_themes(brna);
|
||||
}
|
||||
|
||||
@@ -96,8 +96,10 @@ void WM_init_splash (struct bContext *C);
|
||||
|
||||
void WM_check (struct bContext *C);
|
||||
|
||||
int WM_window_pixels_x (struct wmWindow *win);
|
||||
int WM_window_pixels_y (struct wmWindow *win);
|
||||
int WM_window_pixels_x(const struct wmWindow *win);
|
||||
int WM_window_pixels_y(const struct wmWindow *win);
|
||||
int WM_window_screen_pixels_x(const struct wmWindow *win);
|
||||
int WM_window_screen_pixels_y(const struct wmWindow *win);
|
||||
bool WM_window_is_fullscreen(struct wmWindow *win);
|
||||
|
||||
void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATTR_NONNULL();
|
||||
|
||||
@@ -278,6 +278,7 @@ typedef struct wmNotifier {
|
||||
#define ND_LAYOUTSET (7<<16)
|
||||
#define ND_SKETCH (8<<16)
|
||||
#define ND_WORKSPACE_SET (9<<16)
|
||||
#define ND_WORKSPACE_DELETE (10<<16)
|
||||
|
||||
/* NC_SCENE Scene */
|
||||
#define ND_SCENEBROWSE (1<<16)
|
||||
|
||||
@@ -165,6 +165,11 @@ void wm_operator_register(bContext *C, wmOperator *op)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
int tot = 0;
|
||||
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
op->execution_area = CTX_wm_area(C);
|
||||
op->execution_region = CTX_wm_region(C);
|
||||
#endif
|
||||
|
||||
BLI_addtail(&wm->operators, op);
|
||||
|
||||
/* only count registered operators */
|
||||
@@ -465,6 +470,7 @@ void wm_add_default(Main *bmain, bContext *C)
|
||||
WM_window_set_active_workspace(win, workspace);
|
||||
WM_window_set_active_layout(win, workspace, layout);
|
||||
screen->winid = win->winid;
|
||||
ED_screen_global_areas_create(win);
|
||||
|
||||
wm->winactive = win;
|
||||
wm->file_saved = 1;
|
||||
|
||||
@@ -162,6 +162,14 @@ static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph *
|
||||
}
|
||||
}
|
||||
|
||||
static void wm_draw_region(bContext *C, ARegion *ar)
|
||||
{
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
ar->do_draw = false;
|
||||
CTX_wm_region_set(C, NULL);
|
||||
}
|
||||
|
||||
/********************** draw all **************************/
|
||||
/* - reference method, draw all each time */
|
||||
|
||||
@@ -208,11 +216,10 @@ static void wm_draw_callbacks(wmWindow *win)
|
||||
static void wm_method_draw_full(bContext *C, wmWindow *win)
|
||||
{
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
/* draw area regions */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
@@ -254,12 +261,11 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
|
||||
/* same buffer as we swapped to the front */
|
||||
|
||||
/* mark area-regions to redraw if overlapped with rect */
|
||||
static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
|
||||
static void wm_flush_regions_down(wmWindow *win, bScreen *screen, rcti *dirty)
|
||||
{
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) {
|
||||
ar->do_draw = RGN_DRAW;
|
||||
@@ -288,23 +294,24 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
static rcti rect = {0, 0, 0, 0};
|
||||
|
||||
/* after backbuffer selection draw, we need to redraw */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next)
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
if (ar->visible && !wm_area_test_invalid_backbuf(sa))
|
||||
ED_region_tag_redraw(ar);
|
||||
}
|
||||
|
||||
/* flush overlapping regions */
|
||||
if (screen->regionbase.first) {
|
||||
/* flush redraws of area regions up to overlapping regions */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next)
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
if (ar->visible && ar->do_draw)
|
||||
wm_flush_regions_up(screen, &ar->winrct);
|
||||
}
|
||||
|
||||
/* flush between overlapping regions */
|
||||
for (ar = screen->regionbase.last; ar; ar = ar->prev)
|
||||
@@ -314,12 +321,12 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
||||
/* flush redraws of overlapping regions down to area regions */
|
||||
for (ar = screen->regionbase.last; ar; ar = ar->prev)
|
||||
if (ar->visible && ar->do_draw)
|
||||
wm_flush_regions_down(screen, &ar->winrct);
|
||||
wm_flush_regions_down(win, screen, &ar->winrct);
|
||||
}
|
||||
|
||||
/* flush drag item */
|
||||
if (rect.xmin != rect.xmax) {
|
||||
wm_flush_regions_down(screen, &rect);
|
||||
wm_flush_regions_down(win, screen, &rect);
|
||||
rect.xmin = rect.xmax = 0;
|
||||
}
|
||||
if (wm->drags.first) {
|
||||
@@ -328,7 +335,7 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
||||
}
|
||||
|
||||
/* draw marked area regions */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
@@ -526,7 +533,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmDrawData *dd, *dd_next, *drawdata = win->drawdata.first;
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
bool copytex = false;
|
||||
|
||||
@@ -567,17 +573,14 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
|
||||
wmDrawTriple *triple = drawdata->triple;
|
||||
|
||||
/* draw marked area regions */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
/* draw marked area regions (also global ones) */
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->visible && ar->do_draw) {
|
||||
if (ar->overlap == false) {
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
ar->do_draw = false;
|
||||
CTX_wm_region_set(C, NULL);
|
||||
wm_draw_region(C, ar);
|
||||
copytex = true;
|
||||
}
|
||||
}
|
||||
@@ -594,7 +597,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
}
|
||||
|
||||
if (wm->paintcursors.first) {
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->visible && ar == screen->active_region) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
@@ -614,16 +617,12 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
}
|
||||
|
||||
/* draw overlapping area regions (always like popups) */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->visible && ar->overlap) {
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
ar->do_draw = false;
|
||||
CTX_wm_region_set(C, NULL);
|
||||
|
||||
wm_draw_region(C, ar);
|
||||
wm_draw_region_blend(win, ar, triple);
|
||||
}
|
||||
}
|
||||
@@ -662,7 +661,6 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
|
||||
wmDrawData *drawdata;
|
||||
wmDrawTriple *triple_data, *triple_all;
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
int copytex = false;
|
||||
int id;
|
||||
@@ -703,7 +701,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
|
||||
triple_all = ((wmDrawData *) BLI_findlink(&win->drawdata, (sview * 2) + 1))->triple;
|
||||
|
||||
/* draw marked area regions */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
switch (sa->spacetype) {
|
||||
@@ -769,7 +767,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
|
||||
}
|
||||
|
||||
if (wm->paintcursors.first) {
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->visible && ar == screen->active_region) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
@@ -789,7 +787,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
|
||||
}
|
||||
|
||||
/* draw overlapping area regions (always like popups) */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
@@ -849,7 +847,6 @@ static bool wm_draw_update_test_window(wmWindow *win)
|
||||
/*const*/ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
|
||||
struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
|
||||
const bScreen *screen = WM_window_get_active_screen(win);
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
bool do_draw = false;
|
||||
|
||||
@@ -862,7 +859,7 @@ static bool wm_draw_update_test_window(wmWindow *win)
|
||||
do_draw = true;
|
||||
}
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
wm_region_test_render_do_draw(scene, depsgraph, sa, ar);
|
||||
|
||||
@@ -963,8 +960,7 @@ void wm_draw_update(bContext *C)
|
||||
wm_window_make_drawable(wm, win);
|
||||
|
||||
/* notifiers for screen redraw */
|
||||
if (screen->do_refresh)
|
||||
ED_screen_refresh(wm, win);
|
||||
ED_screen_ensure_updated(wm, win, screen);
|
||||
|
||||
int drawmethod = wm_automatic_draw_method(win);
|
||||
|
||||
@@ -1011,16 +1007,17 @@ void wm_draw_data_free(wmWindow *win)
|
||||
void wm_draw_window_clear(wmWindow *win)
|
||||
{
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
wm_draw_data_free(win);
|
||||
|
||||
/* clear screen swap flags */
|
||||
if (screen) {
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next)
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
ar->swap = WIN_NONE_OK;
|
||||
}
|
||||
}
|
||||
|
||||
screen->swap = WIN_NONE_OK;
|
||||
}
|
||||
@@ -1032,7 +1029,7 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar)
|
||||
int drawmethod = wm_automatic_draw_method(win);
|
||||
|
||||
if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP))
|
||||
wm_flush_regions_down(screen, &ar->winrct);
|
||||
wm_flush_regions_down(win, screen, &ar->winrct);
|
||||
|
||||
screen->do_draw = true;
|
||||
}
|
||||
|
||||
@@ -386,6 +386,13 @@ void wm_event_do_notifiers(bContext *C)
|
||||
if (G.debug & G_DEBUG_EVENTS)
|
||||
printf("%s: Workspace set %p\n", __func__, note->reference);
|
||||
}
|
||||
else if (note->data == ND_WORKSPACE_DELETE) {
|
||||
WorkSpace *workspace = note->reference;
|
||||
|
||||
ED_workspace_delete(workspace, CTX_data_main(C), C, wm); // XXX hrms, think this over!
|
||||
if (G.debug & G_DEBUG_EVENTS)
|
||||
printf("%s: Workspace delete %p\n", __func__, workspace);
|
||||
}
|
||||
else if (note->data == ND_LAYOUTBROWSE) {
|
||||
bScreen *ref_screen = BKE_workspace_layout_screen_get(note->reference);
|
||||
|
||||
@@ -455,7 +462,6 @@ void wm_event_do_notifiers(bContext *C)
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
/* XXX context in notifiers? */
|
||||
@@ -468,7 +474,7 @@ void wm_event_do_notifiers(bContext *C)
|
||||
ED_region_do_listen(screen, NULL, ar, note, scene);
|
||||
}
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
ED_area_do_listen(screen, sa, note, scene, workspace);
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
ED_region_do_listen(screen, sa, ar, note, scene);
|
||||
@@ -938,7 +944,18 @@ int WM_operator_call_notest(bContext *C, wmOperator *op)
|
||||
*/
|
||||
int WM_operator_repeat(bContext *C, wmOperator *op)
|
||||
{
|
||||
#ifdef WITH_REDO_REGION_REMOVAL
|
||||
const OperatorRepeatContextHandle *context_info;
|
||||
int retval;
|
||||
|
||||
context_info = ED_operator_repeat_prepare_context(C, op);
|
||||
retval = wm_operator_exec(C, op, true, true);
|
||||
ED_operator_repeat_reset_context(C, context_info);
|
||||
|
||||
return retval;
|
||||
#else
|
||||
return wm_operator_exec(C, op, true, true);
|
||||
#endif
|
||||
}
|
||||
/**
|
||||
* \return true if #WM_operator_repeat can run
|
||||
@@ -1528,17 +1545,22 @@ void wm_event_free_handler(wmEventHandler *handler)
|
||||
/* only set context when area/region is part of screen */
|
||||
static void wm_handler_op_context(bContext *C, wmEventHandler *handler, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
|
||||
if (screen && handler->op) {
|
||||
if (handler->op_area == NULL)
|
||||
CTX_wm_area_set(C, NULL);
|
||||
else {
|
||||
ScrArea *sa;
|
||||
ScrArea *sa = NULL;
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next)
|
||||
if (sa == handler->op_area)
|
||||
ED_screen_areas_iter(win, screen, sa_iter) {
|
||||
if (sa_iter == handler->op_area) {
|
||||
sa = sa_iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sa == NULL) {
|
||||
/* when changing screen layouts with running modal handlers (like render display), this
|
||||
* is not an error to print */
|
||||
@@ -2493,13 +2515,15 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect)
|
||||
|
||||
static ScrArea *area_event_inside(bContext *C, const int xy[2])
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
ScrArea *sa;
|
||||
|
||||
if (screen)
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next)
|
||||
if (screen) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
if (BLI_rcti_isect_pt_v(&sa->totrct, xy))
|
||||
return sa;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2739,7 +2763,6 @@ void wm_event_do_handlers(bContext *C)
|
||||
wm_tweakevent_test(C, event, action);
|
||||
|
||||
if ((action & WM_HANDLER_BREAK) == 0) {
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
/* Note: setting subwin active should be done here, after modal handlers have been done */
|
||||
@@ -2755,7 +2778,7 @@ void wm_event_do_handlers(bContext *C)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
/* after restoring a screen from SCREENMAXIMIZED we have to wait
|
||||
* with the screen handling till the region coordinates are updated */
|
||||
if (screen->skip_handling == true) {
|
||||
@@ -2935,26 +2958,28 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
|
||||
|
||||
if (handler->type == WM_HANDLER_FILESELECT) {
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
ScrArea *sa;
|
||||
bool cancel_handler = true;
|
||||
|
||||
/* find the area with the file selector for this handler */
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
ED_screen_areas_iter(win, screen, sa) {
|
||||
if (sa->spacetype == SPACE_FILE) {
|
||||
SpaceFile *sfile = sa->spacedata.first;
|
||||
|
||||
if (sfile->op == handler->op) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL);
|
||||
cancel_handler = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if not found we stop the handler without changing the screen */
|
||||
if (!sa)
|
||||
if (cancel_handler) {
|
||||
wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler");
|
||||
|
||||
|
||||
@@ -1498,13 +1498,15 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
|
||||
|
||||
if (op->type->flag & OPTYPE_MACRO) {
|
||||
for (op = op->macro.first; op; op = op->next) {
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
|
||||
UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
if (op->next)
|
||||
uiItemS(layout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
|
||||
UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
}
|
||||
|
||||
UI_block_bounds_set_popup(block, 4, 0, 0);
|
||||
@@ -1573,7 +1575,8 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
|
||||
|
||||
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
|
||||
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'H', UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
|
||||
UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
|
||||
|
||||
/* clear so the OK button is left alone */
|
||||
UI_block_func_set(block, NULL, NULL, NULL);
|
||||
@@ -1612,7 +1615,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
|
||||
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
|
||||
|
||||
/* since ui is defined the auto-layout args are not used */
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, 'V', 0);
|
||||
uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
|
||||
|
||||
UI_block_func_set(block, NULL, NULL, NULL);
|
||||
|
||||
|
||||
@@ -208,6 +208,8 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
CTX_wm_window_set(C, NULL);
|
||||
}
|
||||
|
||||
BKE_screen_area_map_free(&win->global_areas);
|
||||
|
||||
/* end running jobs, a job end also removes its timer */
|
||||
for (wt = wm->timers.first; wt; wt = wtnext) {
|
||||
wtnext = wt->next;
|
||||
@@ -302,6 +304,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
|
||||
WM_window_set_active_workspace(win_dst, workspace);
|
||||
layout_new = duplicate_layout ? ED_workspace_layout_duplicate(workspace, layout_old, win_dst) : layout_old;
|
||||
WM_window_set_active_layout(win_dst, workspace, layout_new);
|
||||
ED_screen_global_areas_create(win_dst);
|
||||
|
||||
win_dst->drawmethod = U.wmdrawmethod;
|
||||
|
||||
@@ -782,6 +785,11 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
|
||||
WM_event_add_dropbox_handler(&win->handlers, lb);
|
||||
}
|
||||
wm_window_title(wm, win);
|
||||
|
||||
/* add topbar */
|
||||
if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
|
||||
ED_screen_global_areas_create(win);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,6 +1016,8 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
|
||||
win_dst->scene = win_src->scene;
|
||||
screen_new->winid = win_dst->winid;
|
||||
CTX_wm_window_set(C, win_dst);
|
||||
|
||||
ED_screen_global_areas_create(win_dst);
|
||||
ED_screen_refresh(CTX_wm_manager(C), win_dst);
|
||||
}
|
||||
|
||||
@@ -2074,19 +2084,35 @@ float WM_cursor_pressure(const struct wmWindow *win)
|
||||
|
||||
/* support for native pixel size */
|
||||
/* mac retina opens window in size X, but it has up to 2 x more pixels */
|
||||
int WM_window_pixels_x(wmWindow *win)
|
||||
int WM_window_pixels_x(const wmWindow *win)
|
||||
{
|
||||
float f = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
|
||||
return (int)(f * (float)win->sizex);
|
||||
}
|
||||
|
||||
int WM_window_pixels_y(wmWindow *win)
|
||||
int WM_window_pixels_y(const wmWindow *win)
|
||||
{
|
||||
float f = GHOST_GetNativePixelSize(win->ghostwin);
|
||||
|
||||
return (int)(f * (float)win->sizey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total pixels that are usable by the screen-layouts, excluding global areas.
|
||||
*/
|
||||
int WM_window_screen_pixels_x(const wmWindow *win)
|
||||
{
|
||||
return WM_window_pixels_x(win);
|
||||
}
|
||||
int WM_window_screen_pixels_y(const wmWindow *win)
|
||||
{
|
||||
short screen_size_y = WM_window_pixels_y(win);
|
||||
|
||||
for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) {
|
||||
screen_size_y -= ED_area_global_size_y(sa);
|
||||
}
|
||||
|
||||
return screen_size_y;
|
||||
}
|
||||
|
||||
bool WM_window_is_fullscreen(wmWindow *win)
|
||||
|
||||
Reference in New Issue
Block a user