Blender V4.5
screen.cc File Reference
#include <fmt/format.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "BLI_listbase.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_idprop.hh"
#include "BKE_idtype.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_preview_image.hh"
#include "BKE_screen.hh"
#include "BLO_read_write.hh"
#include "../editors/asset/ED_asset_shelf.hh"
#include "WM_types.hh"

Go to the source code of this file.

Macros

#define DNA_DEPRECATED_ALLOW

Functions

Space-type/region-type handling
static Vector< std::unique_ptr< SpaceType > > & get_space_types ()
void BKE_spacetypes_free ()
SpaceTypeBKE_spacetype_from_id (int spaceid)
ARegionTypeBKE_regiontype_from_id (const SpaceType *st, int regionid)
Span< std::unique_ptr< SpaceType > > BKE_spacetypes_list ()
void BKE_spacetype_register (std::unique_ptr< SpaceType > st)
bool BKE_spacetype_exists (int spaceid)
Screen edges & verts
ScrEdgeBKE_screen_find_edge (const bScreen *screen, ScrVert *v1, ScrVert *v2)
void BKE_screen_sort_scrvert (ScrVert **v1, ScrVert **v2)
void BKE_screen_remove_double_scrverts (bScreen *screen)
void BKE_screen_remove_double_scredges (bScreen *screen)
void BKE_screen_remove_unused_scredges (bScreen *screen)
void BKE_screen_remove_unused_scrverts (bScreen *screen)
Utilities
ARegionBKE_region_find_in_listbase_by_type (const ListBase *regionbase, const int region_type)
ARegionBKE_area_find_region_type (const ScrArea *area, int region_type)
ARegionBKE_area_find_region_active_win (const ScrArea *area)
ARegionBKE_area_find_region_xy (const ScrArea *area, const int regiontype, const int xy[2])
ARegionBKE_screen_find_region_type (const bScreen *screen, const int region_type)
ARegionBKE_screen_find_region_xy (const bScreen *screen, const int regiontype, const int xy[2])
ScrAreaBKE_screen_find_area_from_space (const bScreen *screen, const SpaceLink *sl)
std::optional< std::string > BKE_screen_path_from_screen_to_space (const PointerRNA *ptr)
ScrAreaBKE_screen_find_big_area (const bScreen *screen, const int spacetype, const short min)
ScrAreaBKE_screen_area_map_find_area_xy (const ScrAreaMap *areamap, const int spacetype, const int xy[2])
ScrAreaBKE_screen_find_area_xy (const bScreen *screen, const int spacetype, const int xy[2])
void BKE_screen_view3d_sync (View3D *v3d, Scene *scene)
void BKE_screen_view3d_scene_sync (bScreen *screen, Scene *scene)
void BKE_screen_view3d_shading_init (View3DShading *shading)
ARegionBKE_screen_find_main_region_at_xy (const bScreen *screen, const int space_type, const int xy[2])
float BKE_screen_view3d_zoom_to_fac (float camzoom)
float BKE_screen_view3d_zoom_from_fac (float zoomfac)
bool BKE_screen_is_fullscreen_area (const bScreen *screen)
bool BKE_screen_is_used (const bScreen *screen)
void BKE_screen_header_alignment_reset (bScreen *screen)
Blend File IO (Screen & Related Data)
void BKE_screen_view3d_shading_blend_write (BlendWriter *writer, View3DShading *shading)
void BKE_screen_view3d_shading_blend_read_data (BlendDataReader *reader, View3DShading *shading)
static void write_region (BlendWriter *writer, ARegion *region, int spacetype)
static void write_uilist (BlendWriter *writer, uiList *ui_list)
static void write_panel_list (BlendWriter *writer, ListBase *lb)
static void write_area (BlendWriter *writer, ScrArea *area)
void BKE_screen_area_map_blend_write (BlendWriter *writer, ScrAreaMap *area_map)
static void remove_least_recently_used_panel_states (Panel &panel, const int64_t max_kept)
static void direct_link_panel_list (BlendDataReader *reader, ListBase *lb)
static void direct_link_region (BlendDataReader *reader, ARegion *region, int spacetype)
void BKE_screen_view3d_do_versions_250 (View3D *v3d, ListBase *regions)
static void direct_link_area (BlendDataReader *reader, ScrArea *area)
bool BKE_screen_area_map_blend_read_data (BlendDataReader *reader, ScrAreaMap *area_map)
static void regions_remove_invalid (SpaceType *space_type, ListBase *regionbase)
void BKE_screen_area_blend_read_after_liblink (BlendLibReader *reader, ID *parent_id, ScrArea *area)

ID Type Implementation

