2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-02-04 11:52:16 +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.
|
2009-02-04 11:52:16 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/interface/interface_utils.c
|
|
|
|
* \ingroup edinterface
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-09-16 19:36:17 +00:00
|
|
|
#include <stdio.h>
|
2009-02-04 11:52:16 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-12-15 05:42:23 +00:00
|
|
|
#include <assert.h>
|
2009-02-04 11:52:16 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
#include "DNA_object_types.h"
|
2014-02-08 09:03:25 +11:00
|
|
|
#include "DNA_screen_types.h"
|
2009-06-10 11:43:21 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2014-01-08 17:04:10 +01:00
|
|
|
#include "BLI_math.h"
|
2011-09-26 16:53:04 +00:00
|
|
|
#include "BLI_string.h"
|
2014-02-08 09:03:25 +11:00
|
|
|
#include "BLI_listbase.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2011-06-15 11:41:15 +00:00
|
|
|
|
2014-02-09 12:00:03 +11:00
|
|
|
#include "BKE_report.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2014-02-08 09:03:25 +11:00
|
|
|
#include "MEM_guardedalloc.h"
|
2009-02-04 11:52:16 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2015-04-27 01:17:51 +10:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2014-02-08 09:03:25 +11:00
|
|
|
#include "interface_intern.h"
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
|
2009-02-04 11:52:16 +00:00
|
|
|
/*************************** RNA Utilities ******************************/
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2)
|
2009-02-04 11:52:16 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *but = NULL;
|
2009-11-18 14:00:23 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (RNA_property_type(prop)) {
|
2011-08-06 16:00:00 +00:00
|
|
|
case PROP_BOOLEAN:
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int arraylen = RNA_property_array_length(ptr, prop);
|
2009-02-04 11:52:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (arraylen && index == -1)
|
2009-02-04 11:52:16 +00:00
|
|
|
return NULL;
|
2009-10-28 10:16:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon && name && name[0] == '\0')
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_CHECKBOX, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROP_INT:
|
|
|
|
case PROP_FLOAT:
|
2011-08-06 16:00:00 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int arraylen = RNA_property_array_length(ptr, prop);
|
2011-08-06 16:00:00 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (arraylen && index == -1) {
|
2014-12-30 07:37:59 +11:00
|
|
|
if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_COLOR, 0, name, x1, y1, x2, y2, ptr, prop, -1, 0, 0, -1, -1, NULL);
|
2014-12-30 07:37:59 +11:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_NUM_SLIDER, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-02-04 11:52:16 +00:00
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2014-12-25 12:53:13 +01:00
|
|
|
|
|
|
|
if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
|
|
|
|
UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE);
|
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
2011-08-06 16:00:00 +00:00
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
case PROP_ENUM:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon && name && name[0] == '\0')
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButR_prop(block, UI_BTYPE_MENU, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButR_prop(block, UI_BTYPE_MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-09-10 14:20:21 +00:00
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_MENU, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
|
|
|
case PROP_STRING:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon && name && name[0] == '\0')
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButR_prop(block, UI_BTYPE_TEXT, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButR_prop(block, UI_BTYPE_TEXT, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-06-27 01:15:31 +00:00
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2014-12-25 12:53:13 +01:00
|
|
|
|
|
|
|
if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) {
|
2017-01-11 22:11:13 +01:00
|
|
|
/* TEXTEDIT_UPDATE is usally used for search buttons. For these we also want
|
|
|
|
* the 'x' icon to clear search string, so setting VALUE_CLEAR flag, too. */
|
|
|
|
UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE | UI_BUT_VALUE_CLEAR);
|
2014-12-25 12:53:13 +01:00
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_POINTER:
|
|
|
|
{
|
2017-03-31 12:13:34 +02:00
|
|
|
if (icon == 0) {
|
|
|
|
PointerRNA pptr = RNA_property_pointer_get(ptr, prop);
|
|
|
|
icon = RNA_struct_ui_icon(pptr.type ? pptr.type : RNA_property_pointer_type(ptr, prop));
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon == ICON_DOT)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = 0;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButR_prop(block, UI_BTYPE_SEARCH_MENU, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-08 08:59:47 +00:00
|
|
|
case PROP_COLLECTION:
|
|
|
|
{
|
2009-02-04 11:52:16 +00:00
|
|
|
char text[256];
|
2011-10-20 20:38:26 +00:00
|
|
|
BLI_snprintf(text, sizeof(text), IFACE_("%d items"), RNA_property_collection_length(ptr, prop));
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_LABEL, 0, text, x1, y1, x2, y2, NULL, 0, 0, 0, 0, NULL);
|
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-30 01:51:25 +00:00
|
|
|
but = NULL;
|
2009-02-04 11:52:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return but;
|
|
|
|
}
|
|
|
|
|
2012-06-14 22:48:40 +00:00
|
|
|
/**
|
|
|
|
* \a check_prop callback filters functions to avoid drawing certain properties,
|
|
|
|
* in cases where PROP_HIDDEN flag can't be used for a property.
|
|
|
|
*/
|
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
|
|
|
eAutoPropButsReturn uiDefAutoButsRNA(
|
2015-05-05 03:13:47 +10:00
|
|
|
uiLayout *layout, PointerRNA *ptr,
|
|
|
|
bool (*check_prop)(PointerRNA *, PropertyRNA *),
|
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
|
|
|
const eButLabelAlign label_align, const bool compact)
|
2009-02-04 11:52:16 +00:00
|
|
|
{
|
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
|
|
|
eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED;
|
2009-06-24 21:27:10 +00:00
|
|
|
uiLayout *split, *col;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
int flag;
|
2010-12-15 05:42:23 +00:00
|
|
|
const char *name;
|
2009-02-04 11:52:16 +00:00
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
RNA_STRUCT_BEGIN (ptr, prop)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
flag = RNA_property_flag(prop);
|
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
|
|
|
|
|
|
|
if (flag & PROP_HIDDEN) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (check_prop && check_prop(ptr, prop) == 0) {
|
|
|
|
return_info |= UI_PROP_BUTS_ANY_FAILED_CHECK;
|
2009-02-04 11:52:16 +00:00
|
|
|
continue;
|
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
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
|
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
|
|
|
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));
|
2011-04-02 16:45:17 +00:00
|
|
|
|
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
|
|
|
name = RNA_property_ui_name(prop);
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
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
|
|
|
if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) {
|
|
|
|
col = uiLayoutColumn(layout, true);
|
2011-04-02 16:45:17 +00:00
|
|
|
|
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
|
|
|
if (!is_boolean)
|
|
|
|
uiItemL(col, name, ICON_NONE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN);
|
|
|
|
split = uiLayoutSplit(layout, 0.5f, false);
|
2009-02-04 11:52:16 +00:00
|
|
|
|
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
|
|
|
col = uiLayoutColumn(split, false);
|
|
|
|
uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
|
|
|
|
col = uiLayoutColumn(split, false);
|
|
|
|
}
|
2010-12-15 05:42:23 +00:00
|
|
|
|
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
|
|
|
/* may meed to add more cases here.
|
|
|
|
* don't override enum flag names */
|
2011-04-02 16:45:17 +00:00
|
|
|
|
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
|
|
|
/* name is shown above, empty name for button below */
|
|
|
|
name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UI_BUT_LABEL_ALIGN_NONE:
|
|
|
|
col = layout;
|
|
|
|
name = NULL; /* no smart label alignment, show default name with button */
|
|
|
|
break;
|
2009-06-24 21:27:10 +00:00
|
|
|
}
|
2009-02-04 11:52:16 +00:00
|
|
|
|
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
|
|
|
uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
|
|
|
|
return_info &= ~UI_PROP_BUTS_NONE_ADDED;
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
}
|
2009-06-24 21:27:10 +00:00
|
|
|
RNA_STRUCT_END;
|
2010-12-15 05:42:23 +00:00
|
|
|
|
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
|
|
|
return return_info;
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
}
|
2017-05-13 19:48:04 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/* *** RNA collection search menu *** */
|
|
|
|
|
|
|
|
typedef struct CollItemSearch {
|
|
|
|
struct CollItemSearch *next, *prev;
|
2017-05-13 19:48:04 +02:00
|
|
|
void *data;
|
2017-05-12 01:42:42 +02:00
|
|
|
char *name;
|
|
|
|
int index;
|
|
|
|
int iconid;
|
|
|
|
} CollItemSearch;
|
|
|
|
|
|
|
|
static int sort_search_items_list(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
const CollItemSearch *cis1 = a;
|
|
|
|
const CollItemSearch *cis2 = b;
|
|
|
|
|
|
|
|
if (BLI_strcasecmp(cis1->name, cis2->name) > 0)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_rna_collection_search_cb(const struct bContext *C, void *arg, const char *str, uiSearchItems *items)
|
|
|
|
{
|
|
|
|
uiRNACollectionSearch *data = arg;
|
|
|
|
char *name;
|
|
|
|
int i = 0, iconid = 0, flag = RNA_property_flag(data->target_prop);
|
|
|
|
ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list");
|
|
|
|
CollItemSearch *cis;
|
|
|
|
const bool skip_filter = !(data->but_changed && *data->but_changed);
|
|
|
|
|
|
|
|
/* build a temporary list of relevant items first */
|
|
|
|
RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (flag & PROP_ID_SELF_CHECK)
|
|
|
|
if (itemptr.data == data->target_ptr.id.data)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* use filter */
|
|
|
|
if (RNA_property_type(data->target_prop) == PROP_POINTER) {
|
|
|
|
if (RNA_property_pointer_poll(&data->target_ptr, data->target_prop, &itemptr) == 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
|
|
|
|
iconid = 0;
|
|
|
|
if (itemptr.type && RNA_struct_is_ID(itemptr.type)) {
|
2017-05-13 19:48:04 +02:00
|
|
|
iconid = ui_id_icon_get(C, itemptr.data, false);
|
2017-05-12 01:42:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
if (skip_filter || BLI_strcasestr(name, str)) {
|
|
|
|
cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
|
2017-05-13 19:48:04 +02:00
|
|
|
cis->data = itemptr.data;
|
2017-05-12 01:42:42 +02:00
|
|
|
cis->name = MEM_dupallocN(name);
|
|
|
|
cis->index = i;
|
|
|
|
cis->iconid = iconid;
|
|
|
|
BLI_addtail(items_list, cis);
|
|
|
|
}
|
|
|
|
MEM_freeN(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
RNA_PROP_END;
|
|
|
|
|
|
|
|
BLI_listbase_sort(items_list, sort_search_items_list);
|
|
|
|
|
|
|
|
/* add search items from temporary list */
|
|
|
|
for (cis = items_list->first; cis; cis = cis->next) {
|
2017-05-13 19:48:04 +02:00
|
|
|
if (UI_search_item_add(items, cis->name, cis->data, cis->iconid) == false) {
|
2017-05-12 01:42:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (cis = items_list->first; cis; cis = cis->next) {
|
|
|
|
MEM_freeN(cis->name);
|
|
|
|
}
|
|
|
|
BLI_freelistN(items_list);
|
|
|
|
MEM_freeN(items_list);
|
|
|
|
}
|
|
|
|
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
|
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
|
|
|
/***************************** ID Utilities *******************************/
|
2014-11-09 21:20:40 +01:00
|
|
|
int UI_icon_from_id(ID *id)
|
2009-09-16 01:15:30 +00:00
|
|
|
{
|
2009-09-16 19:36:17 +00:00
|
|
|
Object *ob;
|
|
|
|
PointerRNA ptr;
|
|
|
|
short idcode;
|
2009-06-03 00:14:12 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (id == NULL)
|
2011-02-27 18:03:19 +00:00
|
|
|
return ICON_NONE;
|
2009-06-03 00:14:12 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
idcode = GS(id->name);
|
2009-07-23 20:50:24 +00:00
|
|
|
|
2009-09-16 19:36:17 +00:00
|
|
|
/* exception for objects */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idcode == ID_OB) {
|
2012-03-30 01:51:25 +00:00
|
|
|
ob = (Object *)id;
|
2009-06-03 00:14:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->type == OB_EMPTY)
|
2009-09-16 19:36:17 +00:00
|
|
|
return ICON_EMPTY_DATA;
|
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
return UI_icon_from_id(ob->data);
|
2009-06-03 00:14:12 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 19:36:17 +00:00
|
|
|
/* otherwise get it through RNA, creating the pointer
|
2012-03-03 16:31:46 +00:00
|
|
|
* will set the right type, also with subclassing */
|
2009-09-16 19:36:17 +00:00
|
|
|
RNA_id_pointer_create(id, &ptr);
|
2009-06-03 00:14:12 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
return (ptr.type) ? RNA_struct_ui_icon(ptr.type) : ICON_NONE;
|
2009-06-03 00:14:12 +00:00
|
|
|
}
|
2014-01-08 17:04:10 +01:00
|
|
|
|
2014-02-09 12:00:03 +11:00
|
|
|
/* see: report_type_str */
|
2014-11-09 21:20:40 +01:00
|
|
|
int UI_icon_from_report_type(int type)
|
2014-02-09 12:00:03 +11:00
|
|
|
{
|
|
|
|
if (type & RPT_ERROR_ALL)
|
|
|
|
return ICON_ERROR;
|
|
|
|
else if (type & RPT_WARNING_ALL)
|
|
|
|
return ICON_ERROR;
|
|
|
|
else if (type & RPT_INFO_ALL)
|
|
|
|
return ICON_INFO;
|
|
|
|
else
|
|
|
|
return ICON_NONE;
|
|
|
|
}
|
|
|
|
|
2014-01-08 17:04:10 +01:00
|
|
|
/********************************** Misc **************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the best "UI" precision for given floating value, so that e.g. 10.000001 rather gets drawn as '10'...
|
|
|
|
*/
|
2014-11-09 21:20:40 +01:00
|
|
|
int UI_calc_float_precision(int prec, double value)
|
2014-01-08 17:04:10 +01:00
|
|
|
{
|
2017-07-21 10:52:36 +02:00
|
|
|
static const double pow10_neg[UI_PRECISION_FLOAT_MAX + 1] = {1e0, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6};
|
2014-01-08 17:04:10 +01:00
|
|
|
static const double max_pow = 10000000.0; /* pow(10, UI_PRECISION_FLOAT_MAX) */
|
|
|
|
|
|
|
|
BLI_assert(prec <= UI_PRECISION_FLOAT_MAX);
|
2014-06-18 13:13:22 +09:00
|
|
|
BLI_assert(fabs(pow10_neg[prec] - pow(10, -prec)) < 1e-16);
|
2014-01-08 17:04:10 +01:00
|
|
|
|
|
|
|
/* check on the number of decimal places need to display the number, this is so 0.00001 is not displayed as 0.00,
|
|
|
|
* _but_, this is only for small values si 10.0001 will not get the same treatment.
|
|
|
|
*/
|
|
|
|
value = ABS(value);
|
|
|
|
if ((value < pow10_neg[prec]) && (value > (1.0 / max_pow))) {
|
|
|
|
int value_i = (int)((value * max_pow) + 0.5);
|
|
|
|
if (value_i != 0) {
|
|
|
|
const int prec_span = 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */
|
|
|
|
int test_prec;
|
|
|
|
int prec_min = -1;
|
|
|
|
int dec_flag = 0;
|
|
|
|
int i = UI_PRECISION_FLOAT_MAX;
|
|
|
|
while (i && value_i) {
|
|
|
|
if (value_i % 10) {
|
|
|
|
dec_flag |= 1 << i;
|
|
|
|
prec_min = i;
|
|
|
|
}
|
|
|
|
value_i /= 10;
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* even though its a small value, if the second last digit is not 0, use it */
|
|
|
|
test_prec = prec_min;
|
|
|
|
|
|
|
|
dec_flag = (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
|
|
|
|
|
|
|
|
while (dec_flag) {
|
|
|
|
test_prec++;
|
|
|
|
dec_flag = dec_flag >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_prec > prec) {
|
|
|
|
prec = test_prec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CLAMP(prec, 0, UI_PRECISION_FLOAT_MAX);
|
|
|
|
|
|
|
|
return prec;
|
|
|
|
}
|
2014-02-08 09:03:25 +11:00
|
|
|
|
2015-04-27 01:17:51 +10:00
|
|
|
bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t maxlength)
|
|
|
|
{
|
|
|
|
if (but->rnapoin.id.data && but->rnapoin.data && but->rnaprop) {
|
|
|
|
BLI_snprintf(r_str, maxlength, "%s.%s", RNA_struct_identifier(but->rnapoin.type),
|
|
|
|
RNA_property_identifier(but->rnaprop));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (but->optype) {
|
|
|
|
WM_operator_py_idname(r_str, but->optype->idname);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*r_str = '\0';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UI_but_online_manual_id_from_active(const struct bContext *C, char *r_str, size_t maxlength)
|
|
|
|
{
|
|
|
|
uiBut *but = UI_context_active_but_get(C);
|
|
|
|
|
|
|
|
if (but) {
|
|
|
|
return UI_but_online_manual_id(but, r_str, maxlength);
|
|
|
|
}
|
|
|
|
|
|
|
|
*r_str = '\0';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-08 09:03:25 +11:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/* Modal Button Store API */
|
|
|
|
|
|
|
|
/** \name Button Store
|
|
|
|
*
|
|
|
|
* Store for modal operators & handlers to register button pointers
|
|
|
|
* which are maintained while drawing or NULL when removed.
|
|
|
|
*
|
|
|
|
* This is needed since button pointers are continuously freed and re-allocated.
|
|
|
|
*
|
|
|
|
* \{ */
|
|
|
|
|
2014-02-09 13:56:49 +01:00
|
|
|
struct uiButStore {
|
2014-02-08 09:03:25 +11:00
|
|
|
struct uiButStore *next, *prev;
|
|
|
|
uiBlock *block;
|
|
|
|
ListBase items;
|
2014-02-09 13:56:49 +01:00
|
|
|
};
|
2014-02-08 09:03:25 +11:00
|
|
|
|
2014-02-09 13:56:49 +01:00
|
|
|
struct uiButStoreElem {
|
2014-02-08 09:03:25 +11:00
|
|
|
struct uiButStoreElem *next, *prev;
|
|
|
|
uiBut **but_p;
|
2014-02-09 13:56:49 +01:00
|
|
|
};
|
2014-02-08 09:03:25 +11:00
|
|
|
|
|
|
|
/**
|
2014-03-15 20:08:29 +11:00
|
|
|
* Create a new button store, the caller must manage and run #UI_butstore_free
|
2014-02-08 09:03:25 +11:00
|
|
|
*/
|
|
|
|
uiButStore *UI_butstore_create(uiBlock *block)
|
|
|
|
{
|
|
|
|
uiButStore *bs_handle = MEM_callocN(sizeof(uiButStore), __func__);
|
|
|
|
|
|
|
|
bs_handle->block = block;
|
|
|
|
BLI_addtail(&block->butstore, bs_handle);
|
|
|
|
|
|
|
|
return bs_handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
|
|
|
|
{
|
2017-07-11 19:07:37 +10:00
|
|
|
/* Workaround for button store being moved into new block,
|
|
|
|
* which then can't use the previous buttons state ('ui_but_update_from_old_block' fails to find a match),
|
|
|
|
* keeping the active button in the old block holding a reference to the button-state in the new block: see T49034.
|
|
|
|
*
|
|
|
|
* Ideally we would manage moving the 'uiButStore', keeping a correct state.
|
|
|
|
* All things considered this is the most straightforward fix - Campbell.
|
|
|
|
*/
|
|
|
|
if (block != bs_handle->block && bs_handle->block != NULL) {
|
|
|
|
block = bs_handle->block;
|
|
|
|
}
|
|
|
|
|
2014-02-08 09:03:25 +11:00
|
|
|
BLI_freelistN(&bs_handle->items);
|
|
|
|
BLI_remlink(&block->butstore, bs_handle);
|
|
|
|
|
|
|
|
MEM_freeN(bs_handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UI_butstore_is_valid(uiButStore *bs)
|
|
|
|
{
|
|
|
|
return (bs->block != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UI_butstore_is_registered(uiBlock *block, uiBut *but)
|
|
|
|
{
|
|
|
|
uiButStore *bs_handle;
|
|
|
|
|
|
|
|
for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
|
|
|
|
uiButStoreElem *bs_elem;
|
|
|
|
|
|
|
|
for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
|
|
|
|
if (*bs_elem->but_p == but) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p)
|
|
|
|
{
|
|
|
|
uiButStoreElem *bs_elem = MEM_callocN(sizeof(uiButStoreElem), __func__);
|
|
|
|
BLI_assert(*but_p);
|
|
|
|
bs_elem->but_p = but_p;
|
|
|
|
|
|
|
|
BLI_addtail(&bs_handle->items, bs_elem);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p)
|
|
|
|
{
|
|
|
|
uiButStoreElem *bs_elem, *bs_elem_next;
|
|
|
|
|
|
|
|
for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem_next) {
|
|
|
|
bs_elem_next = bs_elem->next;
|
|
|
|
if (bs_elem->but_p == but_p) {
|
|
|
|
BLI_remlink(&bs_handle->items, bs_elem);
|
|
|
|
MEM_freeN(bs_elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_assert(0);
|
|
|
|
}
|
|
|
|
|
2014-12-01 23:30:54 +01:00
|
|
|
/**
|
|
|
|
* Update the pointer for a registered button.
|
|
|
|
*/
|
|
|
|
bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src)
|
|
|
|
{
|
|
|
|
uiButStore *bs_handle;
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
|
|
|
|
uiButStoreElem *bs_elem;
|
|
|
|
for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
|
|
|
|
if (*bs_elem->but_p == but_src) {
|
|
|
|
*bs_elem->but_p = but_dst;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2014-02-08 09:03:25 +11:00
|
|
|
/**
|
|
|
|
* NULL all pointers, don't free since the owner needs to be able to inspect.
|
|
|
|
*/
|
|
|
|
void UI_butstore_clear(uiBlock *block)
|
|
|
|
{
|
|
|
|
uiButStore *bs_handle;
|
|
|
|
|
|
|
|
for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
|
|
|
|
uiButStoreElem *bs_elem;
|
|
|
|
|
|
|
|
bs_handle->block = NULL;
|
|
|
|
|
|
|
|
for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
|
|
|
|
*bs_elem->but_p = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Map freed buttons from the old block and update pointers.
|
|
|
|
*/
|
|
|
|
void UI_butstore_update(uiBlock *block)
|
|
|
|
{
|
|
|
|
uiButStore *bs_handle;
|
|
|
|
|
|
|
|
/* move this list to the new block */
|
|
|
|
if (block->oldblock) {
|
|
|
|
if (block->oldblock->butstore.first) {
|
|
|
|
block->butstore = block->oldblock->butstore;
|
|
|
|
BLI_listbase_clear(&block->oldblock->butstore);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LIKELY(block->butstore.first == NULL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* warning, loop-in-loop, in practice we only store <10 buttons at a time,
|
|
|
|
* so this isn't going to be a problem, if that changes old-new mapping can be cached first */
|
|
|
|
for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
|
|
|
|
|
|
|
|
BLI_assert((bs_handle->block == NULL) ||
|
|
|
|
(bs_handle->block == block) ||
|
|
|
|
(block->oldblock && block->oldblock == bs_handle->block));
|
|
|
|
|
|
|
|
if (bs_handle->block == block->oldblock) {
|
|
|
|
uiButStoreElem *bs_elem;
|
|
|
|
|
|
|
|
bs_handle->block = block;
|
|
|
|
|
|
|
|
for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
|
|
|
|
if (*bs_elem->but_p) {
|
|
|
|
uiBut *but_new = ui_but_find_new(block, *bs_elem->but_p);
|
|
|
|
|
|
|
|
/* can be NULL if the buttons removed,
|
|
|
|
* note: we could allow passing in a callback when buttons are removed
|
|
|
|
* so the caller can cleanup */
|
|
|
|
*bs_elem->but_p = but_new;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \} */
|