1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2008 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup editors 22 */ 23 24 #pragma once 25 26 #include "DNA_screen_types.h" 27 #include "DNA_space_types.h" 28 #include "DNA_view2d_types.h" 29 #include "DNA_view3d_types.h" 30 #include "DNA_workspace_types.h" 31 32 #include "DNA_object_enums.h" 33 34 #include "BLI_compiler_attrs.h" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 struct ARegion; 41 struct Depsgraph; 42 struct IDProperty; 43 struct Main; 44 struct MenuType; 45 struct Scene; 46 struct SpaceLink; 47 struct WorkSpace; 48 struct WorkSpaceInstanceHook; 49 struct bContext; 50 struct bScreen; 51 struct rcti; 52 struct uiBlock; 53 struct uiLayout; 54 struct wmKeyConfig; 55 struct wmMsgBus; 56 struct wmMsgSubscribeKey; 57 struct wmMsgSubscribeValue; 58 struct wmNotifier; 59 struct wmOperatorType; 60 struct wmWindow; 61 struct wmWindowManager; 62 63 /* regions */ 64 void ED_region_do_listen(struct wmWindow *win, 65 struct ScrArea *area, 66 struct ARegion *region, 67 struct wmNotifier *note, 68 const Scene *scene); 69 void ED_region_do_layout(struct bContext *C, struct ARegion *region); 70 void ED_region_do_draw(struct bContext *C, struct ARegion *region); 71 void ED_region_exit(struct bContext *C, struct ARegion *region); 72 void ED_region_remove(struct bContext *C, struct ScrArea *area, struct ARegion *region); 73 void ED_region_pixelspace(struct ARegion *region); 74 void ED_region_update_rect(struct ARegion *region); 75 void ED_region_floating_init(struct ARegion *region); 76 void ED_region_tag_redraw(struct ARegion *region); 77 void ED_region_tag_redraw_partial(struct ARegion *region, const struct rcti *rct, bool rebuild); 78 void ED_region_tag_redraw_cursor(struct ARegion *region); 79 void ED_region_tag_redraw_no_rebuild(struct ARegion *region); 80 void ED_region_tag_refresh_ui(struct ARegion *region); 81 void ED_region_tag_redraw_editor_overlays(struct ARegion *region); 82 83 void ED_region_search_filter_update(const struct ScrArea *area, struct ARegion *region); 84 const char *ED_area_region_search_filter_get(const struct ScrArea *area, 85 const struct ARegion *region); 86 87 void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *region); 88 void ED_region_panels_ex(const struct bContext *C, struct ARegion *region, const char *contexts[]); 89 void ED_region_panels(const struct bContext *C, struct ARegion *region); 90 void ED_region_panels_layout_ex(const struct bContext *C, 91 struct ARegion *region, 92 struct ListBase *paneltypes, 93 const char *contexts[], 94 const char *category_override); 95 bool ED_region_property_search(const struct bContext *C, 96 struct ARegion *region, 97 struct ListBase *paneltypes, 98 const char *contexts[], 99 const char *category_override); 100 101 void ED_region_panels_layout(const struct bContext *C, struct ARegion *region); 102 void ED_region_panels_draw(const struct bContext *C, struct ARegion *region); 103 104 void ED_region_header_init(struct ARegion *region); 105 void ED_region_header(const struct bContext *C, struct ARegion *region); 106 void ED_region_header_layout(const struct bContext *C, struct ARegion *region); 107 void ED_region_header_draw(const struct bContext *C, struct ARegion *region); 108 109 void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *area, struct ARegion *region); 110 void ED_region_toggle_hidden(struct bContext *C, struct ARegion *region); 111 void ED_region_visibility_change_update(struct bContext *C, 112 struct ScrArea *area, 113 struct ARegion *region); 114 /* screen_ops.c */ 115 void ED_region_visibility_change_update_animated(struct bContext *C, 116 struct ScrArea *area, 117 struct ARegion *region); 118 119 void ED_region_info_draw(struct ARegion *region, 120 const char *text, 121 float fill_color[4], 122 const bool full_redraw); 123 void ED_region_info_draw_multiline(ARegion *region, 124 const char *text_array[], 125 float fill_color[4], 126 const bool full_redraw); 127 void ED_region_image_metadata_draw( 128 int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy); 129 void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout); 130 void ED_region_grid_draw(struct ARegion *region, float zoomx, float zoomy, float x0, float y0); 131 float ED_region_blend_alpha(struct ARegion *region); 132 void ED_region_visible_rect_calc(struct ARegion *region, struct rcti *rect); 133 const rcti *ED_region_visible_rect(ARegion *region); 134 bool ED_region_is_overlap(int spacetype, int regiontype); 135 136 int ED_region_snap_size_test(const struct ARegion *region); 137 bool ED_region_snap_size_apply(struct ARegion *region, int snap_flag); 138 139 /* message_bus callbacks */ 140 void ED_region_do_msg_notify_tag_redraw(struct bContext *C, 141 struct wmMsgSubscribeKey *msg_key, 142 struct wmMsgSubscribeValue *msg_val); 143 void ED_area_do_msg_notify_tag_refresh(struct bContext *C, 144 struct wmMsgSubscribeKey *msg_key, 145 struct wmMsgSubscribeValue *msg_val); 146 147 void ED_area_do_mgs_subscribe_for_tool_header(const struct bContext *C, 148 struct WorkSpace *workspace, 149 struct Scene *scene, 150 struct bScreen *screen, 151 struct ScrArea *area, 152 struct ARegion *region, 153 struct wmMsgBus *mbus); 154 void ED_area_do_mgs_subscribe_for_tool_ui(const struct bContext *C, 155 struct WorkSpace *workspace, 156 struct Scene *scene, 157 struct bScreen *screen, 158 struct ScrArea *area, 159 struct ARegion *region, 160 struct wmMsgBus *mbus); 161 162 /* message bus */ 163 void ED_region_message_subscribe(struct bContext *C, 164 struct WorkSpace *workspace, 165 struct Scene *scene, 166 struct bScreen *screen, 167 struct ScrArea *area, 168 struct ARegion *region, 169 struct wmMsgBus *mbus); 170 171 /* spaces */ 172 void ED_spacetypes_keymap(struct wmKeyConfig *keyconf); 173 int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco); 174 175 /* areas */ 176 void ED_area_init(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); 177 void ED_area_exit(struct bContext *C, struct ScrArea *area); 178 int ED_screen_area_active(const struct bContext *C); 179 void ED_screen_global_areas_refresh(struct wmWindow *win); 180 void ED_screen_global_areas_sync(struct wmWindow *win); 181 void ED_area_do_listen(struct wmWindow *win, ScrArea *area, struct wmNotifier *note, Scene *scene); 182 void ED_area_tag_redraw(ScrArea *area); 183 void ED_area_tag_redraw_no_rebuild(ScrArea *area); 184 void ED_area_tag_redraw_regiontype(ScrArea *area, int type); 185 void ED_area_tag_refresh(ScrArea *area); 186 void ED_area_do_refresh(struct bContext *C, ScrArea *area); 187 struct AZone *ED_area_azones_update(ScrArea *area, const int mouse_xy[]); 188 void ED_area_status_text(ScrArea *area, const char *str); 189 void ED_area_newspace(struct bContext *C, ScrArea *area, int type, const bool skip_region_exit); 190 void ED_area_prevspace(struct bContext *C, ScrArea *area); 191 void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2); 192 int ED_area_headersize(void); 193 int ED_area_footersize(void); 194 int ED_area_global_size_y(const ScrArea *area); 195 int ED_area_global_min_size_y(const ScrArea *area); 196 int ED_area_global_max_size_y(const ScrArea *area); 197 bool ED_area_is_global(const ScrArea *area); 198 int ED_region_global_size_y(void); 199 void ED_area_update_region_sizes(struct wmWindowManager *wm, 200 struct wmWindow *win, 201 struct ScrArea *area); 202 203 ScrArea *ED_screen_areas_iter_first(const struct wmWindow *win, const bScreen *screen); 204 ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area); 205 /** 206 * Iterate over all areas visible in the screen (screen as in everything 207 * visible in the window, not just bScreen). 208 * \note Skips global areas with flag GLOBAL_AREA_IS_HIDDEN. 209 */ 210 #define ED_screen_areas_iter(win, screen, area_name) \ 211 for (ScrArea *area_name = ED_screen_areas_iter_first(win, screen); area_name != NULL; \ 212 area_name = ED_screen_areas_iter_next(screen, area_name)) 213 #define ED_screen_verts_iter(win, screen, vert_name) \ 214 for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \ 215 (win)->global_areas.vertbase.first : \ 216 (screen)->vertbase.first; \ 217 vert_name != NULL; \ 218 vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : \ 219 vert_name->next) 220 221 /* screens */ 222 void ED_screens_init(struct Main *bmain, struct wmWindowManager *wm); 223 void ED_screen_draw_edges(struct wmWindow *win); 224 void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2); 225 void ED_screen_draw_split_preview(struct ScrArea *area, const int dir, const float fac); 226 void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win); 227 void ED_screen_ensure_updated(struct wmWindowManager *wm, 228 struct wmWindow *win, 229 struct bScreen *screen); 230 void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note); 231 bool ED_screen_change(struct bContext *C, struct bScreen *screen); 232 void ED_screen_scene_change(struct bContext *C, struct wmWindow *win, struct Scene *scene); 233 void ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, const int xy[2]); 234 void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); 235 void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable); 236 void ED_screen_animation_timer_update(struct bScreen *screen, int redraws); 237 void ED_screen_restore_temp_type(struct bContext *C, ScrArea *area); 238 ScrArea *ED_screen_full_newspace(struct bContext *C, ScrArea *area, int type); 239 void ED_screen_full_prevspace(struct bContext *C, ScrArea *area); 240 void ED_screen_full_restore(struct bContext *C, ScrArea *area); 241 struct ScrArea *ED_screen_state_toggle(struct bContext *C, 242 struct wmWindow *win, 243 struct ScrArea *area, 244 const short state); 245 ScrArea *ED_screen_temp_space_open(struct bContext *C, 246 const char *title, 247 int x, 248 int y, 249 int sizex, 250 int sizey, 251 eSpace_Type space_type, 252 int display_type, 253 bool dialog); 254 void ED_screens_header_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg); 255 void ED_screens_footer_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg); 256 void ED_screens_navigation_bar_tools_menu_create(struct bContext *C, 257 struct uiLayout *layout, 258 void *arg); 259 bool ED_screen_stereo3d_required(const struct bScreen *screen, const struct Scene *scene); 260 Scene *ED_screen_scene_find(const struct bScreen *screen, const struct wmWindowManager *wm); 261 Scene *ED_screen_scene_find_with_window(const struct bScreen *screen, 262 const struct wmWindowManager *wm, 263 struct wmWindow **r_window); 264 ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen, 265 const struct SpaceLink *sl, 266 const bool only_visible); 267 struct wmWindow *ED_screen_window_find(const struct bScreen *screen, 268 const struct wmWindowManager *wm); 269 void ED_screen_preview_render(const struct bScreen *screen, 270 int size_x, 271 int size_y, 272 unsigned int *r_rect) ATTR_NONNULL(); 273 274 /* workspaces */ 275 struct WorkSpace *ED_workspace_add(struct Main *bmain, const char *name) ATTR_NONNULL(); 276 bool ED_workspace_change(struct WorkSpace *workspace_new, 277 struct bContext *C, 278 struct wmWindowManager *wm, 279 struct wmWindow *win) ATTR_NONNULL(); 280 struct WorkSpace *ED_workspace_duplicate(struct WorkSpace *workspace_old, 281 struct Main *bmain, 282 struct wmWindow *win); 283 bool ED_workspace_delete(struct WorkSpace *workspace, 284 struct Main *bmain, 285 struct bContext *C, 286 struct wmWindowManager *wm) ATTR_NONNULL(); 287 void ED_workspace_scene_data_sync(struct WorkSpaceInstanceHook *hook, Scene *scene) ATTR_NONNULL(); 288 struct WorkSpaceLayout *ED_workspace_screen_change_ensure_unused_layout( 289 struct Main *bmain, 290 struct WorkSpace *workspace, 291 struct WorkSpaceLayout *layout_new, 292 const struct WorkSpaceLayout *layout_fallback_base, 293 struct wmWindow *win) ATTR_NONNULL(); 294 struct WorkSpaceLayout *ED_workspace_layout_add(struct Main *bmain, 295 struct WorkSpace *workspace, 296 struct wmWindow *win, 297 const char *name) ATTR_NONNULL(); 298 struct WorkSpaceLayout *ED_workspace_layout_duplicate(struct Main *bmain, 299 struct WorkSpace *workspace, 300 const struct WorkSpaceLayout *layout_old, 301 struct wmWindow *win) ATTR_NONNULL(); 302 bool ED_workspace_layout_delete(struct WorkSpace *workspace, 303 struct WorkSpaceLayout *layout_old, 304 struct bContext *C) ATTR_NONNULL(); 305 bool ED_workspace_layout_cycle(struct WorkSpace *workspace, 306 const short direction, 307 struct bContext *C) ATTR_NONNULL(); 308 309 void ED_workspace_status_text(struct bContext *C, const char *str); 310 311 /* anim */ 312 void ED_update_for_newframe(struct Main *bmain, struct Depsgraph *depsgraph); 313 314 void ED_refresh_viewport_fps(struct bContext *C); 315 int ED_screen_animation_play(struct bContext *C, int sync, int mode); 316 bScreen *ED_screen_animation_playing(const struct wmWindowManager *wm); 317 bScreen *ED_screen_animation_no_scrub(const struct wmWindowManager *wm); 318 319 /* screen keymaps */ 320 void ED_operatortypes_screen(void); 321 void ED_keymap_screen(struct wmKeyConfig *keyconf); 322 /* workspace keymaps */ 323 void ED_operatortypes_workspace(void); 324 325 /* operators; context poll callbacks */ 326 bool ED_operator_screenactive(struct bContext *C); 327 bool ED_operator_screen_mainwinactive(struct bContext *C); 328 bool ED_operator_areaactive(struct bContext *C); 329 bool ED_operator_regionactive(struct bContext *C); 330 331 bool ED_operator_scene(struct bContext *C); 332 bool ED_operator_scene_editable(struct bContext *C); 333 bool ED_operator_objectmode(struct bContext *C); 334 335 bool ED_operator_view3d_active(struct bContext *C); 336 bool ED_operator_region_view3d_active(struct bContext *C); 337 bool ED_operator_animview_active(struct bContext *C); 338 bool ED_operator_outliner_active(struct bContext *C); 339 bool ED_operator_outliner_active_no_editobject(struct bContext *C); 340 bool ED_operator_file_active(struct bContext *C); 341 bool ED_operator_action_active(struct bContext *C); 342 bool ED_operator_buttons_active(struct bContext *C); 343 bool ED_operator_node_active(struct bContext *C); 344 bool ED_operator_node_editable(struct bContext *C); 345 bool ED_operator_graphedit_active(struct bContext *C); 346 bool ED_operator_sequencer_active(struct bContext *C); 347 bool ED_operator_sequencer_active_editable(struct bContext *C); 348 bool ED_operator_image_active(struct bContext *C); 349 bool ED_operator_nla_active(struct bContext *C); 350 bool ED_operator_info_active(struct bContext *C); 351 bool ED_operator_console_active(struct bContext *C); 352 353 bool ED_operator_object_active(struct bContext *C); 354 bool ED_operator_object_active_editable_ex(struct bContext *C, const Object *ob); 355 bool ED_operator_object_active_editable(struct bContext *C); 356 bool ED_operator_object_active_local_editable_ex(struct bContext *C, const Object *ob); 357 bool ED_operator_object_active_local_editable(struct bContext *C); 358 bool ED_operator_object_active_editable_mesh(struct bContext *C); 359 bool ED_operator_object_active_editable_font(struct bContext *C); 360 bool ED_operator_editable_mesh(struct bContext *C); 361 bool ED_operator_editmesh(struct bContext *C); 362 bool ED_operator_editmesh_view3d(struct bContext *C); 363 bool ED_operator_editmesh_region_view3d(struct bContext *C); 364 bool ED_operator_editmesh_auto_smooth(struct bContext *C); 365 bool ED_operator_editarmature(struct bContext *C); 366 bool ED_operator_editcurve(struct bContext *C); 367 bool ED_operator_editcurve_3d(struct bContext *C); 368 bool ED_operator_editsurf(struct bContext *C); 369 bool ED_operator_editsurfcurve(struct bContext *C); 370 bool ED_operator_editsurfcurve_region_view3d(struct bContext *C); 371 bool ED_operator_editfont(struct bContext *C); 372 bool ED_operator_editlattice(struct bContext *C); 373 bool ED_operator_editmball(struct bContext *C); 374 bool ED_operator_uvedit(struct bContext *C); 375 bool ED_operator_uvedit_space_image(struct bContext *C); 376 bool ED_operator_uvmap(struct bContext *C); 377 bool ED_operator_posemode_exclusive(struct bContext *C); 378 bool ED_operator_posemode_context(struct bContext *C); 379 bool ED_operator_posemode(struct bContext *C); 380 bool ED_operator_posemode_local(struct bContext *C); 381 bool ED_operator_mask(struct bContext *C); 382 bool ED_operator_camera(struct bContext *C); 383 384 /* screen_user_menu.c */ 385 386 bUserMenu **ED_screen_user_menus_find(const struct bContext *C, uint *r_len); 387 struct bUserMenu *ED_screen_user_menu_ensure(struct bContext *C); 388 389 struct bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(struct ListBase *lb, 390 const struct wmOperatorType *ot, 391 struct IDProperty *prop, 392 short opcontext); 393 struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(struct ListBase *lb, 394 const struct MenuType *mt); 395 struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *lb, 396 const char *context_data_path, 397 const char *prop_id, 398 int prop_index); 399 400 void ED_screen_user_menu_item_add_operator(struct ListBase *lb, 401 const char *ui_name, 402 const struct wmOperatorType *ot, 403 const struct IDProperty *prop, 404 short opcontext); 405 void ED_screen_user_menu_item_add_menu(struct ListBase *lb, 406 const char *ui_name, 407 const struct MenuType *mt); 408 void ED_screen_user_menu_item_add_prop(ListBase *lb, 409 const char *ui_name, 410 const char *context_data_path, 411 const char *prop_id, 412 int prop_index); 413 414 void ED_screen_user_menu_item_remove(struct ListBase *lb, struct bUserMenuItem *umi); 415 void ED_screen_user_menu_register(void); 416 417 /* Cache display helpers */ 418 419 void ED_region_cache_draw_background(struct ARegion *region); 420 void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y); 421 void ED_region_cache_draw_cached_segments(struct ARegion *region, 422 const int num_segments, 423 const int *points, 424 const int sfra, 425 const int efra); 426 427 /* area_utils.c */ 428 void ED_region_generic_tools_region_message_subscribe(const struct bContext *C, 429 struct WorkSpace *workspace, 430 struct Scene *scene, 431 struct bScreen *screen, 432 struct ScrArea *area, 433 struct ARegion *region, 434 struct wmMsgBus *mbus); 435 int ED_region_generic_tools_region_snap_size(const struct ARegion *region, int size, int axis); 436 437 /* area_query.c */ 438 bool ED_region_overlap_isect_x(const ARegion *region, const int event_x); 439 bool ED_region_overlap_isect_y(const ARegion *region, const int event_y); 440 bool ED_region_overlap_isect_xy(const ARegion *region, const int event_xy[2]); 441 bool ED_region_overlap_isect_any_xy(const ScrArea *area, const int event_xy[2]); 442 bool ED_region_overlap_isect_x_with_margin(const ARegion *region, 443 const int event_x, 444 const int margin); 445 bool ED_region_overlap_isect_y_with_margin(const ARegion *region, 446 const int event_y, 447 const int margin); 448 bool ED_region_overlap_isect_xy_with_margin(const ARegion *region, 449 const int event_xy[2], 450 const int margin); 451 452 bool ED_region_panel_category_gutter_calc_rect(const ARegion *region, rcti *r_region_gutter); 453 bool ED_region_panel_category_gutter_isect_xy(const ARegion *region, const int event_xy[2]); 454 455 bool ED_region_contains_xy(const struct ARegion *region, const int event_xy[2]); 456 457 /* interface_region_hud.c */ 458 struct ARegionType *ED_area_type_hud(int space_type); 459 void ED_area_type_hud_clear(struct wmWindowManager *wm, ScrArea *area_keep); 460 void ED_area_type_hud_ensure(struct bContext *C, struct ScrArea *area); 461 462 /* default keymaps, bitflags (matches order of evaluation). */ 463 enum { 464 ED_KEYMAP_UI = (1 << 1), 465 ED_KEYMAP_GIZMO = (1 << 2), 466 ED_KEYMAP_TOOL = (1 << 3), 467 ED_KEYMAP_VIEW2D = (1 << 4), 468 ED_KEYMAP_ANIMATION = (1 << 6), 469 ED_KEYMAP_FRAMES = (1 << 7), 470 ED_KEYMAP_HEADER = (1 << 8), 471 ED_KEYMAP_FOOTER = (1 << 9), 472 ED_KEYMAP_GPENCIL = (1 << 10), 473 ED_KEYMAP_NAVBAR = (1 << 11), 474 }; 475 476 /* SCREEN_OT_space_context_cycle direction */ 477 enum { 478 SPACE_CONTEXT_CYCLE_PREV, 479 SPACE_CONTEXT_CYCLE_NEXT, 480 }; 481 482 #ifdef __cplusplus 483 } 484 #endif 485