IDTypeInfo IDType_ID_SCR
static void screen_free_data (ID *id)
void BKE_screen_foreach_id_screen_area (LibraryForeachIDData *data, ScrArea *area)
static void screen_foreach_id (ID *id, LibraryForeachIDData *data)
static void screen_blend_write (BlendWriter *writer, ID *id, const void *id_address)
bool BKE_screen_blend_read_data (BlendDataReader *reader, bScreen *screen)
static void screen_blend_read_after_liblink (BlendLibReader *reader, ID *id)

Space handling

static void(*) spacedata_id_remap_cb (ScrArea *area, SpaceLink *sl, ID *old_id, ID *new_id) = nullptr
static void(*) region_refresh_tag_gizmomap_callback (wmGizmoMap *) = nullptr
static void(*) region_free_gizmomap_callback (wmGizmoMap *) = nullptr
void BKE_spacedata_freelist (ListBase *lb)
static void panel_list_copy (ListBase *newlb, const ListBase *lb)
ARegionBKE_area_region_copy (const SpaceType *st, const ARegion *region)
ARegionBKE_area_region_new ()
static void region_copylist (SpaceType *st, ListBase *lb_dst, ListBase *lb_src)
void BKE_spacedata_copylist (ListBase *lb_dst, ListBase *lb_src)
void BKE_spacedata_draw_locks (ARegionDrawLockFlags lock_flags)
ARegionBKE_spacedata_find_region_type (const SpaceLink *slink, const ScrArea *area, int region_type)
void BKE_spacedata_callback_id_remap_set (void(*func)(ScrArea *area, SpaceLink *sl, ID *, ID *))
void BKE_spacedata_id_unref (ScrArea *area, SpaceLink *sl, ID *id)
void BKE_region_callback_refresh_tag_gizmomap_set (void(*callback)(wmGizmoMap *))
void BKE_screen_gizmo_tag_refresh (bScreen *screen)
void BKE_screen_runtime_refresh_for_blendfile (bScreen *screen)
void BKE_region_callback_free_gizmomap_set (void(*callback)(wmGizmoMap *))
LayoutPanelStateBKE_panel_layout_panel_state_ensure (Panel *panel, const StringRef idname, const bool default_closed)
PanelBKE_panel_new (PanelType *panel_type)
static void layout_panel_state_delete (LayoutPanelState *state)
void BKE_panel_free (Panel *panel)
static void area_region_panels_free_recursive (Panel *panel)
void BKE_area_region_panels_free (ListBase *panels)
void BKE_area_region_free (SpaceType *st, ARegion *region)
void BKE_screen_area_free (ScrArea *area)
void BKE_screen_area_map_free (ScrAreaMap *area_map)
void BKE_screen_free_data (bScreen *screen)

Macro Definition Documentation

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 10 of file screen.cc.

Function Documentation

◆ area_region_panels_free_recursive()

void area_region_panels_free_recursive ( Panel * panel)
static

◆ BKE_area_find_region_active_win()

◆ BKE_area_find_region_type()

ARegion * BKE_area_find_region_type ( const ScrArea * area,
int region_type )

Find a region of type region_type in the currently active space of area.

Note
This does not work if the region to look up is not in the active space. Use BKE_spacedata_find_region_type if that may be the case.

Definition at line 840 of file screen.cc.

References BKE_area_find_region_type(), LISTBASE_FOREACH, and ScrArea::regionbase.

