2011-02-23 10:52:22 +00:00
|
|
|
/*
|
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
|
|
|
* ***** 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.
|
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
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation 2009.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/interface/interface_templates.c
|
|
|
|
* \ingroup edinterface
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
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
|
|
|
#include <stdlib.h>
|
2009-12-29 15:40:26 +00:00
|
|
|
#include <stddef.h>
|
2009-06-07 13:20:41 +00:00
|
|
|
#include <string.h>
|
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
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "DNA_node_types.h"
|
2009-06-27 01:15:31 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2012-09-23 18:50:56 +00:00
|
|
|
#include "DNA_object_types.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "DNA_object_force.h"
|
2014-07-21 12:02:05 +02:00
|
|
|
#include "DNA_brush_types.h"
|
2014-08-15 15:29:08 +10:00
|
|
|
#include "DNA_texture_types.h"
|
2009-06-24 17:22:22 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-10-20 13:50:24 +00:00
|
|
|
#include "BLI_string.h"
|
2011-08-11 06:06:17 +00:00
|
|
|
#include "BLI_ghash.h"
|
2012-08-20 23:06:17 +00:00
|
|
|
#include "BLI_rect.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_listbase.h"
|
2013-08-29 12:55:31 +00:00
|
|
|
#include "BLI_fnmatch.h"
|
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
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
#include "BLF_api.h"
|
2011-11-09 14:13:17 +00:00
|
|
|
#include "BLF_translation.h"
|
|
|
|
|
2010-01-04 17:28:37 +00:00
|
|
|
#include "BKE_colortools.h"
|
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
|
|
|
#include "BKE_context.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2009-06-27 01:15:31 +00:00
|
|
|
#include "BKE_global.h"
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
#include "BKE_idcode.h"
|
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
|
|
|
#include "BKE_library.h"
|
2014-05-03 18:51:53 +09:00
|
|
|
#include "BKE_linestyle.h"
|
2009-09-16 18:47:42 +00:00
|
|
|
#include "BKE_main.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BKE_modifier.h"
|
|
|
|
#include "BKE_object.h"
|
2013-01-27 14:28:45 +00:00
|
|
|
#include "BKE_packedFile.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BKE_particle.h"
|
2014-07-21 12:02:05 +02:00
|
|
|
#include "BKE_paint.h"
|
2010-07-14 14:11:03 +00:00
|
|
|
#include "BKE_report.h"
|
2012-09-23 18:50:56 +00:00
|
|
|
#include "BKE_sca.h"
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
#include "BKE_screen.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BKE_texture.h"
|
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
|
|
|
|
|
|
|
#include "ED_screen.h"
|
2011-08-08 08:22:01 +00:00
|
|
|
#include "ED_object.h"
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "ED_render.h"
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "ED_util.h"
|
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
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
#include "UI_interface_icons.h"
|
2009-06-25 15:41:27 +00:00
|
|
|
#include "interface_intern.h"
|
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
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
void UI_template_fix_linking(void)
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************** Header Template *************************/
|
|
|
|
|
2014-01-27 18:38:53 +11:00
|
|
|
void uiTemplateHeader(uiLayout *layout, bContext *C)
|
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
|
|
|
{
|
|
|
|
uiBlock *block;
|
2009-12-07 11:50:05 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutAbsoluteBlock(layout);
|
2014-01-27 18:38:53 +11:00
|
|
|
ED_area_header_switchbutton(C, block, 0);
|
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
|
|
|
}
|
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
/********************** Search Callbacks *************************/
|
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
|
|
|
|
2009-06-07 13:20:41 +00:00
|
|
|
typedef struct TemplateID {
|
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
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
ListBase *idlb;
|
2010-01-03 08:37:18 +00:00
|
|
|
int prv_rows, prv_cols;
|
2013-04-04 02:05:11 +00:00
|
|
|
bool preview;
|
2009-06-07 13:20:41 +00:00
|
|
|
} TemplateID;
|
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
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
/* Search browse menu, assign */
|
2009-09-16 18:47:42 +00:00
|
|
|
static void id_search_call_cb(bContext *C, void *arg_template, void *item)
|
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
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
TemplateID *template = (TemplateID *)arg_template;
|
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
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
/* ID */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item) {
|
2009-06-27 01:15:31 +00:00
|
|
|
PointerRNA idptr;
|
2009-06-11 17:21:27 +00:00
|
|
|
|
|
|
|
RNA_id_pointer_create(item, &idptr);
|
|
|
|
RNA_property_pointer_set(&template->ptr, template->prop, idptr);
|
|
|
|
RNA_property_update(C, &template->ptr, template->prop);
|
2009-06-27 01:15:31 +00:00
|
|
|
}
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ID Search browse menu, do the search */
|
2010-11-17 09:45:45 +00:00
|
|
|
static void id_search_cb(const bContext *C, void *arg_template, const char *str, uiSearchItems *items)
|
2009-06-11 17:21:27 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
TemplateID *template = (TemplateID *)arg_template;
|
|
|
|
ListBase *lb = template->idlb;
|
|
|
|
ID *id, *id_from = template->ptr.id.data;
|
2009-06-27 01:15:31 +00:00
|
|
|
int iconid;
|
2012-03-30 01:51:25 +00:00
|
|
|
int flag = RNA_property_flag(template->prop);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
|
|
|
/* ID listbase */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (id = lb->first; id; id = id->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!((flag & PROP_ID_SELF_CHECK) && id == id_from)) {
|
2010-07-14 14:11:03 +00:00
|
|
|
|
|
|
|
/* use filter */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (RNA_property_type(template->prop) == PROP_POINTER) {
|
2010-08-03 06:51:36 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
RNA_id_pointer_create(id, &ptr);
|
2012-03-30 01:51:25 +00:00
|
|
|
if (RNA_property_pointer_poll(&template->ptr, template->prop, &ptr) == 0)
|
2010-08-03 08:12:55 +00:00
|
|
|
continue;
|
2010-08-03 06:51:36 +00:00
|
|
|
}
|
|
|
|
|
2010-07-14 14:11:03 +00:00
|
|
|
/* hide dot-datablocks, but only if filter does not force it visible */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (U.uiflag & USER_HIDE_DOT)
|
2012-03-30 01:51:25 +00:00
|
|
|
if ((id->name[2] == '.') && (str[0] != '.'))
|
2010-03-22 09:30:00 +00:00
|
|
|
continue;
|
2010-03-16 17:23:51 +00:00
|
|
|
|
2013-06-03 05:07:16 +00:00
|
|
|
if (*str == '\0' || BLI_strcasestr(id->name + 2, str)) {
|
2013-05-23 18:19:50 +00:00
|
|
|
/* +1 is needed because name_uiprefix_id used 3 letter prefix
|
|
|
|
* followed by ID_NAME-2 characters from id->name
|
|
|
|
*/
|
|
|
|
char name_ui[MAX_ID_NAME + 1];
|
2010-07-31 01:06:08 +00:00
|
|
|
name_uiprefix_id(name_ui, id);
|
|
|
|
|
2015-01-01 23:26:03 +11:00
|
|
|
iconid = ui_id_icon_get(C, id, template->preview);
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (false == UI_search_item_add(items, name_ui, id, iconid))
|
2010-02-22 08:27:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-07-21 01:26:17 +00:00
|
|
|
}
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ID Search browse menu, open */
|
2009-11-11 09:59:51 +00:00
|
|
|
static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
2009-06-11 17:21:27 +00:00
|
|
|
{
|
|
|
|
static char search[256];
|
|
|
|
static TemplateID template;
|
2009-06-29 11:29:52 +00:00
|
|
|
PointerRNA idptr;
|
2012-03-30 01:51:25 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
2009-06-11 17:21:27 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
|
|
|
|
/* clear initial search string, then all items show */
|
2012-03-30 01:51:25 +00:00
|
|
|
search[0] = 0;
|
2009-06-11 17:21:27 +00:00
|
|
|
/* arg_litem is malloced, can be freed by parent button */
|
2012-03-30 01:51:25 +00:00
|
|
|
template = *((TemplateID *)arg_litem);
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2009-06-29 11:29:52 +00:00
|
|
|
/* get active id for showing first item */
|
2012-03-30 01:51:25 +00:00
|
|
|
idptr = RNA_property_pointer_get(&template.ptr, template.prop);
|
2009-06-29 11:29:52 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
|
2014-11-15 14:11:51 +01:00
|
|
|
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU);
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2010-01-03 08:37:18 +00:00
|
|
|
/* preview thumbnails */
|
|
|
|
if (template.prv_rows > 0 && template.prv_cols > 0) {
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
int w = 4 * U.widget_unit * template.prv_cols;
|
|
|
|
int h = 4 * U.widget_unit * template.prv_rows + U.widget_unit;
|
2010-01-03 08:37:18 +00:00
|
|
|
|
|
|
|
/* fake button, it holds space for search items */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL);
|
2010-01-03 08:37:18 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
template.prv_rows, template.prv_cols, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_search_set(but, id_search_cb, &template, id_search_call_cb, idptr.data);
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
/* list view */
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
const int searchbox_width = UI_searchbox_size_x();
|
|
|
|
const int searchbox_height = UI_searchbox_size_y();
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
2010-01-03 08:37:18 +00:00
|
|
|
/* fake button, it holds space for search items */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
|
2012-11-26 13:23:37 +00:00
|
|
|
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_search_set(but, id_search_cb, &template, id_search_call_cb, idptr.data);
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
|
|
|
|
UI_block_direction_set(block, UI_DIR_DOWN);
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2011-02-15 01:24:12 +00:00
|
|
|
/* give search-field focus */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_focus_on_enter_event(win, but);
|
2011-03-18 16:09:29 +00:00
|
|
|
/* this type of search menu requires undo */
|
|
|
|
but->flag |= UI_BUT_UNDO;
|
2009-06-11 17:21:27 +00:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
/************************ ID Template ***************************/
|
2009-10-14 09:08:53 +00:00
|
|
|
/* This is for browsing and editing the ID-blocks used */
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2009-10-01 23:32:57 +00:00
|
|
|
/* for new/open operators */
|
2014-11-09 21:20:40 +01:00
|
|
|
void UI_context_active_but_prop_get_templateID(bContext *C, PointerRNA *ptr, PropertyRNA **prop)
|
2009-10-01 23:32:57 +00:00
|
|
|
{
|
|
|
|
TemplateID *template;
|
2012-03-30 01:51:25 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2009-10-01 23:32:57 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
|
|
|
|
memset(ptr, 0, sizeof(*ptr));
|
2012-03-30 01:51:25 +00:00
|
|
|
*prop = NULL;
|
2009-10-01 23:32:57 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ar)
|
2009-10-01 23:32:57 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (block = ar->uiblocks.first; block; block = block->next) {
|
|
|
|
for (but = block->buttons.first; but; but = but->next) {
|
2009-10-01 23:32:57 +00:00
|
|
|
/* find the button before the active one */
|
2012-03-30 01:51:25 +00:00
|
|
|
if ((but->flag & (UI_BUT_LAST_ACTIVE | UI_ACTIVE))) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->func_argN) {
|
2012-03-30 01:51:25 +00:00
|
|
|
template = but->func_argN;
|
|
|
|
*ptr = template->ptr;
|
|
|
|
*prop = template->prop;
|
2009-10-01 23:32:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
TemplateID *template = (TemplateID *)arg_litem;
|
|
|
|
PointerRNA idptr = RNA_property_pointer_get(&template->ptr, template->prop);
|
|
|
|
ID *id = idptr.data;
|
|
|
|
int event = GET_INT_FROM_POINTER(arg_event);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (event) {
|
2009-06-27 01:15:31 +00:00
|
|
|
case UI_ID_BROWSE:
|
|
|
|
case UI_ID_PIN:
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("warning, id event %d shouldnt come here", event);
|
2009-06-30 19:20:45 +00:00
|
|
|
break;
|
2009-06-27 01:15:31 +00:00
|
|
|
case UI_ID_OPEN:
|
|
|
|
case UI_ID_ADD_NEW:
|
2014-11-09 21:20:40 +01:00
|
|
|
/* these call UI_context_active_but_prop_get_templateID */
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
|
|
|
case UI_ID_DELETE:
|
|
|
|
memset(&idptr, 0, sizeof(idptr));
|
|
|
|
RNA_property_pointer_set(&template->ptr, template->prop, idptr);
|
|
|
|
RNA_property_update(C, &template->ptr, template->prop);
|
2010-02-23 15:34:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id && CTX_wm_window(C)->eventstate->shift) /* useful hidden functionality, */
|
2012-03-30 01:51:25 +00:00
|
|
|
id->us = 0;
|
2010-02-23 15:34:02 +00:00
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
|
|
|
case UI_ID_FAKE_USER:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
|
|
|
if (id->flag & LIB_FAKEUSER) id_us_plus(id);
|
2010-12-17 14:20:20 +00:00
|
|
|
else id_us_min(id);
|
2009-06-27 01:15:31 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
|
|
|
case UI_ID_LOCAL:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
2013-03-10 05:46:24 +00:00
|
|
|
if (id_make_local(id, false)) {
|
2009-09-04 21:02:43 +00:00
|
|
|
/* reassign to get get proper updates/notifiers */
|
2012-03-30 01:51:25 +00:00
|
|
|
idptr = RNA_property_pointer_get(&template->ptr, template->prop);
|
2009-09-04 21:02:43 +00:00
|
|
|
RNA_property_pointer_set(&template->ptr, template->prop, idptr);
|
|
|
|
RNA_property_update(C, &template->ptr, template->prop);
|
|
|
|
}
|
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
2009-09-04 21:02:43 +00:00
|
|
|
case UI_ID_ALONE:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool do_scene_obj = (GS(id->name) == ID_OB) &&
|
|
|
|
(template->ptr.type == &RNA_SceneObjects);
|
2011-08-08 08:22:01 +00:00
|
|
|
|
2009-09-04 21:02:43 +00:00
|
|
|
/* make copy */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_scene_obj) {
|
2013-04-24 23:09:25 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-03-30 01:51:25 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2013-04-24 23:09:25 +00:00
|
|
|
ED_object_single_user(bmain, scene, (struct Object *)id);
|
2012-03-30 01:51:25 +00:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
2014-05-04 08:34:47 +10:00
|
|
|
DAG_relations_tag_update(bmain);
|
2011-08-08 08:22:01 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
2011-08-11 05:04:01 +00:00
|
|
|
id_single_user(C, id, &template->ptr, template->prop);
|
2011-08-08 08:22:01 +00:00
|
|
|
}
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#if 0
|
2009-06-27 01:15:31 +00:00
|
|
|
case UI_ID_AUTO_NAME:
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2010-12-24 10:15:57 +00:00
|
|
|
static const char *template_id_browse_tip(StructRNA *type)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type) {
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (RNA_type_to_ID_code(type)) {
|
2011-09-19 15:10:38 +00:00
|
|
|
case ID_SCE: return N_("Browse Scene to be linked");
|
2012-11-23 15:33:44 +00:00
|
|
|
case ID_OB: return N_("Browse Object to be linked");
|
|
|
|
case ID_ME: return N_("Browse Mesh Data to be linked");
|
|
|
|
case ID_CU: return N_("Browse Curve Data to be linked");
|
|
|
|
case ID_MB: return N_("Browse Metaball Data to be linked");
|
|
|
|
case ID_MA: return N_("Browse Material to be linked");
|
|
|
|
case ID_TE: return N_("Browse Texture to be linked");
|
|
|
|
case ID_IM: return N_("Browse Image to be linked");
|
2012-11-26 02:32:34 +00:00
|
|
|
case ID_LS: return N_("Browse Line Style Data to be linked");
|
2012-11-23 15:33:44 +00:00
|
|
|
case ID_LT: return N_("Browse Lattice Data to be linked");
|
|
|
|
case ID_LA: return N_("Browse Lamp Data to be linked");
|
|
|
|
case ID_CA: return N_("Browse Camera Data to be linked");
|
|
|
|
case ID_WO: return N_("Browse World Settings to be linked");
|
2014-06-22 23:47:05 +10:00
|
|
|
case ID_SCR: return N_("Choose Screen layout");
|
2011-09-19 15:10:38 +00:00
|
|
|
case ID_TXT: return N_("Browse Text to be linked");
|
|
|
|
case ID_SPK: return N_("Browse Speaker Data to be linked");
|
2012-11-23 15:33:44 +00:00
|
|
|
case ID_SO: return N_("Browse Sound to be linked");
|
|
|
|
case ID_AR: return N_("Browse Armature data to be linked");
|
|
|
|
case ID_AC: return N_("Browse Action to be linked");
|
|
|
|
case ID_NT: return N_("Browse Node Tree to be linked");
|
|
|
|
case ID_BR: return N_("Browse Brush to be linked");
|
2014-01-03 02:14:32 +01:00
|
|
|
case ID_PA: return N_("Browse Particle Settings to be linked");
|
2012-11-23 15:33:44 +00:00
|
|
|
case ID_GD: return N_("Browse Grease Pencil Data to be linked");
|
2014-12-15 11:46:25 +01:00
|
|
|
case ID_MC: return N_("Browse Movie Clip to be linked");
|
|
|
|
case ID_MSK: return N_("Browse Mask to be linked");
|
2014-07-21 12:02:05 +02:00
|
|
|
case ID_PAL: return N_("Browse Palette Data to be linked");
|
|
|
|
case ID_PC: return N_("Browse Paint Curve Data to be linked");
|
2010-12-24 10:15:57 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-19 15:10:38 +00:00
|
|
|
return N_("Browse ID data to be linked");
|
2010-12-24 10:15:57 +00:00
|
|
|
}
|
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
/* Return a type-based i18n context, needed e.g. by "New" button.
|
|
|
|
* In most languages, this adjective takes different form based on gender of type name...
|
|
|
|
*/
|
2012-12-18 18:25:48 +00:00
|
|
|
#ifdef WITH_INTERNATIONAL
|
2012-11-23 15:33:44 +00:00
|
|
|
static const char *template_id_context(StructRNA *type)
|
|
|
|
{
|
|
|
|
if (type) {
|
|
|
|
switch (RNA_type_to_ID_code(type)) {
|
|
|
|
case ID_SCE: return BLF_I18NCONTEXT_ID_SCENE;
|
|
|
|
case ID_OB: return BLF_I18NCONTEXT_ID_OBJECT;
|
|
|
|
case ID_ME: return BLF_I18NCONTEXT_ID_MESH;
|
|
|
|
case ID_CU: return BLF_I18NCONTEXT_ID_CURVE;
|
|
|
|
case ID_MB: return BLF_I18NCONTEXT_ID_METABALL;
|
|
|
|
case ID_MA: return BLF_I18NCONTEXT_ID_MATERIAL;
|
|
|
|
case ID_TE: return BLF_I18NCONTEXT_ID_TEXTURE;
|
|
|
|
case ID_IM: return BLF_I18NCONTEXT_ID_IMAGE;
|
2012-11-26 02:32:34 +00:00
|
|
|
case ID_LS: return BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE;
|
2012-11-23 15:33:44 +00:00
|
|
|
case ID_LT: return BLF_I18NCONTEXT_ID_LATTICE;
|
|
|
|
case ID_LA: return BLF_I18NCONTEXT_ID_LAMP;
|
|
|
|
case ID_CA: return BLF_I18NCONTEXT_ID_CAMERA;
|
|
|
|
case ID_WO: return BLF_I18NCONTEXT_ID_WORLD;
|
|
|
|
case ID_SCR: return BLF_I18NCONTEXT_ID_SCREEN;
|
|
|
|
case ID_TXT: return BLF_I18NCONTEXT_ID_TEXT;
|
|
|
|
case ID_SPK: return BLF_I18NCONTEXT_ID_SPEAKER;
|
|
|
|
case ID_SO: return BLF_I18NCONTEXT_ID_SOUND;
|
|
|
|
case ID_AR: return BLF_I18NCONTEXT_ID_ARMATURE;
|
|
|
|
case ID_AC: return BLF_I18NCONTEXT_ID_ACTION;
|
|
|
|
case ID_NT: return BLF_I18NCONTEXT_ID_NODETREE;
|
|
|
|
case ID_BR: return BLF_I18NCONTEXT_ID_BRUSH;
|
|
|
|
case ID_PA: return BLF_I18NCONTEXT_ID_PARTICLESETTINGS;
|
|
|
|
case ID_GD: return BLF_I18NCONTEXT_ID_GPENCIL;
|
2014-12-15 11:46:25 +01:00
|
|
|
case ID_MC: return BLF_I18NCONTEXT_ID_MOVIECLIP;
|
|
|
|
case ID_MSK: return BLF_I18NCONTEXT_ID_MASK;
|
|
|
|
case ID_PAL: return BLF_I18NCONTEXT_ID_PALETTE;
|
|
|
|
case ID_PC: return BLF_I18NCONTEXT_ID_PAINTCURVE;
|
2012-11-23 15:33:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return BLF_I18NCONTEXT_DEFAULT;
|
|
|
|
}
|
2012-12-18 18:25:48 +00:00
|
|
|
#endif
|
2012-11-23 15:33:44 +00:00
|
|
|
|
|
|
|
static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, short idcode, int flag,
|
|
|
|
const char *newop, const char *openop, const char *unlinkop)
|
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
|
|
|
{
|
|
|
|
uiBut *but;
|
2010-01-03 08:37:18 +00:00
|
|
|
uiBlock *block;
|
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
|
|
|
PointerRNA idptr;
|
2011-03-28 02:34:55 +00:00
|
|
|
// ListBase *lb; // UNUSED
|
2009-09-04 21:02:43 +00:00
|
|
|
ID *id, *idfrom;
|
2014-01-04 17:16:19 +11:00
|
|
|
const bool editable = RNA_property_editable(&template->ptr, template->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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
idptr = RNA_property_pointer_get(&template->ptr, template->prop);
|
|
|
|
id = idptr.data;
|
|
|
|
idfrom = template->ptr.id.data;
|
2012-05-27 19:40:36 +00:00
|
|
|
// lb = template->idlb;
|
2009-06-07 13:20:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idptr.type)
|
2012-03-30 01:51:25 +00:00
|
|
|
type = idptr.type;
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & UI_ID_PREVIEWS) {
|
2013-04-04 02:05:11 +00:00
|
|
|
template->preview = true;
|
2010-01-03 08:37:18 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6,
|
|
|
|
TIP_(template_id_browse_tip(type)));
|
2014-05-29 12:33:13 +10:00
|
|
|
but->icon = id ? ui_id_icon_get(C, id, true) : RNA_struct_ui_icon(type);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
|
2014-05-29 12:33:13 +10:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((idfrom && idfrom->lib) || !editable)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2010-01-03 08:37:18 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutRow(layout, true);
|
2011-06-01 16:13:48 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (flag & UI_ID_BROWSE) {
|
2012-03-30 01:51:25 +00:00
|
|
|
but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 1.6, UI_UNIT_Y,
|
|
|
|
TIP_(template_id_browse_tip(type)));
|
2014-05-29 12:33:13 +10:00
|
|
|
but->icon = RNA_struct_ui_icon(type);
|
|
|
|
/* default dragging of icon for id browse buttons */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_drag_set_id(but, id);
|
|
|
|
UI_but_flag_enable(but, UI_HAS_ICON);
|
|
|
|
UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT);
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((idfrom && idfrom->lib) || !editable)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2009-07-09 19:45:27 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
/* text button with name */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
2010-01-29 00:47:38 +00:00
|
|
|
char name[UI_MAX_NAME_STR];
|
2014-05-07 04:35:55 +10:00
|
|
|
const bool user_alert = (id->us <= 0);
|
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
|
|
|
|
2009-09-04 21:02:43 +00:00
|
|
|
//text_idbutton(id, name);
|
2012-03-30 01:51:25 +00:00
|
|
|
name[0] = '\0';
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR(block, UI_BTYPE_TEXT, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
&idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
|
|
|
|
if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT);
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id->lib) {
|
|
|
|
if (id->flag & LIB_INDIRECT) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0, 0, 0, 0, TIP_("Indirect library datablock, cannot change"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local"));
|
2013-03-10 05:46:24 +00:00
|
|
|
if (!id_make_local(id, true /* test */) || (idfrom && idfrom->lib))
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_LOCAL));
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id->us > 1) {
|
2012-01-11 09:33:44 +00:00
|
|
|
char numstr[32];
|
2014-11-24 17:24:07 +01:00
|
|
|
short numstr_len;
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2014-11-24 17:24:07 +01:00
|
|
|
numstr_len = BLI_snprintf(numstr, sizeof(numstr), "%d", id->us);
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2014-11-24 17:24:07 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_BUT, 0, numstr, 0, 0,
|
|
|
|
numstr_len * 0.2f * UI_UNIT_X + UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0,
|
2012-03-30 01:51:25 +00:00
|
|
|
TIP_("Display number of users of this data (click to make a single-user copy)"));
|
2014-11-04 18:52:38 +05:00
|
|
|
but->flag |= UI_BUT_UNDO;
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
|
2012-09-23 18:50:56 +00:00
|
|
|
if (/* test only */
|
2013-03-10 05:46:24 +00:00
|
|
|
(id_copy(id, NULL, true) == false) ||
|
2012-09-23 18:50:56 +00:00
|
|
|
(idfrom && idfrom->lib) ||
|
2014-01-04 17:16:19 +11:00
|
|
|
(!editable) ||
|
2012-09-23 18:50:56 +00:00
|
|
|
/* object in editmode - don't change data */
|
|
|
|
(idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT)))
|
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2012-09-23 18:50:56 +00:00
|
|
|
}
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
2010-11-12 11:49:33 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT);
|
2010-07-26 02:31:45 +00:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButR(block, UI_BTYPE_TOGGLE, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL);
|
2010-07-26 02:31:45 +00:00
|
|
|
}
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & UI_ID_ADD_NEW) {
|
2012-03-30 01:51:25 +00:00
|
|
|
int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
/* i18n markup, does nothing! */
|
|
|
|
BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_DEFAULT,
|
|
|
|
BLF_I18NCONTEXT_ID_SCENE,
|
|
|
|
BLF_I18NCONTEXT_ID_OBJECT,
|
|
|
|
BLF_I18NCONTEXT_ID_MESH,
|
|
|
|
BLF_I18NCONTEXT_ID_CURVE,
|
|
|
|
BLF_I18NCONTEXT_ID_METABALL,
|
|
|
|
BLF_I18NCONTEXT_ID_MATERIAL,
|
|
|
|
BLF_I18NCONTEXT_ID_TEXTURE,
|
|
|
|
BLF_I18NCONTEXT_ID_IMAGE,
|
|
|
|
BLF_I18NCONTEXT_ID_LATTICE,
|
|
|
|
BLF_I18NCONTEXT_ID_LAMP,
|
|
|
|
BLF_I18NCONTEXT_ID_CAMERA,
|
|
|
|
BLF_I18NCONTEXT_ID_WORLD,
|
|
|
|
BLF_I18NCONTEXT_ID_SCREEN,
|
2013-02-15 14:30:36 +00:00
|
|
|
BLF_I18NCONTEXT_ID_TEXT,
|
|
|
|
);
|
2012-11-23 15:33:44 +00:00
|
|
|
BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_ID_SPEAKER,
|
|
|
|
BLF_I18NCONTEXT_ID_SOUND,
|
|
|
|
BLF_I18NCONTEXT_ID_ARMATURE,
|
|
|
|
BLF_I18NCONTEXT_ID_ACTION,
|
|
|
|
BLF_I18NCONTEXT_ID_NODETREE,
|
|
|
|
BLF_I18NCONTEXT_ID_BRUSH,
|
|
|
|
BLF_I18NCONTEXT_ID_PARTICLESETTINGS,
|
2012-11-26 02:41:46 +00:00
|
|
|
BLF_I18NCONTEXT_ID_GPENCIL,
|
2013-03-23 03:00:37 +00:00
|
|
|
BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE,
|
2012-12-20 07:57:26 +00:00
|
|
|
);
|
2012-11-23 15:33:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (newop) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButO(block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
|
2012-12-18 18:25:48 +00:00
|
|
|
(id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
|
2012-11-23 15:33:44 +00:00
|
|
|
0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((idfrom && idfrom->lib) || !editable)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 14:28:45 +00:00
|
|
|
/* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
|
2013-04-08 04:39:09 +00:00
|
|
|
* Only for images, sound and fonts */
|
2013-01-27 14:28:45 +00:00
|
|
|
if (id && BKE_pack_check(id)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0,
|
2013-02-19 15:45:56 +00:00
|
|
|
UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_operator_ptr_get(but);
|
2013-01-27 14:28:45 +00:00
|
|
|
|
2013-01-28 01:59:59 +00:00
|
|
|
RNA_string_set(but->opptr, "id_name", id->name + 2);
|
2013-01-27 14:28:45 +00:00
|
|
|
RNA_int_set(but->opptr, "id_type", GS(id->name));
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (flag & UI_ID_OPEN) {
|
2012-03-30 01:51:25 +00:00
|
|
|
int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (openop) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButO(block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"),
|
2012-11-23 15:33:44 +00:00
|
|
|
0, 0, w, UI_UNIT_Y, NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0, 0, 0, 0, NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
|
2009-09-04 21:02:43 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((idfrom && idfrom->lib) || !editable)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* delete button */
|
2013-05-04 22:29:33 +00:00
|
|
|
/* don't use RNA_property_is_unlink here */
|
2014-08-21 17:00:35 +10:00
|
|
|
if (id && (flag & UI_ID_DELETE)) {
|
|
|
|
/* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */
|
|
|
|
but = NULL;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (unlinkop) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButO(block, UI_BTYPE_BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
|
2010-12-06 04:05:34 +00:00
|
|
|
/* so we can access the template from operators, font unlinking needs this */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, NULL, MEM_dupallocN(template), NULL);
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-08-21 17:00:35 +10:00
|
|
|
if ((RNA_property_flag(template->prop) & PROP_NEVER_UNLINK) == 0) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0,
|
2014-08-21 17:00:35 +10:00
|
|
|
TIP_("Unlink datablock "
|
|
|
|
"(Shift + Click to set users to zero, data will then not be saved)"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE));
|
2010-02-21 22:55:35 +00:00
|
|
|
|
2014-08-21 17:00:35 +10:00
|
|
|
if (RNA_property_flag(template->prop) & PROP_NEVER_NULL) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2014-08-21 17:00:35 +10:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2009-09-04 21:02:43 +00:00
|
|
|
|
2014-08-21 17:00:35 +10:00
|
|
|
if (but) {
|
|
|
|
if ((idfrom && idfrom->lib) || !editable) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2014-08-21 17:00:35 +10:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (idcode == ID_TE)
|
2011-11-08 13:07:16 +00:00
|
|
|
uiTemplateTextureShow(layout, C, &template->ptr, template->prop);
|
2009-06-11 17:21:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
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
|
|
|
}
|
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
|
|
|
const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols)
|
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
|
|
|
{
|
2009-06-07 13:20:41 +00:00
|
|
|
TemplateID *template;
|
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
|
|
|
PropertyRNA *prop;
|
2009-06-07 13:20:41 +00:00
|
|
|
StructRNA *type;
|
2011-11-08 13:07:16 +00:00
|
|
|
short idcode;
|
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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop || RNA_property_type(prop) != PROP_POINTER) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
template = MEM_callocN(sizeof(TemplateID), "TemplateID");
|
|
|
|
template->ptr = *ptr;
|
|
|
|
template->prop = prop;
|
2010-01-03 08:37:18 +00:00
|
|
|
template->prv_rows = prv_rows;
|
|
|
|
template->prv_cols = prv_cols;
|
2010-07-14 14:11:03 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (newop)
|
2009-06-27 01:15:31 +00:00
|
|
|
flag |= UI_ID_ADD_NEW;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (openop)
|
2009-09-04 21:02:43 +00:00
|
|
|
flag |= UI_ID_OPEN;
|
2010-12-24 10:15:57 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_pointer_type(ptr, prop);
|
|
|
|
idcode = RNA_type_to_ID_code(type);
|
|
|
|
template->idlb = which_libbase(CTX_data_main(C), idcode);
|
2009-10-14 09:08:53 +00:00
|
|
|
|
|
|
|
/* create UI elements for this template
|
|
|
|
* - template_ID makes a copy of the template data and assigns it to the relevant buttons
|
|
|
|
*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if (template->idlb) {
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutRow(layout, true);
|
2011-11-08 13:07:16 +00:00
|
|
|
template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop);
|
2009-06-07 13:20:41 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
MEM_freeN(template);
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
|
|
|
const char *openop, const char *unlinkop)
|
2010-01-03 08:37:18 +00:00
|
|
|
{
|
2012-11-23 15:33:44 +00:00
|
|
|
ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
|
|
|
|
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0);
|
2010-01-13 06:35:12 +00:00
|
|
|
}
|
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
|
|
|
const char *openop, const char *unlinkop)
|
2010-01-13 06:35:12 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, 0, 0);
|
2010-01-03 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
|
|
|
|
const char *openop, const char *unlinkop, int rows, int cols)
|
2010-01-03 08:37:18 +00:00
|
|
|
{
|
2012-11-23 15:33:44 +00:00
|
|
|
ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
|
|
|
|
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols);
|
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
|
|
|
}
|
|
|
|
|
2009-10-14 09:08:53 +00:00
|
|
|
/************************ ID Chooser Template ***************************/
|
|
|
|
|
2009-10-15 10:13:59 +00:00
|
|
|
/* This is for selecting the type of ID-block to use, and then from the relevant type choosing the block to use
|
|
|
|
*
|
|
|
|
* - propname: property identifier for property that ID-pointer gets stored to
|
2009-10-14 09:08:53 +00:00
|
|
|
* - proptypename: property identifier for property used to determine the type of ID-pointer that can be used
|
|
|
|
*/
|
2012-11-23 15:33:44 +00:00
|
|
|
void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename,
|
|
|
|
const char *text)
|
2009-10-14 09:08:53 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *propID, *propType;
|
2013-03-16 03:59:03 +00:00
|
|
|
uiLayout *split, *row, *sub;
|
2009-10-14 09:08:53 +00:00
|
|
|
|
|
|
|
/* get properties... */
|
2012-03-30 01:51:25 +00:00
|
|
|
propID = RNA_struct_find_property(ptr, propname);
|
|
|
|
propType = RNA_struct_find_property(ptr, proptypename);
|
2009-10-14 09:08:53 +00:00
|
|
|
|
|
|
|
if (!propID || RNA_property_type(propID) != PROP_POINTER) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-10-14 09:08:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
if (!propType || RNA_property_type(propType) != PROP_ENUM) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename);
|
2009-10-14 09:08:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start drawing UI Elements using standard defines */
|
2014-01-04 17:16:19 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.33f, false); /* NOTE: split amount here needs to be synced with normal labels */
|
2013-03-16 03:59:03 +00:00
|
|
|
|
|
|
|
/* FIRST PART ................................................ */
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, false);
|
2009-10-14 09:08:53 +00:00
|
|
|
|
|
|
|
/* Label - either use the provided text, or will become "ID-Block:" */
|
2012-06-04 16:42:58 +00:00
|
|
|
if (text) {
|
|
|
|
if (text[0])
|
|
|
|
uiItemL(row, text, ICON_NONE);
|
|
|
|
}
|
2013-03-16 03:59:03 +00:00
|
|
|
else {
|
2013-02-19 15:45:56 +00:00
|
|
|
uiItemL(row, IFACE_("ID-Block:"), ICON_NONE);
|
2013-03-16 03:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SECOND PART ................................................ */
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, true);
|
2009-10-14 09:08:53 +00:00
|
|
|
|
|
|
|
/* ID-Type Selector - just have a menu of icons */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(row, true); /* HACK: special group just for the enum, otherwise we */
|
2013-03-16 03:59:03 +00:00
|
|
|
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */
|
|
|
|
|
|
|
|
uiItemFullR(sub, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
2009-10-14 09:08:53 +00:00
|
|
|
|
|
|
|
/* ID-Block Selector - just use pointer widget... */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(row, true); /* HACK: special group to counteract the effects of the previous */
|
2013-03-16 03:59:03 +00:00
|
|
|
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */
|
|
|
|
|
|
|
|
uiItemFullR(sub, ptr, propID, 0, 0, 0, "", ICON_NONE);
|
2009-10-14 09:08:53 +00:00
|
|
|
}
|
|
|
|
|
2009-10-15 10:13:59 +00:00
|
|
|
/********************* RNA Path Builder Template ********************/
|
|
|
|
|
2009-11-11 09:59:51 +00:00
|
|
|
/* ---------- */
|
|
|
|
|
2009-10-15 10:13:59 +00:00
|
|
|
/* This is creating/editing RNA-Paths
|
|
|
|
*
|
|
|
|
* - ptr: struct which holds the path property
|
|
|
|
* - propname: property identifier for property that path gets stored to
|
|
|
|
* - root_ptr: struct that path gets built from
|
|
|
|
*/
|
2012-11-23 15:33:44 +00:00
|
|
|
void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *UNUSED(root_ptr),
|
|
|
|
const char *text)
|
2009-10-15 10:13:59 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *propPath;
|
|
|
|
uiLayout *row;
|
|
|
|
|
|
|
|
/* check that properties are valid */
|
2012-03-30 01:51:25 +00:00
|
|
|
propPath = RNA_struct_find_property(ptr, propname);
|
2009-10-15 10:13:59 +00:00
|
|
|
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-10-15 10:13:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start drawing UI Elements using standard defines */
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, true);
|
2009-10-15 10:13:59 +00:00
|
|
|
|
|
|
|
/* Path (existing string) Widget */
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemR(row, ptr, propname, 0, text, ICON_RNA);
|
2009-10-15 10:13:59 +00:00
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: attach something to this to make allow searching of nested properties to 'build' the path */
|
2009-10-15 10:13:59 +00:00
|
|
|
}
|
|
|
|
|
2009-05-21 15:34:09 +00:00
|
|
|
/************************ Modifier Template *************************/
|
|
|
|
|
2013-02-19 15:45:56 +00:00
|
|
|
#define ERROR_LIBDATA_MESSAGE IFACE_("Can't edit external libdata")
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
|
|
|
|
{
|
|
|
|
Object *ob = ob_v;
|
|
|
|
ModifierData *md = md_v;
|
|
|
|
ModifierData *nmd = modifier_new(md->type);
|
|
|
|
|
|
|
|
modifier_copyData(md, nmd);
|
|
|
|
nmd->mode &= ~eModifierMode_Virtual;
|
|
|
|
|
|
|
|
BLI_addhead(&ob->modifiers, nmd);
|
2009-10-09 09:48:04 +00:00
|
|
|
|
|
|
|
modifier_unique_name(&ob->modifiers, nmd);
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
ob->partype = PAROBJECT;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2009-06-03 00:09:30 +00:00
|
|
|
ED_undo_push(C, "Modifier convert to real");
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 00:09:30 +00:00
|
|
|
static int modifier_can_delete(ModifierData *md)
|
2009-05-21 15:34:09 +00:00
|
|
|
{
|
2011-12-22 00:03:20 +00:00
|
|
|
/* fluid particle modifier can't be deleted here */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (md->type == eModifierType_ParticleSystem)
|
|
|
|
if (((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
|
2009-06-03 00:09:30 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 06:53:26 +00:00
|
|
|
/* Check whether Modifier is a simulation or not, this is used for switching to the physics/particles context tab */
|
2011-04-25 13:47:15 +00:00
|
|
|
static int modifier_is_simulation(ModifierData *md)
|
|
|
|
{
|
2011-12-22 00:03:20 +00:00
|
|
|
/* Physic Tab */
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke,
|
2012-03-30 01:51:25 +00:00
|
|
|
eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint))
|
2011-12-22 00:03:20 +00:00
|
|
|
{
|
2011-04-25 13:47:15 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2011-12-22 00:03:20 +00:00
|
|
|
/* Particle Tab */
|
2011-04-25 13:47:15 +00:00
|
|
|
else if (md->type == eModifierType_ParticleSystem) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 00:03:20 +00:00
|
|
|
static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
|
|
|
|
ModifierData *md, int index, int cageIndex, int lastCageIndex)
|
2009-05-21 15:34:09 +00:00
|
|
|
{
|
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
2009-06-03 00:09:30 +00:00
|
|
|
PointerRNA ptr;
|
2009-05-21 15:34:09 +00:00
|
|
|
uiBut *but;
|
|
|
|
uiBlock *block;
|
2014-08-17 09:35:57 +02:00
|
|
|
uiLayout *box, *column, *row, *sub;
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayout *result = NULL;
|
2009-12-29 10:25:14 +00:00
|
|
|
int isVirtual = (md->mode & eModifierMode_Virtual);
|
2009-05-21 15:34:09 +00:00
|
|
|
char str[128];
|
|
|
|
|
2009-07-02 19:41:31 +00:00
|
|
|
/* create RNA pointer */
|
2009-06-03 00:09:30 +00:00
|
|
|
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
column = uiLayoutColumn(layout, true);
|
2009-06-03 00:09:30 +00:00
|
|
|
uiLayoutSetContextPointer(column, "modifier", &ptr);
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2009-12-29 10:25:14 +00:00
|
|
|
/* rounded header ------------------------------------------------------------------- */
|
2012-03-30 01:51:25 +00:00
|
|
|
box = uiLayoutBox(column);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
|
|
|
if (isVirtual) {
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2010-01-20 05:41:59 +00:00
|
|
|
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(row);
|
2009-12-29 10:25:14 +00:00
|
|
|
/* VIRTUAL MODIFIER */
|
2012-07-06 23:56:59 +00:00
|
|
|
/* XXX this is not used now, since these cannot be accessed via RNA */
|
2013-02-19 15:45:56 +00:00
|
|
|
BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name"));
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0,
|
2012-03-30 01:51:25 +00:00
|
|
|
TIP_("Convert virtual modifier to a real modifier"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, modifiers_convertToReal, ob, md);
|
2009-07-02 19:41:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-12-29 10:25:14 +00:00
|
|
|
/* REAL MODIFIER */
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2010-01-20 05:41:59 +00:00
|
|
|
block = uiLayoutGetBlock(row);
|
2009-07-31 10:21:29 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2010-01-20 05:41:59 +00:00
|
|
|
/* Open/Close ................................. */
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
|
|
|
/* modifier-type icon */
|
|
|
|
uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2010-01-20 05:41:59 +00:00
|
|
|
/* modifier name */
|
2014-11-09 14:52:52 +01:00
|
|
|
md->scene = scene;
|
2014-08-20 20:25:58 +02:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md, 0)) {
|
|
|
|
uiLayoutSetRedAlert(row, true);
|
|
|
|
}
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
|
2014-08-20 20:25:58 +02:00
|
|
|
uiLayoutSetRedAlert(row, false);
|
2010-01-20 05:41:59 +00:00
|
|
|
|
|
|
|
/* mode enabling buttons */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2010-01-20 05:41:59 +00:00
|
|
|
/* Softbody not allowed in this situation, enforce! */
|
2012-04-21 15:11:03 +00:00
|
|
|
if (((md->type != eModifierType_Softbody && md->type != eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) &&
|
2012-11-23 15:33:44 +00:00
|
|
|
(md->type != eModifierType_Surface) )
|
2010-01-20 05:41:59 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
|
|
|
|
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2014-08-17 09:35:57 +02:00
|
|
|
if (mti->flags & eModifierTypeFlag_SupportsEditmode) {
|
|
|
|
sub = uiLayoutRow(row, true);
|
|
|
|
if (!(md->mode & eModifierMode_Realtime)) {
|
|
|
|
uiLayoutSetActive(sub, false);
|
|
|
|
}
|
|
|
|
uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE);
|
|
|
|
}
|
2010-01-20 05:41:59 +00:00
|
|
|
}
|
2011-01-14 16:57:53 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2014-08-17 09:35:57 +02:00
|
|
|
if (modifier_supportsCage(scene, md) && (index <= lastCageIndex)) {
|
|
|
|
sub = uiLayoutRow(row, true);
|
|
|
|
if (index < cageIndex || !modifier_couldBeCage(scene, md)) {
|
|
|
|
uiLayoutSetActive(sub, false);
|
|
|
|
}
|
|
|
|
uiItemR(sub, &ptr, "show_on_cage", 0, "", ICON_NONE);
|
2011-10-20 08:12:39 +00:00
|
|
|
}
|
2012-03-02 16:05:54 +00:00
|
|
|
} /* tessellation point for curve-typed objects */
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
2012-03-18 07:38:51 +00:00
|
|
|
/* some modifiers could work with pre-tessellated curves only */
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) {
|
2012-03-18 07:38:51 +00:00
|
|
|
/* add disabled pre-tessellated button, so users could have
|
2012-03-03 16:31:46 +00:00
|
|
|
* message for this modifiers */
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButBitI(block, UI_BTYPE_TOGGLE, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0,
|
2012-11-23 15:33:44 +00:00
|
|
|
UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0,
|
2014-08-17 09:35:57 +02:00
|
|
|
TIP_("This modifier can only be applied on splines' points"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else if (mti->type != eModifierTypeType_Constructive) {
|
2012-03-03 11:45:08 +00:00
|
|
|
/* constructive modifiers tessellates curve before applying */
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &ptr, "use_apply_on_spline", 0, "", ICON_NONE);
|
2011-01-14 16:57:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2010-01-20 05:41:59 +00:00
|
|
|
|
2009-12-29 10:25:14 +00:00
|
|
|
/* Up/Down + Delete ........................... */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2010-01-20 05:41:59 +00:00
|
|
|
uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_modifier_move_up");
|
|
|
|
uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_modifier_move_down");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2012-07-06 23:56:59 +00:00
|
|
|
/* When Modifier is a simulation, show button to switch to context rather than the delete button. */
|
2014-10-28 12:49:04 +01:00
|
|
|
if (modifier_can_delete(md) &&
|
|
|
|
(!modifier_is_simulation(md) ||
|
|
|
|
STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME)))
|
|
|
|
{
|
2010-08-16 23:28:20 +00:00
|
|
|
uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove");
|
2014-10-28 12:49:04 +01:00
|
|
|
}
|
|
|
|
else if (modifier_is_simulation(md) == 1) {
|
2011-04-25 13:47:15 +00:00
|
|
|
uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PHYSICS");
|
2014-10-28 12:49:04 +01:00
|
|
|
}
|
|
|
|
else if (modifier_is_simulation(md) == 2) {
|
2011-04-25 13:47:15 +00:00
|
|
|
uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PARTICLES");
|
2014-10-28 12:49:04 +01:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 10:25:14 +00:00
|
|
|
|
|
|
|
/* modifier settings (under the header) --------------------------------------------------- */
|
|
|
|
if (!isVirtual && (md->mode & eModifierMode_Expanded)) {
|
2009-07-02 19:41:31 +00:00
|
|
|
/* apply/convert/copy */
|
2012-03-30 01:51:25 +00:00
|
|
|
box = uiLayoutBox(column);
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
|
|
|
if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) {
|
2009-07-02 19:41:31 +00:00
|
|
|
/* only here obdata, the rest of modifiers is ob level */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (md->type == eModifierType_ParticleSystem) {
|
|
|
|
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2013-11-04 18:40:45 +00:00
|
|
|
if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
|
2013-02-19 15:45:56 +00:00
|
|
|
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
|
|
|
|
"OBJECT_OT_duplicates_make_real");
|
2013-11-04 18:40:45 +00:00
|
|
|
else if (psys->part->ren_as == PART_DRAW_PATH && psys->pathcache)
|
2013-02-19 15:45:56 +00:00
|
|
|
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
|
|
|
|
"OBJECT_OT_modifier_convert");
|
2009-12-29 10:25:14 +00:00
|
|
|
}
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
2009-12-07 18:17:39 +00:00
|
|
|
else {
|
2010-04-22 01:55:10 +00:00
|
|
|
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
|
2013-02-19 15:45:56 +00:00
|
|
|
uiItemEnumO(row, "OBJECT_OT_modifier_apply", CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"),
|
|
|
|
0, "apply_as", MODIFIER_APPLY_DATA);
|
2009-12-07 18:17:39 +00:00
|
|
|
|
2012-11-23 15:33:44 +00:00
|
|
|
if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) {
|
2013-02-19 15:45:56 +00:00
|
|
|
uiItemEnumO(row, "OBJECT_OT_modifier_apply",
|
|
|
|
CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"),
|
|
|
|
0, "apply_as", MODIFIER_APPLY_SHAPE);
|
2012-11-23 15:33:44 +00:00
|
|
|
}
|
2009-12-07 18:17:39 +00:00
|
|
|
}
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_clear(block);
|
|
|
|
UI_block_lock_set(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (!ELEM(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem,
|
2012-11-23 15:33:44 +00:00
|
|
|
eModifierType_Cloth, eModifierType_Smoke))
|
|
|
|
{
|
2013-02-19 15:45:56 +00:00
|
|
|
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"), ICON_NONE,
|
|
|
|
"OBJECT_OT_modifier_copy");
|
2012-11-23 15:33:44 +00:00
|
|
|
}
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
2009-12-29 10:25:14 +00:00
|
|
|
|
|
|
|
/* result is the layout block inside the box, that we return so that modifier settings can be drawn */
|
2014-01-04 17:16:19 +11:00
|
|
|
result = uiLayoutColumn(box, false);
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutAbsoluteBlock(box);
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
2009-12-29 10:25:14 +00:00
|
|
|
|
|
|
|
/* error messages */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (md->error) {
|
2009-12-29 10:25:14 +00:00
|
|
|
box = uiLayoutBox(column);
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2009-05-21 15:34:09 +00:00
|
|
|
uiItemL(row, md->error, ICON_ERROR);
|
|
|
|
}
|
2009-12-29 10:25:14 +00:00
|
|
|
|
2009-05-21 15:34:09 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-08-16 23:28:20 +00:00
|
|
|
uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2009-05-21 15:34:09 +00:00
|
|
|
{
|
2010-01-25 11:39:56 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-05-21 15:34:09 +00:00
|
|
|
Object *ob;
|
|
|
|
ModifierData *md, *vmd;
|
2013-08-19 09:05:34 +00:00
|
|
|
VirtualModifierData virtualModifierData;
|
2009-05-21 15:34:09 +00:00
|
|
|
int i, lastCageIndex, cageIndex;
|
|
|
|
|
|
|
|
/* verify we have valid data */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("Expected modifier on object");
|
2009-05-21 15:34:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ob = ptr->id.data;
|
|
|
|
md = ptr->data;
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ob || !(GS(ob->id.name) == ID_OB)) {
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("Expected modifier on object");
|
2009-05-21 15:34:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
|
2009-05-21 15:34:09 +00:00
|
|
|
|
|
|
|
/* find modifier and draw it */
|
2010-01-25 11:39:56 +00:00
|
|
|
cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0);
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* XXX virtual modifiers are not accesible for python */
|
2013-08-19 09:05:34 +00:00
|
|
|
vmd = modifiers_getVirtualModifierList(ob, &virtualModifierData);
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (i = 0; vmd; i++, vmd = vmd->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (md == vmd)
|
2010-08-16 23:28:20 +00:00
|
|
|
return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (vmd->mode & eModifierMode_Virtual)
|
2009-05-21 15:34:09 +00:00
|
|
|
i--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/************************ Constraint Template *************************/
|
|
|
|
|
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
|
|
|
|
#include "BKE_action.h"
|
|
|
|
#include "BKE_constraint.h"
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define B_CONSTRAINT_TEST 5
|
2012-09-23 18:50:56 +00:00
|
|
|
// #define B_CONSTRAINT_CHANGETARGET 6
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static void do_constraint_panels(bContext *C, void *ob_pt, int event)
|
2009-05-27 00:03:49 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
Object *ob = (Object *)ob_pt;
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case B_CONSTRAINT_TEST:
|
2012-07-06 23:56:59 +00:00
|
|
|
break; /* no handling */
|
2012-09-23 18:50:56 +00:00
|
|
|
#if 0 /* UNUSED */
|
2012-03-30 01:51:25 +00:00
|
|
|
case B_CONSTRAINT_CHANGETARGET:
|
2012-09-23 18:50:56 +00:00
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-07-06 23:56:59 +00:00
|
|
|
if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(bmain);
|
2012-03-30 01:51:25 +00:00
|
|
|
break;
|
2012-09-23 18:50:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
2012-03-30 01:51:25 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* note: RNA updates now call this, commenting else it gets called twice.
|
|
|
|
* if there are problems because of this, then rna needs changed update functions.
|
|
|
|
*
|
|
|
|
* object_test_constraints(ob);
|
|
|
|
* if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); */
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
|
2010-12-05 18:59:23 +00:00
|
|
|
else DAG_id_tag_update(&ob->id, OB_RECALC_OB);
|
2009-09-24 21:22:24 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
|
2009-05-27 00:03:49 +00:00
|
|
|
{
|
|
|
|
ED_object_constraint_set_active(ob_v, con_v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw panel showing settings for a constraint */
|
2010-08-16 23:28:20 +00:00
|
|
|
static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
|
2009-05-27 00:03:49 +00:00
|
|
|
{
|
2012-05-05 16:03:57 +00:00
|
|
|
bPoseChannel *pchan = BKE_pose_channel_active(ob);
|
2009-05-27 00:03:49 +00:00
|
|
|
bConstraintTypeInfo *cti;
|
|
|
|
uiBlock *block;
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayout *result = NULL, *col, *box, *row;
|
2009-06-03 00:09:30 +00:00
|
|
|
PointerRNA ptr;
|
2009-05-27 00:03:49 +00:00
|
|
|
char typestr[32];
|
2012-03-30 01:51:25 +00:00
|
|
|
short proxy_protected, xco = 0, yco = 0;
|
2011-03-28 02:34:55 +00:00
|
|
|
// int rb_col; // UNUSED
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
/* get constraint typeinfo */
|
2014-04-11 11:47:07 +10:00
|
|
|
cti = BKE_constraint_typeinfo_get(con);
|
2009-05-27 00:03:49 +00:00
|
|
|
if (cti == NULL) {
|
|
|
|
/* exception for 'Null' constraint - it doesn't have constraint typeinfo! */
|
2013-02-19 15:45:56 +00:00
|
|
|
BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? IFACE_("Null") : IFACE_("Unknown"), sizeof(typestr));
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
else
|
2013-02-19 15:45:56 +00:00
|
|
|
BLI_strncpy(typestr, IFACE_(cti->name), sizeof(typestr));
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
/* determine whether constraint is proxy protected or not */
|
2014-04-11 11:47:07 +10:00
|
|
|
if (BKE_constraints_proxylocked_owner(ob, pchan))
|
2012-03-30 01:51:25 +00:00
|
|
|
proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0;
|
2009-05-27 00:03:49 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
proxy_protected = 0;
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
/* unless button has own callback, it adds this callback to button */
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, do_constraint_panels, ob);
|
|
|
|
UI_block_func_set(block, constraint_active_func, ob, con);
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2009-06-03 00:09:30 +00:00
|
|
|
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
2009-06-03 00:09:30 +00:00
|
|
|
uiLayoutSetContextPointer(col, "constraint", &ptr);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
box = uiLayoutBox(col);
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(box, false);
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(box);
|
2009-06-03 00:09:30 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* Draw constraint header */
|
2010-07-07 14:10:41 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* open/close */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2013-08-21 02:29:13 +00:00
|
|
|
|
2010-07-07 14:10:41 +00:00
|
|
|
/* name */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, B_CONSTRAINT_TEST, typestr,
|
2013-08-21 02:29:13 +00:00
|
|
|
xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "");
|
2010-07-04 09:42:00 +00:00
|
|
|
|
2010-12-11 17:47:36 +00:00
|
|
|
if (con->flag & CONSTRAINT_DISABLE)
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutSetRedAlert(row, true);
|
2010-12-11 17:47:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (proxy_protected == 0) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &ptr, "name", 0, "", ICON_NONE);
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
2009-07-10 13:56:29 +00:00
|
|
|
else
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(row, con->name, ICON_NONE);
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutSetRedAlert(row, false);
|
2010-12-11 17:47:36 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* proxy-protected constraints cannot be edited, so hide up/down + close buttons */
|
|
|
|
if (proxy_protected) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
/* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
short prev_proxylock, show_upbut, show_downbut;
|
|
|
|
|
|
|
|
/* Up/Down buttons:
|
|
|
|
* Proxy-constraints are not allowed to occur after local (non-proxy) constraints
|
|
|
|
* as that poses problems when restoring them, so disable the "up" button where
|
|
|
|
* it may cause this situation.
|
|
|
|
*
|
2012-07-03 19:09:07 +00:00
|
|
|
* Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose.
|
2009-05-27 00:03:49 +00:00
|
|
|
*/
|
2014-04-11 11:47:07 +10:00
|
|
|
if (BKE_constraints_proxylocked_owner(ob, pchan)) {
|
2009-05-27 00:03:49 +00:00
|
|
|
if (con->prev) {
|
2012-03-30 01:51:25 +00:00
|
|
|
prev_proxylock = (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
prev_proxylock = 0;
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
prev_proxylock = 0;
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
show_upbut = ((prev_proxylock == 0) && (con->prev));
|
|
|
|
show_downbut = (con->next) ? 1 : 0;
|
2010-07-07 14:10:41 +00:00
|
|
|
|
2010-09-06 07:26:21 +00:00
|
|
|
/* enabled */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2012-11-23 15:33:44 +00:00
|
|
|
uiItemR(row, &ptr, "mute", 0, "",
|
|
|
|
(con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2010-09-06 07:26:21 +00:00
|
|
|
|
2010-08-16 23:28:20 +00:00
|
|
|
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
|
2010-07-04 09:42:00 +00:00
|
|
|
|
2010-07-07 14:10:41 +00:00
|
|
|
/* up/down */
|
2009-05-27 00:03:49 +00:00
|
|
|
if (show_upbut || show_downbut) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2010-07-07 14:10:41 +00:00
|
|
|
if (show_upbut)
|
2010-08-16 23:28:20 +00:00
|
|
|
uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up");
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2010-07-07 14:10:41 +00:00
|
|
|
if (show_downbut)
|
2010-08-16 23:28:20 +00:00
|
|
|
uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
2010-07-07 14:10:41 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* Close 'button' - emboss calls here disable drawing of 'button' behind X */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2010-07-07 14:10:41 +00:00
|
|
|
uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
2010-07-07 14:10:41 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* Set but-locks for protected settings (magic numbers are used here!) */
|
|
|
|
if (proxy_protected)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_set(block, true, IFACE_("Cannot edit Proxy-Protected Constraint"));
|
2010-05-09 08:33:18 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* Draw constraint data */
|
|
|
|
if ((con->flag & CONSTRAINT_EXPAND) == 0) {
|
2013-08-08 17:36:19 +00:00
|
|
|
(yco) -= 10.5f * UI_UNIT_Y;
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
box = uiLayoutBox(col);
|
|
|
|
block = uiLayoutAbsoluteBlock(box);
|
|
|
|
result = box;
|
2010-12-11 17:47:36 +00:00
|
|
|
}
|
2010-05-09 08:33:18 +00:00
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
/* clear any locks set up for proxies/lib-linking */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_clear(block);
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-08-16 23:28:20 +00:00
|
|
|
uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
|
2009-05-27 00:03:49 +00:00
|
|
|
{
|
|
|
|
Object *ob;
|
|
|
|
bConstraint *con;
|
|
|
|
|
|
|
|
/* verify we have valid data */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("Expected constraint on object");
|
2009-05-27 00:03:49 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ob = ptr->id.data;
|
|
|
|
con = ptr->data;
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ob || !(GS(ob->id.name) == ID_OB)) {
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("Expected constraint on object");
|
2009-05-27 00:03:49 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
|
2009-05-27 00:03:49 +00:00
|
|
|
|
|
|
|
/* hrms, the temporal constraint should not draw! */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
|
|
|
|
bKinematicConstraint *data = con->data;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (data->flag & CONSTRAINT_IK_TEMP)
|
2009-05-27 00:03:49 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-08-16 23:28:20 +00:00
|
|
|
return draw_constraint(layout, ob, con);
|
2009-05-27 00:03:49 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 23:41:12 +00:00
|
|
|
|
|
|
|
/************************* Preview Template ***************************/
|
|
|
|
|
2009-07-21 12:57:55 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
2009-05-28 23:41:12 +00:00
|
|
|
#include "DNA_material_types.h"
|
2009-07-21 12:57:55 +00:00
|
|
|
#include "DNA_world_types.h"
|
2009-05-28 23:41:12 +00:00
|
|
|
|
|
|
|
#define B_MATPRV 1
|
|
|
|
|
2009-06-07 11:12:35 +00:00
|
|
|
static void do_preview_buttons(bContext *C, void *arg, int event)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (event) {
|
2009-06-07 11:12:35 +00:00
|
|
|
case B_MATPRV:
|
2013-06-24 22:41:33 +00:00
|
|
|
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, arg);
|
2009-06-07 11:12:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
void uiTemplatePreview(uiLayout *layout, bContext *C, ID *id, int show_buttons, ID *parent, MTex *slot,
|
|
|
|
const char *preview_id)
|
2009-05-28 23:41:12 +00:00
|
|
|
{
|
|
|
|
uiLayout *row, *col;
|
|
|
|
uiBlock *block;
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
uiPreview *ui_preview = NULL;
|
|
|
|
ARegion *ar;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
Material *ma = NULL;
|
|
|
|
Tex *tex = (Tex *)id;
|
2009-07-21 01:57:46 +00:00
|
|
|
ID *pid, *pparent;
|
2012-03-30 01:51:25 +00:00
|
|
|
short *pr_texture = NULL;
|
2010-04-04 12:09:59 +00:00
|
|
|
PointerRNA material_ptr;
|
|
|
|
PointerRNA texture_ptr;
|
2009-05-28 23:41:12 +00:00
|
|
|
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
char _preview_id[UI_MAX_NAME_STR];
|
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (id && !ELEM(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA, ID_LS)) {
|
2014-05-03 18:51:53 +09:00
|
|
|
RNA_warning("Expected ID of type material, texture, lamp, world or line style");
|
2009-05-28 23:41:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:57:46 +00:00
|
|
|
/* decide what to render */
|
2012-03-30 01:51:25 +00:00
|
|
|
pid = id;
|
|
|
|
pparent = NULL;
|
2009-05-28 23:41:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id && (GS(id->name) == ID_TE)) {
|
|
|
|
if (parent && (GS(parent->name) == ID_MA))
|
2012-03-30 01:51:25 +00:00
|
|
|
pr_texture = &((Material *)parent)->pr_texture;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (parent && (GS(parent->name) == ID_WO))
|
2012-03-30 01:51:25 +00:00
|
|
|
pr_texture = &((World *)parent)->pr_texture;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (parent && (GS(parent->name) == ID_LA))
|
2012-03-30 01:51:25 +00:00
|
|
|
pr_texture = &((Lamp *)parent)->pr_texture;
|
2014-05-03 18:51:53 +09:00
|
|
|
else if (parent && (GS(parent->name) == ID_LS))
|
|
|
|
pr_texture = &((FreestyleLineStyle *)parent)->pr_texture;
|
2009-07-21 12:57:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pr_texture) {
|
|
|
|
if (*pr_texture == TEX_PR_OTHER)
|
2012-03-30 01:51:25 +00:00
|
|
|
pid = parent;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (*pr_texture == TEX_PR_BOTH)
|
2012-03-30 01:51:25 +00:00
|
|
|
pparent = parent;
|
2009-07-21 12:57:55 +00:00
|
|
|
}
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
|
|
|
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
if (!preview_id || (preview_id[0] == '\0')) {
|
|
|
|
/* If no identifier given, generate one from ID type. */
|
|
|
|
BLI_snprintf(_preview_id, UI_MAX_NAME_STR, "uiPreview_%s", BKE_idcode_to_name(GS(id->name)));
|
|
|
|
preview_id = _preview_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find or add the uiPreview to the current Region. */
|
|
|
|
ar = CTX_wm_region(C);
|
|
|
|
ui_preview = BLI_findstring(&ar->ui_previews, preview_id, offsetof(uiPreview, preview_id));
|
|
|
|
|
|
|
|
if (!ui_preview) {
|
|
|
|
ui_preview = MEM_callocN(sizeof(uiPreview), "uiPreview");
|
|
|
|
BLI_strncpy(ui_preview->preview_id, preview_id, sizeof(ui_preview->preview_id));
|
|
|
|
ui_preview->height = (short)(UI_UNIT_Y * 5.6f);
|
|
|
|
BLI_addtail(&ar->ui_previews, ui_preview);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui_preview->height < UI_UNIT_Y) {
|
|
|
|
ui_preview->height = UI_UNIT_Y;
|
|
|
|
}
|
|
|
|
else if (ui_preview->height > UI_UNIT_Y * 50) { /* Rather high upper limit, yet not insane! */
|
|
|
|
ui_preview->height = UI_UNIT_Y * 50;
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:57:46 +00:00
|
|
|
/* layout */
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
|
|
|
col = uiLayoutColumn(row, false);
|
|
|
|
uiLayoutSetKeepAspect(col, true);
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
|
2009-07-21 01:57:46 +00:00
|
|
|
/* add preview */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_EXTRA, 0, "", 0, 0, UI_UNIT_X * 10, ui_preview->height, pid, 0.0, 0.0, 0, 0, "");
|
|
|
|
UI_but_func_drawextra_set(block, ED_preview_draw, pparent, slot);
|
|
|
|
UI_block_func_handle_set(block, do_preview_buttons, NULL);
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButS(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &ui_preview->height,
|
Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget).
This is done by adding a new button type, GRIP, similar to other numbuttons
(scroll, slider, ...), which here controls the preview height.
Then, we add a new DNA struct to be able to save that height in Blend files
(note I choose not to use Panel struct for this, because we would then have the
same limitation we used to have with uiLists, only one preview per panel
and no preview outside panel).
This implies a change to template_preview UI RNA/py API (each preview needs an ID),
but this is backward compatible, as by default datablock type will be used if no ID is
given (which means e.g. all material previews with no ID will have same height).
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D342
2014-04-02 12:59:48 +02:00
|
|
|
UI_UNIT_Y, UI_UNIT_Y * 50.0f, 0.0f, 0.0f, "");
|
|
|
|
|
2009-07-21 01:57:46 +00:00
|
|
|
/* add buttons */
|
2010-11-19 07:46:23 +00:00
|
|
|
if (pid && show_buttons) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (GS(pid->name) == ID_MA) ma = (Material *)pid;
|
|
|
|
else ma = (Material *)pparent;
|
2010-04-04 12:09:59 +00:00
|
|
|
|
|
|
|
/* Create RNA Pointer */
|
2012-10-27 16:47:08 +00:00
|
|
|
RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr);
|
2009-06-07 13:20:41 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(row, true);
|
2010-04-04 12:09:59 +00:00
|
|
|
uiLayoutSetScaleX(col, 1.5);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE);
|
2009-06-07 13:20:41 +00:00
|
|
|
}
|
2009-07-21 01:57:46 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pr_texture) {
|
2010-04-04 12:09:59 +00:00
|
|
|
/* Create RNA Pointer */
|
|
|
|
RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutRow(layout, true);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
pr_texture, 10, TEX_PR_TEXTURE, 0, 0, "");
|
|
|
|
if (GS(parent->name) == ID_MA) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
|
|
|
|
}
|
|
|
|
else if (GS(parent->name) == ID_LA) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
|
|
|
|
}
|
|
|
|
else if (GS(parent->name) == ID_WO) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
|
|
|
|
}
|
2014-05-03 18:51:53 +09:00
|
|
|
else if (GS(parent->name) == ID_LS) {
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Line Style"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2014-05-03 18:51:53 +09:00
|
|
|
pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
|
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
|
2010-04-04 12:09:59 +00:00
|
|
|
|
2011-12-04 16:55:46 +00:00
|
|
|
/* Alpha button for texture preview */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (*pr_texture != TEX_PR_OTHER) {
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE);
|
2010-04-04 12:09:59 +00:00
|
|
|
}
|
2009-07-21 01:57:46 +00:00
|
|
|
}
|
2009-05-28 23:41:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-03 00:14:12 +00:00
|
|
|
/********************** ColorRamp Template **************************/
|
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
typedef struct RNAUpdateCb {
|
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
} RNAUpdateCb;
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
/* we call update here on the pointer property, this way the
|
2012-03-03 16:31:46 +00:00
|
|
|
* owner of the curve mapping can still define it's own update
|
|
|
|
* and notifier, even if the CurveMapping struct is shared. */
|
2009-09-16 18:47:42 +00:00
|
|
|
RNA_property_update(C, &cb->ptr, cb->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
|
2009-06-03 00:14:12 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ColorBand *coba = coba_v;
|
|
|
|
float pos = 0.5f;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (coba->tot > 1) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (coba->cur > 0) pos = (coba->data[coba->cur - 1].pos + coba->data[coba->cur].pos) * 0.5f;
|
|
|
|
else pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f;
|
2010-04-28 09:29:17 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (colorband_element_add(coba, pos)) {
|
2010-07-30 00:20:05 +00:00
|
|
|
rna_update_cb(C, cb_v, NULL);
|
2012-10-21 05:46:41 +00:00
|
|
|
ED_undo_push(C, "Add colorband");
|
2010-07-30 00:20:05 +00:00
|
|
|
}
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ColorBand *coba = coba_v;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (colorband_element_remove(coba, coba->cur)) {
|
2010-07-30 00:20:05 +00:00
|
|
|
ED_undo_push(C, "Delete colorband");
|
|
|
|
rna_update_cb(C, cb_v, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-28 16:07:21 +00:00
|
|
|
static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v)
|
|
|
|
{
|
|
|
|
CBData data_tmp[MAXCOLORBAND];
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ColorBand *coba = coba_v;
|
2010-06-28 16:07:21 +00:00
|
|
|
int a;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < coba->tot; a++) {
|
|
|
|
data_tmp[a] = coba->data[coba->tot - (a + 1)];
|
2010-06-28 16:07:21 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < coba->tot; a++) {
|
2010-06-28 16:07:21 +00:00
|
|
|
data_tmp[a].pos = 1.0f - data_tmp[a].pos;
|
2012-03-30 01:51:25 +00:00
|
|
|
coba->data[a] = data_tmp[a];
|
2010-06-28 16:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* may as well flip the cur*/
|
2012-03-30 01:51:25 +00:00
|
|
|
coba->cur = coba->tot - (coba->cur + 1);
|
2010-06-28 16:07:21 +00:00
|
|
|
|
|
|
|
ED_undo_push(C, "Flip colorband");
|
|
|
|
|
|
|
|
rna_update_cb(C, cb_v, NULL);
|
|
|
|
}
|
|
|
|
|
2012-02-02 14:07:24 +00:00
|
|
|
static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *bt = bt_v;
|
|
|
|
ColorBand *coba = coba_v;
|
2012-02-02 14:07:24 +00:00
|
|
|
|
|
|
|
/* sneaky update here, we need to sort the colorband points to be in order,
|
2012-03-03 16:31:46 +00:00
|
|
|
* however the RNA pointer then is wrong, so we update it */
|
2012-02-02 14:07:24 +00:00
|
|
|
colorband_update_sort(coba);
|
|
|
|
bt->rnapoin.data = coba->data + coba->cur;
|
|
|
|
}
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2013-12-13 17:18:48 +01:00
|
|
|
static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, const rctf *butr,
|
2014-04-20 22:05:05 +10:00
|
|
|
RNAUpdateCb *cb, int expand)
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
2013-12-13 17:18:48 +01:00
|
|
|
uiLayout *row, *split, *subsplit;
|
2009-09-16 18:47:42 +00:00
|
|
|
uiBut *bt;
|
2012-09-23 18:50:56 +00:00
|
|
|
float unit = BLI_rctf_size_x(butr) / 14.0f;
|
2012-03-30 01:51:25 +00:00
|
|
|
float xs = butr->xmin;
|
2013-12-13 17:18:48 +01:00
|
|
|
float ys = butr->ymin;
|
2014-02-10 06:52:57 +11:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
|
|
|
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRamp, coba, &ptr);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.4f, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
|
|
|
UI_block_align_begin(block);
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, false);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, "", 0, 0, 2.0f * unit, UI_UNIT_Y, NULL,
|
2013-12-13 17:18:48 +01:00
|
|
|
0, 0, 0, 0, TIP_("Add a new color stop to the colorband"));
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMOUT, "", xs + 2.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0, 0, 0, 0, TIP_("Delete the active position"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ARROW_LEFTRIGHT, "", xs + 4.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0, 0, 0, 0, TIP_("Flip the color ramp"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
|
|
|
|
UI_block_align_end(block);
|
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, false);
|
2014-02-10 06:52:57 +11:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2014-08-15 15:29:08 +10:00
|
|
|
uiItemR(row, &ptr, "color_mode", 0, "", ICON_NONE);
|
|
|
|
if (ELEM(coba->color_mode, COLBAND_BLEND_HSV, COLBAND_BLEND_HSL)) {
|
|
|
|
uiItemR(row, &ptr, "hue_interpolation", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
else { /* COLBAND_BLEND_RGB */
|
|
|
|
uiItemR(row, &ptr, "interpolation", 0, "", ICON_NONE);
|
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2013-12-10 17:11:03 +01:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefBut(block, UI_BTYPE_COLORBAND, 0, "", xs, ys, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, "");
|
|
|
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2013-12-10 17:11:03 +01:00
|
|
|
if (coba->tot) {
|
|
|
|
CBData *cbd = coba->data + coba->cur;
|
|
|
|
|
|
|
|
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
|
|
|
|
|
2013-12-13 17:18:48 +01:00
|
|
|
if (!expand) {
|
2014-01-04 17:16:19 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.3f, false);
|
2013-12-10 17:11:03 +01:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, false);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_NUM, 0, "", 0, 0, 5.0f * UI_UNIT_X, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)),
|
2013-12-18 15:35:31 +11:00
|
|
|
0, 0, TIP_("Choose active color stop"));
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, false);
|
2013-12-13 17:18:48 +01:00
|
|
|
uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE);
|
|
|
|
bt = block->buttons.last;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(bt, colorband_update_cb, bt, coba);
|
2013-12-10 17:11:03 +01:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2013-12-13 17:18:48 +01:00
|
|
|
uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
|
2014-03-11 21:19:59 +11:00
|
|
|
bt = block->buttons.last;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2013-12-13 17:18:48 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-01-04 17:16:19 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.5f, false);
|
|
|
|
subsplit = uiLayoutSplit(split, 0.35f, false);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(subsplit, false);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButS(block, UI_BTYPE_NUM, 0, "", 0, 0, 5.0f * UI_UNIT_X, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)),
|
2013-12-18 15:35:31 +11:00
|
|
|
0, 0, TIP_("Choose active color stop"));
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(subsplit, false);
|
2014-08-15 15:29:08 +10:00
|
|
|
uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), ICON_NONE);
|
2013-12-13 17:18:48 +01:00
|
|
|
bt = block->buttons.last;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(bt, colorband_update_cb, bt, coba);
|
2013-12-13 17:18:48 +01:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(split, false);
|
2013-12-13 17:18:48 +01:00
|
|
|
uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
|
2014-03-11 21:19:59 +11:00
|
|
|
bt = block->buttons.last;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2013-12-13 17:18:48 +01:00
|
|
|
}
|
2013-12-10 17:11:03 +01:00
|
|
|
}
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand)
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2009-09-16 18:47:42 +00:00
|
|
|
PointerRNA cptr;
|
|
|
|
RNAUpdateCb *cb;
|
2009-06-03 00:14:12 +00:00
|
|
|
uiBlock *block;
|
2014-01-29 19:02:32 +01:00
|
|
|
ID *id;
|
2009-06-03 00:14:12 +00:00
|
|
|
rctf rect;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop || RNA_property_type(prop) != PROP_POINTER)
|
2009-09-16 18:47:42 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cptr = RNA_property_pointer_get(ptr, prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp))
|
2009-09-16 18:47:42 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
|
|
|
|
cb->ptr = *ptr;
|
|
|
|
cb->prop = prop;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
|
|
|
|
rect.ymin = 0; rect.ymax = 19.5f * UI_UNIT_X;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutAbsoluteBlock(layout);
|
2014-01-29 19:02:32 +01:00
|
|
|
|
|
|
|
id = cptr.id.data;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_set(block, (id && id->lib), ERROR_LIBDATA_MESSAGE);
|
2014-01-29 19:02:32 +01:00
|
|
|
|
2013-12-13 17:18:48 +01:00
|
|
|
colorband_buttons_layout(layout, block, cptr.data, &rect, cb, expand);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_clear(block);
|
2014-01-29 19:02:32 +01:00
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
MEM_freeN(cb);
|
2009-06-03 00:14:12 +00:00
|
|
|
}
|
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
/********************* Icon viewer Template ************************/
|
|
|
|
|
|
|
|
/* ID Search browse menu, open */
|
2014-11-09 21:20:40 +01:00
|
|
|
static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
|
2013-01-22 11:18:41 +00:00
|
|
|
{
|
|
|
|
static RNAUpdateCb cb;
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
int icon;
|
|
|
|
EnumPropertyItem *item;
|
2014-01-04 18:08:43 +11:00
|
|
|
int a;
|
|
|
|
bool free;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
/* arg_litem is malloced, can be freed by parent button */
|
|
|
|
cb = *((RNAUpdateCb *)arg_litem);
|
|
|
|
|
2013-02-20 01:23:34 +00:00
|
|
|
/* unused */
|
|
|
|
// icon = RNA_property_enum_get(&cb.ptr, cb.prop);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
|
2014-11-15 14:11:51 +01:00
|
|
|
UI_block_flag_enable(block, UI_BLOCK_LOOP);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
RNA_property_enum_items(C, &cb.ptr, cb.prop, &item, NULL, &free);
|
|
|
|
|
|
|
|
for (a = 0; item[a].identifier; a++) {
|
|
|
|
int x, y;
|
|
|
|
|
2013-02-05 16:16:07 +00:00
|
|
|
/* XXX hardcoded size to 5 x unit */
|
|
|
|
x = (a % 8) * UI_UNIT_X * 5;
|
|
|
|
y = (a / 8) * UI_UNIT_X * 5;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
icon = item[a].icon;
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, x, y, UI_UNIT_X * 5, UI_UNIT_Y * 5, &cb.ptr, cb.prop, -1, 0, icon, -1, -1, NULL);
|
|
|
|
UI_but_flag_enable(but, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
|
2013-01-22 11:18:41 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
|
|
|
|
UI_block_direction_set(block, UI_DIR_UP);
|
2014-06-19 04:24:15 +10:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
if (free) {
|
|
|
|
MEM_freeN(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
RNAUpdateCb *cb;
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
2013-01-23 07:26:39 +00:00
|
|
|
// rctf rect; /* UNUSED */
|
2013-01-22 11:18:41 +00:00
|
|
|
int icon;
|
|
|
|
|
|
|
|
if (!prop || RNA_property_type(prop) != PROP_ENUM)
|
|
|
|
return;
|
|
|
|
|
|
|
|
icon = RNA_property_enum_get(ptr, prop);
|
|
|
|
|
|
|
|
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
|
|
|
|
cb->ptr = *ptr;
|
|
|
|
cb->prop = prop;
|
|
|
|
|
2013-01-23 07:26:39 +00:00
|
|
|
// rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
|
|
|
|
// rect.ymin = 0; rect.ymax = 10.0f * UI_UNIT_X;
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
block = uiLayoutAbsoluteBlock(layout);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBlockButN(block, ui_icon_view_menu_cb, MEM_dupallocN(cb), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, "");
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
// but = uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect), ptr, prop, -1, 0, icon, -1, -1, NULL);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
but->icon = icon;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2013-01-22 11:18:41 +00:00
|
|
|
|
|
|
|
MEM_freeN(cb);
|
|
|
|
}
|
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
/********************* Histogram Template ************************/
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
2010-01-19 01:32:06 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2010-01-19 01:32:06 +00:00
|
|
|
PointerRNA cptr;
|
|
|
|
uiBlock *block;
|
2014-04-02 13:09:43 +02:00
|
|
|
uiLayout *col;
|
2010-01-19 01:32:06 +00:00
|
|
|
Histogram *hist;
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop || RNA_property_type(prop) != PROP_POINTER)
|
2010-01-19 01:32:06 +00:00
|
|
|
return;
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cptr = RNA_property_pointer_get(ptr, prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram))
|
2010-01-19 01:32:06 +00:00
|
|
|
return;
|
|
|
|
hist = (Histogram *)cptr.data;
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
if (hist->height < UI_UNIT_Y) {
|
|
|
|
hist->height = UI_UNIT_Y;
|
|
|
|
}
|
|
|
|
else if (hist->height > UI_UNIT_Y * 20) {
|
|
|
|
hist->height = UI_UNIT_Y * 20;
|
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
block = uiLayoutGetBlock(col);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_HISTOGRAM, 0, "", 0, 0, UI_UNIT_X * 10, hist->height, hist, 0, 0, 0, 0, "");
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
/* Resize grip. */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButI(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &hist->height,
|
2014-04-02 13:09:43 +02:00
|
|
|
UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, "");
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* Waveform Template ************************/
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2010-04-06 02:05:54 +00:00
|
|
|
PointerRNA cptr;
|
|
|
|
uiBlock *block;
|
2014-04-02 13:09:43 +02:00
|
|
|
uiLayout *col;
|
2010-04-06 02:05:54 +00:00
|
|
|
Scopes *scopes;
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop || RNA_property_type(prop) != PROP_POINTER)
|
2010-04-06 02:05:54 +00:00
|
|
|
return;
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cptr = RNA_property_pointer_get(ptr, prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
|
2010-04-06 02:05:54 +00:00
|
|
|
return;
|
|
|
|
scopes = (Scopes *)cptr.data;
|
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
block = uiLayoutGetBlock(col);
|
|
|
|
|
|
|
|
if (scopes->wavefrm_height < UI_UNIT_Y) {
|
|
|
|
scopes->wavefrm_height = UI_UNIT_Y;
|
|
|
|
}
|
|
|
|
else if (scopes->wavefrm_height > UI_UNIT_Y * 20) {
|
|
|
|
scopes->wavefrm_height = UI_UNIT_Y * 20;
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_WAVEFORM, 0, "", 0, 0, UI_UNIT_X * 10, scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
|
2014-04-02 13:09:43 +02:00
|
|
|
|
|
|
|
/* Resize grip. */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButI(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &scopes->wavefrm_height,
|
2014-04-02 13:09:43 +02:00
|
|
|
UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, "");
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************* Vectorscope Template ************************/
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2010-04-06 02:05:54 +00:00
|
|
|
PointerRNA cptr;
|
|
|
|
uiBlock *block;
|
2014-04-02 13:09:43 +02:00
|
|
|
uiLayout *col;
|
2010-04-06 02:05:54 +00:00
|
|
|
Scopes *scopes;
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop || RNA_property_type(prop) != PROP_POINTER)
|
2010-04-06 02:05:54 +00:00
|
|
|
return;
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cptr = RNA_property_pointer_get(ptr, prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
|
2010-04-06 02:05:54 +00:00
|
|
|
return;
|
|
|
|
scopes = (Scopes *)cptr.data;
|
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
if (scopes->vecscope_height < UI_UNIT_Y) {
|
|
|
|
scopes->vecscope_height = UI_UNIT_Y;
|
|
|
|
}
|
|
|
|
else if (scopes->vecscope_height > UI_UNIT_Y * 20) {
|
|
|
|
scopes->vecscope_height = UI_UNIT_Y * 20;
|
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
block = uiLayoutGetBlock(col);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_VECTORSCOPE, 0, "", 0, 0, UI_UNIT_X * 10, scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
|
2014-04-02 13:09:43 +02:00
|
|
|
|
|
|
|
/* Resize grip. */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButI(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &scopes->vecscope_height,
|
2014-04-02 13:09:43 +02:00
|
|
|
UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, "");
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 00:14:12 +00:00
|
|
|
/********************* CurveMapping Template ************************/
|
|
|
|
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(arg))
|
2009-06-03 00:14:12 +00:00
|
|
|
{
|
2009-09-16 18:47:42 +00:00
|
|
|
CurveMapping *cumap = cumap_v;
|
|
|
|
float d;
|
|
|
|
|
|
|
|
/* we allow 20 times zoom */
|
2012-09-23 18:50:56 +00:00
|
|
|
if (BLI_rctf_size_x(&cumap->curr) > 0.04f * BLI_rctf_size_x(&cumap->clipr)) {
|
|
|
|
d = 0.1154f * BLI_rctf_size_x(&cumap->curr);
|
2012-03-30 01:51:25 +00:00
|
|
|
cumap->curr.xmin += d;
|
|
|
|
cumap->curr.xmax -= d;
|
2012-09-23 18:50:56 +00:00
|
|
|
d = 0.1154f * BLI_rctf_size_y(&cumap->curr);
|
2012-03-30 01:51:25 +00:00
|
|
|
cumap->curr.ymin += d;
|
|
|
|
cumap->curr.ymax -= d;
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(unused))
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
|
|
|
float d, d1;
|
|
|
|
|
2012-03-18 07:38:51 +00:00
|
|
|
/* we allow 20 times zoom, but don't view outside clip */
|
2012-09-23 18:50:56 +00:00
|
|
|
if (BLI_rctf_size_x(&cumap->curr) < 20.0f * BLI_rctf_size_x(&cumap->clipr)) {
|
|
|
|
d = d1 = 0.15f * BLI_rctf_size_x(&cumap->curr);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->flag & CUMA_DO_CLIP)
|
2012-03-30 01:51:25 +00:00
|
|
|
if (cumap->curr.xmin - d < cumap->clipr.xmin)
|
|
|
|
d1 = cumap->curr.xmin - cumap->clipr.xmin;
|
|
|
|
cumap->curr.xmin -= d1;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
d1 = d;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->flag & CUMA_DO_CLIP)
|
2012-03-30 01:51:25 +00:00
|
|
|
if (cumap->curr.xmax + d > cumap->clipr.xmax)
|
|
|
|
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
|
|
|
|
cumap->curr.xmax += d1;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-09-23 18:50:56 +00:00
|
|
|
d = d1 = 0.15f * BLI_rctf_size_y(&cumap->curr);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->flag & CUMA_DO_CLIP)
|
2012-03-30 01:51:25 +00:00
|
|
|
if (cumap->curr.ymin - d < cumap->clipr.ymin)
|
|
|
|
d1 = cumap->curr.ymin - cumap->clipr.ymin;
|
|
|
|
cumap->curr.ymin -= d1;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
d1 = d;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->flag & CUMA_DO_CLIP)
|
2012-03-30 01:51:25 +00:00
|
|
|
if (cumap->curr.ymax + d > cumap->clipr.ymax)
|
|
|
|
d1 = -cumap->curr.ymax + cumap->clipr.ymax;
|
|
|
|
cumap->curr.ymax += d1;
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *UNUSED(arg))
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
|
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
curvemap_remove(cumap->cm + cumap->cur, SELECT);
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
rna_update_cb(C, cb_v, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
|
2012-07-26 22:47:05 +00:00
|
|
|
static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v)
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *bt;
|
2012-03-30 01:51:25 +00:00
|
|
|
float width = 8 * UI_UNIT_X;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
/* use this for a fake extra empy space around the buttons */
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButBitI(block, UI_BTYPE_TOGGLE, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"),
|
2012-03-30 01:51:25 +00:00
|
|
|
0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(bt, curvemap_buttons_setclip, cumap, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
|
|
|
uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Min X "), 0, 4 * UI_UNIT_Y, width, UI_UNIT_Y,
|
2013-04-08 18:55:08 +00:00
|
|
|
&cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 2, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Min Y "), 0, 3 * UI_UNIT_Y, width, UI_UNIT_Y,
|
2013-04-08 18:55:08 +00:00
|
|
|
&cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 2, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Max X "), 0, 2 * UI_UNIT_Y, width, UI_UNIT_Y,
|
2013-04-08 18:55:08 +00:00
|
|
|
&cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 2, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Max Y "), 0, UI_UNIT_Y, width, UI_UNIT_Y,
|
2013-04-08 18:55:08 +00:00
|
|
|
&cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 2, "");
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_direction_set(block, UI_DIR_RIGHT);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2013-04-28 20:51:44 +00:00
|
|
|
/* only for curvemap_tools_dofunc */
|
|
|
|
enum {
|
|
|
|
UICURVE_FUNC_RESET_NEG,
|
|
|
|
UICURVE_FUNC_RESET_POS,
|
|
|
|
UICURVE_FUNC_RESET_VIEW,
|
|
|
|
UICURVE_FUNC_HANDLE_VECTOR,
|
|
|
|
UICURVE_FUNC_HANDLE_AUTO,
|
|
|
|
UICURVE_FUNC_EXTEND_HOZ,
|
|
|
|
UICURVE_FUNC_EXTEND_EXP,
|
|
|
|
};
|
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
|
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
2012-03-30 01:51:25 +00:00
|
|
|
CurveMap *cuma = cumap->cm + cumap->cur;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (event) {
|
2013-04-28 20:51:44 +00:00
|
|
|
case UICURVE_FUNC_RESET_NEG:
|
|
|
|
case UICURVE_FUNC_RESET_POS: /* reset */
|
|
|
|
curvemap_reset(cuma, &cumap->clipr, cumap->preset,
|
2013-10-16 01:49:11 +00:00
|
|
|
(event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE);
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
break;
|
2013-04-28 20:51:44 +00:00
|
|
|
case UICURVE_FUNC_RESET_VIEW:
|
2012-03-30 01:51:25 +00:00
|
|
|
cumap->curr = cumap->clipr;
|
2009-09-16 18:47:42 +00:00
|
|
|
break;
|
2013-04-28 20:51:44 +00:00
|
|
|
case UICURVE_FUNC_HANDLE_VECTOR: /* set vector */
|
2009-09-16 18:47:42 +00:00
|
|
|
curvemap_sethandle(cuma, 1);
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
break;
|
2013-04-28 20:51:44 +00:00
|
|
|
case UICURVE_FUNC_HANDLE_AUTO: /* set auto */
|
2009-09-16 18:47:42 +00:00
|
|
|
curvemap_sethandle(cuma, 0);
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
break;
|
2013-04-28 20:51:44 +00:00
|
|
|
case UICURVE_FUNC_EXTEND_HOZ: /* extend horiz */
|
2009-09-16 18:47:42 +00:00
|
|
|
cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
break;
|
2013-04-28 20:51:44 +00:00
|
|
|
case UICURVE_FUNC_EXTEND_EXP: /* extend extrapolate */
|
2009-09-16 18:47:42 +00:00
|
|
|
cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-05-17 16:48:06 +02:00
|
|
|
ED_undo_push(C, "CurveMap tools");
|
2009-09-16 18:47:42 +00:00
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
}
|
|
|
|
|
2014-06-30 16:20:02 +02:00
|
|
|
static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cumap_v)
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
|
|
|
uiBlock *block;
|
2012-03-30 01:51:25 +00:00
|
|
|
short yco = 0, menuwidth = 10 * UI_UNIT_X;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
|
|
|
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_POS, "");
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_direction_set(block, UI_DIR_RIGHT);
|
|
|
|
UI_block_bounds_set_text(block, 50);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2014-06-30 16:20:02 +02:00
|
|
|
static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *ar, void *cumap_v)
|
|
|
|
{
|
|
|
|
uiBlock *block;
|
|
|
|
short yco = 0, menuwidth = 10 * UI_UNIT_X;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
|
|
|
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v);
|
2014-06-30 16:20:02 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y,
|
2014-06-30 16:20:02 +02:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y,
|
2014-06-30 16:20:02 +02:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y,
|
2014-06-30 16:20:02 +02:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y,
|
2014-06-30 16:20:02 +02:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y,
|
2014-06-30 16:20:02 +02:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y,
|
2014-06-30 16:20:02 +02:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, "");
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_direction_set(block, UI_DIR_RIGHT);
|
|
|
|
UI_block_bounds_set_text(block, 50);
|
2014-06-30 16:20:02 +02:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2012-07-26 22:47:05 +00:00
|
|
|
static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v)
|
2010-01-04 17:28:37 +00:00
|
|
|
{
|
|
|
|
uiBlock *block;
|
2012-03-30 01:51:25 +00:00
|
|
|
short yco = 0, menuwidth = 10 * UI_UNIT_X;
|
2010-01-04 17:28:37 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
|
|
|
UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v);
|
2010-01-04 17:28:37 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y,
|
2013-04-28 20:51:44 +00:00
|
|
|
menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, "");
|
2010-01-04 17:28:37 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_direction_set(block, UI_DIR_RIGHT);
|
|
|
|
UI_block_bounds_set_text(block, 50);
|
2010-01-04 17:28:37 +00:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
}
|
|
|
|
|
2012-09-28 01:47:45 +00:00
|
|
|
static void curvemap_buttons_update(bContext *C, void *arg1_v, void *cumap_v)
|
2012-09-04 12:40:47 +00:00
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, true);
|
2012-09-28 01:47:45 +00:00
|
|
|
rna_update_cb(C, arg1_v, NULL);
|
2012-09-04 12:40:47 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
|
|
|
|
{
|
|
|
|
CurveMapping *cumap = cumap_v;
|
|
|
|
int a;
|
|
|
|
|
2010-03-09 07:41:27 +00:00
|
|
|
cumap->preset = CURVE_PRESET_LINE;
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < CM_TOT; a++)
|
|
|
|
curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
|
|
|
|
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
|
2009-09-16 18:47:42 +00:00
|
|
|
curvemapping_set_black_white(cumap, NULL, NULL);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
curvemapping_changed(cumap, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
rna_update_cb(C, cb_v, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
|
2012-11-23 15:33:44 +00:00
|
|
|
static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels,
|
2014-06-30 16:20:02 +02:00
|
|
|
int brush, int neg_slope, RNAUpdateCb *cb)
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
CurveMapping *cumap = ptr->data;
|
2012-09-04 12:40:47 +00:00
|
|
|
CurveMap *cm = &cumap->cm[cumap->cur];
|
|
|
|
CurveMapPoint *cmp = NULL;
|
2009-09-16 18:47:42 +00:00
|
|
|
uiLayout *row, *sub, *split;
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *bt;
|
2012-03-30 01:51:25 +00:00
|
|
|
float dx = UI_UNIT_X;
|
2009-09-16 18:47:42 +00:00
|
|
|
int icon, size;
|
2012-09-04 12:40:47 +00:00
|
|
|
int bg = -1, i;
|
2009-06-03 00:14:12 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
/* curve chooser */
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (labeltype == 'v') {
|
2009-09-16 18:47:42 +00:00
|
|
|
/* vector */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(row, true);
|
2009-09-16 18:47:42 +00:00
|
|
|
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[0].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-08-10 20:48:38 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[1].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[2].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (labeltype == 'c') {
|
2009-09-16 18:47:42 +00:00
|
|
|
/* color */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(row, true);
|
2009-09-16 18:47:42 +00:00
|
|
|
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[3].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[0].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[1].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[2].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2009-08-10 20:48:38 +00:00
|
|
|
}
|
2009-06-03 00:14:12 +00:00
|
|
|
}
|
2010-01-21 22:23:57 +00:00
|
|
|
else if (labeltype == 'h') {
|
|
|
|
/* HSV */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(row, true);
|
2010-01-21 22:23:57 +00:00
|
|
|
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[0].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2010-01-21 22:23:57 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[1].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2010-01-21 22:23:57 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->cm[2].curve) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefButI(block, UI_BTYPE_ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
|
2010-01-21 22:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-16 18:47:42 +00:00
|
|
|
else
|
|
|
|
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
|
2010-01-21 00:00:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (labeltype == 'h')
|
2010-01-21 00:00:45 +00:00
|
|
|
bg = UI_GRAD_H;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
/* operation buttons */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(row, true);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom in"));
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out"));
|
|
|
|
UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (brush)
|
2012-03-30 01:51:25 +00:00
|
|
|
bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
|
2014-06-30 16:20:02 +02:00
|
|
|
else if (neg_slope)
|
|
|
|
bt = uiDefIconBlockBut(block, curvemap_tools_negslope_func, cumap, 0, ICON_MODIFIER,
|
|
|
|
0, 0, dx, dx, TIP_("Tools"));
|
2010-01-04 17:28:37 +00:00
|
|
|
else
|
2014-06-30 16:20:02 +02:00
|
|
|
bt = uiDefIconBlockBut(block, curvemap_tools_posslope_func, cumap, 0, ICON_MODIFIER,
|
|
|
|
0, 0, dx, dx, TIP_("Tools"));
|
2010-01-04 17:28:37 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-09-23 18:50:56 +00:00
|
|
|
icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
|
2012-03-30 01:51:25 +00:00
|
|
|
bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete points"));
|
|
|
|
UI_but_funcN_set(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
|
|
|
/* curve itself */
|
2012-03-30 01:51:25 +00:00
|
|
|
size = uiLayoutGetWidth(layout);
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, "");
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-09-04 12:40:47 +00:00
|
|
|
/* sliders for selected point */
|
|
|
|
for (i = 0; i < cm->totpoint; i++) {
|
|
|
|
if (cm->curve[i].flag & CUMA_SELECT) {
|
|
|
|
cmp = &cm->curve[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmp) {
|
2013-01-12 20:19:58 +00:00
|
|
|
rctf bounds;
|
|
|
|
|
|
|
|
if (cumap->flag & CUMA_DO_CLIP) {
|
|
|
|
bounds = cumap->clipr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bounds.xmin = bounds.ymin = -1000.0;
|
|
|
|
bounds.xmax = bounds.ymax = 1000.0;
|
|
|
|
}
|
2012-12-03 07:10:31 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutRow(layout, true);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_funcN_set(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap);
|
|
|
|
uiDefButF(block, UI_BTYPE_NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y,
|
2013-03-17 10:26:23 +00:00
|
|
|
&cmp->x, bounds.xmin, bounds.xmax, 1, 5, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButF(block, UI_BTYPE_NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y,
|
2013-03-17 10:26:23 +00:00
|
|
|
&cmp->y, bounds.ymin, bounds.ymax, 1, 5, "");
|
2012-09-04 12:40:47 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
/* black/white levels */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (levels) {
|
2014-01-04 17:16:19 +11:00
|
|
|
split = uiLayoutSplit(layout, 0.0f, false);
|
|
|
|
uiItemR(uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
uiItemR(uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutRow(layout, false);
|
2014-11-09 21:20:40 +01:00
|
|
|
bt = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
|
2012-03-30 01:51:25 +00:00
|
|
|
TIP_("Reset Black/White point and curves"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_funcN_set(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_funcN_set(block, NULL, NULL, NULL);
|
2009-09-16 18:47:42 +00:00
|
|
|
}
|
|
|
|
|
2014-06-30 16:20:02 +02:00
|
|
|
void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type,
|
|
|
|
int levels, int brush, int neg_slope)
|
2009-09-16 18:47:42 +00:00
|
|
|
{
|
|
|
|
RNAUpdateCb *cb;
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2009-09-16 18:47:42 +00:00
|
|
|
PointerRNA cptr;
|
2014-01-29 19:02:32 +01:00
|
|
|
ID *id;
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("curve property not found: %s.%s",
|
|
|
|
RNA_struct_identifier(ptr->type), propname);
|
2009-09-16 18:47:42 +00:00
|
|
|
return;
|
2011-03-27 23:11:22 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_property_type(prop) != PROP_POINTER) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("curve is not a pointer: %s.%s",
|
|
|
|
RNA_struct_identifier(ptr->type), propname);
|
2009-09-16 18:47:42 +00:00
|
|
|
return;
|
2011-03-27 23:11:22 +00:00
|
|
|
}
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cptr = RNA_property_pointer_get(ptr, prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping))
|
2009-09-16 18:47:42 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
|
|
|
|
cb->ptr = *ptr;
|
|
|
|
cb->prop = prop;
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-01-29 19:02:32 +01:00
|
|
|
id = cptr.id.data;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_set(block, (id && id->lib), ERROR_LIBDATA_MESSAGE);
|
2014-01-29 19:02:32 +01:00
|
|
|
|
2014-06-30 16:20:02 +02:00
|
|
|
curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, cb);
|
2009-09-16 18:47:42 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_lock_clear(block);
|
2014-01-29 19:02:32 +01:00
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
MEM_freeN(cb);
|
2009-06-03 00:14:12 +00:00
|
|
|
}
|
|
|
|
|
2012-11-09 10:33:42 +00:00
|
|
|
/********************* ColorPicker Template ************************/
|
2010-01-07 09:55:11 +00:00
|
|
|
|
2012-12-13 02:40:49 +00:00
|
|
|
#define WHEEL_SIZE (5 * U.widget_unit)
|
2010-01-07 09:55:11 +00:00
|
|
|
|
2012-11-09 10:33:42 +00:00
|
|
|
/* This template now follows User Preference for type - name is not correct anymore... */
|
2012-11-23 15:33:44 +00:00
|
|
|
void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider,
|
|
|
|
int lock, int lock_luminosity, int cubic)
|
2010-01-07 09:55:11 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
2010-01-07 22:42:59 +00:00
|
|
|
uiLayout *col, *row;
|
2012-12-02 16:01:06 +00:00
|
|
|
uiBut *but = NULL;
|
2014-11-09 21:20:40 +01:00
|
|
|
ColorPicker *cpicker = ui_block_colorpicker_create(block);
|
2010-01-27 00:22:29 +00:00
|
|
|
float softmin, softmax, step, precision;
|
2012-12-02 16:01:06 +00:00
|
|
|
|
2010-01-07 09:55:11 +00:00
|
|
|
if (!prop) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2010-01-07 09:55:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-07-05 07:08:10 +00:00
|
|
|
|
2010-01-27 00:22:29 +00:00
|
|
|
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
|
2012-12-02 16:01:06 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
row = uiLayoutRow(col, true);
|
2012-12-02 16:01:06 +00:00
|
|
|
|
2012-11-09 10:33:42 +00:00
|
|
|
switch (U.color_picker_type) {
|
|
|
|
case USER_CP_SQUARE_SV:
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop,
|
2012-11-23 15:33:44 +00:00
|
|
|
-1, 0.0, 0.0, UI_GRAD_SV, 0, "");
|
2012-11-09 10:33:42 +00:00
|
|
|
break;
|
|
|
|
case USER_CP_SQUARE_HS:
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop,
|
2012-11-23 15:33:44 +00:00
|
|
|
-1, 0.0, 0.0, UI_GRAD_HS, 0, "");
|
2012-11-09 10:33:42 +00:00
|
|
|
break;
|
|
|
|
case USER_CP_SQUARE_HV:
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop,
|
2012-11-23 15:33:44 +00:00
|
|
|
-1, 0.0, 0.0, UI_GRAD_HV, 0, "");
|
2012-11-09 10:33:42 +00:00
|
|
|
break;
|
2014-03-13 06:18:25 +11:00
|
|
|
|
|
|
|
/* user default */
|
|
|
|
case USER_CP_CIRCLE_HSV:
|
|
|
|
case USER_CP_CIRCLE_HSL:
|
2014-03-12 21:06:57 +02:00
|
|
|
default:
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop,
|
2014-03-13 06:18:25 +11:00
|
|
|
-1, 0.0, 0.0, 0, 0, "");
|
2014-03-12 21:06:57 +02:00
|
|
|
break;
|
|
|
|
|
2012-11-09 10:33:42 +00:00
|
|
|
}
|
2010-07-05 07:08:10 +00:00
|
|
|
|
2014-11-06 20:19:21 +01:00
|
|
|
but->custom_data = cpicker;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lock) {
|
2010-07-05 07:08:10 +00:00
|
|
|
but->flag |= UI_BUT_COLOR_LOCK;
|
|
|
|
}
|
2010-07-04 20:59:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (lock_luminosity) {
|
2012-03-09 00:41:09 +00:00
|
|
|
float color[4]; /* in case of alpha */
|
2010-07-04 20:59:10 +00:00
|
|
|
but->flag |= UI_BUT_VEC_SIZE_LOCK;
|
|
|
|
RNA_property_float_get_array(ptr, prop, color);
|
2012-03-30 01:51:25 +00:00
|
|
|
but->a2 = len_v3(color);
|
2010-07-04 20:59:10 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cubic)
|
2010-07-05 15:52:25 +00:00
|
|
|
but->flag |= UI_BUT_COLOR_CUBIC;
|
|
|
|
|
2010-01-07 09:55:11 +00:00
|
|
|
|
2012-11-09 10:33:42 +00:00
|
|
|
if (value_slider) {
|
|
|
|
switch (U.color_picker_type) {
|
2014-03-12 18:58:50 +02:00
|
|
|
case USER_CP_CIRCLE_HSL:
|
|
|
|
uiItemS(row);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop,
|
2014-11-06 20:19:21 +01:00
|
|
|
-1, softmin, softmax, UI_GRAD_L_ALT, 0, "");
|
2014-03-12 18:58:50 +02:00
|
|
|
break;
|
2012-11-09 10:33:42 +00:00
|
|
|
case USER_CP_SQUARE_SV:
|
|
|
|
uiItemS(col);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop,
|
2014-11-06 20:19:21 +01:00
|
|
|
-1, softmin, softmax, UI_GRAD_SV + 3, 0, "");
|
2012-11-09 10:33:42 +00:00
|
|
|
break;
|
|
|
|
case USER_CP_SQUARE_HS:
|
|
|
|
uiItemS(col);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop,
|
2014-11-06 20:19:21 +01:00
|
|
|
-1, softmin, softmax, UI_GRAD_HS + 3, 0, "");
|
2012-11-09 10:33:42 +00:00
|
|
|
break;
|
|
|
|
case USER_CP_SQUARE_HV:
|
|
|
|
uiItemS(col);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop,
|
2014-11-06 20:19:21 +01:00
|
|
|
-1, softmin, softmax, UI_GRAD_HV + 3, 0, "");
|
2012-11-09 10:33:42 +00:00
|
|
|
break;
|
2014-03-13 06:18:25 +11:00
|
|
|
|
|
|
|
/* user default */
|
|
|
|
case USER_CP_CIRCLE_HSV:
|
2014-03-12 21:06:57 +02:00
|
|
|
default:
|
|
|
|
uiItemS(row);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop,
|
2014-11-06 20:19:21 +01:00
|
|
|
-1, softmin, softmax, UI_GRAD_V_ALT, 0, "");
|
2014-03-12 21:06:57 +02:00
|
|
|
break;
|
2012-11-09 10:33:42 +00:00
|
|
|
}
|
2014-11-06 20:19:21 +01:00
|
|
|
|
|
|
|
but->custom_data = cpicker;
|
2012-11-09 10:33:42 +00:00
|
|
|
}
|
2010-01-07 09:55:11 +00:00
|
|
|
}
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, int UNUSED(colors))
|
|
|
|
{
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
PointerRNA cptr;
|
|
|
|
Palette *palette;
|
|
|
|
PaletteColor *color;
|
|
|
|
uiBlock *block;
|
|
|
|
uiLayout *col;
|
|
|
|
int row_cols = 0, col_id = 0;
|
|
|
|
int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
|
|
|
|
|
|
|
|
if (!prop) {
|
|
|
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cptr = RNA_property_pointer_get(ptr, prop);
|
|
|
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette))
|
|
|
|
return;
|
|
|
|
|
|
|
|
block = uiLayoutGetBlock(layout);
|
|
|
|
|
|
|
|
palette = cptr.data;
|
|
|
|
|
|
|
|
color = palette->colors.first;
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
uiLayoutRow(col, true);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButO(block, UI_BTYPE_BUT, "PALETTE_OT_color_add", WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
|
|
|
|
uiDefIconButO(block, UI_BTYPE_BUT, "PALETTE_OT_color_delete", WM_OP_INVOKE_DEFAULT, ICON_ZOOMOUT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
uiLayoutRow(col, true);
|
|
|
|
|
|
|
|
for (; color; color = color->next) {
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
|
|
|
if (row_cols >= cols_per_row) {
|
|
|
|
uiLayoutRow(col, true);
|
|
|
|
row_cols = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &ptr);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButR(block, UI_BTYPE_COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ptr, "color", -1, 0.0, 1.0,
|
2014-09-18 12:45:49 +02:00
|
|
|
UI_PALETTE_COLOR, col_id, "");
|
2014-07-21 12:02:05 +02:00
|
|
|
row_cols++;
|
|
|
|
col_id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-13 11:21:02 +00:00
|
|
|
/********************* Layer Buttons Template ************************/
|
|
|
|
|
2009-11-29 06:04:39 +00:00
|
|
|
static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
|
|
|
|
{
|
|
|
|
uiBut *but = arg1;
|
|
|
|
int cur = GET_INT_FROM_POINTER(arg2);
|
2012-03-30 01:51:25 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
int i, tot, shift = win->eventstate->shift;
|
2009-11-29 06:04:39 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!shift) {
|
2012-03-30 01:51:25 +00:00
|
|
|
tot = RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
2009-11-29 06:04:39 +00:00
|
|
|
|
|
|
|
/* Normally clicking only selects one layer */
|
2014-01-04 17:16:19 +11:00
|
|
|
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i = 0; i < tot; ++i) {
|
|
|
|
if (i != cur)
|
2014-01-04 17:16:19 +11:00
|
|
|
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, false);
|
2009-11-29 06:04:39 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
|
2011-03-19 16:30:52 +00:00
|
|
|
/* view3d layer change should update depsgraph (invisible object changed maybe) */
|
|
|
|
/* see view3d_header.c */
|
2009-11-29 06:04:39 +00:00
|
|
|
}
|
|
|
|
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO:
|
|
|
|
* - for now, grouping of layers is determined by dividing up the length of
|
|
|
|
* the array of layer bitflags */
|
2009-06-13 11:21:02 +00:00
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
|
2012-03-30 01:51:25 +00:00
|
|
|
PointerRNA *used_ptr, const char *used_propname, int active_layer)
|
2009-06-13 11:21:02 +00:00
|
|
|
{
|
2009-11-29 02:42:47 +00:00
|
|
|
uiLayout *uRow, *uCol;
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop, *used_prop = NULL;
|
2009-06-13 11:21:02 +00:00
|
|
|
int groups, cols, layers;
|
|
|
|
int group, col, layer, row;
|
2009-11-29 02:42:47 +00:00
|
|
|
int cols_per_group = 5;
|
2011-01-13 04:53:55 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
2009-06-13 11:21:02 +00:00
|
|
|
if (!prop) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("layers property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-06-13 11:21:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the number of layers determines the way we group them
|
|
|
|
* - we want 2 rows only (for now)
|
|
|
|
* - the number of columns (cols) is the total number of buttons per row
|
|
|
|
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
|
2009-11-29 02:42:47 +00:00
|
|
|
* - for now, only split into groups if group will have at least 5 items
|
2009-06-13 11:21:02 +00:00
|
|
|
*/
|
2012-03-30 01:51:25 +00:00
|
|
|
layers = RNA_property_array_length(ptr, prop);
|
|
|
|
cols = (layers / 2) + (layers % 2);
|
|
|
|
groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
|
2009-11-29 02:42:47 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (used_ptr && used_propname) {
|
2012-03-30 01:51:25 +00:00
|
|
|
used_prop = RNA_struct_find_property(used_ptr, used_propname);
|
2009-11-29 02:42:47 +00:00
|
|
|
if (!used_prop) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
|
2009-11-29 02:42:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_property_array_length(used_ptr, used_prop) < layers)
|
2009-11-29 02:42:47 +00:00
|
|
|
used_prop = NULL;
|
|
|
|
}
|
2009-06-13 11:21:02 +00:00
|
|
|
|
|
|
|
/* layers are laid out going across rows, with the columns being divided into groups */
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (group = 0; group < groups; group++) {
|
2014-01-04 17:16:19 +11:00
|
|
|
uCol = uiLayoutColumn(layout, true);
|
2009-06-13 11:21:02 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (row = 0; row < 2; row++) {
|
2009-11-29 06:04:39 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uRow = uiLayoutRow(uCol, true);
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(uRow);
|
|
|
|
layer = groups * cols_per_group * row + cols_per_group * group;
|
2009-06-13 11:21:02 +00:00
|
|
|
|
|
|
|
/* add layers as toggle buts */
|
2012-03-30 01:51:25 +00:00
|
|
|
for (col = 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
|
2009-11-29 02:42:47 +00:00
|
|
|
int icon = 0;
|
|
|
|
int butlay = 1 << layer;
|
2009-11-29 06:04:39 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (active_layer & butlay)
|
2009-11-29 02:42:47 +00:00
|
|
|
icon = ICON_LAYER_ACTIVE;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer))
|
2009-11-29 02:42:47 +00:00
|
|
|
icon = ICON_LAYER_USED;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer));
|
|
|
|
but->type = UI_BTYPE_TOGGLE;
|
2009-06-13 11:21:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-22 23:58:16 +00:00
|
|
|
|
2012-09-23 18:50:56 +00:00
|
|
|
void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname,
|
2014-04-20 22:05:05 +10:00
|
|
|
PointerRNA *used_ptr, const char *used_propname, int active_state)
|
2012-09-23 18:50:56 +00:00
|
|
|
{
|
|
|
|
uiLayout *uRow, *uCol;
|
|
|
|
PropertyRNA *prop, *used_prop = NULL;
|
|
|
|
int groups, cols, states;
|
|
|
|
int group, col, state, row;
|
|
|
|
int cols_per_group = 5;
|
|
|
|
Object *ob = (Object *)ptr->id.data;
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
if (!prop) {
|
|
|
|
RNA_warning("states property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the number of states determines the way we group them
|
|
|
|
* - we want 2 rows only (for now)
|
|
|
|
* - the number of columns (cols) is the total number of buttons per row
|
|
|
|
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
|
|
|
|
* - for now, only split into groups if group will have at least 5 items
|
|
|
|
*/
|
|
|
|
states = RNA_property_array_length(ptr, prop);
|
|
|
|
cols = (states / 2) + (states % 2);
|
|
|
|
groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
|
|
|
|
|
|
|
|
if (used_ptr && used_propname) {
|
|
|
|
used_prop = RNA_struct_find_property(used_ptr, used_propname);
|
|
|
|
if (!used_prop) {
|
|
|
|
RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RNA_property_array_length(used_ptr, used_prop) < states)
|
|
|
|
used_prop = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* layers are laid out going across rows, with the columns being divided into groups */
|
|
|
|
|
|
|
|
for (group = 0; group < groups; group++) {
|
2014-01-04 17:16:19 +11:00
|
|
|
uCol = uiLayoutColumn(layout, true);
|
2012-09-23 18:50:56 +00:00
|
|
|
|
|
|
|
for (row = 0; row < 2; row++) {
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uRow = uiLayoutRow(uCol, true);
|
2012-09-23 18:50:56 +00:00
|
|
|
block = uiLayoutGetBlock(uRow);
|
|
|
|
state = groups * cols_per_group * row + cols_per_group * group;
|
|
|
|
|
|
|
|
/* add layers as toggle buts */
|
|
|
|
for (col = 0; (col < cols_per_group) && (state < states); col++, state++) {
|
|
|
|
int icon = 0;
|
|
|
|
int butlay = 1 << state;
|
|
|
|
|
|
|
|
if (active_state & butlay)
|
|
|
|
icon = ICON_LAYER_ACTIVE;
|
|
|
|
else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state))
|
|
|
|
icon = ICON_LAYER_USED;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop,
|
2012-11-23 15:33:44 +00:00
|
|
|
state, 0, 0, -1, -1, sca_state_name_get(ob, state));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state));
|
|
|
|
but->type = UI_BTYPE_TOGGLE;
|
2012-09-23 18:50:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-24 14:16:56 +00:00
|
|
|
|
|
|
|
/************************* List Template **************************/
|
2012-12-28 10:32:49 +00:00
|
|
|
static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout,
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
struct PointerRNA *UNUSED(dataptr), struct PointerRNA *itemptr, int icon,
|
|
|
|
struct PointerRNA *UNUSED(active_dataptr), const char *UNUSED(active_propname),
|
2013-08-29 12:55:31 +00:00
|
|
|
int UNUSED(index), int UNUSED(flt_flag))
|
2009-09-28 18:33:45 +00:00
|
|
|
{
|
2013-11-23 18:43:23 +01:00
|
|
|
PropertyRNA *nameprop = RNA_struct_name_property(itemptr->type);
|
2009-10-21 20:58:10 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* Simplest one! */
|
2012-12-28 10:32:49 +00:00
|
|
|
switch (ui_list->layout_type) {
|
2013-06-26 13:22:25 +00:00
|
|
|
case UILST_LAYOUT_GRID:
|
|
|
|
uiItemL(layout, "", icon);
|
|
|
|
break;
|
|
|
|
case UILST_LAYOUT_DEFAULT:
|
|
|
|
case UILST_LAYOUT_COMPACT:
|
|
|
|
default:
|
2013-11-23 18:43:23 +01:00
|
|
|
if (nameprop) {
|
|
|
|
uiItemFullR(layout, itemptr, nameprop, RNA_NO_INDEX, 0, UI_ITEM_R_NO_BG, "", icon);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uiItemL(layout, "", icon);
|
|
|
|
}
|
2013-06-26 13:22:25 +00:00
|
|
|
break;
|
2009-10-21 20:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
static void uilist_draw_filter_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout)
|
|
|
|
{
|
|
|
|
PointerRNA listptr;
|
|
|
|
uiLayout *row, *subrow;
|
|
|
|
|
|
|
|
RNA_pointer_create(NULL, &RNA_UIList, ui_list, &listptr);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, false);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
subrow = uiLayoutRow(row, true);
|
2013-08-29 12:55:31 +00:00
|
|
|
uiItemR(subrow, &listptr, "filter_name", 0, "", ICON_NONE);
|
|
|
|
uiItemR(subrow, &listptr, "use_filter_invert", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "",
|
|
|
|
(ui_list->filter_flag & UILST_FLT_EXCLUDE) ? ICON_ZOOM_OUT : ICON_ZOOM_IN);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
subrow = uiLayoutRow(row, true);
|
2013-08-30 11:49:35 +00:00
|
|
|
uiItemR(subrow, &listptr, "use_filter_sort_alpha", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
|
|
|
uiItemR(subrow, &listptr, "use_filter_sort_reverse", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "",
|
|
|
|
(ui_list->filter_sort_flag & UILST_FLT_SORT_REVERSE) ? ICON_TRIA_UP : ICON_TRIA_DOWN);
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[MAX_IDPROP_NAME];
|
|
|
|
int org_idx;
|
|
|
|
} StringCmp;
|
|
|
|
|
|
|
|
static int cmpstringp(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
/* Case-insensitive comparison. */
|
2013-08-29 13:50:40 +00:00
|
|
|
return BLI_strcasecmp(((StringCmp *) p1)->name, ((StringCmp *) p2)->name);
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uilist_filter_items_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct PointerRNA *dataptr,
|
|
|
|
const char *propname)
|
|
|
|
{
|
|
|
|
uiListDyn *dyn_data = ui_list->dyn_data;
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(dataptr, propname);
|
|
|
|
|
|
|
|
const char *filter_raw = ui_list->filter_byname;
|
|
|
|
char *filter = (char *)filter_raw, filter_buff[32], *filter_dyn = NULL;
|
2014-08-20 20:41:30 +02:00
|
|
|
const bool filter_exclude = (ui_list->filter_flag & UILST_FLT_EXCLUDE) != 0;
|
|
|
|
const bool order_by_name = (ui_list->filter_sort_flag & UILST_FLT_SORT_ALPHA) != 0;
|
2013-08-29 12:55:31 +00:00
|
|
|
int len = RNA_property_collection_length(dataptr, prop);
|
|
|
|
|
|
|
|
dyn_data->items_shown = dyn_data->items_len = len;
|
|
|
|
|
|
|
|
if (len && (order_by_name || filter_raw[0])) {
|
|
|
|
StringCmp *names = NULL;
|
|
|
|
int order_idx = 0, i = 0;
|
|
|
|
|
|
|
|
if (order_by_name) {
|
2013-12-19 03:08:48 +11:00
|
|
|
names = MEM_callocN(sizeof(StringCmp) * len, "StringCmp");
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
if (filter_raw[0]) {
|
2015-01-03 12:27:40 +01:00
|
|
|
size_t slen = strlen(filter_raw);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2013-12-19 03:08:48 +11:00
|
|
|
dyn_data->items_filter_flags = MEM_callocN(sizeof(int) * len, "items_filter_flags");
|
2013-08-29 12:55:31 +00:00
|
|
|
dyn_data->items_shown = 0;
|
|
|
|
|
|
|
|
/* Implicitly add heading/trailing wildcards if needed. */
|
2013-12-03 01:48:05 +11:00
|
|
|
if (slen + 3 <= sizeof(filter_buff)) {
|
2013-08-29 12:55:31 +00:00
|
|
|
filter = filter_buff;
|
|
|
|
}
|
|
|
|
else {
|
2013-12-19 03:08:48 +11:00
|
|
|
filter = filter_dyn = MEM_mallocN((slen + 3) * sizeof(char), "filter_dyn");
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
2015-01-03 10:13:02 +01:00
|
|
|
BLI_strncpy_ensure_pad(filter, filter_raw, '*', slen + 3);
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RNA_PROP_BEGIN (dataptr, itemptr, prop)
|
|
|
|
{
|
|
|
|
char *namebuf;
|
|
|
|
const char *name;
|
|
|
|
bool do_order = false;
|
|
|
|
|
|
|
|
namebuf = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
|
|
|
|
name = namebuf ? namebuf : "";
|
|
|
|
|
|
|
|
if (filter[0]) {
|
|
|
|
/* Case-insensitive! */
|
|
|
|
if (fnmatch(filter, name, FNM_CASEFOLD) == 0) {
|
|
|
|
dyn_data->items_filter_flags[i] = UILST_FLT_ITEM;
|
|
|
|
if (!filter_exclude) {
|
|
|
|
dyn_data->items_shown++;
|
|
|
|
do_order = order_by_name;
|
|
|
|
}
|
|
|
|
//printf("%s: '%s' matches '%s'\n", __func__, name, filter);
|
|
|
|
}
|
|
|
|
else if (filter_exclude) {
|
|
|
|
dyn_data->items_shown++;
|
|
|
|
do_order = order_by_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
do_order = order_by_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (do_order) {
|
|
|
|
names[order_idx].org_idx = order_idx;
|
|
|
|
BLI_strncpy(names[order_idx++].name, name, MAX_IDPROP_NAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free name */
|
|
|
|
if (namebuf) {
|
|
|
|
MEM_freeN(namebuf);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
RNA_PROP_END;
|
|
|
|
|
|
|
|
if (order_by_name) {
|
|
|
|
int new_idx;
|
|
|
|
/* note: order_idx equals either to ui_list->items_len if no filtering done,
|
|
|
|
* or to ui_list->items_shown if filter is enabled,
|
|
|
|
* or to (ui_list->items_len - ui_list->items_shown) if filtered items are excluded.
|
|
|
|
* This way, we only sort items we actually intend to draw!
|
|
|
|
*/
|
|
|
|
qsort(names, order_idx, sizeof(StringCmp), cmpstringp);
|
|
|
|
|
2013-12-19 03:08:48 +11:00
|
|
|
dyn_data->items_filter_neworder = MEM_mallocN(sizeof(int) * order_idx, "items_filter_neworder");
|
2013-08-29 12:55:31 +00:00
|
|
|
for (new_idx = 0; new_idx < order_idx; new_idx++) {
|
|
|
|
dyn_data->items_filter_neworder[names[new_idx].org_idx] = new_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter_dyn) {
|
|
|
|
MEM_freeN(filter_dyn);
|
|
|
|
}
|
|
|
|
if (names) {
|
|
|
|
MEM_freeN(names);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PointerRNA item;
|
|
|
|
int org_idx;
|
|
|
|
int flt_flag;
|
|
|
|
} _uilist_item;
|
|
|
|
|
2013-08-27 15:27:41 +00:00
|
|
|
typedef struct {
|
|
|
|
int visual_items; /* Visual number of items (i.e. number of items we have room to display). */
|
|
|
|
int start_idx; /* Index of first item to display. */
|
|
|
|
int end_idx; /* Index of last item to display + 1. */
|
|
|
|
} uiListLayoutdata;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
static void uilist_prepare(uiList *ui_list, int len, int activei, int rows, int maxrows, int columns,
|
2013-08-27 15:27:41 +00:00
|
|
|
uiListLayoutdata *layoutdata)
|
|
|
|
{
|
|
|
|
uiListDyn *dyn_data = ui_list->dyn_data;
|
|
|
|
int activei_row, max_scroll;
|
2014-04-02 13:09:43 +02:00
|
|
|
const bool use_auto_size = (ui_list->list_grip < (rows - UI_LIST_AUTO_SIZE_THRESHOLD));
|
2013-08-27 15:27:41 +00:00
|
|
|
|
|
|
|
/* default rows */
|
2014-04-02 13:09:43 +02:00
|
|
|
if (rows <= 0)
|
2013-08-27 15:27:41 +00:00
|
|
|
rows = 5;
|
|
|
|
dyn_data->visual_height_min = rows;
|
2014-04-02 13:09:43 +02:00
|
|
|
if (maxrows < rows)
|
|
|
|
maxrows = max_ii(rows, 5);
|
|
|
|
if (columns <= 0)
|
2013-08-27 15:27:41 +00:00
|
|
|
columns = 9;
|
2013-08-27 18:56:04 +00:00
|
|
|
|
2013-08-27 15:27:41 +00:00
|
|
|
if (columns > 1) {
|
|
|
|
dyn_data->height = (int)ceil((double)len / (double)columns);
|
|
|
|
activei_row = (int)floor((double)activei / (double)columns);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dyn_data->height = len;
|
|
|
|
activei_row = activei;
|
|
|
|
}
|
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
if (!use_auto_size) {
|
|
|
|
/* No auto-size, yet we clamp at min size! */
|
|
|
|
maxrows = rows = max_ii(ui_list->list_grip, rows);
|
|
|
|
}
|
|
|
|
else if ((rows != maxrows) && (dyn_data->height > rows)) {
|
|
|
|
/* Expand size if needed and possible. */
|
2013-08-27 15:27:41 +00:00
|
|
|
rows = min_ii(dyn_data->height, maxrows);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If list length changes or list is tagged to check this, and active is out of view, scroll to it .*/
|
|
|
|
if (ui_list->list_last_len != len || ui_list->flag & UILST_SCROLL_TO_ACTIVE_ITEM) {
|
|
|
|
if (activei_row < ui_list->list_scroll) {
|
|
|
|
ui_list->list_scroll = activei_row;
|
|
|
|
}
|
|
|
|
else if (activei_row >= ui_list->list_scroll + rows) {
|
|
|
|
ui_list->list_scroll = activei_row - rows + 1;
|
|
|
|
}
|
|
|
|
ui_list->flag &= ~UILST_SCROLL_TO_ACTIVE_ITEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_scroll = max_ii(0, dyn_data->height - rows);
|
|
|
|
CLAMP(ui_list->list_scroll, 0, max_scroll);
|
|
|
|
ui_list->list_last_len = len;
|
|
|
|
dyn_data->visual_height = rows;
|
|
|
|
layoutdata->visual_items = rows * columns;
|
|
|
|
layoutdata->start_idx = ui_list->list_scroll * columns;
|
|
|
|
layoutdata->end_idx = min_ii(layoutdata->start_idx + rows * columns, len);
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
static void uilist_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSED(arg2))
|
2014-04-02 13:09:43 +02:00
|
|
|
{
|
|
|
|
uiList *ui_list = arg1;
|
|
|
|
uiListDyn *dyn_data = ui_list->dyn_data;
|
|
|
|
|
|
|
|
/* This way we get diff in number of additional items to show (positive) or hide (negative). */
|
|
|
|
const int diff = iroundf((float)(dyn_data->resize - dyn_data->resize_prev) / (float)UI_UNIT_Y);
|
|
|
|
|
|
|
|
if (diff != 0) {
|
|
|
|
ui_list->list_grip += diff;
|
|
|
|
dyn_data->resize_prev += diff * UI_UNIT_Y;
|
|
|
|
ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-11 00:06:03 +01:00
|
|
|
static void *uilist_item_use_dynamic_tooltip(PointerRNA *itemptr, const char *propname)
|
|
|
|
{
|
|
|
|
if (propname && propname[0] && itemptr && itemptr->data) {
|
|
|
|
PropertyRNA *prop = RNA_struct_find_property(itemptr, propname);
|
|
|
|
|
|
|
|
if (prop && (RNA_property_type(prop) == PROP_STRING)) {
|
|
|
|
return RNA_property_string_get_alloc(itemptr, prop, NULL, 0, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *uilist_item_tooltip_func(bContext *UNUSED(C), void *argN, const char *tip)
|
|
|
|
{
|
|
|
|
char *dyn_tooltip = argN;
|
|
|
|
return BLI_sprintfN("%s - %s", tip, dyn_tooltip);
|
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, const char *list_id,
|
2013-11-23 18:43:23 +01:00
|
|
|
PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr, const char *active_propname,
|
2015-02-11 00:06:03 +01:00
|
|
|
const char *item_dyntip_propname, int rows, int maxrows, int layout_type, int columns)
|
2009-07-21 01:26:17 +00:00
|
|
|
{
|
2012-12-28 10:32:49 +00:00
|
|
|
uiListType *ui_list_type;
|
|
|
|
uiList *ui_list = NULL;
|
2013-08-27 15:27:41 +00:00
|
|
|
uiListDyn *dyn_data;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
ARegion *ar;
|
|
|
|
uiListDrawItemFunc draw_item;
|
2013-08-29 12:55:31 +00:00
|
|
|
uiListDrawFilterFunc draw_filter;
|
|
|
|
uiListFilterItemsFunc filter_items;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = NULL, *activeprop;
|
2009-06-24 14:16:56 +00:00
|
|
|
PropertyType type, activetype;
|
2013-08-29 12:55:31 +00:00
|
|
|
_uilist_item *items_ptr = NULL;
|
2009-07-15 19:20:59 +00:00
|
|
|
StructRNA *ptype;
|
2013-08-27 15:27:41 +00:00
|
|
|
uiLayout *glob = NULL, *box, *row, *col, *subrow, *sub, *overlap;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
uiBlock *block, *subblock;
|
2009-06-24 14:16:56 +00:00
|
|
|
uiBut *but;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-08-27 15:27:41 +00:00
|
|
|
uiListLayoutdata layoutdata;
|
2012-12-28 10:32:49 +00:00
|
|
|
char ui_list_id[UI_MAX_NAME_STR];
|
2012-01-11 09:33:44 +00:00
|
|
|
char numstr[32];
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
int rnaicon = ICON_NONE, icon = ICON_NONE;
|
|
|
|
int i = 0, activei = 0;
|
|
|
|
int len = 0;
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2009-06-24 14:16:56 +00:00
|
|
|
/* validate arguments */
|
2013-02-18 14:03:26 +00:00
|
|
|
/* Forbid default UI_UL_DEFAULT_CLASS_NAME list class without a custom list_id! */
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(UI_UL_DEFAULT_CLASS_NAME, listtype_name) && !(list_id && list_id[0])) {
|
2013-02-19 15:45:56 +00:00
|
|
|
RNA_warning("template_list using default '%s' UIList class must provide a custom list_id",
|
|
|
|
UI_UL_DEFAULT_CLASS_NAME);
|
2013-02-18 14:03:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2009-07-01 22:25:49 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
if (!active_dataptr->data) {
|
|
|
|
RNA_warning("No active data");
|
2009-10-21 20:58:10 +00:00
|
|
|
return;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
if (dataptr->data) {
|
|
|
|
prop = RNA_struct_find_property(dataptr, propname);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop) {
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_warning("Property not found: %s.%s", RNA_struct_identifier(dataptr->type), propname);
|
2009-10-21 20:58:10 +00:00
|
|
|
return;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
activeprop = RNA_struct_find_property(active_dataptr, active_propname);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!activeprop) {
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_warning("Property not found: %s.%s", RNA_struct_identifier(active_dataptr->type), active_propname);
|
2009-10-21 20:58:10 +00:00
|
|
|
return;
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (prop) {
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_type(prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type != PROP_COLLECTION) {
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_warning("Expected a collection data property");
|
2009-10-21 20:58:10 +00:00
|
|
|
return;
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
activetype = RNA_property_type(activeprop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (activetype != PROP_INT) {
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_warning("Expected an integer active data property");
|
2009-10-21 20:58:10 +00:00
|
|
|
return;
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
|
2009-07-15 19:20:59 +00:00
|
|
|
/* get icon */
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
if (dataptr->data && prop) {
|
|
|
|
ptype = RNA_property_pointer_type(dataptr, prop);
|
2012-03-30 01:51:25 +00:00
|
|
|
rnaicon = RNA_struct_ui_icon(ptype);
|
2009-07-15 19:20:59 +00:00
|
|
|
}
|
|
|
|
|
2009-06-24 14:16:56 +00:00
|
|
|
/* get active data */
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
activei = RNA_property_int_get(active_dataptr, activeprop);
|
2009-07-21 01:26:17 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* Find the uiList type. */
|
2014-01-04 17:16:19 +11:00
|
|
|
ui_list_type = WM_uilisttype_find(listtype_name, false);
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
if (ui_list_type == NULL) {
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_warning("List type %s not found", listtype_name);
|
|
|
|
return;
|
2013-03-26 09:59:43 +00:00
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
draw_item = ui_list_type->draw_item ? ui_list_type->draw_item : uilist_draw_item_default;
|
2013-08-29 12:55:31 +00:00
|
|
|
draw_filter = ui_list_type->draw_filter ? ui_list_type->draw_filter : uilist_draw_filter_default;
|
|
|
|
filter_items = ui_list_type->filter_items ? ui_list_type->filter_items : uilist_filter_items_default;
|
2009-06-27 01:15:31 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* Find or add the uiList to the current Region. */
|
|
|
|
/* We tag the list id with the list type... */
|
2012-12-28 10:32:49 +00:00
|
|
|
BLI_snprintf(ui_list_id, sizeof(ui_list_id), "%s_%s", ui_list_type->idname, list_id ? list_id : "");
|
2009-07-01 22:25:49 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
ar = CTX_wm_region(C);
|
2012-12-28 10:32:49 +00:00
|
|
|
ui_list = BLI_findstring(&ar->ui_lists, ui_list_id, offsetof(uiList, list_id));
|
2009-07-15 19:20:59 +00:00
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
if (!ui_list) {
|
2013-12-19 03:08:48 +11:00
|
|
|
ui_list = MEM_callocN(sizeof(uiList), "uiList");
|
2012-12-28 10:32:49 +00:00
|
|
|
BLI_strncpy(ui_list->list_id, ui_list_id, sizeof(ui_list->list_id));
|
|
|
|
BLI_addtail(&ar->ui_lists, ui_list);
|
2014-05-23 08:55:31 +02:00
|
|
|
ui_list->list_grip = -UI_LIST_AUTO_SIZE_THRESHOLD; /* Force auto size by default. */
|
2013-03-26 09:59:43 +00:00
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2013-08-27 15:27:41 +00:00
|
|
|
if (!ui_list->dyn_data) {
|
2013-12-19 03:08:48 +11:00
|
|
|
ui_list->dyn_data = MEM_callocN(sizeof(uiListDyn), "uiList.dyn_data");
|
2013-08-27 15:27:41 +00:00
|
|
|
}
|
|
|
|
dyn_data = ui_list->dyn_data;
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* Because we can't actually pass type across save&load... */
|
2012-12-28 10:32:49 +00:00
|
|
|
ui_list->type = ui_list_type;
|
|
|
|
ui_list->layout_type = layout_type;
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
/* Reset filtering data. */
|
2014-01-24 22:12:38 +01:00
|
|
|
MEM_SAFE_FREE(dyn_data->items_filter_flags);
|
|
|
|
MEM_SAFE_FREE(dyn_data->items_filter_neworder);
|
2013-08-29 12:55:31 +00:00
|
|
|
dyn_data->items_len = dyn_data->items_shown = -1;
|
|
|
|
|
2014-01-12 15:56:47 +01:00
|
|
|
/* When active item changed since last draw, scroll to it. */
|
|
|
|
if (activei != ui_list->list_last_activei) {
|
|
|
|
ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM;
|
|
|
|
ui_list->list_last_activei = activei;
|
|
|
|
}
|
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
/* Filter list items! (not for compact layout, though) */
|
|
|
|
if (dataptr->data && prop) {
|
2014-08-20 20:41:30 +02:00
|
|
|
const int filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
|
|
|
|
const bool order_reverse = (ui_list->filter_sort_flag & UILST_FLT_SORT_REVERSE) != 0;
|
2013-08-29 12:55:31 +00:00
|
|
|
int items_shown, idx = 0;
|
|
|
|
#if 0
|
|
|
|
int prev_ii = -1, prev_i;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (layout_type == UILST_LAYOUT_COMPACT) {
|
|
|
|
dyn_data->items_len = dyn_data->items_shown = RNA_property_collection_length(dataptr, prop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//printf("%s: filtering...\n", __func__);
|
|
|
|
filter_items(ui_list, C, dataptr, propname);
|
|
|
|
//printf("%s: filtering done.\n", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
items_shown = dyn_data->items_shown;
|
|
|
|
if (items_shown >= 0) {
|
2013-11-09 17:05:07 +00:00
|
|
|
bool activei_mapping_pending = true;
|
2013-12-19 03:08:48 +11:00
|
|
|
items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, __func__);
|
2013-08-29 12:55:31 +00:00
|
|
|
//printf("%s: items shown: %d.\n", __func__, items_shown);
|
|
|
|
RNA_PROP_BEGIN (dataptr, itemptr, prop)
|
|
|
|
{
|
|
|
|
if (!dyn_data->items_filter_flags ||
|
2014-01-12 22:05:24 +11:00
|
|
|
((dyn_data->items_filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude))
|
2013-08-29 12:55:31 +00:00
|
|
|
{
|
|
|
|
int ii;
|
|
|
|
if (dyn_data->items_filter_neworder) {
|
|
|
|
ii = dyn_data->items_filter_neworder[idx++];
|
|
|
|
ii = order_reverse ? items_shown - ii - 1 : ii;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ii = order_reverse ? items_shown - ++idx : idx++;
|
|
|
|
}
|
|
|
|
//printf("%s: ii: %d\n", __func__, ii);
|
|
|
|
items_ptr[ii].item = itemptr;
|
|
|
|
items_ptr[ii].org_idx = i;
|
|
|
|
items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : 0;
|
|
|
|
|
2013-11-09 17:05:07 +00:00
|
|
|
if (activei_mapping_pending && activei == i) {
|
2013-08-29 12:55:31 +00:00
|
|
|
activei = ii;
|
2013-11-09 17:05:07 +00:00
|
|
|
/* So that we do not map again activei! */
|
|
|
|
activei_mapping_pending = false;
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
# if 0 /* For now, do not alter active element, even if it will be hidden... */
|
|
|
|
else if (activei < i) {
|
|
|
|
/* We do not want an active but invisible item!
|
|
|
|
* Only exception is when all items are filtered out...
|
|
|
|
*/
|
|
|
|
if (prev_ii >= 0) {
|
|
|
|
activei = prev_ii;
|
|
|
|
RNA_property_int_set(active_dataptr, activeprop, prev_i);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
activei = ii;
|
|
|
|
RNA_property_int_set(active_dataptr, activeprop, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prev_i = i;
|
|
|
|
prev_ii = ii;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
RNA_PROP_END;
|
|
|
|
}
|
|
|
|
if (dyn_data->items_shown >= 0) {
|
|
|
|
len = dyn_data->items_shown;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
len = dyn_data->items_len;
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 15:27:41 +00:00
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
switch (layout_type) {
|
2013-06-26 13:22:25 +00:00
|
|
|
case UILST_LAYOUT_DEFAULT:
|
|
|
|
/* layout */
|
|
|
|
box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
|
2014-01-04 17:16:19 +11:00
|
|
|
glob = uiLayoutColumn(box, true);
|
|
|
|
row = uiLayoutRow(glob, false);
|
|
|
|
col = uiLayoutColumn(row, true);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* init numbers */
|
2014-11-09 21:20:40 +01:00
|
|
|
uilist_prepare(ui_list, len, activei, rows, maxrows, 1, &layoutdata);
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
if (dataptr->data && prop) {
|
|
|
|
/* create list items */
|
2013-08-29 12:55:31 +00:00
|
|
|
for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) {
|
|
|
|
PointerRNA *itemptr = &items_ptr[i].item;
|
2015-02-11 00:06:03 +01:00
|
|
|
void *dyntip_data;
|
2013-08-29 12:55:31 +00:00
|
|
|
int org_i = items_ptr[i].org_idx;
|
|
|
|
int flt_flag = items_ptr[i].flt_flag;
|
|
|
|
subblock = uiLayoutGetBlock(col);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
overlap = uiLayoutOverlap(col);
|
Fix [#35750] list items in properties editor (text colors not following list item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e. since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL, but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did nothing more than default widget_state().
Thanks to Brecht for the review and advices.
2013-06-26 07:28:55 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_flag_enable(subblock, UI_BLOCK_LIST_ITEM);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
/* list item behind label & other buttons */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(overlap, false);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(subblock, UI_BTYPE_LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2015-02-11 00:06:03 +01:00
|
|
|
active_dataptr, activeprop, 0, 0, org_i, 0, 0,
|
|
|
|
TIP_("Double click to rename"));
|
|
|
|
if ((dyntip_data = uilist_item_use_dynamic_tooltip(itemptr, item_dyntip_propname))) {
|
|
|
|
UI_but_func_tooltip_set(but, uilist_item_tooltip_func, dyntip_data);
|
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(overlap, false);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
|
|
|
icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false);
|
|
|
|
if (icon == ICON_DOT)
|
|
|
|
icon = ICON_NONE;
|
|
|
|
draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname,
|
|
|
|
org_i, flt_flag);
|
Fix [#35750] list items in properties editor (text colors not following list item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e. since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL, but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did nothing more than default widget_state().
Thanks to Brecht for the review and advices.
2013-06-26 07:28:55 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
/* If we are "drawing" active item, set all labels as active. */
|
|
|
|
if (i == activei) {
|
|
|
|
ui_layout_list_set_labels_active(sub);
|
Fix [#35750] list items in properties editor (text colors not following list item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e. since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL, but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did nothing more than default widget_state().
Thanks to Brecht for the review and advices.
2013-06-26 07:28:55 +00:00
|
|
|
}
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_flag_disable(subblock, UI_BLOCK_LIST_ITEM);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
}
|
2009-07-01 22:25:49 +00:00
|
|
|
}
|
2009-06-24 14:16:56 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* add dummy buttons to fill space */
|
2013-08-27 15:27:41 +00:00
|
|
|
for (; i < layoutdata.start_idx + layoutdata.visual_items; i++) {
|
|
|
|
uiItemL(col, "", ICON_NONE);
|
2013-06-26 13:22:25 +00:00
|
|
|
}
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* add scrollbar */
|
2013-08-27 15:27:41 +00:00
|
|
|
if (len > layoutdata.visual_items) {
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(row, false);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height,
|
2013-08-27 15:27:41 +00:00
|
|
|
&ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height,
|
|
|
|
dyn_data->visual_height, 0, "");
|
2013-06-26 13:22:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case UILST_LAYOUT_COMPACT:
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(layout, true);
|
2013-06-26 13:22:25 +00:00
|
|
|
|
2013-12-06 10:52:04 +11:00
|
|
|
if ((dataptr->data && prop) && (dyn_data->items_shown > 0) &&
|
|
|
|
(activei >= 0) && (activei < dyn_data->items_shown))
|
|
|
|
{
|
2013-08-29 12:55:31 +00:00
|
|
|
PointerRNA *itemptr = &items_ptr[activei].item;
|
|
|
|
int org_i = items_ptr[activei].org_idx;
|
2013-06-26 13:22:25 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false);
|
|
|
|
if (icon == ICON_DOT)
|
|
|
|
icon = ICON_NONE;
|
|
|
|
draw_item(ui_list, C, row, dataptr, itemptr, icon, active_dataptr, active_propname, org_i, 0);
|
2013-03-26 09:59:43 +00:00
|
|
|
}
|
2013-06-26 13:22:25 +00:00
|
|
|
/* if list is empty, add in dummy button */
|
2013-08-29 12:55:31 +00:00
|
|
|
else {
|
2013-06-26 13:22:25 +00:00
|
|
|
uiItemL(row, "", ICON_NONE);
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* next/prev button */
|
2013-08-29 12:55:31 +00:00
|
|
|
BLI_snprintf(numstr, sizeof(numstr), "%d :", dyn_data->items_shown);
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButR_prop(block, UI_BTYPE_NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y,
|
2013-06-26 13:22:25 +00:00
|
|
|
active_dataptr, activeprop, 0, 0, 0, 0, 0, "");
|
2013-08-29 12:55:31 +00:00
|
|
|
if (dyn_data->items_shown == 0)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2013-06-26 13:22:25 +00:00
|
|
|
break;
|
|
|
|
case UILST_LAYOUT_GRID:
|
|
|
|
box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop);
|
2014-01-04 17:16:19 +11:00
|
|
|
glob = uiLayoutColumn(box, true);
|
|
|
|
row = uiLayoutRow(glob, false);
|
|
|
|
col = uiLayoutColumn(row, true);
|
2013-08-27 15:27:41 +00:00
|
|
|
subrow = NULL; /* Quite gcc warning! */
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uilist_prepare(ui_list, len, activei, rows, maxrows, columns, &layoutdata);
|
2013-06-26 13:22:25 +00:00
|
|
|
|
|
|
|
if (dataptr->data && prop) {
|
|
|
|
/* create list items */
|
2013-08-29 12:55:31 +00:00
|
|
|
for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) {
|
|
|
|
PointerRNA *itemptr = &items_ptr[i].item;
|
|
|
|
int org_i = items_ptr[i].org_idx;
|
|
|
|
int flt_flag = items_ptr[i].flt_flag;
|
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* create button */
|
2013-08-27 15:27:41 +00:00
|
|
|
if (!(i % columns))
|
2014-01-04 17:16:19 +11:00
|
|
|
subrow = uiLayoutRow(col, false);
|
2013-06-26 13:22:25 +00:00
|
|
|
|
2013-08-27 15:27:41 +00:00
|
|
|
subblock = uiLayoutGetBlock(subrow);
|
|
|
|
overlap = uiLayoutOverlap(subrow);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_flag_enable(subblock, UI_BLOCK_LIST_ITEM);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* list item behind label & other buttons */
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(overlap, false);
|
Fix [#35750] list items in properties editor (text colors not following list item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e. since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL, but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did nothing more than default widget_state().
Thanks to Brecht for the review and advices.
2013-06-26 07:28:55 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(subblock, UI_BTYPE_LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
|
2013-08-29 12:55:31 +00:00
|
|
|
active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_drawflag_enable(but, UI_BUT_NO_TOOLTIP);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
sub = uiLayoutRow(overlap, false);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false);
|
|
|
|
draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname,
|
|
|
|
org_i, flt_flag);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-06-26 13:22:25 +00:00
|
|
|
/* If we are "drawing" active item, set all labels as active. */
|
|
|
|
if (i == activei) {
|
|
|
|
ui_layout_list_set_labels_active(sub);
|
|
|
|
}
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_flag_disable(subblock, UI_BLOCK_LIST_ITEM);
|
Fix [#35750] list items in properties editor (text colors not following list item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e. since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL, but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did nothing more than default widget_state().
Thanks to Brecht for the review and advices.
2013-06-26 07:28:55 +00:00
|
|
|
}
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
}
|
2013-08-27 15:27:41 +00:00
|
|
|
|
|
|
|
/* add dummy buttons to fill space */
|
|
|
|
for (; i < layoutdata.start_idx + layoutdata.visual_items; i++) {
|
|
|
|
if (!(i % columns)) {
|
2014-01-04 17:16:19 +11:00
|
|
|
subrow = uiLayoutRow(col, false);
|
2013-08-27 15:27:41 +00:00
|
|
|
}
|
|
|
|
uiItemL(subrow, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add scrollbar */
|
|
|
|
if (len > layoutdata.visual_items) {
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(row, false);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height,
|
2013-08-27 15:27:41 +00:00
|
|
|
&ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height,
|
|
|
|
dyn_data->visual_height, 0, "");
|
|
|
|
}
|
2013-06-26 13:22:25 +00:00
|
|
|
break;
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
2013-08-27 15:27:41 +00:00
|
|
|
|
|
|
|
if (glob) {
|
2014-11-09 21:20:40 +01:00
|
|
|
/* About UI_BTYPE_GRIP drag-resize:
|
|
|
|
* We can't directly use results from a grip button, since we have a rather complex behavior here
|
2014-04-02 13:09:43 +02:00
|
|
|
* (sizing by discrete steps and, overall, autosize feature).
|
|
|
|
* Since we *never* know whether we are grip-resizing or not (because there is no callback for when a
|
|
|
|
* button enters/leaves its "edit mode"), we use the fact that grip-controlled value (dyn_data->resize)
|
|
|
|
* is completely handled by the grip during the grab resize, so settings its value here has no effect
|
|
|
|
* at all.
|
|
|
|
* It is only meaningful when we are not resizing, in which case this gives us the correct "init drag" value.
|
|
|
|
* Note we cannot affect dyn_data->resize_prev here, since this value is not controlled by the grip!
|
|
|
|
*/
|
|
|
|
dyn_data->resize = dyn_data->resize_prev + (dyn_data->visual_height - ui_list->list_grip) * UI_UNIT_Y;
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(glob, true);
|
2013-08-27 15:27:41 +00:00
|
|
|
subblock = uiLayoutGetBlock(row);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(subblock, UI_EMBOSS_NONE);
|
2013-08-27 15:27:41 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
if (ui_list->filter_flag & UILST_FLT_SHOW) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButBitI(subblock, UI_BTYPE_TOGGLE, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_DOWN, 0, 0,
|
2014-04-02 13:22:12 +02:00
|
|
|
UI_UNIT_X, UI_UNIT_Y * 0.5f, &(ui_list->filter_flag), 0, 0, 0, 0,
|
2013-08-29 12:55:31 +00:00
|
|
|
TIP_("Hide filtering options"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButI(subblock, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.5f,
|
2014-04-02 13:09:43 +02:00
|
|
|
&dyn_data->resize, 0.0, 0.0, 0, 0, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, uilist_resize_update_cb, ui_list, NULL);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(subblock, UI_EMBOSS);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(glob, false);
|
2013-08-29 12:55:31 +00:00
|
|
|
subblock = uiLayoutGetBlock(col);
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(subblock, UI_BTYPE_SEPR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y * 0.05f, NULL, 0.0, 0.0, 0, 0, "");
|
2013-08-29 12:55:31 +00:00
|
|
|
|
|
|
|
draw_filter(ui_list, C, col);
|
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButBitI(subblock, UI_BTYPE_TOGGLE, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0,
|
2014-04-02 13:22:12 +02:00
|
|
|
UI_UNIT_X, UI_UNIT_Y * 0.5f, &(ui_list->filter_flag), 0, 0, 0, 0,
|
2013-08-29 12:55:31 +00:00
|
|
|
TIP_("Show filtering options"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButI(subblock, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.5f,
|
2014-04-02 13:09:43 +02:00
|
|
|
&dyn_data->resize, 0.0, 0.0, 0, 0, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, uilist_resize_update_cb, ui_list, NULL);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(subblock, UI_EMBOSS);
|
2013-08-30 11:49:35 +00:00
|
|
|
}
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
2013-08-27 15:27:41 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
if (items_ptr) {
|
|
|
|
MEM_freeN(items_ptr);
|
2013-08-27 15:27:41 +00:00
|
|
|
}
|
2009-06-24 14:16:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
/************************* Operator Search Template **************************/
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wmOperatorType *ot = arg2;
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ot)
|
2014-07-11 15:07:55 +10:00
|
|
|
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL);
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2014-10-28 15:41:05 +01:00
|
|
|
GHashIterator iter;
|
2011-08-11 06:06:17 +00:00
|
|
|
|
2014-10-28 15:41:05 +01:00
|
|
|
for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) {
|
|
|
|
wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
|
2011-08-11 06:06:17 +00:00
|
|
|
|
2012-12-04 18:22:41 +00:00
|
|
|
if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0)
|
|
|
|
continue;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BLI_strcasestr(ot->name, str)) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (WM_operator_poll((bContext *)C, ot)) {
|
2009-06-30 19:20:45 +00:00
|
|
|
char name[256];
|
2012-03-30 01:51:25 +00:00
|
|
|
int len = strlen(ot->name);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
/* display name for menu, can hold hotkey */
|
2012-01-11 12:33:51 +00:00
|
|
|
BLI_strncpy(name, ot->name, sizeof(name));
|
2009-06-30 19:20:45 +00:00
|
|
|
|
|
|
|
/* check for hotkey */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (len < sizeof(name) - 6) {
|
2013-05-10 23:41:41 +00:00
|
|
|
if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, true,
|
2012-03-30 01:51:25 +00:00
|
|
|
&name[len + 1], sizeof(name) - len - 1))
|
2012-01-11 12:33:51 +00:00
|
|
|
{
|
2013-09-11 05:06:27 +00:00
|
|
|
name[len] = UI_SEP_CHAR;
|
2012-01-11 12:33:51 +00:00
|
|
|
}
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (false == UI_search_item_add(items, name, ot, 0))
|
2009-06-30 19:20:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
void UI_but_func_operator_search(uiBut *but)
|
2012-12-04 18:22:41 +00:00
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_search_set(but, operator_search_cb, NULL, operator_call_cb, NULL);
|
2012-12-04 18:22:41 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
void uiTemplateOperatorSearch(uiLayout *layout)
|
|
|
|
{
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
2012-03-30 01:51:25 +00:00
|
|
|
static char search[256] = "";
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, 0, "");
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_operator_search(but);
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************* Running Jobs Template **************************/
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
#define B_STOPRENDER 1
|
|
|
|
#define B_STOPCAST 2
|
|
|
|
#define B_STOPANIM 3
|
|
|
|
#define B_STOPCOMPO 4
|
|
|
|
#define B_STOPSEQ 5
|
|
|
|
#define B_STOPCLIP 6
|
2012-09-03 16:05:37 +00:00
|
|
|
#define B_STOPOTHER 7
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
|
2009-06-30 19:20:45 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (event) {
|
2009-06-30 19:20:45 +00:00
|
|
|
case B_STOPRENDER:
|
2014-01-04 17:16:19 +11:00
|
|
|
G.is_break = true;
|
2009-06-30 19:20:45 +00:00
|
|
|
break;
|
|
|
|
case B_STOPCAST:
|
2010-07-04 19:58:52 +00:00
|
|
|
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), NULL);
|
2009-06-30 19:20:45 +00:00
|
|
|
break;
|
|
|
|
case B_STOPANIM:
|
2009-08-16 20:37:22 +00:00
|
|
|
WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL);
|
2009-06-30 19:20:45 +00:00
|
|
|
break;
|
2010-04-13 17:15:11 +00:00
|
|
|
case B_STOPCOMPO:
|
2012-08-15 10:31:52 +00:00
|
|
|
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL);
|
2010-04-13 17:15:11 +00:00
|
|
|
break;
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
case B_STOPSEQ:
|
|
|
|
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
|
|
|
|
break;
|
2011-11-07 12:55:18 +00:00
|
|
|
case B_STOPCLIP:
|
|
|
|
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_area(C), NULL);
|
|
|
|
break;
|
2012-09-03 16:05:37 +00:00
|
|
|
case B_STOPOTHER:
|
2014-01-04 17:16:19 +11:00
|
|
|
G.is_break = true;
|
2012-09-03 16:05:37 +00:00
|
|
|
break;
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2009-06-30 19:20:45 +00:00
|
|
|
uiBlock *block;
|
2012-03-30 01:51:25 +00:00
|
|
|
void *owner = NULL;
|
2010-05-27 08:22:16 +00:00
|
|
|
int handle_event;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, do_running_jobs, NULL);
|
2009-06-30 19:20:45 +00:00
|
|
|
|
2012-08-15 10:31:52 +00:00
|
|
|
if (sa->spacetype == SPACE_SEQ) {
|
2012-08-15 09:42:06 +00:00
|
|
|
if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY))
|
== Sequencer ==
This patch adds:
* support for proxy building again (missing feature from Blender 2.49)
additionally to the way, Blender 2.49 worked, you can select several
strips at once and make Blender build proxies in the background (using
the job system)
Also a new thing: movie proxies are now build into AVI files, and
the proxy system is moved into ImBuf-library, so that other parts
of blender can also benefit from it.
* Timecode support: to fix seeking issues with files, that have
a) varying frame rates
b) very large GOP lengths
c) are broken inbetween
d) use different time code tracks
the proxy builder can now also build timecode indices, which are
used (optionally) for seeking.
For the first time, it is possible, to do frame exact seeking on
all file types.
* Support for different video-streams in one video file (can be
selected in sequencer, other parts of blender can also use it,
but UI has to be added accordingly)
* IMPORTANT: this patch *requires* ffmpeg 0.7 or newer, since
older versions don't support the pkt_pts field, that is essential
for building timecode indices.
Windows and Mac libs are already updated, Linux-users have to build
their own ffmpeg verions until distros keep up.
2011-08-28 14:46:03 +00:00
|
|
|
owner = sa;
|
|
|
|
handle_event = B_STOPSEQ;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
else if (sa->spacetype == SPACE_CLIP) {
|
2012-08-15 09:42:06 +00:00
|
|
|
if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY))
|
2012-03-30 01:51:25 +00:00
|
|
|
owner = sa;
|
|
|
|
handle_event = B_STOPCLIP;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-01-12 03:41:12 +00:00
|
|
|
Scene *scene;
|
2010-12-17 17:06:36 +00:00
|
|
|
/* another scene can be rendering too, for example via compositor */
|
2012-08-15 10:31:52 +00:00
|
|
|
for (scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) {
|
|
|
|
if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) {
|
|
|
|
handle_event = B_STOPRENDER;
|
2010-12-17 17:06:36 +00:00
|
|
|
break;
|
2012-08-15 10:31:52 +00:00
|
|
|
}
|
|
|
|
else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) {
|
|
|
|
handle_event = B_STOPCOMPO;
|
|
|
|
break;
|
|
|
|
}
|
2014-05-08 21:46:51 -03:00
|
|
|
else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE) ||
|
2014-05-09 18:29:21 +10:00
|
|
|
WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE))
|
|
|
|
{
|
2013-11-18 14:02:58 +06:00
|
|
|
/* Skip bake jobs in compositor to avoid compo header displaying
|
|
|
|
* progress bar which is not being updated (bake jobs only need
|
|
|
|
* to update NC_IMAGE context.
|
|
|
|
*/
|
|
|
|
if (sa->spacetype != SPACE_NODE) {
|
|
|
|
handle_event = B_STOPOTHER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-09-03 16:05:37 +00:00
|
|
|
else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) {
|
|
|
|
handle_event = B_STOPOTHER;
|
|
|
|
break;
|
|
|
|
}
|
2012-08-15 10:31:52 +00:00
|
|
|
}
|
2010-05-27 08:22:16 +00:00
|
|
|
owner = scene;
|
2010-04-13 17:15:11 +00:00
|
|
|
}
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (owner) {
|
2010-12-03 12:30:59 +00:00
|
|
|
uiLayout *ui_abs;
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
ui_abs = uiLayoutAbsolute(layout, false);
|
2012-08-19 10:41:27 +00:00
|
|
|
(void)ui_abs; /* UNUSED */
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconBut(block, UI_BTYPE_BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job"));
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_PROGRESS_BAR, 0, WM_jobs_name(wm, owner),
|
2013-04-24 23:09:29 +00:00
|
|
|
UI_UNIT_X, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress"));
|
2010-05-27 08:22:16 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutRow(layout, false);
|
2010-04-13 17:15:11 +00:00
|
|
|
}
|
2012-08-15 10:23:06 +00:00
|
|
|
if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST))
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, UI_UNIT_X * 4.25f, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast"));
|
2012-03-24 06:38:07 +00:00
|
|
|
if (screen->animtimer)
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback"));
|
2009-06-30 19:20:45 +00:00
|
|
|
}
|
|
|
|
|
Info Header: Non-blocking Info Messages
Reports (i.e. 'info' or 'errors') are now shown in the info header in place of the scene statistics if the last executed operator had some, with this info disappearing again once another operator is run (to show scene statistics again).
For example, this means that info such as the the number of verts merged, or whether a Keying Set successfully inserted keyframes, etc. is now shown again somewhere, and that this is done in a non-blocking manner.
The current implementation is still a bit crude (i.e. lacking fancy polish), but is at least barebones functional. The todos...
* When more than 1 report message is generated by the last operator, there is currently a display of the number of reports. In future, it would be nice to be able to add a button beside this or make the label clickable with appropriate text indicating this (commented out atm) to show popup menu of all the reports...
* There could probably be some kind of coloured backdrop behind the text. Currently using standard box, but that has padding problems, and lacks visual interest.
* Timer based fade out/disappear?
2010-03-02 11:48:40 +00:00
|
|
|
/************************* Reports for Last Operator Template **************************/
|
|
|
|
|
2010-06-03 07:27:55 +00:00
|
|
|
void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
|
Info Header: Non-blocking Info Messages
Reports (i.e. 'info' or 'errors') are now shown in the info header in place of the scene statistics if the last executed operator had some, with this info disappearing again once another operator is run (to show scene statistics again).
For example, this means that info such as the the number of verts merged, or whether a Keying Set successfully inserted keyframes, etc. is now shown again somewhere, and that this is done in a non-blocking manner.
The current implementation is still a bit crude (i.e. lacking fancy polish), but is at least barebones functional. The todos...
* When more than 1 report message is generated by the last operator, there is currently a display of the number of reports. In future, it would be nice to be able to add a button beside this or make the label clickable with appropriate text indicating this (commented out atm) to show popup menu of all the reports...
* There could probably be some kind of coloured backdrop behind the text. Currently using standard box, but that has padding problems, and lacks visual interest.
* Timer based fade out/disappear?
2010-03-02 11:48:40 +00:00
|
|
|
{
|
2010-06-03 07:27:55 +00:00
|
|
|
ReportList *reports = CTX_wm_reports(C);
|
2012-03-30 01:51:25 +00:00
|
|
|
Report *report = BKE_reports_last_displayable(reports);
|
2010-06-03 07:27:55 +00:00
|
|
|
ReportTimerInfo *rti;
|
Info Header: Non-blocking Info Messages
Reports (i.e. 'info' or 'errors') are now shown in the info header in place of the scene statistics if the last executed operator had some, with this info disappearing again once another operator is run (to show scene statistics again).
For example, this means that info such as the the number of verts merged, or whether a Keying Set successfully inserted keyframes, etc. is now shown again somewhere, and that this is done in a non-blocking manner.
The current implementation is still a bit crude (i.e. lacking fancy polish), but is at least barebones functional. The todos...
* When more than 1 report message is generated by the last operator, there is currently a display of the number of reports. In future, it would be nice to be able to add a button beside this or make the label clickable with appropriate text indicating this (commented out atm) to show popup menu of all the reports...
* There could probably be some kind of coloured backdrop behind the text. Currently using standard box, but that has padding problems, and lacks visual interest.
* Timer based fade out/disappear?
2010-03-02 11:48:40 +00:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
uiLayout *ui_abs;
|
2010-06-03 07:27:55 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
2014-11-09 21:20:40 +01:00
|
|
|
uiStyle *style = UI_style_get();
|
2010-06-03 07:27:55 +00:00
|
|
|
int width;
|
2014-02-09 12:00:03 +11:00
|
|
|
int icon;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
/* if the report display has timed out, don't show */
|
|
|
|
if (!reports->reporttimer) return;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (!rti || rti->widthfac == 0.0f || !report) return;
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
ui_abs = uiLayoutAbsolute(layout, false);
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(ui_abs);
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
width = BLF_width(style->widget.uifont_id, report->message, report->len);
|
2012-10-27 11:18:54 +00:00
|
|
|
width = min_ii((int)(rti->widthfac * width), width);
|
|
|
|
width = max_ii(width, 10);
|
Info Header: Non-blocking Info Messages
Reports (i.e. 'info' or 'errors') are now shown in the info header in place of the scene statistics if the last executed operator had some, with this info disappearing again once another operator is run (to show scene statistics again).
For example, this means that info such as the the number of verts merged, or whether a Keying Set successfully inserted keyframes, etc. is now shown again somewhere, and that this is done in a non-blocking manner.
The current implementation is still a bit crude (i.e. lacking fancy polish), but is at least barebones functional. The todos...
* When more than 1 report message is generated by the last operator, there is currently a display of the number of reports. In future, it would be nice to be able to add a button beside this or make the label clickable with appropriate text indicating this (commented out atm) to show popup menu of all the reports...
* There could probably be some kind of coloured backdrop behind the text. Currently using standard box, but that has padding problems, and lacks visual interest.
* Timer based fade out/disappear?
2010-03-02 11:48:40 +00:00
|
|
|
|
|
|
|
/* make a box around the report to make it stand out */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
|
|
|
but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
|
|
|
|
/* set the report's bg color in but->col - UI_BTYPE_ROUNDBOX feature */
|
2012-01-19 10:04:51 +00:00
|
|
|
rgb_float_to_uchar(but->col, rti->col);
|
2012-03-30 01:51:25 +00:00
|
|
|
but->col[3] = 255;
|
2010-10-13 13:53:49 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0f, 0.0f, 0, 0, "");
|
2012-07-03 19:09:07 +00:00
|
|
|
but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->grayscale);
|
2012-03-30 01:51:25 +00:00
|
|
|
but->col[3] = 255;
|
2010-10-13 13:53:49 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2010-06-03 07:27:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* icon and report message on top */
|
2014-11-09 21:20:40 +01:00
|
|
|
icon = UI_icon_from_report_type(report->type);
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2010-11-17 12:02:36 +00:00
|
|
|
/* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report
|
|
|
|
* to be shown instead of icon when appropriate...
|
|
|
|
*/
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2010-11-24 19:06:56 +00:00
|
|
|
|
2010-11-17 12:02:36 +00:00
|
|
|
if (reports->list.first != reports->list.last)
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X,
|
2012-11-23 15:33:44 +00:00
|
|
|
UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'"));
|
2010-11-17 12:02:36 +00:00
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2010-06-03 07:27:55 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y,
|
2012-11-23 15:33:44 +00:00
|
|
|
NULL, 0.0f, 0.0f, 0, 0, "");
|
Info Header: Non-blocking Info Messages
Reports (i.e. 'info' or 'errors') are now shown in the info header in place of the scene statistics if the last executed operator had some, with this info disappearing again once another operator is run (to show scene statistics again).
For example, this means that info such as the the number of verts merged, or whether a Keying Set successfully inserted keyframes, etc. is now shown again somewhere, and that this is done in a non-blocking manner.
The current implementation is still a bit crude (i.e. lacking fancy polish), but is at least barebones functional. The todos...
* When more than 1 report message is generated by the last operator, there is currently a display of the number of reports. In future, it would be nice to be able to add a button beside this or make the label clickable with appropriate text indicating this (commented out atm) to show popup menu of all the reports...
* There could probably be some kind of coloured backdrop behind the text. Currently using standard box, but that has padding problems, and lacks visual interest.
* Timer based fade out/disappear?
2010-03-02 11:48:40 +00:00
|
|
|
}
|
2009-07-21 12:57:55 +00:00
|
|
|
|
2011-10-04 13:24:48 +00:00
|
|
|
/********************************* Keymap *************************************/
|
|
|
|
|
|
|
|
static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused))
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p;
|
2011-10-04 13:24:48 +00:00
|
|
|
WM_keyconfig_update_tag(NULL, kmi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void template_keymap_item_properties(uiLayout *layout, const char *title, PointerRNA *ptr)
|
|
|
|
{
|
2013-09-20 09:10:17 +00:00
|
|
|
uiLayout *flow, *box, *row;
|
2011-10-04 13:24:48 +00:00
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (title)
|
2011-10-04 13:24:48 +00:00
|
|
|
uiItemL(layout, title, ICON_NONE);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
flow = uiLayoutColumnFlow(layout, 2, false);
|
2011-10-04 13:24:48 +00:00
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
RNA_STRUCT_BEGIN (ptr, prop)
|
|
|
|
{
|
2014-08-20 20:41:30 +02:00
|
|
|
const bool is_set = RNA_property_is_set(ptr, prop);
|
2013-09-20 09:10:17 +00:00
|
|
|
uiBut *but;
|
2011-10-04 13:24:48 +00:00
|
|
|
|
|
|
|
/* recurse for nested properties */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_property_type(prop) == PROP_POINTER) {
|
2012-03-30 01:51:25 +00:00
|
|
|
PointerRNA propptr = RNA_property_pointer_get(ptr, prop);
|
2011-10-04 13:24:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (propptr.data && RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) {
|
2013-07-09 00:13:17 +00:00
|
|
|
const char *name = RNA_property_ui_name(prop);
|
2011-10-04 13:24:48 +00:00
|
|
|
template_keymap_item_properties(layout, name, &propptr);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-20 09:10:17 +00:00
|
|
|
box = uiLayoutBox(flow);
|
|
|
|
uiLayoutSetActive(box, is_set);
|
|
|
|
row = uiLayoutRow(box, false);
|
|
|
|
|
|
|
|
/* property value */
|
|
|
|
uiItemFullR(row, ptr, prop, -1, 0, 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
if (is_set) {
|
|
|
|
/* unset operator */
|
|
|
|
uiBlock *block = uiLayoutGetBlock(row);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
|
|
|
but = uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_unset_property_button", WM_OP_EXEC_DEFAULT, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
|
2013-09-20 09:10:17 +00:00
|
|
|
but->rnapoin = *ptr;
|
|
|
|
but->rnaprop = prop;
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2013-09-20 09:10:17 +00:00
|
|
|
}
|
2011-10-04 13:24:48 +00:00
|
|
|
}
|
|
|
|
RNA_STRUCT_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PointerRNA propptr = RNA_pointer_get(ptr, "properties");
|
2011-10-04 13:24:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (propptr.data) {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *but = uiLayoutGetBlock(layout)->buttons.last;
|
2011-10-04 13:24:48 +00:00
|
|
|
|
|
|
|
template_keymap_item_properties(layout, NULL, &propptr);
|
|
|
|
|
|
|
|
/* attach callbacks to compensate for missing properties update,
|
2012-03-03 16:31:46 +00:00
|
|
|
* we don't know which keymap (item) is being modified there */
|
2013-09-10 02:49:33 +00:00
|
|
|
for (; but; but = but->next) {
|
|
|
|
/* operator buttons may store props for use (file selector, [#36492]) */
|
|
|
|
if (but->rnaprop) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, keymap_item_modified, ptr->data, NULL);
|
2013-09-10 02:49:33 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-04 13:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
/********************************* Color management *************************************/
|
|
|
|
|
|
|
|
void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
PointerRNA colorspace_settings_ptr;
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
|
|
|
|
if (!prop) {
|
|
|
|
printf("%s: property not found: %s.%s\n",
|
|
|
|
__func__, RNA_struct_identifier(ptr->type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
colorspace_settings_ptr = RNA_property_pointer_get(ptr, prop);
|
|
|
|
|
2015-02-09 23:11:30 +01:00
|
|
|
uiItemR(layout, &colorspace_settings_ptr, "name", 0, IFACE_("Color Space"), ICON_NONE);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr, const char *propname)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
PointerRNA view_transform_ptr;
|
|
|
|
uiLayout *col, *row;
|
|
|
|
ColorManagedViewSettings *view_settings;
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
|
|
|
|
if (!prop) {
|
|
|
|
printf("%s: property not found: %s.%s\n",
|
|
|
|
__func__, RNA_struct_identifier(ptr->type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
view_transform_ptr = RNA_property_pointer_get(ptr, prop);
|
|
|
|
view_settings = view_transform_ptr.data;
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
row = uiLayoutRow(col, false);
|
2014-08-08 01:30:22 +06:00
|
|
|
uiItemR(row, &view_transform_ptr, "view_transform", 0, IFACE_("View"), ICON_NONE);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE);
|
|
|
|
|
2013-09-09 14:23:58 +00:00
|
|
|
uiItemR(col, &view_transform_ptr, "look", 0, IFACE_("Look"), ICON_NONE);
|
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
col = uiLayoutColumn(layout, false);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
|
|
|
|
if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES)
|
2014-06-30 16:20:02 +02:00
|
|
|
uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', true, false, false);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
}
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/********************************* Component Menu *************************************/
|
|
|
|
|
|
|
|
typedef struct ComponentMenuArgs {
|
|
|
|
PointerRNA ptr;
|
|
|
|
char propname[64]; /* XXX arbitrary */
|
|
|
|
} ComponentMenuArgs;
|
|
|
|
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
|
|
|
|
static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v)
|
|
|
|
{
|
2013-03-18 18:25:05 +00:00
|
|
|
ComponentMenuArgs *args = (ComponentMenuArgs *)args_v;
|
2013-03-18 16:34:57 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiLayout *layout;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
|
|
|
|
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
layout = uiLayoutColumn(UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, UI_style_get()), 0);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_bounds_set_normal(block, 6);
|
|
|
|
UI_block_direction_set(block, UI_DIR_DOWN);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name)
|
|
|
|
{
|
|
|
|
ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args");
|
|
|
|
uiBlock *block;
|
2013-05-08 14:18:09 +00:00
|
|
|
uiBut *but;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
args->ptr = *ptr;
|
|
|
|
BLI_strncpy(args->propname, propname, sizeof(args->propname));
|
|
|
|
|
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2013-05-08 14:18:09 +00:00
|
|
|
but = uiDefBlockButN(block, component_menu, args, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, "");
|
|
|
|
/* set rna directly, uiDefBlockButN doesn't do this */
|
|
|
|
but->rnapoin = *ptr;
|
|
|
|
but->rnaprop = RNA_struct_find_property(ptr, propname);
|
|
|
|
but->rnaindex = 0;
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************* Node Socket Icon **************************/
|
|
|
|
|
|
|
|
void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float *color)
|
|
|
|
{
|
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but;
|
|
|
|
|
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
|
|
|
/* XXX using explicit socket colors is not quite ideal.
|
|
|
|
* Eventually it should be possible to use theme colors for this purpose,
|
|
|
|
* but this requires a better design for extendable color palettes in user prefs.
|
|
|
|
*/
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
|
2013-03-18 16:34:57 +00:00
|
|
|
rgba_float_to_uchar(but->col, color);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|