2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup editors
|
2018-04-02 15:02:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
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
2018-04-20 17:14:03 +02:00
|
|
|
#include "BLI_compiler_attrs.h"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "BLI_sys_types.h"
|
2024-03-22 16:24:30 +01:00
|
|
|
#include "BLI_vector.hh"
|
2020-03-02 15:09:10 +01:00
|
|
|
|
2020-02-04 18:26:57 +11:00
|
|
|
struct Base;
|
2018-04-16 16:27:55 +02:00
|
|
|
struct CLG_LogRef;
|
2019-02-07 20:27:11 +11:00
|
|
|
struct Object;
|
2022-09-14 21:30:20 +02:00
|
|
|
struct Scene;
|
2023-08-04 22:15:25 -04:00
|
|
|
struct MemFile;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct UndoStack;
|
2019-02-07 20:27:11 +11:00
|
|
|
struct ViewLayer;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct bContext;
|
2018-04-02 15:02:08 +02:00
|
|
|
struct wmOperator;
|
|
|
|
|
struct wmOperatorType;
|
2023-10-27 11:39:49 +11:00
|
|
|
struct wmWindowManager;
|
2018-04-02 15:02:08 +02:00
|
|
|
|
|
|
|
|
/* undo.c */
|
2022-04-04 13:17:03 +10:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Run from the main event loop, basic checks that undo is left in a correct state.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
bool ED_undo_is_state_valid(bContext *C);
|
|
|
|
|
void ED_undo_group_begin(bContext *C);
|
|
|
|
|
void ED_undo_group_end(bContext *C);
|
|
|
|
|
void ED_undo_push(bContext *C, const char *str);
|
|
|
|
|
void ED_undo_push_op(bContext *C, wmOperator *op);
|
|
|
|
|
void ED_undo_grouped_push(bContext *C, const char *str);
|
|
|
|
|
void ED_undo_grouped_push_op(bContext *C, wmOperator *op);
|
|
|
|
|
void ED_undo_pop_op(bContext *C, wmOperator *op);
|
|
|
|
|
void ED_undo_pop(bContext *C);
|
|
|
|
|
void ED_undo_redo(bContext *C);
|
|
|
|
|
void ED_OT_undo(wmOperatorType *ot);
|
|
|
|
|
void ED_OT_undo_push(wmOperatorType *ot);
|
|
|
|
|
void ED_OT_redo(wmOperatorType *ot);
|
|
|
|
|
void ED_OT_undo_redo(wmOperatorType *ot);
|
|
|
|
|
void ED_OT_undo_history(wmOperatorType *ot);
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* UI callbacks should call this rather than calling WM_operator_repeat() themselves.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
int ED_undo_operator_repeat(bContext *C, wmOperator *op);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Convenience since UI callbacks use this mostly.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *arg_unused);
|
|
|
|
|
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int arg_unused);
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Name optionally, function used to check for operator redo panel.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
bool ED_undo_is_valid(const bContext *C, const char *undoname);
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
bool ED_undo_is_memfile_compatible(const bContext *C);
|
2019-01-19 00:48:00 +11:00
|
|
|
|
2019-07-05 13:46:48 +10:00
|
|
|
/* Unfortunate workaround for limits mixing undo systems. */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* When a property of ID changes, return false.
|
|
|
|
|
*
|
|
|
|
|
* This is to avoid changes to a property making undo pushes
|
|
|
|
|
* which are ignored by the undo-system.
|
|
|
|
|
* For example, changing a brush property isn't stored by sculpt-mode undo steps.
|
2023-02-12 14:37:16 +11:00
|
|
|
* This workaround is needed until the limitation is removed, see: #61948.
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id);
|
2019-07-05 13:46:48 +10:00
|
|
|
|
2023-10-27 11:39:49 +11:00
|
|
|
/**
|
|
|
|
|
* This function addresses the problem of restoring undo steps when multiple windows are used.
|
|
|
|
|
* Since undo steps don't track the full context that created them it's possible an edit-mode
|
|
|
|
|
* undo step will attempt to restore edit-mode into a different window, scene or view-layer.
|
|
|
|
|
*
|
|
|
|
|
* Values `scene_p` & `view_layer_p` (typically initialized from the context)
|
|
|
|
|
* are updated from the visible windows using `scene_ref` as a reference.
|
|
|
|
|
* If the no window can be found, the values are left as-is.
|
|
|
|
|
*
|
|
|
|
|
* Since users may close windows before undoing, it's expected the window may be unavailable.
|
|
|
|
|
* When this happens the edit-mode objects wont be restored into edit-mode by
|
|
|
|
|
* #ED_undo_object_editmode_restore_helper which is acceptable since objects
|
|
|
|
|
* which aren't visible in any window don't need to enter edit-mode.
|
|
|
|
|
*/
|
|
|
|
|
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm,
|
|
|
|
|
const Scene *scene_ref,
|
|
|
|
|
Scene **scene_p,
|
|
|
|
|
ViewLayer **view_layer_p);
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Load all our objects from `object_array` into edit-mode, clear everything else.
|
|
|
|
|
*/
|
2023-10-27 11:39:49 +11:00
|
|
|
void ED_undo_object_editmode_restore_helper(Scene *scene,
|
|
|
|
|
ViewLayer *view_layer,
|
2023-08-04 22:15:25 -04:00
|
|
|
Object **object_array,
|
2019-02-07 20:27:11 +11:00
|
|
|
uint object_array_len,
|
|
|
|
|
uint object_array_stride);
|
|
|
|
|
|
2024-03-22 16:24:30 +01:00
|
|
|
blender::Vector<Object *> ED_undo_editmode_objects_from_view_layer(const Scene *scene,
|
|
|
|
|
ViewLayer *view_layer);
|
|
|
|
|
blender::Vector<Base *> ED_undo_editmode_bases_from_view_layer(const Scene *scene,
|
|
|
|
|
ViewLayer *view_layer);
|
2020-02-04 18:26:57 +11:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Ideally we won't access the stack directly,
|
|
|
|
|
* this is needed for modes which handle undo themselves (bypassing #ED_undo_push).
|
|
|
|
|
*
|
|
|
|
|
* Using global isn't great, this just avoids doing inline,
|
2024-02-10 18:25:14 +01:00
|
|
|
* causing 'BKE_global.hh' & 'BKE_main.hh' includes.
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
UndoStack *ED_undo_stack_get();
|
2018-04-03 08:35:42 +02:00
|
|
|
|
2022-04-04 13:17:03 +10:00
|
|
|
/* Helpers. */
|
|
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_undo_object_set_active_or_warn(
|
|
|
|
|
Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log);
|
2018-04-16 16:27:55 +02:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `undo_system_types.cc` */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_undosys_type_init();
|
|
|
|
|
void ED_undosys_type_free();
|
2018-04-02 15:02:08 +02:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `memfile_undo.cc` */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2024-02-29 13:14:58 +01:00
|
|
|
MemFile *ED_undosys_stack_memfile_get_if_active(UndoStack *ustack);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* If the last undo step is a memfile one, find the first #MemFileChunk matching given ID
|
|
|
|
|
* (using its session UUID), and tag it as "changed in the future".
|
|
|
|
|
*
|
|
|
|
|
* Since non-memfile undo-steps cannot automatically set this flag in the previous step as done
|
|
|
|
|
* with memfile ones, this has to be called manually by relevant undo code.
|
|
|
|
|
*
|
|
|
|
|
* \note Only current known case for this is undoing a switch from Object to Sculpt mode (see
|
2023-02-12 14:37:16 +11:00
|
|
|
* #82388).
|
2021-12-09 00:55:11 +11:00
|
|
|
*
|
|
|
|
|
* \note Calling this ID by ID is not optimal, as it will loop over all #MemFile.chunks until it
|
|
|
|
|
* finds the expected one. If this becomes an issue we'll have to add a mapping from session UUID
|
|
|
|
|
* to first #MemFileChunk in #MemFile itself
|
|
|
|
|
* (currently we only do that in #MemFileWriteData when writing a new step).
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_undosys_stack_memfile_id_changed_tag(UndoStack *ustack, ID *id);
|