Referenced by blender::ed::asset::shelf::active_shelf_from_area(), ANIM_deselect_keys_in_animation_editors(), ANIM_frame_channel_y_extents(), animchannels_select_filter_invoke(), BKE_area_find_region_active_win(), BKE_area_find_region_type(), BKE_spacedata_find_region_type(), blend_file_thumb_from_camera(), blo_do_versions_260(), blo_do_versions_430(), blender::ui::bonedropper_set_draw_callback_region(), buttons_start_filter_exec(), blender::ed::vse::channel_draw_context_init(), clip_refresh(), console_clear_exec(), console_clear_line_exec(), console_delete_exec(), console_history_append_exec(), console_history_cycle_exec(), console_indent_exec(), console_insert_exec(), console_modal_select_apply(), console_move_exec(), console_paste_exec(), console_scrollback_append_exec(), console_select_set_invoke(), console_selectword_invoke(), console_unindent_exec(), context_find_graph_editor(), datadropper_set_draw_callback_region(), do_version_area_change_space_to_space_action(), do_versions_area_ensure_tool_region(), ED_area_type_hud_ensure(), ED_drivers_editor_init(), ed_markers_poll_markers_exist_visible(), ED_screens_header_tools_menu_create(), ED_text_activate_in_screen(), ED_view3d_gizmo_ruler_remove_by_gpencil_layer(), blender::ed::animrig::ensure_asset_ui_visible(), file_refresh(), file_smoothscroll_invoke(), graphkeys_channel_view_pick_invoke(), graphkeys_view_selected_channels_exec(), hud_panel_operator_redo_poll(), hud_region_add(), menu_items_from_ui_create(), blender::ed::space_node::node_area_listener(), blender::ed::outliner::outliner_deactivate(), blender::ed::outliner::outliner_start_filter_exec(), blender::ed::space_node::viewer_linking::position_viewer_node(), region_scale_toggle_hidden(), region_toggle_exec(), blender::ed::asset::screenshot_preview_exec(), blender::ed::space_node::snode_set_context(), space_text_scroll_to_cursor_with_area(), blender::ed::spreadsheet::spreadsheet_main_region_draw(), text_autocomplete_modal(), text_has_properties_region(), UI_view2d_fromcontext_rwin(), userpref_execute_region_poll(), userpref_show_exec(), v3d_cursor_snap_draw_fn(), v3d_cursor_snap_poll_fn(), wm_handler_fileselect_do(), wm_keymap_item_find_props(), wm_operator_call_internal(), and WM_window_cursor_keymap_status_refresh().

◆ BKE_area_find_region_xy()

◆ BKE_area_region_copy()

◆ BKE_area_region_free()

◆ BKE_area_region_new()

◆ BKE_area_region_panels_free()

◆ BKE_panel_free()

◆ BKE_panel_layout_panel_state_ensure()

LayoutPanelState * BKE_panel_layout_panel_state_ensure ( Panel * panel,
blender::StringRef idname,
bool default_closed )

◆ BKE_panel_new()

◆ BKE_region_callback_free_gizmomap_set()

void BKE_region_callback_free_gizmomap_set ( void(* callback )(wmGizmoMap *))

Gizmo-maps of a region need to be freed with the region. Uses callback to avoid low-level call.

Definition at line 509 of file screen.cc.

References BKE_region_callback_free_gizmomap_set(), and region_free_gizmomap_callback.

Referenced by BKE_region_callback_free_gizmomap_set(), and WM_init().

◆ BKE_region_callback_refresh_tag_gizmomap_set()

void BKE_region_callback_refresh_tag_gizmomap_set ( void(* callback )(wmGizmoMap *))

◆ BKE_region_find_in_listbase_by_type()

ARegion * BKE_region_find_in_listbase_by_type ( const ListBase * regionbase,
const int region_type )

Find a region of type region_type in provided regionbase.

Note
this is useful for versioning where either the #Area or SpaceLink regionbase are typical inputs

Definition at line 829 of file screen.cc.

References BKE_region_find_in_listbase_by_type(), and LISTBASE_FOREACH.

Referenced by BKE_region_find_in_listbase_by_type(), blo_do_versions_300(), and do_versions_after_linking_300().

◆ BKE_regiontype_from_id()

◆ BKE_screen_area_blend_read_after_liblink()

void BKE_screen_area_blend_read_after_liblink ( BlendLibReader * reader,
ID * parent_id,
ScrArea * area )

Called after lib linking process is done, to perform some validation on the read data, or some complex specific reading process that requires the data to be fully read and ID pointers to be valid.

Definition at line 1458 of file screen.cc.

References BKE_area_region_free(), BKE_screen_area_blend_read_after_liblink(), BKE_spacetype_from_id(), SpaceType::blend_read_after_liblink, BLI_freelinkN(), ListBase::first, LISTBASE_FOREACH, LISTBASE_FOREACH_MUTABLE, ScrArea::regionbase, regions_remove_invalid(), and ScrArea::spacedata.

Referenced by BKE_screen_area_blend_read_after_liblink(), BKE_screen_find_area_xy(), screen_blend_read_after_liblink(), and window_manager_blend_read_after_liblink().

◆ BKE_screen_area_free()

◆ BKE_screen_area_map_blend_read_data()

◆ BKE_screen_area_map_blend_write()

◆ BKE_screen_area_map_find_area_xy()

ScrArea * BKE_screen_area_map_find_area_xy ( const ScrAreaMap * areamap,
const int spacetype,
const int xy[2] )

◆ BKE_screen_area_map_free()

◆ BKE_screen_blend_read_data()

◆ BKE_screen_find_area_from_space()

ScrArea * BKE_screen_find_area_from_space ( const bScreen * screen,
const SpaceLink * sl )

◆ BKE_screen_find_area_xy()

