2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-12 18:47:12 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-12 18:47:12 +00:00
|
|
|
*
|
2008-12-20 12:36:14 +00:00
|
|
|
* The Original Code is Copyright (C) 2004-2008 Blender Foundation.
|
2008-12-12 18:47:12 +00:00
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_view3d/view3d_header.c
|
|
|
|
|
* \ingroup spview3d
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-12 18:47:12 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
2008-12-20 12:36:14 +00:00
|
|
|
#include <stdlib.h>
|
2008-12-12 18:47:12 +00:00
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_object_types.h"
|
2015-12-13 21:03:13 +13:00
|
|
|
#include "DNA_gpencil_types.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2011-06-15 11:41:15 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-20 12:36:14 +00:00
|
|
|
#include "BKE_main.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
#include "BKE_screen.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2009-01-01 18:05:12 +00:00
|
|
|
#include "ED_mesh.h"
|
2018-04-02 15:02:08 +02:00
|
|
|
#include "ED_undo.h"
|
2009-01-05 19:32:04 +00:00
|
|
|
#include "ED_screen.h"
|
2008-12-12 18:47:12 +00:00
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
|
|
#include "view3d_intern.h"
|
|
|
|
|
|
2009-02-10 15:38:00 +00:00
|
|
|
static void do_view3d_header_buttons(bContext *C, void *arg, int event);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
#define B_SEL_VERT 110
|
|
|
|
|
#define B_SEL_EDGE 111
|
|
|
|
|
#define B_SEL_FACE 112
|
2009-10-26 12:42:25 +00:00
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
/* XXX quickly ported across */
|
|
|
|
|
static void handle_view3d_lock(bContext *C)
|
2009-07-03 04:24:19 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
|
2009-07-03 04:24:19 +00:00
|
|
|
if (v3d != NULL && sa != NULL) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (v3d->localvd == NULL && v3d->scenelock && sa->spacetype == SPACE_VIEW3D) {
|
2009-07-03 04:24:19 +00:00
|
|
|
/* copy to scene */
|
2012-03-25 23:54:33 +00:00
|
|
|
scene->lay = v3d->lay;
|
|
|
|
|
scene->layact = v3d->layact;
|
|
|
|
|
scene->camera = v3d->camera;
|
2009-10-26 12:42:25 +00:00
|
|
|
|
2009-10-19 04:56:19 +00:00
|
|
|
/* notifiers for scene update */
|
2012-03-25 23:54:33 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
|
2009-07-03 04:24:19 +00:00
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
/**
|
|
|
|
|
* layer code is on three levels actually:
|
|
|
|
|
* - here for operator
|
|
|
|
|
* - uiTemplateLayers in interface/ code for buttons
|
2017-11-22 10:52:39 -02:00
|
|
|
* - ED_view3d_view_layer_set for RNA
|
2011-03-19 16:30:52 +00:00
|
|
|
*/
|
2018-02-13 19:29:08 +11:00
|
|
|
static void view3d_layers_editmode_ensure(View3D *v3d, Object *obedit)
|
2011-03-30 15:28:38 +00:00
|
|
|
{
|
|
|
|
|
/* sanity check - when in editmode disallow switching the editmode layer off since its confusing
|
|
|
|
|
* an alternative would be to always draw the editmode object. */
|
2018-02-13 19:29:08 +11:00
|
|
|
if (obedit && (obedit->lay & v3d->lay) == 0) {
|
2011-03-30 15:28:38 +00:00
|
|
|
int bit;
|
2012-03-25 23:54:33 +00:00
|
|
|
for (bit = 0; bit < 32; bit++) {
|
2018-02-13 19:29:08 +11:00
|
|
|
if (obedit->lay & (1u << bit)) {
|
2015-03-20 15:26:47 +11:00
|
|
|
v3d->lay |= (1u << bit);
|
2011-03-30 15:28:38 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static int view3d_layers_exec(bContext *C, wmOperator *op)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
2018-02-13 19:29:08 +11:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2012-03-25 23:54:33 +00:00
|
|
|
int nr = RNA_int_get(op->ptr, "nr");
|
2013-03-22 04:40:45 +00:00
|
|
|
const bool toggle = RNA_boolean_get(op->ptr, "toggle");
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nr < 0)
|
2009-02-20 18:01:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-03-26 08:32:54 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (nr == 0) {
|
2009-09-22 04:40:16 +00:00
|
|
|
/* all layers */
|
2013-05-23 21:24:56 +00:00
|
|
|
if (!v3d->lay_prev)
|
|
|
|
|
v3d->lay_prev = 1;
|
2010-03-26 08:32:54 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (toggle && v3d->lay == ((1 << 20) - 1)) {
|
2010-03-26 08:32:54 +00:00
|
|
|
/* return to active layer only */
|
2013-05-23 21:24:56 +00:00
|
|
|
v3d->lay = v3d->lay_prev;
|
2011-03-30 15:28:38 +00:00
|
|
|
|
2018-02-13 19:29:08 +11:00
|
|
|
view3d_layers_editmode_ensure(v3d, obedit);
|
2011-03-30 15:28:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-05-23 21:24:56 +00:00
|
|
|
v3d->lay_prev = v3d->lay;
|
2012-03-25 23:54:33 +00:00
|
|
|
v3d->lay |= (1 << 20) - 1;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-01-30 15:23:17 +00:00
|
|
|
int bit;
|
2009-09-22 04:40:16 +00:00
|
|
|
nr--;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (RNA_boolean_get(op->ptr, "extend")) {
|
2012-03-25 23:54:33 +00:00
|
|
|
if (toggle && v3d->lay & (1 << nr) && (v3d->lay & ~(1 << nr)))
|
|
|
|
|
v3d->lay &= ~(1 << nr);
|
2010-01-03 04:21:40 +00:00
|
|
|
else
|
2012-03-25 23:54:33 +00:00
|
|
|
v3d->lay |= (1 << nr);
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:54:33 +00:00
|
|
|
v3d->lay = (1 << nr);
|
2010-01-30 15:23:17 +00:00
|
|
|
}
|
2011-03-30 15:28:38 +00:00
|
|
|
|
2018-02-13 19:29:08 +11:00
|
|
|
view3d_layers_editmode_ensure(v3d, obedit);
|
2011-03-30 15:28:38 +00:00
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
/* set active layer, ensure to always have one */
|
2012-03-25 23:54:33 +00:00
|
|
|
if (v3d->lay & (1 << nr))
|
|
|
|
|
v3d->layact = 1 << nr;
|
|
|
|
|
else if ((v3d->lay & v3d->layact) == 0) {
|
|
|
|
|
for (bit = 0; bit < 32; bit++) {
|
2015-03-20 15:26:47 +11:00
|
|
|
if (v3d->lay & (1u << bit)) {
|
|
|
|
|
v3d->layact = (1u << bit);
|
2009-09-22 04:40:16 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2009-07-19 16:53:57 +00:00
|
|
|
}
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2009-07-19 16:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (v3d->scenelock) handle_view3d_lock(C);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_on_visible_update(CTX_data_main(C), false);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
/* applies shift and alt, lazy coding or ok? :) */
|
|
|
|
|
/* the local per-keymap-entry keymap will solve it */
|
2013-03-13 09:03:46 +00:00
|
|
|
static int view3d_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2012-02-22 16:52:06 +00:00
|
|
|
if (event->ctrl || event->oskey)
|
2009-02-20 18:01:33 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (event->shift)
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_boolean_set(op->ptr, "extend", true);
|
2012-01-26 07:33:14 +00:00
|
|
|
else
|
2013-03-20 23:14:18 +00:00
|
|
|
RNA_boolean_set(op->ptr, "extend", false);
|
2009-02-20 18:01:33 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (event->alt) {
|
2013-03-22 04:40:45 +00:00
|
|
|
const int nr = RNA_int_get(op->ptr, "nr") + 10;
|
2009-02-20 18:01:33 +00:00
|
|
|
RNA_int_set(op->ptr, "nr", nr);
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2011-02-13 14:16:36 +00:00
|
|
|
view3d_layers_exec(C, op);
|
2009-02-20 18:01:33 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static int view3d_layers_poll(bContext *C)
|
2010-01-03 04:21:40 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd == NULL);
|
2010-01-03 04:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
void VIEW3D_OT_layers(wmOperatorType *ot)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2009-02-20 18:01:33 +00:00
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Layers";
|
|
|
|
|
ot->description = "Toggle layer(s) visibility";
|
|
|
|
|
ot->idname = "VIEW3D_OT_layers";
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = view3d_layers_invoke;
|
|
|
|
|
ot->exec = view3d_layers_exec;
|
|
|
|
|
ot->poll = view3d_layers_poll;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-02-20 18:01:33 +00:00
|
|
|
/* flags */
|
2012-03-25 23:54:33 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20);
|
|
|
|
|
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers");
|
2010-01-03 04:21:40 +00:00
|
|
|
RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2012-03-02 12:09:49 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2012-11-11 23:33:59 +00:00
|
|
|
const int ctrl = win->eventstate->ctrl, shift = win->eventstate->shift;
|
2012-11-13 05:44:49 +00:00
|
|
|
|
2008-12-20 12:36:14 +00:00
|
|
|
/* watch it: if sa->win does not exist, check that when calling direct drawing routines */
|
|
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
switch (event) {
|
|
|
|
|
case B_SEL_VERT:
|
2012-11-13 05:44:49 +00:00
|
|
|
if (EDBM_selectmode_toggle(C, SCE_SELECT_VERTEX, -1, shift, ctrl)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
ED_undo_push(C, "Selectmode Set: Vertex");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case B_SEL_EDGE:
|
2012-11-13 05:44:49 +00:00
|
|
|
if (EDBM_selectmode_toggle(C, SCE_SELECT_EDGE, -1, shift, ctrl)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
ED_undo_push(C, "Selectmode Set: Edge");
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
break;
|
|
|
|
|
case B_SEL_FACE:
|
2012-11-13 05:44:49 +00:00
|
|
|
if (EDBM_selectmode_toggle(C, SCE_SELECT_FACE, -1, shift, ctrl)) {
|
2012-03-25 23:54:33 +00:00
|
|
|
ED_undo_push(C, "Selectmode Set: Face");
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
2012-03-25 23:54:33 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2008-12-20 12:36:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-02 11:34:57 +00:00
|
|
|
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2012-03-25 23:54:33 +00:00
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
2011-05-02 11:34:57 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, do_view3d_header_buttons, NULL);
|
2011-05-02 11:34:57 +00:00
|
|
|
|
2012-02-22 16:52:06 +00:00
|
|
|
if (obedit && (obedit->type == OB_MESH)) {
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
2011-05-02 11:34:57 +00:00
|
|
|
uiLayout *row;
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(layout, true);
|
2012-03-25 23:54:33 +00:00
|
|
|
block = uiLayoutGetBlock(row);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL,
|
2012-11-11 23:33:59 +00:00
|
|
|
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
|
2014-04-28 03:52:42 +10:00
|
|
|
TIP_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection"));
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL,
|
2012-11-11 23:33:59 +00:00
|
|
|
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
|
2014-04-28 03:52:42 +10:00
|
|
|
TIP_("Edge select - Shift-Click for multiple modes, Ctrl-Click expands/contracts selection"));
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL,
|
2012-11-11 23:33:59 +00:00
|
|
|
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
|
2013-02-24 15:40:28 +00:00
|
|
|
TIP_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
|
2011-05-02 11:34:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-11 13:32:20 +00:00
|
|
|
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
|
2008-12-20 12:36:14 +00:00
|
|
|
{
|
2012-03-25 23:54:33 +00:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
View3D *v3d = sa->spacedata.first;
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2017-11-23 13:51:49 -02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2012-03-25 23:54:33 +00:00
|
|
|
ToolSettings *ts = CTX_data_tool_settings(C);
|
2009-11-29 02:42:47 +00:00
|
|
|
PointerRNA v3dptr, toolsptr, sceneptr;
|
2017-11-23 13:51:49 -02:00
|
|
|
Object *ob = OBACT(view_layer);
|
2008-12-31 22:43:29 +00:00
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2015-12-13 21:03:13 +13:00
|
|
|
bGPdata *gpd = CTX_data_gpencil_data(C);
|
2008-12-20 12:36:14 +00:00
|
|
|
uiBlock *block;
|
2009-11-01 14:04:37 +00:00
|
|
|
uiLayout *row;
|
2018-02-06 17:28:00 +11:00
|
|
|
bool is_paint = (
|
|
|
|
|
ob && !(gpd && (gpd->flag & GP_DATA_STROKE_EDITMODE)) &&
|
2018-04-05 18:20:27 +02:00
|
|
|
ELEM(ob->mode,
|
2018-02-06 17:28:00 +11:00
|
|
|
OB_MODE_SCULPT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, OB_MODE_TEXTURE_PAINT));
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);
|
2009-11-28 19:38:05 +00:00
|
|
|
RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
|
2009-11-29 02:42:47 +00:00
|
|
|
RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
|
2009-11-28 19:38:05 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, do_view3d_header_buttons, NULL);
|
2008-12-20 12:36:14 +00:00
|
|
|
|
|
|
|
|
/* other buttons: */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
|
2017-01-05 00:09:42 +01:00
|
|
|
row = uiLayoutRow(layout, true);
|
|
|
|
|
uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
2018-04-05 18:20:27 +02:00
|
|
|
if (!ob || ELEM(ob->mode, OB_MODE_OBJECT, OB_MODE_POSE, OB_MODE_WEIGHT_PAINT)) {
|
2017-01-05 00:09:42 +01:00
|
|
|
uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
|
|
|
|
}
|
2013-02-26 18:35:16 +00:00
|
|
|
|
2017-01-05 00:09:42 +01:00
|
|
|
if (obedit == NULL && is_paint) {
|
2012-02-17 06:59:32 +00:00
|
|
|
/* Manipulators aren't used in paint modes */
|
2018-04-05 18:20:27 +02:00
|
|
|
if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) {
|
2012-02-17 06:59:32 +00:00
|
|
|
/* masks aren't used for sculpt and particle painting */
|
|
|
|
|
PointerRNA meshptr;
|
2008-12-20 12:36:14 +00:00
|
|
|
|
2013-10-21 23:46:45 +00:00
|
|
|
RNA_pointer_create(ob->data, &RNA_Mesh, ob->data, &meshptr);
|
2018-04-05 18:20:27 +02:00
|
|
|
if (ob->mode & (OB_MODE_TEXTURE_PAINT)) {
|
2012-02-17 06:59:32 +00:00
|
|
|
uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(layout, true);
|
2012-02-17 06:59:32 +00:00
|
|
|
uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
|
|
|
|
uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
|
|
|
|
}
|
2011-07-20 15:56:35 +00:00
|
|
|
}
|
2012-02-22 16:52:06 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-11-28 20:02:10 +00:00
|
|
|
/* Transform widget / manipulators */
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(layout, true);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
2018-04-18 09:12:44 +02:00
|
|
|
uiItemR(row, &sceneptr, "transform_orientation", 0, "", ICON_NONE);
|
2009-11-28 20:02:10 +00:00
|
|
|
}
|
2011-04-21 15:53:30 +00:00
|
|
|
|
2012-03-25 23:54:33 +00:00
|
|
|
if (obedit == NULL && v3d->localvd == NULL) {
|
2009-11-28 21:27:28 +00:00
|
|
|
/* Scene lock */
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
2009-11-28 20:02:10 +00:00
|
|
|
}
|
2010-01-30 01:25:02 +00:00
|
|
|
|
2011-05-02 11:34:57 +00:00
|
|
|
uiTemplateEditModeSelection(layout, C);
|
2008-12-12 18:47:12 +00:00
|
|
|
}
|