ScrArea * BKE_screen_find_area_xy ( const bScreen * screen,
const int spacetype,
const int xy[2] )

◆ BKE_screen_find_big_area()

◆ BKE_screen_find_edge()

◆ BKE_screen_find_main_region_at_xy()

ARegion * BKE_screen_find_main_region_at_xy ( const bScreen * screen,
const int space_type,
const int xy[2] )

◆ BKE_screen_find_region_type()

ARegion * BKE_screen_find_region_type ( const bScreen * screen,
int region_type )
Note
This is only for screen level regions (typically menus/popups).

Definition at line 885 of file screen.cc.

References BKE_screen_find_region_type(), LISTBASE_FOREACH, and bScreen::regionbase.

Referenced by BKE_screen_find_region_type(), and blender::ed::sculpt_paint::paint_update_mouse_cursor().

◆ BKE_screen_find_region_xy()

ARegion * BKE_screen_find_region_xy ( const bScreen * screen,
const int regiontype,
const int xy[2] )

◆ BKE_screen_foreach_id_screen_area()

void BKE_screen_foreach_id_screen_area ( LibraryForeachIDData * data,
ScrArea * area )

◆ BKE_screen_free_data()

void BKE_screen_free_data ( bScreen * screen)

Free (or release) any data used by this screen (does not free the screen itself).

Definition at line 659 of file screen.cc.

References BKE_screen_free_data(), bScreen::id, and screen_free_data().

Referenced by BKE_screen_find_area_xy(), BKE_screen_free_data(), and screen_data_copy().

◆ BKE_screen_gizmo_tag_refresh()

◆ BKE_screen_header_alignment_reset()

◆ BKE_screen_is_fullscreen_area()

◆ BKE_screen_is_used()

bool BKE_screen_is_used ( const bScreen * screen)

◆ BKE_screen_path_from_screen_to_space()

std::optional< std::string > BKE_screen_path_from_screen_to_space ( const PointerRNA * ptr)

◆ BKE_screen_remove_double_scredges()

◆ BKE_screen_remove_double_scrverts()

◆ BKE_screen_remove_unused_scredges()

◆ BKE_screen_remove_unused_scrverts()

◆ BKE_screen_runtime_refresh_for_blendfile()

void BKE_screen_runtime_refresh_for_blendfile ( bScreen * screen)

Refresh any screen data that should be set on file-load with "Load UI" disabled.

Definition at line 496 of file screen.cc.

References bScreen::areabase, BKE_screen_runtime_refresh_for_blendfile(), ScrArea_Runtime::is_tool_set, LISTBASE_FOREACH, ScrArea::runtime, and ScrArea_Runtime::tool.

Referenced by BKE_screen_find_area_xy(), BKE_screen_runtime_refresh_for_blendfile(), and setup_app_data().

◆ BKE_screen_sort_scrvert()

◆ BKE_screen_view3d_do_versions_250()

◆ BKE_screen_view3d_scene_sync()

◆ BKE_screen_view3d_shading_blend_read_data()

◆ BKE_screen_view3d_shading_blend_write()

◆ BKE_screen_view3d_shading_init()

void BKE_screen_view3d_shading_init ( View3DShading * shading)

◆ BKE_screen_view3d_sync()

◆ BKE_screen_view3d_zoom_from_fac()

◆ BKE_screen_view3d_zoom_to_fac()

◆ BKE_spacedata_callback_id_remap_set()

void BKE_spacedata_callback_id_remap_set ( void(* func )(ScrArea *area, SpaceLink *sl, ID *, ID *))

◆ BKE_spacedata_copylist()

void BKE_spacedata_copylist ( ListBase * lb_dst,
ListBase * lb_src )

◆ BKE_spacedata_draw_locks()

void BKE_spacedata_draw_locks ( ARegionDrawLockFlags lock_flags)

Facility to set locks for drawing to survive (render) threads accessing drawing data.

Note
Should be replaced in future by better local data handling for threads.
Effect of multiple calls to this function is not accumulative. The locking flags will be set to by the last call.

Definition at line 417 of file screen.cc.

References BKE_spacedata_draw_locks(), get_space_types(), and LISTBASE_FOREACH.

Referenced by BKE_spacedata_draw_locks(), dpaint_bake_startjob(), fluid_bake_startjob(), fluid_free_startjob(), lineart_bake_startjob(), render_drawlock(), and WM_set_locked_interface_with_flags().

◆ BKE_spacedata_find_region_type()

ARegion * BKE_spacedata_find_region_type ( const SpaceLink * slink,
const ScrArea * area,
int region_type )

◆ BKE_spacedata_freelist()

◆ BKE_spacedata_id_unref()

void BKE_spacedata_id_unref ( ScrArea * area,
SpaceLink * sl,
ID * id )

Currently unused!

Definition at line 464 of file screen.cc.

References BKE_spacedata_id_unref(), and spacedata_id_remap_cb.

Referenced by BKE_spacedata_id_unref().

◆ BKE_spacetype_exists()

bool BKE_spacetype_exists ( int spaceid)

Definition at line 288 of file screen.cc.

References BKE_spacetype_exists(), and BKE_spacetype_from_id().

Referenced by BKE_spacetype_exists(), and direct_link_area().

◆ BKE_spacetype_from_id()

◆ BKE_spacetype_register()

◆ BKE_spacetypes_free()

void BKE_spacetypes_free ( )

Only for quitting blender.

Definition at line 246 of file screen.cc.

References BKE_spacetypes_free(), and get_space_types().

Referenced by BKE_blender_free(), and BKE_spacetypes_free().

◆ BKE_spacetypes_list()

Span< std::unique_ptr< SpaceType > > BKE_spacetypes_list ( )

◆ direct_link_area()

◆ direct_link_panel_list()

void direct_link_panel_list ( BlendDataReader * reader,
ListBase * lb )
static

◆ direct_link_region()

◆ get_space_types()

Vector< std::unique_ptr< SpaceType > > & get_space_types ( )
static

Keep global; this has to be accessible outside of window-manager.

Definition at line 210 of file screen.cc.

References get_space_types().

Referenced by BKE_spacedata_draw_locks(), BKE_spacetype_from_id(), BKE_spacetype_register(), BKE_spacetypes_free(), BKE_spacetypes_list(), and get_space_types().

◆ layout_panel_state_delete()

void layout_panel_state_delete ( LayoutPanelState * state)
static

◆ panel_list_copy()

◆ region_copylist()

void region_copylist ( SpaceType * st,
ListBase * lb_dst,
ListBase * lb_src )
static

◆ regions_remove_invalid()

void regions_remove_invalid ( SpaceType * space_type,
ListBase * regionbase )
static

Removes all regions whose type cannot be reconstructed. For example files from new versions may be stored with a newly introduced region type that this version cannot handle.

Definition at line 1441 of file screen.cc.

References BKE_area_region_free(), BKE_regiontype_from_id(), BLI_freelinkN(), LISTBASE_FOREACH_MUTABLE, SpaceType::name, printf, regions_remove_invalid(), and SpaceType::spaceid.

Referenced by BKE_screen_area_blend_read_after_liblink(), and regions_remove_invalid().

◆ remove_least_recently_used_panel_states()

◆ screen_blend_read_after_liblink()

void screen_blend_read_after_liblink ( BlendLibReader * reader,
ID * id )
static

◆ screen_blend_write()

◆ screen_foreach_id()

◆ screen_free_data()

◆ write_area()

◆ write_panel_list()

void write_panel_list ( BlendWriter * writer,
ListBase * lb )
static

◆ write_region()

◆ write_uilist()

void write_uilist ( BlendWriter * writer,
uiList * ui_list )
static

Definition at line 1135 of file screen.cc.

References BLO_write_struct, IDP_BlendWrite(), uiList::properties, and write_uilist().

Referenced by write_area(), and write_uilist().

Variable Documentation

◆ IDType_ID_SCR

IDTypeInfo IDType_ID_SCR

Definition at line 169 of file screen.cc.

◆ region_free_gizmomap_callback

void(*) region_free_gizmomap_callback(wmGizmoMap *) ( wmGizmoMap * ) = nullptr
static

Avoid bad-level calls to #WM_gizmomap_delete.

Definition at line 507 of file screen.cc.

Referenced by BKE_area_region_free(), and BKE_region_callback_free_gizmomap_set().

◆ region_refresh_tag_gizmomap_callback

void(*) region_refresh_tag_gizmomap_callback(wmGizmoMap *) ( wmGizmoMap * ) = nullptr
static

Avoid bad-level calls to WM_gizmomap_tag_refresh.

Definition at line 474 of file screen.cc.

Referenced by BKE_region_callback_refresh_tag_gizmomap_set(), and BKE_screen_gizmo_tag_refresh().

◆ spacedata_id_remap_cb

void(*) spacedata_id_remap_cb(ScrArea *area, SpaceLink *sl, ID *old_id, ID *new_id) ( ScrArea * area,
SpaceLink * sl,
ID * old_id,
ID * new_id ) = nullptr
static

Definition at line 454 of file screen.cc.

Referenced by BKE_spacedata_callback_id_remap_set(), and BKE_spacedata_id_unref().