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 *****
|
|
|
|
*/
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/interface/interface_layout.c
|
|
|
|
* \ingroup edinterface
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-01-24 05:15:14 +00:00
|
|
|
#include <assert.h>
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_screen_types.h"
|
2010-12-12 18:16:54 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2009-04-27 18:05:58 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
2009-04-22 18:39:44 +00:00
|
|
|
#include "BLI_string.h"
|
2012-08-21 19:35:06 +00:00
|
|
|
#include "BLI_rect.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2012-10-24 05:06:40 +00:00
|
|
|
#include "BLI_math.h"
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2011-06-15 11:41:15 +00:00
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_idprop.h"
|
2009-03-29 19:44:39 +00:00
|
|
|
#include "BKE_screen.h"
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
2013-11-18 16:06:31 +13:00
|
|
|
#include "ED_armature.h"
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2009-04-02 01:39:33 +00:00
|
|
|
#include "interface_intern.h"
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
/************************ Structs and Defines *************************/
|
|
|
|
|
2012-01-22 19:52:41 +00:00
|
|
|
#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \
|
|
|
|
if (ot == NULL) { \
|
|
|
|
ui_item_disabled(layout, _opname); \
|
|
|
|
RNA_warning("'%s' unknown operator", _opname); \
|
|
|
|
return_statement; \
|
|
|
|
} (void)0 \
|
|
|
|
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* uiLayoutRoot */
|
|
|
|
|
|
|
|
typedef struct uiLayoutRoot {
|
|
|
|
struct uiLayoutRoot *next, *prev;
|
2009-03-13 13:38: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
|
|
|
int type;
|
|
|
|
int opcontext;
|
2009-03-13 13:38: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
|
|
|
int emw, emh;
|
2014-01-17 00:23:00 +01:00
|
|
|
int padding;
|
2009-03-13 13:38: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
|
|
|
uiMenuHandleFunc handlefunc;
|
|
|
|
void *argv;
|
2009-03-13 13:38: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
|
|
|
uiStyle *style;
|
|
|
|
uiBlock *block;
|
2009-05-19 17:13:33 +00:00
|
|
|
uiLayout *layout;
|
|
|
|
} uiLayoutRoot;
|
2009-04-22 18:39:44 +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
|
|
|
/* Item */
|
2009-04-22 18:39:44 +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
|
|
|
typedef enum uiItemType {
|
|
|
|
ITEM_BUTTON,
|
2009-03-13 13:38: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
|
|
|
ITEM_LAYOUT_ROW,
|
|
|
|
ITEM_LAYOUT_COLUMN,
|
|
|
|
ITEM_LAYOUT_COLUMN_FLOW,
|
|
|
|
ITEM_LAYOUT_ROW_FLOW,
|
|
|
|
ITEM_LAYOUT_BOX,
|
2009-10-09 10:45:11 +00:00
|
|
|
ITEM_LAYOUT_ABSOLUTE,
|
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
|
|
|
ITEM_LAYOUT_SPLIT,
|
2009-10-21 20:58:10 +00:00
|
|
|
ITEM_LAYOUT_OVERLAP,
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
ITEM_LAYOUT_RADIAL,
|
2009-03-13 13:38: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
|
|
|
ITEM_LAYOUT_ROOT
|
|
|
|
#if 0
|
2009-04-11 01:52:27 +00:00
|
|
|
TEMPLATE_COLUMN_FLOW,
|
2009-04-16 12:17:58 +00:00
|
|
|
TEMPLATE_SPLIT,
|
|
|
|
TEMPLATE_BOX,
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
TEMPLATE_HEADER,
|
2009-03-13 13:38:41 +00:00
|
|
|
TEMPLATE_HEADER_ID
|
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
|
|
|
#endif
|
|
|
|
} uiItemType;
|
2009-03-13 13:38: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
|
|
|
typedef struct uiItem {
|
|
|
|
void *next, *prev;
|
|
|
|
uiItemType type;
|
2009-06-03 00:04:48 +00:00
|
|
|
int flag;
|
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
|
|
|
} uiItem;
|
|
|
|
|
2017-01-10 16:19:10 +01:00
|
|
|
enum {
|
|
|
|
UI_ITEM_FIXED = 1 << 0,
|
|
|
|
UI_ITEM_MIN = 1 << 1,
|
2017-07-27 10:27:29 +03:00
|
|
|
|
|
|
|
UI_ITEM_BOX_ITEM = 1 << 2, /* The item is "inside" a box item */
|
2017-01-10 16:19:10 +01: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
|
|
|
typedef struct uiButtonItem {
|
|
|
|
uiItem item;
|
|
|
|
uiBut *but;
|
|
|
|
} uiButtonItem;
|
|
|
|
|
|
|
|
struct uiLayout {
|
|
|
|
uiItem item;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
uiLayoutRoot *root;
|
2009-05-28 23:13:42 +00:00
|
|
|
bContextStore *context;
|
2009-03-13 13:38:41 +00:00
|
|
|
ListBase items;
|
|
|
|
|
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
|
|
|
int x, y, w, h;
|
2009-06-03 00:04:48 +00:00
|
|
|
float scale[2];
|
2009-05-28 23:37:55 +00:00
|
|
|
short space;
|
2013-04-04 02:05:11 +00:00
|
|
|
bool align;
|
|
|
|
bool active;
|
|
|
|
bool enabled;
|
|
|
|
bool redalert;
|
|
|
|
bool keepaspect;
|
2009-05-28 23:37:55 +00:00
|
|
|
char alignment;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct uiLayoutItemFlow {
|
|
|
|
uiLayout litem;
|
2009-04-16 12:17:58 +00:00
|
|
|
int number;
|
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
|
|
|
int totcol;
|
|
|
|
} uiLayoutItemFlow;
|
2009-04-11 01:52: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
|
|
|
typedef struct uiLayoutItemBx {
|
|
|
|
uiLayout litem;
|
2009-05-21 15:34:09 +00:00
|
|
|
uiBut *roundbox;
|
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
|
|
|
} uiLayoutItemBx;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2011-07-26 20:22:54 +00:00
|
|
|
typedef struct uiLayoutItemSplit {
|
2009-06-07 13:20:41 +00:00
|
|
|
uiLayout litem;
|
|
|
|
float percentage;
|
2011-07-26 20:22:54 +00:00
|
|
|
} uiLayoutItemSplit;
|
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
|
|
|
typedef struct uiLayoutItemRoot {
|
|
|
|
uiLayout litem;
|
|
|
|
} uiLayoutItemRoot;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
/************************** Item ***************************/
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_NAME_STR])
|
2009-04-27 18:05:58 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
int len = strlen(name);
|
2009-04-27 18:05:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (len != 0 && len + 1 < UI_MAX_NAME_STR) {
|
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
|
|
|
BLI_strncpy(namestr, name, UI_MAX_NAME_STR);
|
2012-03-30 01:51:25 +00:00
|
|
|
namestr[len] = ':';
|
|
|
|
namestr[len + 1] = '\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
|
|
|
return namestr;
|
2009-04-27 18:05:58 +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
|
|
|
|
|
|
|
return name;
|
2009-04-27 18:05:58 +00:00
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2017-02-25 13:18:41 +03:00
|
|
|
static int ui_item_fit(int item, int pos, int all, int available, bool is_last, int alignment, float *extra_pixel)
|
2009-03-13 13:38: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
|
|
|
/* available == 0 is unlimited */
|
2017-07-28 10:56:41 +02:00
|
|
|
if (ELEM(0, available, all)) {
|
2009-06-03 00:04:48 +00:00
|
|
|
return item;
|
2017-07-28 10:56:41 +02:00
|
|
|
}
|
2012-12-24 14:21:14 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (all > available) {
|
2009-04-16 12:17:58 +00:00
|
|
|
/* contents is bigger than available space */
|
2015-02-13 11:43:28 +11:00
|
|
|
if (is_last)
|
2012-03-30 01:51:25 +00:00
|
|
|
return available - pos;
|
2017-02-25 13:18:41 +03:00
|
|
|
else {
|
|
|
|
float width = *extra_pixel + (item * available) / (float)all;
|
|
|
|
*extra_pixel = width - (int)width;
|
|
|
|
return (int)width;
|
|
|
|
}
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* contents is smaller or equal to available space */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (alignment == UI_LAYOUT_ALIGN_EXPAND) {
|
2015-02-13 11:43:28 +11:00
|
|
|
if (is_last)
|
2012-03-30 01:51:25 +00:00
|
|
|
return available - pos;
|
2017-02-25 13:18:41 +03:00
|
|
|
else {
|
|
|
|
float width = *extra_pixel + (item * available) / (float)all;
|
|
|
|
*extra_pixel = width - (int)width;
|
|
|
|
return (int)width;
|
|
|
|
}
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
2017-07-28 10:56:41 +02:00
|
|
|
else {
|
2009-04-16 12:17:58 +00:00
|
|
|
return item;
|
2017-07-28 10:56:41 +02:00
|
|
|
}
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
2009-03-13 13:38: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
|
|
|
/* variable button size in which direction? */
|
2012-03-30 01:51:25 +00:00
|
|
|
#define UI_ITEM_VARY_X 1
|
|
|
|
#define UI_ITEM_VARY_Y 2
|
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
|
|
|
|
2015-02-13 09:10:53 +01:00
|
|
|
static int ui_layout_vary_direction(uiLayout *layout)
|
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
|
|
|
{
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
return ((ELEM(layout->root->type, UI_LAYOUT_HEADER, UI_LAYOUT_PIEMENU) ||
|
|
|
|
(layout->alignment != UI_LAYOUT_ALIGN_EXPAND)) ?
|
|
|
|
UI_ITEM_VARY_X : UI_ITEM_VARY_Y);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* estimated size of text + icon */
|
2014-02-27 15:50:30 +11:00
|
|
|
static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool compact)
|
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
|
|
|
{
|
2014-02-27 15:50:30 +11:00
|
|
|
bool variable;
|
2018-04-27 19:57:58 +02:00
|
|
|
const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
|
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 (icon && !name[0])
|
2018-04-27 19:57:58 +02:00
|
|
|
return unit_x; /* icon only */
|
2014-02-27 15:50:30 +11:00
|
|
|
|
|
|
|
variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X);
|
|
|
|
|
|
|
|
if (variable) {
|
2017-08-11 13:18:30 +03:00
|
|
|
if (layout->alignment != UI_LAYOUT_ALIGN_EXPAND) {
|
|
|
|
layout->item.flag |= UI_ITEM_MIN;
|
|
|
|
}
|
2015-01-20 14:25:39 +11:00
|
|
|
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
|
2018-04-27 19:57:58 +02:00
|
|
|
/* it may seem odd that the icon only adds (unit_x / 4)
|
2014-02-27 15:50:30 +11:00
|
|
|
* but taking margins into account its fine */
|
2015-01-20 14:25:39 +11:00
|
|
|
return (UI_fontstyle_string_width(fstyle, name) +
|
2018-04-27 19:57:58 +02:00
|
|
|
(unit_x * ((compact ? 1.25f : 1.50f) +
|
|
|
|
(icon ? 0.25f : 0.0f))));
|
2014-02-27 15:50:30 +11:00
|
|
|
}
|
|
|
|
else {
|
2018-04-27 19:57:58 +02:00
|
|
|
return unit_x * 10;
|
2014-02-27 15:50:30 +11: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
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_item_size(uiItem *item, int *r_w, int *r_h)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type == ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiButtonItem *bitem = (uiButtonItem *)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-09-15 11:48:20 +00:00
|
|
|
if (r_w) *r_w = BLI_rctf_size_x(&bitem->but->rect);
|
|
|
|
if (r_h) *r_h = BLI_rctf_size_y(&bitem->but->rect);
|
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
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayout *litem = (uiLayout *)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
|
|
|
if (r_w) *r_w = litem->w;
|
|
|
|
if (r_h) *r_h = litem->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_item_offset(uiItem *item, int *r_x, int *r_y)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type == ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiButtonItem *bitem = (uiButtonItem *)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-08-18 16:53:46 +00:00
|
|
|
if (r_x) *r_x = bitem->but->rect.xmin;
|
|
|
|
if (r_y) *r_y = bitem->but->rect.ymin;
|
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
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (r_x) *r_x = 0;
|
|
|
|
if (r_y) *r_y = 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_item_position(uiItem *item, int x, int y, int w, int h)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type == ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiButtonItem *bitem = (uiButtonItem *)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-08-18 16:53:46 +00:00
|
|
|
bitem->but->rect.xmin = x;
|
|
|
|
bitem->but->rect.ymin = y;
|
|
|
|
bitem->but->rect.xmax = x + w;
|
|
|
|
bitem->but->rect.ymax = y + h;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_update(bitem->but); /* for strlen */
|
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
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayout *litem = (uiLayout *)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
|
|
|
litem->x = x;
|
|
|
|
litem->y = y + h;
|
|
|
|
litem->w = w;
|
|
|
|
litem->h = 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-25 13:18:41 +03:00
|
|
|
static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax)
|
|
|
|
{
|
|
|
|
if (item->type == ITEM_BUTTON) {
|
|
|
|
uiButtonItem *bitem = (uiButtonItem *)item;
|
|
|
|
|
|
|
|
bitem->but->rect.xmin += delta_xmin;
|
|
|
|
bitem->but->rect.xmax += delta_xmax;
|
|
|
|
|
|
|
|
ui_but_update(bitem->but); /* for strlen */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uiLayout *litem = (uiLayout *)item;
|
|
|
|
|
|
|
|
if (delta_xmin > 0)
|
|
|
|
litem->x += delta_xmin;
|
|
|
|
else
|
|
|
|
litem->w += delta_xmax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/******************** Special RNA Items *********************/
|
|
|
|
|
|
|
|
static int ui_layout_local_dir(uiLayout *layout)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (layout->item.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
|
|
|
case ITEM_LAYOUT_ROW:
|
|
|
|
case ITEM_LAYOUT_ROOT:
|
2009-10-21 20:58:10 +00:00
|
|
|
case ITEM_LAYOUT_OVERLAP:
|
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 UI_LAYOUT_HORIZONTAL;
|
|
|
|
case ITEM_LAYOUT_COLUMN:
|
|
|
|
case ITEM_LAYOUT_COLUMN_FLOW:
|
|
|
|
case ITEM_LAYOUT_SPLIT:
|
2009-10-09 10:45:11 +00:00
|
|
|
case ITEM_LAYOUT_ABSOLUTE:
|
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
|
|
|
case ITEM_LAYOUT_BOX:
|
|
|
|
default:
|
|
|
|
return UI_LAYOUT_VERTICAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int align)
|
|
|
|
{
|
|
|
|
uiLayout *sub;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ui_layout_local_dir(test) == UI_LAYOUT_HORIZONTAL)
|
2012-03-30 01:51:25 +00:00
|
|
|
sub = uiLayoutRow(layout, align);
|
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
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
sub = uiLayoutColumn(layout, align);
|
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
|
|
|
sub->space = 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
|
|
|
return sub;
|
|
|
|
}
|
|
|
|
|
2009-09-09 17:39:19 +00:00
|
|
|
static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
uiBut *but = arg_but, *cbut;
|
|
|
|
PointerRNA *ptr = &but->rnapoin;
|
|
|
|
PropertyRNA *prop = but->rnaprop;
|
|
|
|
int i, index = GET_INT_FROM_POINTER(arg_index);
|
|
|
|
int shift = win->eventstate->shift;
|
|
|
|
int len = RNA_property_array_length(ptr, prop);
|
2009-09-09 17:39:19 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!shift) {
|
2014-01-04 17:16:19 +11:00
|
|
|
RNA_property_boolean_set_index(ptr, prop, index, true);
|
2009-09-09 17:39:19 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (i = 0; i < len; i++)
|
2012-03-24 06:38:07 +00:00
|
|
|
if (i != index)
|
2009-09-09 17:39:19 +00:00
|
|
|
RNA_property_boolean_set_index(ptr, prop, i, 0);
|
|
|
|
|
|
|
|
RNA_property_update(C, ptr, prop);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (cbut = but->block->buttons.first; cbut; cbut = cbut->next)
|
2014-11-09 21:20:40 +01:00
|
|
|
ui_but_update(cbut);
|
2009-09-09 17:39:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
/* create buttons for an item with an RNA array */
|
2015-05-05 03:13:47 +10:00
|
|
|
static void ui_item_array(
|
|
|
|
uiLayout *layout, uiBlock *block, const char *name, int icon,
|
|
|
|
PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h),
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
bool expand, bool slider, bool toggle, bool icon_only, bool compact)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiStyle *style = layout->root->style;
|
2009-05-19 17:13:33 +00:00
|
|
|
uiBut *but;
|
2009-03-13 13:38:41 +00:00
|
|
|
PropertyType type;
|
|
|
|
PropertySubType subtype;
|
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
|
|
|
uiLayout *sub;
|
2013-08-04 00:01:41 +00:00
|
|
|
unsigned int a, b;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
/* retrieve type and subtype */
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_type(prop);
|
|
|
|
subtype = RNA_property_subtype(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
|
|
|
sub = ui_item_local_sublayout(layout, layout, 1);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, sub);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
/* create label */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (name[0])
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
|
2009-03-13 13:38:41 +00:00
|
|
|
|
|
|
|
/* create buttons */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) {
|
2009-03-13 13:38:41 +00:00
|
|
|
/* special check for layer layout */
|
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
|
|
|
int butw, buth, unit;
|
2012-03-30 01:51:25 +00:00
|
|
|
int cols = (len >= 20) ? 2 : 1;
|
2013-08-04 00:01:41 +00:00
|
|
|
const unsigned int colbuts = len / (2 * cols);
|
|
|
|
unsigned int layer_used = 0;
|
2013-11-18 16:06:31 +13:00
|
|
|
unsigned int layer_active = 0;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, false));
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
unit = UI_UNIT_X * 0.75;
|
|
|
|
butw = unit;
|
|
|
|
buth = unit;
|
2011-08-14 11:38:17 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr->type == &RNA_Armature) {
|
2012-03-30 01:51:25 +00:00
|
|
|
bArmature *arm = (bArmature *)ptr->data;
|
2013-11-18 16:06:31 +13:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
layer_used = arm->layer_used;
|
2013-11-18 16:06:31 +13:00
|
|
|
|
2013-11-22 10:36:35 +11:00
|
|
|
if (arm->edbo) {
|
|
|
|
if (arm->act_edbone) {
|
|
|
|
layer_active |= arm->act_edbone->layer;
|
|
|
|
}
|
2013-11-18 16:06:31 +13:00
|
|
|
}
|
2013-11-22 10:36:35 +11:00
|
|
|
else {
|
|
|
|
if (arm->act_bone) {
|
|
|
|
layer_active |= arm->act_bone->layer;
|
|
|
|
}
|
2013-11-18 16:06:31 +13:00
|
|
|
}
|
2010-12-12 18:16:54 +00:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (b = 0; b < cols; b++) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2009-09-09 17:39:19 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < colbuts; a++) {
|
2014-05-01 05:57:01 +10:00
|
|
|
const int layer_num = a + b * colbuts;
|
|
|
|
const unsigned int layer_flag = (1u << layer_num);
|
2013-11-18 15:53:46 +13:00
|
|
|
|
2013-11-18 16:06:31 +13:00
|
|
|
if (layer_used & layer_flag) {
|
|
|
|
if (layer_active & layer_flag)
|
|
|
|
icon = ICON_LAYER_ACTIVE;
|
|
|
|
else
|
|
|
|
icon = ICON_LAYER_USED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
icon = ICON_BLANK1;
|
|
|
|
}
|
2009-09-09 17:39:19 +00:00
|
|
|
|
2013-11-18 15:53:46 +13:00
|
|
|
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (subtype == PROP_LAYER_MEMBER)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
|
2009-09-09 17:39:19 +00:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < colbuts; a++) {
|
2014-05-01 05:57:01 +10:00
|
|
|
const int layer_num = a + len / 2 + b * colbuts;
|
|
|
|
const unsigned int layer_flag = (1u << layer_num);
|
2013-11-18 15:53:46 +13:00
|
|
|
|
2013-11-18 16:06:31 +13:00
|
|
|
if (layer_used & layer_flag) {
|
|
|
|
if (layer_active & layer_flag)
|
|
|
|
icon = ICON_LAYER_ACTIVE;
|
|
|
|
else
|
|
|
|
icon = ICON_LAYER_USED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
icon = ICON_BLANK1;
|
|
|
|
}
|
2011-08-14 10:17:41 +00:00
|
|
|
|
2013-11-18 15:53:46 +13:00
|
|
|
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (subtype == PROP_LAYER_MEMBER)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
|
2009-09-09 17:39:19 +00:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2009-09-09 17:39:19 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
x += colbuts * butw + style->buttonspacex;
|
2009-09-09 17:39:19 +00:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (subtype == PROP_MATRIX) {
|
2012-03-30 01:51:25 +00:00
|
|
|
int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */
|
2009-03-13 13:38:41 +00:00
|
|
|
int row, col;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, true));
|
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
|
|
|
totdim = RNA_property_array_dimension(ptr, prop, dim_size);
|
|
|
|
if (totdim != 2) return; /* only 2D matrices supported in UI so far */
|
2010-01-06 01:41:00 +00:00
|
|
|
|
|
|
|
w /= dim_size[0];
|
2011-09-12 00:00:21 +00:00
|
|
|
/* h /= dim_size[1]; */ /* UNUSED */
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < len; a++) {
|
|
|
|
col = a % dim_size[0];
|
|
|
|
row = a / dim_size[0];
|
|
|
|
|
|
|
|
but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w * col, y + (dim_size[1] * UI_UNIT_Y) - (row * UI_UNIT_Y), w, UI_UNIT_Y);
|
2014-11-09 21:20:40 +01:00
|
|
|
if (slider && but->type == UI_BTYPE_NUM)
|
|
|
|
but->type = UI_BTYPE_NUM_SLIDER;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-17 16:11:02 +00:00
|
|
|
else if (subtype == PROP_DIRECTION && !expand) {
|
2014-11-15 18:18:47 +01:00
|
|
|
uiDefButR_prop(block, UI_BTYPE_UNITVEC, 0, name, x, y, UI_UNIT_X * 3, UI_UNIT_Y * 3, ptr, prop, -1, 0, 0, -1, -1, NULL);
|
2011-05-19 11:18:09 +00:00
|
|
|
}
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
else {
|
2011-08-14 11:38:17 +00:00
|
|
|
/* note, this block of code is a bit arbitrary and has just been made
|
|
|
|
* to work with common cases, but may need to be re-worked */
|
|
|
|
|
|
|
|
/* special case, boolean array in a menu, this could be used in a more generic way too */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y);
|
2011-08-14 11:38:17 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
int *boolarr = NULL;
|
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-08-14 11:38:17 +00:00
|
|
|
/* even if 'expand' is fale, expanding anyway */
|
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
|
|
|
|
|
|
|
/* layout for known array subtypes */
|
2012-03-30 01:51:25 +00:00
|
|
|
char str[3] = {'\0'};
|
RNA: subtypes and units
* Reviewed subtypes, making them more specific and adding new ones.
* Subtypes now have an associated type of units (length, area, volume,
mass, rotation, time, velocity, acceleration). These are not used
yet anywhere.
* Centralized code that decides the name of array items based on
subtype (XYZ, RGB), was copied in 3 places.
* RNA_def_float etc functions still need to be update, will do this
later together with another change.
2009-08-10 21:31:05 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!icon_only) {
|
|
|
|
if (type != PROP_BOOLEAN) {
|
2012-03-30 01:51:25 +00:00
|
|
|
str[1] = ':';
|
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-08-14 11:38:17 +00:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2011-08-14 11:38:17 +00:00
|
|
|
/* show checkboxes for rna on a non-emboss block (menu for eg) */
|
2014-11-09 21:20:40 +01:00
|
|
|
if (type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
|
2015-02-13 11:43:28 +11:00
|
|
|
boolarr = MEM_callocN(sizeof(int) * len, __func__);
|
2011-08-14 11:38:17 +00:00
|
|
|
RNA_property_boolean_get_array(ptr, prop, boolarr);
|
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; a < len; a++) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
int width_item;
|
|
|
|
|
|
|
|
if (!icon_only) {
|
|
|
|
str[0] = RNA_property_array_item_char(prop, a);
|
|
|
|
}
|
|
|
|
if (boolarr) {
|
|
|
|
icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
|
|
|
}
|
|
|
|
width_item = (compact && type == PROP_BOOLEAN) ?
|
|
|
|
min_ii(w, ui_text_icon_width(layout, str, icon, false)) : w;
|
|
|
|
|
|
|
|
but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, width_item, UI_UNIT_Y);
|
2014-11-09 21:20:40 +01:00
|
|
|
if (slider && but->type == UI_BTYPE_NUM)
|
|
|
|
but->type = UI_BTYPE_NUM_SLIDER;
|
|
|
|
if (toggle && but->type == UI_BTYPE_CHECKBOX)
|
|
|
|
but->type = UI_BTYPE_TOGGLE;
|
2013-09-03 06:27:03 +00:00
|
|
|
if ((a == 0) && (subtype == PROP_AXISANGLE))
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_unit_type_set(but, PROP_UNIT_ROTATION);
|
2009-03-25 20:49:15 +00:00
|
|
|
}
|
2011-08-14 11:38:17 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (boolarr) {
|
2011-08-14 11:38:17 +00:00
|
|
|
MEM_freeN(boolarr);
|
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2)
|
|
|
|
{
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
|
|
|
if (!win->eventstate->shift) {
|
|
|
|
uiBut *but = (uiBut *)arg1;
|
|
|
|
int enum_value = GET_INT_FROM_POINTER(arg2);
|
|
|
|
|
|
|
|
int current_value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
|
|
|
|
if (!(current_value & enum_value)) {
|
|
|
|
current_value = enum_value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
current_value &= enum_value;
|
|
|
|
}
|
|
|
|
RNA_property_enum_set(&but->rnapoin, but->rnaprop, current_value);
|
|
|
|
}
|
|
|
|
}
|
2015-05-05 03:13:47 +10:00
|
|
|
static void ui_item_enum_expand(
|
|
|
|
uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop,
|
|
|
|
const char *uiname, int h, bool icon_only)
|
2009-04-16 12:17:58 +00:00
|
|
|
{
|
2013-10-12 11:28:37 +00:00
|
|
|
/* XXX The way this function currently handles uiname parameter is insane and inconsistent with general UI API:
|
|
|
|
* * uiname is the *enum property* label.
|
|
|
|
* * when it is NULL or empty, we do not draw *enum items* labels, this doubles the icon_only parameter.
|
|
|
|
* * we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
|
|
|
|
* Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/
|
|
|
|
* --mont29
|
|
|
|
*/
|
|
|
|
|
2010-06-26 20:00:45 +00:00
|
|
|
uiBut *but;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
uiLayout *layout_radial = NULL;
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item, *item_array;
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *name;
|
2014-01-04 18:08:43 +11:00
|
|
|
int itemw, icon, value;
|
|
|
|
bool free;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
if (radial)
|
|
|
|
RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free);
|
|
|
|
else
|
|
|
|
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free);
|
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
|
|
|
|
2013-01-17 01:03:56 +00:00
|
|
|
/* we dont want nested rows, cols in menus */
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
if (radial) {
|
2016-12-08 11:53:48 +01:00
|
|
|
if (layout->root->layout == layout) {
|
|
|
|
layout_radial = uiLayoutRadial(layout);
|
|
|
|
UI_block_layout_set_current(block, layout_radial);
|
|
|
|
}
|
|
|
|
else {
|
2017-01-24 21:35:38 +01:00
|
|
|
if (layout->item.type == ITEM_LAYOUT_RADIAL) {
|
|
|
|
layout_radial = layout;
|
|
|
|
}
|
2016-12-08 11:53:48 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
|
|
|
}
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
else if (layout->root->type != UI_LAYOUT_MENU) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, ui_item_local_sublayout(layout, layout, 1));
|
2013-01-17 01:03:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2013-01-17 01:03:56 +00:00
|
|
|
}
|
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
for (item = item_array; item->identifier; item++) {
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
if (!item->identifier[0]) {
|
2017-01-24 21:35:38 +01:00
|
|
|
if (radial && layout_radial) {
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
uiItemS(layout_radial);
|
2017-01-24 21:35:38 +01:00
|
|
|
}
|
2009-07-10 11:36:02 +00:00
|
|
|
continue;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
2009-07-10 11:36:02 +00:00
|
|
|
|
2013-10-12 11:28:37 +00:00
|
|
|
name = (!uiname || uiname[0]) ? item->name : "";
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
icon = item->icon;
|
|
|
|
value = item->value;
|
2013-06-19 15:08:07 +00:00
|
|
|
itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0);
|
2009-06-16 01:08:39 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon && name[0] && !icon_only)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButR_prop(block, UI_BTYPE_ROW, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
2009-06-16 01:08:39 +00:00
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
2010-06-26 20:00:45 +00:00
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, ui_item_enum_expand_handle, but, SET_INT_IN_POINTER(value));
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL)
|
2013-11-21 14:43:08 +01:00
|
|
|
but->drawflag |= UI_BUT_TEXT_LEFT;
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
|
2012-01-21 22:00:40 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item_array);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
/* callback for keymap item change button */
|
2010-10-14 12:24:08 +00:00
|
|
|
static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_v))
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *but = but_v;
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
2009-12-24 09:26:06 +00:00
|
|
|
RNA_boolean_set(&but->rnapoin, "shift", (but->modifier_key & KM_SHIFT) != 0);
|
|
|
|
RNA_boolean_set(&but->rnapoin, "ctrl", (but->modifier_key & KM_CTRL) != 0);
|
|
|
|
RNA_boolean_set(&but->rnapoin, "alt", (but->modifier_key & KM_ALT) != 0);
|
|
|
|
RNA_boolean_set(&but->rnapoin, "oskey", (but->modifier_key & KM_OSKEY) != 0);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
/**
|
|
|
|
* Create label + button for RNA property
|
|
|
|
*
|
|
|
|
* \param w_hint: For varying width layout, this becomes the label width.
|
|
|
|
* Otherwise it's used to fit both items into it.
|
|
|
|
**/
|
|
|
|
static uiBut *ui_item_with_label(
|
|
|
|
uiLayout *layout, uiBlock *block, const char *name, int icon,
|
|
|
|
PointerRNA *ptr, PropertyRNA *prop, int index,
|
|
|
|
int x, int y, int w_hint, int h, int flag)
|
2009-03-13 13:38: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
|
|
|
uiLayout *sub;
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *but = NULL;
|
2009-09-16 18:47:42 +00:00
|
|
|
PropertyType 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
|
|
|
PropertySubType subtype;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
int prop_but_width = w_hint;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2013-08-23 16:53:37 +00:00
|
|
|
sub = uiLayoutRow(layout, layout->align);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, sub);
|
2009-03-30 18:26:58 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (name[0]) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
int w_label;
|
|
|
|
|
|
|
|
if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
|
|
|
|
/* w_hint is width for label in this case. Use a default width for property button(s) */
|
|
|
|
prop_but_width = UI_UNIT_X * 5;
|
|
|
|
w_label = w_hint;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
w_label = w_hint / 3;
|
|
|
|
}
|
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_type(prop);
|
|
|
|
subtype = RNA_property_subtype(prop);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
|
2009-07-28 18:51:06 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
/* BUTTONS_OT_file_browse calls UI_context_active_but_prop_get_filebrowser */
|
|
|
|
uiDefIconButO(block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse",
|
2013-11-23 18:43:23 +01:00
|
|
|
WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (flag & UI_ITEM_R_EVENT) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, prop_but_width, h, ptr, prop, index, 0, 0, -1, -1, NULL);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (flag & UI_ITEM_R_FULL_EVENT) {
|
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
char buf[128];
|
|
|
|
|
2017-11-06 00:04:46 +11:00
|
|
|
WM_keymap_item_to_string(ptr->data, false, buf, sizeof(buf));
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, prop_but_width, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
|
2009-12-24 09:26:06 +00:00
|
|
|
if (flag & UI_ITEM_R_IMMEDIATE)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_IMMEDIATE);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
else {
|
|
|
|
const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "";
|
|
|
|
but = uiDefAutoButR(block, ptr, prop, index, str, icon,
|
|
|
|
x, y, prop_but_width, h);
|
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-06-27 01:15:31 +00:00
|
|
|
return but;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-09 17:17:22 +10:00
|
|
|
void UI_context_active_but_prop_get_filebrowser(
|
|
|
|
const bContext *C,
|
|
|
|
PointerRNA *r_ptr, PropertyRNA **r_prop, bool *r_is_undo)
|
2009-07-28 18:51:06 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2009-07-28 18:51:06 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiBut *but, *prevbut;
|
|
|
|
|
2015-06-09 17:17:22 +10:00
|
|
|
memset(r_ptr, 0, sizeof(*r_ptr));
|
|
|
|
*r_prop = NULL;
|
|
|
|
*r_is_undo = false;
|
2009-07-28 18:51:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ar)
|
2009-07-28 18:51:06 +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) {
|
|
|
|
prevbut = but->prev;
|
2009-07-28 18:51:06 +00:00
|
|
|
|
|
|
|
/* find the button before the active one */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((but->flag & UI_BUT_LAST_ACTIVE) && prevbut && prevbut->rnapoin.data) {
|
|
|
|
if (RNA_property_type(prevbut->rnaprop) == PROP_STRING) {
|
2015-06-09 17:17:22 +10:00
|
|
|
*r_ptr = prevbut->rnapoin;
|
|
|
|
*r_prop = prevbut->rnaprop;
|
|
|
|
*r_is_undo = (prevbut->flag & UI_BUT_UNDO) != 0;
|
2009-07-28 18:51:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/********************* Button Items *************************/
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2013-02-05 05:39:18 +00:00
|
|
|
/**
|
|
|
|
* Update a buttons tip with an enum's description if possible.
|
|
|
|
*/
|
2016-02-16 14:50:26 +01:00
|
|
|
static void ui_but_tip_from_enum_item(uiBut *but, const EnumPropertyItem *item)
|
2013-02-05 05:39:18 +00:00
|
|
|
{
|
|
|
|
if (but->tip == NULL || but->tip[0] == '\0') {
|
|
|
|
if (item->description && item->description[0]) {
|
|
|
|
but->tip = item->description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
/* disabled item */
|
2010-11-17 09:45:45 +00:00
|
|
|
static void ui_item_disabled(uiLayout *layout, const char *name)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->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
|
|
|
uiBut *but;
|
|
|
|
int w;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-03-30 01:51:25 +00:00
|
|
|
name = "";
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
w = ui_text_icon_width(layout, name, 0, 0);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 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
|
|
|
but->flag |= UI_BUT_DISABLED;
|
2016-09-19 02:25:59 +02:00
|
|
|
but->disabled_info = "";
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
/**
|
|
|
|
* Operator Item
|
|
|
|
* \param r_opptr: Optional, initialize with operator properties when not NULL.
|
|
|
|
* Will always be written to even in the case of errors.
|
|
|
|
*/
|
2017-11-02 04:30:07 +11:00
|
|
|
static uiBut *uiItemFullO_ptr_ex(
|
2017-10-31 16:58:26 +11:00
|
|
|
uiLayout *layout, wmOperatorType *ot,
|
|
|
|
const char *name, int icon, IDProperty *properties, int context, int flag,
|
|
|
|
PointerRNA *r_opptr)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2017-10-31 16:58:26 +11:00
|
|
|
/* Take care to fill 'r_opptr' whatever happens. */
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->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
|
|
|
uiBut *but;
|
|
|
|
int w;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name) {
|
2014-01-30 15:28:39 +11:00
|
|
|
if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0)
|
2012-03-16 15:39:25 +00:00
|
|
|
name = RNA_struct_ui_name(ot->srna);
|
|
|
|
else
|
|
|
|
name = "";
|
2011-09-15 13:20:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
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
|
|
|
|
|
|
|
/* create button */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
w = ui_text_icon_width(layout, name, icon, 0);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2010-06-26 20:00:45 +00:00
|
|
|
if (flag & UI_ITEM_R_NO_BG)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2010-06-26 20:00:45 +00:00
|
|
|
|
2012-01-22 03:30:07 +00:00
|
|
|
/* create the button */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon) {
|
2012-01-22 03:30:07 +00:00
|
|
|
if (name[0]) {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextButO_ptr(block, UI_BTYPE_BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL);
|
2012-01-22 03:30:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconButO_ptr(block, UI_BTYPE_BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL);
|
2012-01-22 03:30:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL);
|
2012-01-22 03:30:07 +00:00
|
|
|
}
|
2011-01-24 05:15:14 +00:00
|
|
|
|
|
|
|
assert(but->optype != NULL);
|
|
|
|
|
2009-11-23 09:47:56 +00:00
|
|
|
/* text alignment for toolbar buttons */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon)
|
2013-11-21 14:43:08 +01:00
|
|
|
but->drawflag |= UI_BUT_TEXT_LEFT;
|
2010-06-26 20:00:45 +00:00
|
|
|
|
|
|
|
if (flag & UI_ITEM_R_NO_BG)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2011-06-05 17:02:57 +00:00
|
|
|
|
2017-11-02 05:00:09 +11:00
|
|
|
if (flag & UI_ITEM_O_DEPRESS) {
|
2017-11-03 00:45:30 +11:00
|
|
|
but->flag |= UI_SELECT_DRAW;
|
2017-11-02 05:00:09 +11:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->redalert)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
2010-06-26 20:00:45 +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
|
|
|
/* assign properties */
|
2017-10-31 16:58:26 +11:00
|
|
|
if (properties || r_opptr) {
|
2014-11-09 21:20:40 +01:00
|
|
|
PointerRNA *opptr = UI_but_operator_ptr_get(but);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (properties) {
|
2012-03-30 01:51:25 +00:00
|
|
|
opptr->data = properties;
|
2009-08-21 12:57:47 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
IDPropertyTemplate val = {0};
|
2012-03-30 01:51:25 +00:00
|
|
|
opptr->data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
|
2009-08-21 12:57:47 +00:00
|
|
|
}
|
2017-10-31 16:58:26 +11:00
|
|
|
if (r_opptr) {
|
|
|
|
*r_opptr = *opptr;
|
|
|
|
}
|
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
|
|
|
}
|
2017-11-02 04:30:07 +11:00
|
|
|
|
|
|
|
return but;
|
|
|
|
}
|
|
|
|
|
2017-11-02 23:43:51 +11:00
|
|
|
static void ui_item_menu_hold(struct bContext *C, ARegion *butregion, uiBut *but)
|
2017-11-02 04:30:07 +11:00
|
|
|
{
|
|
|
|
uiPopupMenu *pup = UI_popup_menu_begin(C, "", ICON_NONE);
|
|
|
|
uiLayout *layout = UI_popup_menu_layout(pup);
|
|
|
|
uiBlock *block = layout->root->block;
|
|
|
|
UI_popup_menu_but_set(pup, butregion, but);
|
|
|
|
|
|
|
|
block->flag |= UI_BLOCK_POPUP_HOLD;
|
2017-11-02 23:43:51 +11:00
|
|
|
block->flag |= UI_BLOCK_IS_FLIP;
|
2018-04-25 20:41:26 +02:00
|
|
|
|
|
|
|
char direction = UI_DIR_DOWN;
|
|
|
|
if (!but->drawstr[0]) {
|
|
|
|
if (butregion->alignment == RGN_ALIGN_LEFT) {
|
|
|
|
direction = UI_DIR_RIGHT;
|
|
|
|
}
|
|
|
|
else if (butregion->alignment == RGN_ALIGN_RIGHT) {
|
|
|
|
direction = UI_DIR_LEFT;
|
|
|
|
}
|
|
|
|
else if (butregion->alignment == RGN_ALIGN_BOTTOM) {
|
|
|
|
direction = UI_DIR_UP;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
direction = UI_DIR_DOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UI_block_direction_set(block, direction);
|
2017-11-02 04:30:07 +11:00
|
|
|
|
|
|
|
const char *menu_id = but->hold_argN;
|
|
|
|
MenuType *mt = WM_menutype_find(menu_id, true);
|
|
|
|
if (mt) {
|
2017-11-02 18:19:11 +11:00
|
|
|
uiLayoutSetContextFromBut(layout, but);
|
|
|
|
UI_menutype_draw(C, mt, layout);
|
2017-11-02 04:30:07 +11:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
uiItemL(layout, "Menu Missing:", ICON_NONE);
|
|
|
|
uiItemL(layout, menu_id, ICON_NONE);
|
|
|
|
}
|
|
|
|
UI_popup_menu_end(C, pup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiItemFullO_ptr(
|
|
|
|
uiLayout *layout, wmOperatorType *ot,
|
|
|
|
const char *name, int icon, IDProperty *properties, int context, int flag,
|
|
|
|
PointerRNA *r_opptr)
|
|
|
|
{
|
|
|
|
uiItemFullO_ptr_ex(layout, ot, name, icon, properties, context, flag, r_opptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiItemFullOMenuHold_ptr(
|
|
|
|
uiLayout *layout, wmOperatorType *ot,
|
|
|
|
const char *name, int icon, IDProperty *properties, int context, int flag,
|
|
|
|
const char *menu_id,
|
|
|
|
PointerRNA *r_opptr)
|
|
|
|
{
|
|
|
|
uiBut *but = uiItemFullO_ptr_ex(layout, ot, name, icon, properties, context, flag, r_opptr);
|
2017-11-02 23:43:51 +11:00
|
|
|
UI_but_func_hold_set(but, ui_item_menu_hold, BLI_strdup(menu_id));
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
void uiItemFullO(
|
|
|
|
uiLayout *layout, const char *opname,
|
|
|
|
const char *name, int icon, IDProperty *properties, int context, int flag,
|
|
|
|
PointerRNA *r_opptr)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(
|
|
|
|
ot, opname, {
|
|
|
|
if (r_opptr) {
|
|
|
|
*r_opptr = PointerRNA_NULL;
|
2017-11-01 11:56:56 +11:00
|
|
|
}
|
2017-10-31 16:58:26 +11:00
|
|
|
return;
|
|
|
|
});
|
2012-01-22 19:52:41 +00:00
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag, r_opptr);
|
2012-01-22 03:30:07 +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
|
|
|
|
2012-01-22 03:30:07 +00:00
|
|
|
static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval)
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item;
|
2014-01-04 18:08:43 +11:00
|
|
|
bool free;
|
2012-01-22 03:30:07 +00:00
|
|
|
const char *name;
|
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
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
2012-12-18 13:46:37 +00:00
|
|
|
if (RNA_enum_name(item, retval, &name)) {
|
2012-12-18 18:25:48 +00:00
|
|
|
name = CTX_IFACE_(RNA_property_translation_context(prop), name);
|
2012-12-18 13:46:37 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-01-22 03:30:07 +00:00
|
|
|
name = "";
|
|
|
|
}
|
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-01-22 03:30:07 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2012-01-22 11:59:30 +00:00
|
|
|
return name;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2012-01-22 03:30:07 +00:00
|
|
|
void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, const char *propname, int value)
|
|
|
|
{
|
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
|
|
|
|
|
|
|
if ((prop = RNA_struct_find_property(&ptr, propname))) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RNA_property_enum_set(&ptr, prop, value);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-01-22 03:30:07 +00:00
|
|
|
name = ui_menu_enumpropname(layout, &ptr, prop, value);
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2012-01-22 03:30:07 +00:00
|
|
|
}
|
|
|
|
void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value)
|
|
|
|
{
|
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ot) {
|
2012-01-22 03:30:07 +00:00
|
|
|
uiItemEnumO_ptr(layout, ot, name, icon, propname, value);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui_item_disabled(layout, opname);
|
|
|
|
RNA_warning("unknown operator '%s'", opname);
|
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2016-02-16 14:50:26 +01:00
|
|
|
BLI_INLINE bool ui_layout_is_radial(const uiLayout *layout)
|
|
|
|
{
|
|
|
|
return (layout->item.type == ITEM_LAYOUT_RADIAL) ||
|
|
|
|
((layout->item.type == ITEM_LAYOUT_ROOT) && (layout->root->type == UI_LAYOUT_PIEMENU));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create ui items for enum items in \a item_array.
|
|
|
|
*
|
|
|
|
* A version of #uiItemsFullEnumO that takes pre-calculated item array.
|
|
|
|
*/
|
|
|
|
void uiItemsFullEnumO_items(
|
|
|
|
uiLayout *layout, wmOperatorType *ot, PointerRNA ptr, PropertyRNA *prop, IDProperty *properties,
|
|
|
|
int context, int flag,
|
|
|
|
const EnumPropertyItem *item_array, int totitem)
|
|
|
|
{
|
|
|
|
const char *propname = RNA_property_identifier(prop);
|
|
|
|
if (RNA_property_type(prop) != PROP_ENUM) {
|
|
|
|
RNA_warning("%s.%s, not an enum type", RNA_struct_identifier(ptr.type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiLayout *target, *split = NULL;
|
|
|
|
const EnumPropertyItem *item;
|
|
|
|
uiBlock *block = layout->root->block;
|
|
|
|
const bool radial = ui_layout_is_radial(layout);
|
|
|
|
|
|
|
|
if (radial) {
|
|
|
|
target = uiLayoutRadial(layout);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
split = uiLayoutSplit(layout, 0.0f, false);
|
|
|
|
target = uiLayoutColumn(split, layout->align);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
bool last_iter = false;
|
|
|
|
|
|
|
|
for (i = 1, item = item_array; item->identifier && !last_iter; i++, item++) {
|
|
|
|
/* handle oversized pies */
|
|
|
|
if (radial && (totitem > PIE_MAX_ITEMS) && (i >= PIE_MAX_ITEMS)) {
|
|
|
|
if (item->name) { /* only visible items */
|
|
|
|
const EnumPropertyItem *tmp;
|
|
|
|
|
|
|
|
/* Check if there are more visible items for the next level. If not, we don't
|
|
|
|
* add a new level and add the remaining item instead of the 'more' button. */
|
|
|
|
for (tmp = item + 1; tmp->identifier; tmp++)
|
|
|
|
if (tmp->name)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (tmp->identifier) { /* only true if loop above found item and did early-exit */
|
|
|
|
ui_pie_menu_level_create(block, ot, propname, properties, item_array, totitem, context, flag);
|
|
|
|
/* break since rest of items is handled in new pie level */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
last_iter = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->identifier[0]) {
|
|
|
|
PointerRNA tptr;
|
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&tptr, ot);
|
|
|
|
if (properties) {
|
|
|
|
if (tptr.data) {
|
|
|
|
IDP_FreeProperty(tptr.data);
|
|
|
|
MEM_freeN(tptr.data);
|
|
|
|
}
|
|
|
|
tptr.data = IDP_CopyProperty(properties);
|
|
|
|
}
|
|
|
|
RNA_property_enum_set(&tptr, prop, item->value);
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(target, ot, item->name, item->icon, tptr.data, context, flag, NULL);
|
2016-02-16 14:50:26 +01:00
|
|
|
|
|
|
|
ui_but_tip_from_enum_item(block->buttons.last, item);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (item->name) {
|
|
|
|
uiBut *but;
|
|
|
|
|
|
|
|
if (item != item_array && !radial) {
|
|
|
|
target = uiLayoutColumn(split, layout->align);
|
|
|
|
|
|
|
|
/* inconsistent, but menus with labels do not look good flipped */
|
|
|
|
block->flag |= UI_BLOCK_NO_FLIP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->icon || radial) {
|
|
|
|
uiItemL(target, item->name, item->icon);
|
|
|
|
|
|
|
|
but = block->buttons.last;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */
|
|
|
|
but = uiDefBut(block, UI_BTYPE_LABEL, 0, item->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL,
|
|
|
|
0.0, 0.0, 0, 0, "");
|
|
|
|
}
|
|
|
|
ui_but_tip_from_enum_item(but, item);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (radial) {
|
|
|
|
/* invisible dummy button to ensure all items are always at the same position */
|
|
|
|
uiItemS(target);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* XXX bug here, colums draw bottom item badly */
|
|
|
|
uiItemS(target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:13:47 +10:00
|
|
|
void uiItemsFullEnumO(
|
|
|
|
uiLayout *layout, const char *opname, const char *propname, IDProperty *properties,
|
|
|
|
int context, int flag)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ot || !ot->srna) {
|
2009-04-22 18:39:44 +00:00
|
|
|
ui_item_disabled(layout, opname);
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
|
2009-03-13 13:38:41 +00:00
|
|
|
return;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
|
|
|
/* so the context is passed to itemf functions (some need it) */
|
|
|
|
WM_operator_properties_sanitize(&ptr, false);
|
2012-01-22 03:30:07 +00:00
|
|
|
prop = RNA_struct_find_property(&ptr, propname);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2011-05-25 10:07:59 +00:00
|
|
|
/* don't let bad properties slip through */
|
|
|
|
BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM));
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (prop && RNA_property_type(prop) == PROP_ENUM) {
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item_array = NULL;
|
2016-02-16 14:50:26 +01:00
|
|
|
int totitem;
|
2014-01-04 18:08:43 +11:00
|
|
|
bool free;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
2016-02-16 14:50:26 +01:00
|
|
|
if (ui_layout_is_radial(layout)) {
|
|
|
|
RNA_property_enum_items_gettexted_all(block->evil_C, &ptr, prop, &item_array, &totitem, &free);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-02-16 14:50:26 +01:00
|
|
|
RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item_array, &totitem, &free);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2016-02-16 14:50:26 +01:00
|
|
|
/* add items */
|
|
|
|
uiItemsFullEnumO_items(
|
|
|
|
layout, ot, ptr, prop, properties, context, flag,
|
|
|
|
item_array, totitem);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-01-21 22:00:40 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item_array);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2014-11-15 14:32:23 +01:00
|
|
|
|
2014-11-16 17:40:46 +01:00
|
|
|
/* intentionally don't touch UI_BLOCK_IS_FLIP here,
|
|
|
|
* we don't know the context this is called in */
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
2012-06-21 20:14:27 +00:00
|
|
|
else if (prop && RNA_property_type(prop) != PROP_ENUM) {
|
|
|
|
RNA_warning("%s.%s, not an enum type", RNA_struct_identifier(ptr.type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
|
|
|
|
return;
|
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname)
|
2009-12-22 11:59:30 +00:00
|
|
|
{
|
|
|
|
uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0);
|
|
|
|
}
|
|
|
|
|
2009-06-07 14:53:08 +00:00
|
|
|
/* for use in cases where we have */
|
2011-03-24 12:36:12 +00:00
|
|
|
void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
|
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2011-03-24 12:36:12 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2015-02-07 04:33:48 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
2012-01-22 03:30:07 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
2011-03-24 12:36:12 +00:00
|
|
|
|
|
|
|
/* enum lookup */
|
2012-01-22 03:30:07 +00:00
|
|
|
if ((prop = RNA_struct_find_property(&ptr, propname))) {
|
2011-03-24 12:36:12 +00:00
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
|
2011-03-24 12:36:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RNA_property_enum_set(&ptr, prop, value);
|
|
|
|
|
|
|
|
/* same as uiItemEnumO */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-01-22 03:30:07 +00:00
|
|
|
name = ui_menu_enumpropname(layout, &ptr, prop, value);
|
2011-03-24 12:36:12 +00:00
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2011-03-24 12:36:12 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str)
|
2009-06-07 14:53:08 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2009-06-07 14:53:08 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
PropertyRNA *prop;
|
2012-01-22 03:30:07 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item;
|
2014-01-04 18:08:43 +11:00
|
|
|
int value;
|
|
|
|
bool free;
|
2009-06-07 14:53:08 +00:00
|
|
|
|
2015-02-07 04:33:48 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
2012-01-22 03:30:07 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
2012-12-18 18:25:48 +00:00
|
|
|
|
2009-06-09 05:39:01 +00:00
|
|
|
/* enum lookup */
|
2012-03-30 01:51:25 +00:00
|
|
|
if ((prop = RNA_struct_find_property(&ptr, propname))) {
|
2012-12-18 13:46:37 +00:00
|
|
|
/* no need for translations here */
|
|
|
|
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
|
2012-03-30 01:51:25 +00:00
|
|
|
if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str);
|
2009-06-07 14:53:08 +00:00
|
|
|
return;
|
|
|
|
}
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
|
2012-01-21 22:00:40 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2009-06-07 14:53:08 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-09-19 12:26:20 +00:00
|
|
|
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
|
2009-06-07 14:53:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-12-18 18:25:48 +00:00
|
|
|
|
2009-06-09 05:39:01 +00:00
|
|
|
RNA_property_enum_set(&ptr, prop, value);
|
2012-12-18 18:25:48 +00:00
|
|
|
|
2009-06-07 14:53:08 +00:00
|
|
|
/* same as uiItemEnumO */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-01-22 03:30:07 +00:00
|
|
|
name = ui_menu_enumpropname(layout, &ptr, prop, value);
|
2009-06-07 14:53:08 +00:00
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2009-06-07 14:53:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2009-03-13 13:38:41 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
2015-02-07 04:33:48 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
2012-01-22 03:30:07 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
2009-03-13 13:38:41 +00:00
|
|
|
RNA_boolean_set(&ptr, propname, value);
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2009-03-13 13:38:41 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
2015-02-07 04:33:48 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
2012-01-22 03:30:07 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
2009-03-13 13:38:41 +00:00
|
|
|
RNA_int_set(&ptr, propname, value);
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2009-03-13 13:38:41 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
2015-02-07 04:33:48 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
2012-01-22 03:30:07 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
2009-03-13 13:38:41 +00:00
|
|
|
RNA_float_set(&ptr, propname, value);
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
2009-03-13 13:38:41 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
2015-02-07 04:33:48 +11:00
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
2012-01-22 03:30:07 +00:00
|
|
|
|
|
|
|
WM_operator_properties_create_ptr(&ptr, ot);
|
2009-03-13 13:38:41 +00:00
|
|
|
RNA_string_set(&ptr, propname, value);
|
|
|
|
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2017-10-31 16:58:26 +11:00
|
|
|
uiItemFullO(layout, opname, name, icon, NULL, layout->root->opcontext, 0, NULL);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* RNA property items */
|
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
|
|
|
|
2015-05-05 03:13:47 +10:00
|
|
|
static void ui_item_rna_size(
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
uiLayout *layout, const char *name, int icon,
|
|
|
|
PointerRNA *ptr, PropertyRNA *prop,
|
|
|
|
int index, bool icon_only, bool compact,
|
|
|
|
int *r_w, int *r_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
|
|
|
{
|
|
|
|
PropertyType type;
|
|
|
|
PropertySubType subtype;
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
int len, w = 0, 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
|
|
|
|
|
|
|
/* arbitrary extended width by type */
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_type(prop);
|
|
|
|
subtype = RNA_property_subtype(prop);
|
|
|
|
len = RNA_property_array_length(ptr, 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
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
if (!name[0] && !icon_only) {
|
|
|
|
if (ELEM(type, PROP_STRING, PROP_POINTER)) {
|
|
|
|
name = "non-empty text";
|
|
|
|
}
|
|
|
|
else if (type == PROP_BOOLEAN) {
|
|
|
|
icon = ICON_DOT;
|
|
|
|
}
|
|
|
|
else if (type == PROP_ENUM) {
|
|
|
|
/* Find the longest enum item name, instead of using a dummy text! */
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item, *item_array;
|
2014-01-04 18:08:43 +11:00
|
|
|
bool free;
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
|
|
|
|
RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
|
|
|
|
for (item = item_array; item->identifier; item++) {
|
|
|
|
if (item->identifier[0]) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, compact));
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item_array);
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2016-12-15 22:22:54 +01:00
|
|
|
if (!w) {
|
|
|
|
if (type == PROP_ENUM && icon_only) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
w = ui_text_icon_width(layout, "", ICON_BLANK1, compact);
|
2017-04-11 13:25:46 +03:00
|
|
|
if (index != RNA_ENUM_VALUE)
|
|
|
|
w += 0.6f * UI_UNIT_X;
|
2016-12-15 22:22:54 +01:00
|
|
|
}
|
|
|
|
else {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
/* not compact for float/int buttons, looks too squashed */
|
|
|
|
w = ui_text_icon_width(layout, name, icon, ELEM(type, PROP_FLOAT, PROP_INT) ? false : compact);
|
2016-12-15 22:22:54 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
h = UI_UNIT_Y;
|
2009-07-02 19:41:31 +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
|
|
|
/* increase height for arrays */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (index == RNA_NO_INDEX && len > 0) {
|
|
|
|
if (!name[0] && icon == ICON_NONE)
|
2012-03-30 01:51:25 +00:00
|
|
|
h = 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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER))
|
2012-03-30 01:51:25 +00:00
|
|
|
h += 2 * UI_UNIT_Y;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (subtype == PROP_MATRIX)
|
2014-03-28 14:53:37 +11:00
|
|
|
h += ceilf(sqrtf(len)) * UI_UNIT_Y;
|
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
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
h += len * UI_UNIT_Y;
|
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
|
|
|
else if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
|
|
|
|
if (type == PROP_BOOLEAN && name[0])
|
2012-03-30 01:51:25 +00:00
|
|
|
w += UI_UNIT_X / 5;
|
2016-12-15 22:22:54 +01:00
|
|
|
else if (type == PROP_ENUM && !icon_only)
|
2012-03-30 01:51:25 +00:00
|
|
|
w += UI_UNIT_X / 4;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == PROP_FLOAT || type == PROP_INT)
|
2012-03-30 01:51:25 +00:00
|
|
|
w += UI_UNIT_X * 3;
|
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
|
|
|
*r_w = w;
|
|
|
|
*r_h = 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
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
2013-11-23 18:43:23 +01:00
|
|
|
uiBut *but = NULL;
|
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
|
|
|
PropertyType type;
|
|
|
|
char namestr[UI_MAX_NAME_STR];
|
2015-02-13 11:43:28 +11:00
|
|
|
int len, w, h;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
bool slider, toggle, expand, icon_only, no_bg, compact;
|
2014-01-04 17:16:19 +11:00
|
|
|
bool is_array;
|
2009-04-11 01:52:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
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
|
|
|
|
|
|
|
/* retrieve info */
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_type(prop);
|
|
|
|
is_array = RNA_property_array_check(prop);
|
|
|
|
len = (is_array) ? RNA_property_array_length(ptr, prop) : 0;
|
2009-03-13 13:38: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
|
|
|
/* set name and icon */
|
2014-01-30 15:28:39 +11:00
|
|
|
if (!name) {
|
|
|
|
if ((flag & UI_ITEM_R_ICON_ONLY) == 0) {
|
|
|
|
name = RNA_property_ui_name(prop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon == ICON_NONE)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = RNA_property_ui_icon(prop);
|
2010-01-06 01:41:00 +00:00
|
|
|
|
2014-03-12 19:24:47 +11:00
|
|
|
if (flag & UI_ITEM_R_ICON_ONLY) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_POINTER)) {
|
2012-03-30 01:51:25 +00:00
|
|
|
name = ui_item_name_add_colon(name, namestr);
|
2014-03-12 19:24:47 +11:00
|
|
|
}
|
|
|
|
else if (type == PROP_BOOLEAN && is_array && index == RNA_NO_INDEX) {
|
2012-03-30 01:51:25 +00:00
|
|
|
name = ui_item_name_add_colon(name, namestr);
|
2014-03-12 19:24:47 +11:00
|
|
|
}
|
|
|
|
else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
if (flag & UI_ITEM_R_COMPACT) {
|
|
|
|
name = "";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = ui_item_name_add_colon(name, namestr);
|
|
|
|
}
|
2014-03-12 19:24:47 +11: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
|
|
|
|
2015-02-13 11:32:24 +11:00
|
|
|
/* menus and pie-menus don't show checkbox without this */
|
2015-08-18 19:18:16 +10:00
|
|
|
if ((layout->root->type == UI_LAYOUT_MENU) ||
|
|
|
|
/* use checkboxes only as a fallback in pie-menu's, when no icon is defined */
|
|
|
|
((layout->root->type == UI_LAYOUT_PIEMENU) && (icon == ICON_NONE)))
|
|
|
|
{
|
2014-01-04 17:16:19 +11:00
|
|
|
if (type == PROP_BOOLEAN && ((is_array == false) || (index != RNA_NO_INDEX))) {
|
2012-03-30 01:51:25 +00:00
|
|
|
if (is_array) icon = (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
|
|
|
else icon = (RNA_property_boolean_get(ptr, prop)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
2011-08-14 10:17:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
|
2012-03-30 01:51:25 +00:00
|
|
|
int enum_value = RNA_property_enum_get(ptr, prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = (enum_value & value) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
2010-09-23 07:31:44 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = (enum_value == value) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
2010-09-23 07:31:44 +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
|
|
|
}
|
|
|
|
|
2015-02-13 11:43:28 +11:00
|
|
|
slider = (flag & UI_ITEM_R_SLIDER) != 0;
|
|
|
|
toggle = (flag & UI_ITEM_R_TOGGLE) != 0;
|
|
|
|
expand = (flag & UI_ITEM_R_EXPAND) != 0;
|
|
|
|
icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
|
2015-08-18 19:18:16 +10:00
|
|
|
no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
compact = (flag & UI_ITEM_R_COMPACT) != 0;
|
2009-08-21 12:57:47 +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
|
|
|
/* get size */
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2009-12-16 10:13:26 +00:00
|
|
|
if (no_bg)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
2009-12-16 10:13:26 +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
|
|
|
/* array property */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (index == RNA_NO_INDEX && is_array)
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
ui_item_array(
|
|
|
|
layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
|
|
|
|
expand, slider, toggle, icon_only, compact);
|
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
|
|
|
/* enum item */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
|
|
|
|
if (icon && name[0] && !icon_only)
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextButR_prop(block, UI_BTYPE_ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
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
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
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
|
|
|
}
|
|
|
|
/* expanded enum */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG))
|
2010-10-16 02:40:31 +00:00
|
|
|
ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
|
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
|
|
|
/* property with separate label */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
|
2012-03-30 01:51:25 +00:00
|
|
|
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
|
2009-06-27 01:15:31 +00:00
|
|
|
ui_but_add_search(but, ptr, prop, NULL, NULL);
|
2010-12-11 17:47:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->redalert)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
2009-06-27 01:15:31 +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
|
|
|
/* single button */
|
2009-05-19 17:13:33 +00:00
|
|
|
else {
|
2012-03-24 02:51:46 +00:00
|
|
|
but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (slider && but->type == UI_BTYPE_NUM)
|
|
|
|
but->type = UI_BTYPE_NUM_SLIDER;
|
2009-05-27 00:03:49 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (toggle && but->type == UI_BTYPE_CHECKBOX)
|
|
|
|
but->type = UI_BTYPE_TOGGLE;
|
2010-12-11 17:47:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->redalert)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
2009-05-19 17:13:33 +00:00
|
|
|
}
|
2013-11-23 18:43:23 +01:00
|
|
|
|
|
|
|
/* Mark non-embossed textfields inside a listbox. */
|
2018-03-23 20:32:58 +01:00
|
|
|
if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->dt & UI_EMBOSS_NONE)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(but, UI_BUT_LIST_ITEM);
|
2013-11-23 18:43:23 +01:00
|
|
|
}
|
|
|
|
|
2009-12-16 10:13:26 +00:00
|
|
|
if (no_bg)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2014-03-12 19:24:47 +11:00
|
|
|
|
|
|
|
/* ensure text isn't added to icon_only buttons */
|
|
|
|
if (but && icon_only) {
|
|
|
|
BLI_assert(but->str[0] == '\0');
|
|
|
|
}
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2009-04-15 15:09:36 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop) {
|
2009-04-22 18:39:44 +00:00
|
|
|
ui_item_disabled(layout, propname);
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-04-15 15:09:36 +00:00
|
|
|
return;
|
2009-04-22 18:39:44 +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
|
|
|
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemFullR(layout, ptr, prop, RNA_NO_INDEX, 0, flag, name, icon);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2015-08-18 19:04:06 +10:00
|
|
|
void uiItemEnumR_prop(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, PropertyRNA *prop, int value)
|
|
|
|
{
|
|
|
|
if (RNA_property_type(prop) != PROP_ENUM) {
|
|
|
|
const char *propname = RNA_property_identifier(prop);
|
|
|
|
ui_item_disabled(layout, propname);
|
|
|
|
RNA_warning("property not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, value, 0, name, icon);
|
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2015-08-18 19:04:06 +10:00
|
|
|
if (prop == NULL) {
|
2009-04-22 18:39:44 +00:00
|
|
|
ui_item_disabled(layout, propname);
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-04-15 15:09:36 +00:00
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
|
2010-03-23 15:31:12 +00:00
|
|
|
uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, value, 0, name, icon);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon)
|
2009-07-02 19:41:31 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item;
|
2014-01-04 18:08:43 +11:00
|
|
|
int ivalue, a;
|
|
|
|
bool free;
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop || RNA_property_type(prop) != PROP_ENUM) {
|
2009-07-02 19:41:31 +00:00
|
|
|
ui_item_disabled(layout, propname);
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-07-02 19:41:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-18 13:46:37 +00:00
|
|
|
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!RNA_enum_value_from_id(item, value, &ivalue)) {
|
2012-01-21 22:00:40 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2009-07-02 19:41:31 +00:00
|
|
|
ui_item_disabled(layout, propname);
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("enum property value not found: %s", value);
|
2009-07-02 19:41:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (a = 0; item[a].identifier; a++) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item[a].value == ivalue) {
|
2014-07-23 14:31:44 +02:00
|
|
|
const char *item_name = name ? name : CTX_IFACE_(RNA_property_translation_context(prop), item[a].name);
|
2016-12-28 15:07:18 +01:00
|
|
|
const int flag = item_name[0] ? 0 : UI_ITEM_R_ICON_ONLY;
|
2012-12-18 13:46:37 +00:00
|
|
|
|
2016-12-28 15:07:18 +01:00
|
|
|
uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, ivalue, flag, item_name, icon ? icon : item[a].icon);
|
2009-07-02 19:41:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
|
2012-01-21 22:00:40 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2009-07-02 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
2009-08-21 02:51:56 +00:00
|
|
|
uiBut *bt;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop) {
|
2009-04-22 18:39:44 +00:00
|
|
|
ui_item_disabled(layout, propname);
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2009-04-22 18:39:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_property_type(prop) != PROP_ENUM) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("not an enum property: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
2011-03-25 04:36:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem *item;
|
2014-01-04 18:08:43 +11:00
|
|
|
int totitem, i;
|
|
|
|
bool free;
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
|
|
|
|
uiLayout *column = uiLayoutColumn(split, false);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2011-09-15 13:20:18 +00:00
|
|
|
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (i = 0; i < totitem; i++) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item[i].identifier[0]) {
|
2015-08-18 19:18:16 +10:00
|
|
|
uiItemEnumR_prop(column, item[i].name, item[i].icon, ptr, prop, item[i].value);
|
2013-02-05 05:39:18 +00:00
|
|
|
ui_but_tip_from_enum_item(block->buttons.last, &item[i]);
|
2009-08-21 02:51:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item[i].name) {
|
|
|
|
if (i != 0) {
|
2014-01-04 17:16:19 +11:00
|
|
|
column = uiLayoutColumn(split, false);
|
2009-08-21 02:51:56 +00:00
|
|
|
/* inconsistent, but menus with labels do not look good flipped */
|
|
|
|
block->flag |= UI_BLOCK_NO_FLIP;
|
|
|
|
}
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(column, item[i].name, ICON_NONE);
|
2012-03-30 01:51:25 +00:00
|
|
|
bt = block->buttons.last;
|
2013-11-21 14:43:08 +01:00
|
|
|
bt->drawflag = UI_BUT_TEXT_LEFT;
|
2013-02-05 05:39:18 +00:00
|
|
|
|
|
|
|
ui_but_tip_from_enum_item(bt, &item[i]);
|
2009-08-21 02:51:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
uiItemS(column);
|
|
|
|
}
|
|
|
|
}
|
RNA
* Enums can now be dynamically created in the _itemf callback,
using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking
for enum items now need to potentially free the items.
* This callback now also gets context, this was added specifically
for operators. This doesn't fit design well at all, needed to do
some ugly hacks, but can't find a good solution at the moment.
* All enums must have a default list of items too, even with an
_itemf callback, for docs and fallback in case there is no context.
* Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation.
* Also changes some operator properties that were enums to booleas
(unselected, deselect), to make them consistent with other ops.
2009-07-10 19:56:13 +00:00
|
|
|
|
2012-01-21 22:00:40 +00:00
|
|
|
if (free) {
|
2017-10-18 15:07:26 +11:00
|
|
|
MEM_freeN((void *)item);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
2014-11-15 14:32:23 +01:00
|
|
|
|
2014-11-16 17:40:46 +01:00
|
|
|
/* intentionally don't touch UI_BLOCK_IS_FLIP here,
|
|
|
|
* we don't know the context this is called in */
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
/* Pointer RNA button with search */
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
|
|
|
|
/* look for collection property in Main */
|
|
|
|
RNA_main_pointer_create(G.main, ptr);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
*prop = NULL;
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2012-04-30 16:22:40 +00:00
|
|
|
RNA_STRUCT_BEGIN (ptr, iprop)
|
|
|
|
{
|
2009-06-27 01:15:31 +00:00
|
|
|
/* if it's a collection and has same pointer type, we've got it */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_property_type(iprop) == PROP_COLLECTION) {
|
2012-03-30 01:51:25 +00:00
|
|
|
srna = RNA_property_pointer_type(ptr, iprop);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptype == srna) {
|
2012-03-30 01:51:25 +00:00
|
|
|
*prop = iprop;
|
2009-06-27 01:15:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RNA_STRUCT_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop)
|
|
|
|
{
|
|
|
|
StructRNA *ptype;
|
|
|
|
PointerRNA sptr;
|
|
|
|
|
|
|
|
/* for ID's we do automatic lookup */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!searchprop) {
|
|
|
|
if (RNA_property_type(prop) == PROP_POINTER) {
|
2012-03-30 01:51:25 +00:00
|
|
|
ptype = RNA_property_pointer_type(ptr, prop);
|
2009-06-27 01:15:31 +00:00
|
|
|
search_id_collection(ptype, &sptr, &searchprop);
|
2012-03-30 01:51:25 +00:00
|
|
|
searchptr = &sptr;
|
2009-06-27 01:15:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* turn button into search button */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (searchprop) {
|
2017-05-12 01:42:42 +02:00
|
|
|
uiRNACollectionSearch *coll_search = MEM_mallocN(sizeof(*coll_search), __func__);
|
|
|
|
|
2015-03-24 15:05:27 +11:00
|
|
|
but->type = UI_BTYPE_SEARCH_MENU;
|
2012-10-27 11:18:54 +00:00
|
|
|
but->hardmax = MAX2(but->hardmax, 256.0f);
|
2012-03-30 01:51:25 +00:00
|
|
|
but->rnasearchpoin = *searchptr;
|
|
|
|
but->rnasearchprop = searchprop;
|
2013-11-21 14:43:08 +01:00
|
|
|
but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
|
2015-03-24 15:05:27 +11:00
|
|
|
if (RNA_property_is_unlink(prop)) {
|
2016-11-28 18:59:31 +01:00
|
|
|
but->flag |= UI_BUT_VALUE_CLEAR;
|
2015-03-24 15:05:27 +11:00
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
coll_search->target_ptr = *ptr;
|
|
|
|
coll_search->target_prop = prop;
|
|
|
|
coll_search->search_ptr = *searchptr;
|
|
|
|
coll_search->search_prop = searchprop;
|
|
|
|
coll_search->but_changed = &but->changed;
|
|
|
|
|
2012-11-24 05:15:48 +00:00
|
|
|
if (RNA_property_type(prop) == PROP_ENUM) {
|
|
|
|
/* XXX, this will have a menu string,
|
|
|
|
* but in this case we just want the text */
|
|
|
|
but->str[0] = 0;
|
|
|
|
}
|
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
UI_but_func_search_set(
|
|
|
|
but, ui_searchbox_create_generic, ui_rna_collection_search_cb,
|
|
|
|
coll_search, NULL, NULL);
|
|
|
|
but->free_search_arg = true;
|
2009-06-27 01:15:31 +00:00
|
|
|
}
|
2017-09-14 10:58:47 +02:00
|
|
|
else if (but->type == UI_BTYPE_SEARCH_MENU) {
|
|
|
|
/* In case we fail to find proper searchprop, so other code might have already set but->type to search menu... */
|
2017-12-28 17:57:18 +01:00
|
|
|
but->flag |= UI_BUT_DISABLED;
|
2017-09-14 10:58:47 +02:00
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon)
|
2009-06-27 01:15:31 +00:00
|
|
|
{
|
|
|
|
PropertyRNA *prop, *searchprop;
|
|
|
|
PropertyType type;
|
|
|
|
uiBut *but;
|
|
|
|
uiBlock *block;
|
|
|
|
StructRNA *icontype;
|
|
|
|
int w, h;
|
2013-08-23 16:53:37 +00:00
|
|
|
char namestr[UI_MAX_NAME_STR];
|
2009-06-27 01:15:31 +00:00
|
|
|
|
|
|
|
/* validate arguments */
|
2012-03-30 01:51:25 +00:00
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!prop) {
|
2012-11-24 04:51:56 +00:00
|
|
|
RNA_warning("property not found: %s.%s",
|
|
|
|
RNA_struct_identifier(ptr->type), propname);
|
2009-06-27 01:15:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
type = RNA_property_type(prop);
|
2014-07-20 01:30:29 +10:00
|
|
|
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
|
2012-11-24 05:15:48 +00:00
|
|
|
RNA_warning("Property %s must be a pointer, string or enum", propname);
|
2009-06-27 01:15:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
searchprop = RNA_struct_find_property(searchptr, searchpropname);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
use ICON_NULL define rather then 0, makes UI calls less confusing. (no functional change)
eg: uiItemR(row, &dvar_ptr, "type", 0, "", 0); -> uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NULL);
2010-12-23 02:43:40 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!searchprop) {
|
2012-11-24 04:51:56 +00:00
|
|
|
RNA_warning("search collection property not found: %s.%s",
|
|
|
|
RNA_struct_identifier(searchptr->type), searchpropname);
|
2009-06-27 01:15:31 +00:00
|
|
|
return;
|
|
|
|
}
|
use ICON_NULL define rather then 0, makes UI calls less confusing. (no functional change)
eg: uiItemR(row, &dvar_ptr, "type", 0, "", 0); -> uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NULL);
2010-12-23 02:43:40 +00:00
|
|
|
else if (RNA_property_type(searchprop) != PROP_COLLECTION) {
|
2012-11-24 04:51:56 +00:00
|
|
|
RNA_warning("search collection property is not a collection type: %s.%s",
|
|
|
|
RNA_struct_identifier(searchptr->type), searchpropname);
|
use ICON_NULL define rather then 0, makes UI calls less confusing. (no functional change)
eg: uiItemR(row, &dvar_ptr, "type", 0, "", 0); -> uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NULL);
2010-12-23 02:43:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-06-27 01:15:31 +00:00
|
|
|
|
|
|
|
/* get icon & name */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (icon == ICON_NONE) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (type == PROP_POINTER)
|
2012-03-30 01:51:25 +00:00
|
|
|
icontype = RNA_property_pointer_type(ptr, prop);
|
2009-06-27 01:15:31 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
icontype = RNA_property_pointer_type(searchptr, searchprop);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = RNA_struct_ui_icon(icontype);
|
2009-06-27 01:15:31 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-03-30 01:51:25 +00:00
|
|
|
name = RNA_property_ui_name(prop);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
2013-08-23 16:53:37 +00:00
|
|
|
name = ui_item_name_add_colon(name, namestr);
|
|
|
|
|
2009-06-27 01:15:31 +00:00
|
|
|
/* create button */
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, false, &w, &h);
|
2013-01-24 13:02:00 +00:00
|
|
|
w += UI_UNIT_X; /* X icon needs more space */
|
2012-03-30 01:51:25 +00:00
|
|
|
but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
|
2009-06-27 01:15:31 +00:00
|
|
|
|
|
|
|
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
|
|
|
|
}
|
|
|
|
|
2009-03-13 13:38:41 +00:00
|
|
|
/* menu item */
|
2009-04-22 18:39:44 +00:00
|
|
|
static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
MenuType *mt = (MenuType *)arg_mt;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2017-11-02 18:19:11 +11:00
|
|
|
UI_menutype_draw(C, mt, layout);
|
2014-11-15 14:32:23 +01:00
|
|
|
|
|
|
|
/* menus are created flipped (from event handling pov) */
|
|
|
|
layout->root->block->flag ^= UI_BLOCK_IS_FLIP;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2018-04-22 17:16:39 +02:00
|
|
|
static void ui_item_paneltype_func(bContext *C, uiLayout *layout, void *arg_mt)
|
|
|
|
{
|
|
|
|
PanelType *pt = (PanelType *)arg_mt;
|
|
|
|
|
|
|
|
/* TODO: move into UI_paneltype_draw */
|
|
|
|
Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
|
|
|
|
panel->type = pt;
|
|
|
|
|
|
|
|
if (layout->context) {
|
|
|
|
CTX_store_set(C, layout->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pt->draw_header) {
|
|
|
|
panel->layout = uiLayoutRow(layout, false);
|
|
|
|
pt->draw_header(C, panel);
|
|
|
|
panel->layout = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
panel->layout = layout;
|
|
|
|
pt->draw(C, panel);
|
|
|
|
panel->layout = NULL;
|
|
|
|
|
|
|
|
if (layout->context) {
|
|
|
|
CTX_store_set(C, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(panel);
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:13:47 +10:00
|
|
|
static uiBut *ui_item_menu(
|
|
|
|
uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN,
|
|
|
|
const char *tip, bool force_menu)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->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
|
|
|
uiBut *but;
|
|
|
|
int w, h;
|
2009-04-11 01:52:27 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_HEADER)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-03-30 01:51:25 +00:00
|
|
|
name = "";
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
w = ui_text_icon_width(layout, name, icon, 1);
|
|
|
|
h = UI_UNIT_Y;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_HEADER) { /* ugly .. */
|
2014-01-27 19:10:53 +11:00
|
|
|
if (force_menu) {
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
w += UI_UNIT_Y;
|
2014-01-27 19:10:53 +11:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (name[0]) {
|
|
|
|
w -= UI_UNIT_Y / 2;
|
|
|
|
}
|
|
|
|
}
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
}
|
2009-04-11 01:52:27 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (name[0] && icon)
|
2012-03-24 02:51:46 +00:00
|
|
|
but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2012-03-24 02:51:46 +00:00
|
|
|
but = uiDefIconMenuBut(block, func, arg, icon, 0, 0, w, h, tip);
|
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
|
|
|
else
|
2012-03-24 02:51:46 +00:00
|
|
|
but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (argN) { /* ugly .. */
|
2012-03-30 01:51:25 +00:00
|
|
|
but->poin = (char *)but;
|
|
|
|
but->func_argN = argN;
|
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-03-13 13:38:41 +00:00
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_HEADER) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
}
|
|
|
|
if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR) ||
|
|
|
|
(force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */
|
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_type_set_menu_from_pulldown(but);
|
2010-06-27 19:10:36 +00:00
|
|
|
}
|
2014-05-06 18:11:28 +10:00
|
|
|
|
|
|
|
return but;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const char *name, int icon)
|
2009-04-22 18:39:44 +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
|
|
|
MenuType *mt;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2014-01-04 17:16:19 +11:00
|
|
|
mt = WM_menutype_find(menuname, false);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (mt == NULL) {
|
2011-09-09 01:29:53 +00:00
|
|
|
RNA_warning("not found %s", menuname);
|
2009-10-06 13:04:31 +00:00
|
|
|
return;
|
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-07-08 21:31:28 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name) {
|
2013-03-15 14:32:29 +00:00
|
|
|
name = CTX_IFACE_(mt->translation_context, mt->label);
|
2011-09-15 13:20:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
2009-10-06 13:04:31 +00:00
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, TIP_(mt->description), false);
|
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-04-22 18:39:44 +00:00
|
|
|
|
2018-04-22 17:16:39 +02:00
|
|
|
/* popover */
|
|
|
|
void uiItemPopoverPanel_ptr(uiLayout *layout, bContext *UNUSED(C), PanelType *pt, const char *name, int icon)
|
|
|
|
{
|
|
|
|
if (!name) {
|
|
|
|
name = CTX_IFACE_(pt->translation_context, pt->label);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
|
|
|
icon = ICON_BLANK1;
|
|
|
|
|
|
|
|
uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, pt, NULL, NULL, false);
|
|
|
|
but->type = UI_BTYPE_POPOVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiItemPopoverPanel(
|
|
|
|
uiLayout *layout, bContext *C,
|
|
|
|
int space_id, int region_id, const char *panel_type,
|
|
|
|
const char *name, int icon)
|
|
|
|
{
|
|
|
|
SpaceType *st = BKE_spacetype_from_id(space_id);
|
|
|
|
if (st == NULL) {
|
|
|
|
RNA_warning("space type not found %d", space_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ARegionType *art = BKE_regiontype_from_id(st, region_id);
|
|
|
|
if (art == NULL) {
|
|
|
|
RNA_warning("region type not found %d", region_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PanelType *pt;
|
|
|
|
for (pt = art->paneltypes.first; pt; pt = pt->next) {
|
|
|
|
if (STREQ(pt->idname, panel_type)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pt == NULL) {
|
|
|
|
RNA_warning("area type not found %s", panel_type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiItemPopoverPanel_ptr(layout, C, pt, name, icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiItemPopoverPanelFromGroup(
|
|
|
|
uiLayout *layout, bContext *C,
|
|
|
|
int space_id, int region_id, const char *context, const char *category)
|
|
|
|
{
|
|
|
|
SpaceType *st = BKE_spacetype_from_id(space_id);
|
|
|
|
if (st == NULL) {
|
|
|
|
RNA_warning("space type not found %d", space_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ARegionType *art = BKE_regiontype_from_id(st, region_id);
|
|
|
|
if (art == NULL) {
|
|
|
|
RNA_warning("region type not found %d", region_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) {
|
|
|
|
/* Causes too many panels, check context. */
|
|
|
|
if (/* (*context == '\0') || */ STREQ(pt->context, context)) {
|
|
|
|
if ((*category == '\0') || STREQ(pt->category, category)) {
|
|
|
|
if (pt->poll == NULL || pt->poll(C, pt)) {
|
|
|
|
uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
/* label item */
|
2010-11-17 09:45:45 +00:00
|
|
|
static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->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
|
|
|
uiBut *but;
|
|
|
|
int w;
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
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 (!name)
|
2012-03-30 01:51:25 +00:00
|
|
|
name = "";
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
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
|
|
|
w = ui_text_icon_width(layout, name, icon, 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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon && name[0])
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconTextBut(block, UI_BTYPE_LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 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
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
|
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-03-21 12:58:31 +00:00
|
|
|
/* to compensate for string size padding in ui_text_icon_width,
|
|
|
|
* make text aligned right if the layout is aligned right.
|
|
|
|
*/
|
|
|
|
if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) {
|
2013-11-21 14:43:08 +01:00
|
|
|
but->drawflag &= ~UI_BUT_TEXT_LEFT; /* default, needs to be unset */
|
|
|
|
but->drawflag |= UI_BUT_TEXT_RIGHT;
|
2013-03-21 12:58:31 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
/* Mark as a label inside a listbox. */
|
|
|
|
if (block->flag & UI_BLOCK_LIST_ITEM) {
|
2013-11-21 16:51:29 +01:00
|
|
|
but->flag |= UI_BUT_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
|
|
|
}
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
return but;
|
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemL(uiLayout *layout, const char *name, int icon)
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
{
|
|
|
|
uiItemL_(layout, name, icon);
|
|
|
|
}
|
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon)
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *but = uiItemL_(layout, name, icon);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->type)
|
|
|
|
if (RNA_struct_is_ID(ptr->type))
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_drag_set_id(but, ptr->id.data);
|
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
|
|
|
}
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +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
|
|
|
/* value item */
|
2010-12-03 17:05:21 +00:00
|
|
|
void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
|
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
|
|
|
{
|
|
|
|
/* label */
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
2014-06-02 13:15:29 +10:00
|
|
|
int *retvalue = (block->handle) ? &block->handle->retvalue : NULL;
|
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
|
|
|
int w;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-03-30 01:51:25 +00:00
|
|
|
name = "";
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
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
|
|
|
w = ui_text_icon_width(layout, name, icon, 0);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (icon && name[0])
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconTextButI(block, UI_BTYPE_BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, "");
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (icon)
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefIconButI(block, UI_BTYPE_BUT, argval, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, "");
|
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
|
|
|
else
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefButI(block, UI_BTYPE_BUT, argval, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, "");
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* separator item */
|
|
|
|
void uiItemS(uiLayout *layout)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
2014-01-17 00:23:00 +01:00
|
|
|
bool is_menu = ui_block_is_menu(block);
|
|
|
|
int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X;
|
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
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(block, layout);
|
|
|
|
uiDefBut(block, (is_menu) ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, "");
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* level items */
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!func)
|
2009-04-22 18:39:44 +00:00
|
|
|
return;
|
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
ui_item_menu(layout, name, icon, func, arg, NULL, "", false);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct MenuItemLevel {
|
|
|
|
int opcontext;
|
2012-03-18 07:38:51 +00:00
|
|
|
/* don't use pointers to the strings because python can dynamically
|
2011-05-06 02:55:09 +00:00
|
|
|
* allocate strings and free before the menu draws, see [#27304] */
|
|
|
|
char opname[OP_MAX_TYPENAME];
|
|
|
|
char propname[MAX_IDPROP_NAME];
|
2009-04-22 18:39:44 +00:00
|
|
|
PointerRNA rnapoin;
|
|
|
|
} MenuItemLevel;
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2011-09-05 17:57:04 +00:00
|
|
|
uiLayoutSetOperatorContext(layout, lvl->opcontext);
|
2009-04-22 18:39:44 +00:00
|
|
|
uiItemsEnumO(layout, lvl->opname, lvl->propname);
|
2014-02-12 10:29:15 +11:00
|
|
|
|
2014-11-16 17:40:46 +01:00
|
|
|
layout->root->block->flag |= UI_BLOCK_IS_FLIP;
|
|
|
|
|
2014-02-12 10:29:15 +11:00
|
|
|
/* override default, needed since this was assumed pre 2.70 */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_direction_set(layout->root->block, UI_DIR_DOWN);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 12:44:41 +11:00
|
|
|
void uiItemMenuEnumO_ptr(
|
|
|
|
uiLayout *layout, bContext *C, wmOperatorType *ot, const char *propname,
|
|
|
|
const char *name, int icon)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
|
|
|
MenuItemLevel *lvl;
|
2014-05-06 18:11:28 +10:00
|
|
|
uiBut *but;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2017-10-31 12:44:41 +11:00
|
|
|
/* Caller must check */
|
|
|
|
BLI_assert(ot->srna != NULL);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2014-05-06 18:11:28 +10:00
|
|
|
if (name == NULL) {
|
|
|
|
name = RNA_struct_ui_name(ot->srna);
|
|
|
|
}
|
2013-05-10 23:41:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
|
2017-10-31 12:44:41 +11:00
|
|
|
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
|
2011-05-06 02:55:09 +00:00
|
|
|
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
|
2012-03-30 01:51:25 +00:00
|
|
|
lvl->opcontext = layout->root->opcontext;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2014-05-06 18:11:28 +10:00
|
|
|
but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl,
|
|
|
|
RNA_struct_ui_description(ot->srna), true);
|
|
|
|
|
2013-05-10 23:41:41 +00:00
|
|
|
/* add hotkey here, lower UI code can't detect it */
|
2014-05-06 18:11:28 +10:00
|
|
|
if ((layout->root->block->flag & UI_BLOCK_LOOP) &&
|
|
|
|
(ot->prop && ot->invoke))
|
|
|
|
{
|
|
|
|
char keybuf[128];
|
2017-11-06 00:04:46 +11:00
|
|
|
if (WM_key_event_operator_string(
|
|
|
|
C, ot->idname, layout->root->opcontext, NULL, false,
|
|
|
|
keybuf, sizeof(keybuf)))
|
2013-05-11 01:06:01 +00:00
|
|
|
{
|
2014-05-06 18:11:28 +10:00
|
|
|
ui_but_add_shortcut(but, keybuf, false);
|
2013-05-10 23:41:41 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 12:44:41 +11:00
|
|
|
void uiItemMenuEnumO(
|
|
|
|
uiLayout *layout, bContext *C, const char *opname, const char *propname,
|
|
|
|
const char *name, int icon)
|
|
|
|
{
|
|
|
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
|
|
|
|
|
|
|
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
|
|
|
|
|
|
|
if (!ot->srna) {
|
|
|
|
ui_item_disabled(layout, opname);
|
|
|
|
RNA_warning("operator missing srna '%s'", opname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiItemMenuEnumO_ptr(layout, C, ot, propname, name, icon);
|
|
|
|
}
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-05-28 23:37:55 +00:00
|
|
|
uiLayoutSetOperatorContext(layout, lvl->opcontext);
|
2009-04-22 18:39:44 +00:00
|
|
|
uiItemsEnumR(layout, &lvl->rnapoin, lvl->propname);
|
2014-11-16 17:40:46 +01:00
|
|
|
layout->root->block->flag |= UI_BLOCK_IS_FLIP;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2014-11-24 21:03:00 +01:00
|
|
|
void uiItemMenuEnumR_prop(uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
|
|
|
MenuItemLevel *lvl;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!name)
|
2012-03-30 01:51:25 +00:00
|
|
|
name = RNA_property_ui_name(prop);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->type == UI_LAYOUT_MENU && !icon)
|
2012-03-30 01:51:25 +00:00
|
|
|
icon = ICON_BLANK1;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
|
|
|
|
lvl->rnapoin = *ptr;
|
2014-11-24 21:03:00 +01:00
|
|
|
BLI_strncpy(lvl->propname, RNA_property_identifier(prop), sizeof(lvl->propname));
|
2012-03-30 01:51:25 +00:00
|
|
|
lvl->opcontext = layout->root->opcontext;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl, RNA_property_description(prop), false);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2014-11-24 21:03:00 +01:00
|
|
|
void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
prop = RNA_struct_find_property(ptr, propname);
|
|
|
|
if (!prop) {
|
|
|
|
ui_item_disabled(layout, propname);
|
|
|
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**************************** Layout Items ***************************/
|
2009-03-13 13:38: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
|
|
|
/* single-row layout */
|
|
|
|
static void ui_litem_estimate_row(uiLayout *litem)
|
2009-04-16 12:17:58 +00:00
|
|
|
{
|
|
|
|
uiItem *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
|
|
|
int itemw, itemh;
|
2017-01-10 16:19:10 +01:00
|
|
|
bool min_size_flag = true;
|
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
|
|
|
litem->w = 0;
|
|
|
|
litem->h = 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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2017-02-02 17:30:50 +03:00
|
|
|
min_size_flag = min_size_flag && (item->flag & UI_ITEM_MIN);
|
2017-01-10 16:19:10 +01: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
|
|
|
litem->w += itemw;
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->h = MAX2(itemh, litem->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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->next)
|
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
|
|
|
litem->w += litem->space;
|
|
|
|
}
|
2017-01-10 16:19:10 +01:00
|
|
|
|
|
|
|
if (min_size_flag) {
|
|
|
|
litem->item.flag |= UI_ITEM_MIN;
|
|
|
|
}
|
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-03 00:04:48 +00:00
|
|
|
static int ui_litem_min_width(int itemw)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
return MIN2(2 * UI_UNIT_X, itemw);
|
2009-06-03 00:04:48 +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
|
|
|
static void ui_litem_layout_row(uiLayout *litem)
|
|
|
|
{
|
2017-02-25 13:18:41 +03:00
|
|
|
uiItem *item, *last_free_item = NULL;
|
2013-11-27 05:23:02 +01:00
|
|
|
int x, y, w, tot, totw, neww, newtotw, itemw, minw, itemh, offset;
|
2012-03-30 01:51:25 +00:00
|
|
|
int fixedw, freew, fixedx, freex, flag = 0, lastw = 0;
|
2017-02-25 13:18:41 +03:00
|
|
|
float extra_pixel;
|
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-10-23 03:38:26 +00:00
|
|
|
/* x = litem->x; */ /* UNUSED */
|
2012-03-30 01:51:25 +00:00
|
|
|
y = litem->y;
|
|
|
|
w = litem->w;
|
|
|
|
totw = 0;
|
|
|
|
tot = 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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2009-04-16 12:17:58 +00:00
|
|
|
totw += itemw;
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (totw == 0)
|
2009-04-16 12:17:58 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (w != 0)
|
2012-03-30 01:51:25 +00:00
|
|
|
w -= (tot - 1) * litem->space;
|
|
|
|
fixedw = 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-03 00:04:48 +00:00
|
|
|
/* keep clamping items to fixed minimum size until all are done */
|
|
|
|
do {
|
2012-03-30 01:51:25 +00:00
|
|
|
freew = 0;
|
|
|
|
x = 0;
|
|
|
|
flag = 0;
|
2013-11-27 05:23:02 +01:00
|
|
|
newtotw = totw;
|
2017-02-25 13:18:41 +03:00
|
|
|
extra_pixel = 0.0f;
|
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
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
2017-01-10 16:19:10 +01:00
|
|
|
if (item->flag & UI_ITEM_FIXED)
|
2009-06-03 00:04:48 +00:00
|
|
|
continue;
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2009-06-03 00:04:48 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2012-03-30 01:51:25 +00:00
|
|
|
minw = ui_litem_min_width(itemw);
|
2009-06-03 00:04:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (w - lastw > 0)
|
2017-02-25 13:18:41 +03:00
|
|
|
neww = ui_item_fit(itemw, x, totw, w - lastw, !item->next, litem->alignment, &extra_pixel);
|
2009-06-03 00:04:48 +00:00
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
neww = 0; /* no space left, all will need clamping to minimum size */
|
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-03 00:04:48 +00:00
|
|
|
x += neww;
|
|
|
|
|
2017-03-26 12:19:01 +03:00
|
|
|
bool min_flag = item->flag & UI_ITEM_MIN;
|
|
|
|
/* ignore min flag for rows with right or center alignment */
|
|
|
|
if (item->type != ITEM_BUTTON &&
|
2017-04-01 12:09:17 +11:00
|
|
|
ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) &&
|
|
|
|
litem->alignment == UI_LAYOUT_ALIGN_EXPAND &&
|
|
|
|
((uiItem *)litem)->flag & UI_ITEM_MIN)
|
|
|
|
{
|
2017-03-26 12:19:01 +03:00
|
|
|
min_flag = false;
|
|
|
|
}
|
2017-04-01 12:09:17 +11:00
|
|
|
|
2017-03-26 12:19:01 +03:00
|
|
|
if ((neww < minw || min_flag) && w != 0) {
|
2009-06-03 00:04:48 +00:00
|
|
|
/* fixed size */
|
2017-01-10 16:19:10 +01:00
|
|
|
item->flag |= UI_ITEM_FIXED;
|
|
|
|
if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_MIN) {
|
|
|
|
minw = itemw;
|
|
|
|
}
|
2009-06-03 00:04:48 +00:00
|
|
|
fixedw += minw;
|
2012-03-30 01:51:25 +00:00
|
|
|
flag = 1;
|
2013-11-27 05:23:02 +01:00
|
|
|
newtotw -= itemw;
|
2009-06-03 00:04:48 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* keep free size */
|
2017-01-10 16:19:10 +01:00
|
|
|
item->flag &= ~UI_ITEM_FIXED;
|
2009-06-03 00:04:48 +00:00
|
|
|
freew += itemw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-27 05:23:02 +01:00
|
|
|
totw = newtotw;
|
2012-03-30 01:51:25 +00:00
|
|
|
lastw = fixedw;
|
2012-03-24 06:38:07 +00:00
|
|
|
} while (flag);
|
2009-06-03 00:04:48 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
freex = 0;
|
|
|
|
fixedx = 0;
|
2017-02-25 13:18:41 +03:00
|
|
|
extra_pixel = 0.0f;
|
2012-03-30 01:51:25 +00:00
|
|
|
x = litem->x;
|
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
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2012-03-30 01:51:25 +00:00
|
|
|
minw = ui_litem_min_width(itemw);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2017-01-10 16:19:10 +01:00
|
|
|
if (item->flag & UI_ITEM_FIXED) {
|
2009-06-03 00:04:48 +00:00
|
|
|
/* fixed minimum size items */
|
2017-01-10 16:19:10 +01:00
|
|
|
if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_MIN) {
|
|
|
|
minw = itemw;
|
|
|
|
}
|
2017-02-25 13:18:41 +03:00
|
|
|
itemw = ui_item_fit(minw, fixedx, fixedw, min_ii(w, fixedw), !item->next, litem->alignment, &extra_pixel);
|
2009-06-03 00:04:48 +00:00
|
|
|
fixedx += itemw;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* free size item */
|
2017-02-25 13:18:41 +03:00
|
|
|
itemw = ui_item_fit(itemw, freex, freew, w - fixedw, !item->next, litem->alignment, &extra_pixel);
|
2009-06-03 00:04:48 +00:00
|
|
|
freex += itemw;
|
2017-02-25 13:18:41 +03:00
|
|
|
last_free_item = 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
|
|
|
}
|
|
|
|
|
2009-06-03 00:04:48 +00:00
|
|
|
/* align right/center */
|
2012-03-30 01:51:25 +00:00
|
|
|
offset = 0;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) {
|
2012-05-11 17:05:10 +00:00
|
|
|
if (freew + fixedw > 0 && freew + fixedw < w)
|
|
|
|
offset = w - (fixedw + freew);
|
2009-06-03 00:04:48 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) {
|
2012-05-11 17:05:10 +00:00
|
|
|
if (freew + fixedw > 0 && freew + fixedw < w)
|
|
|
|
offset = (w - (fixedw + freew)) / 2;
|
2009-06-03 00:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* position item */
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_item_position(item, x + offset, y - itemh, itemw, itemh);
|
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-03 00:04:48 +00:00
|
|
|
x += itemw;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->next)
|
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
|
|
|
x += litem->space;
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 13:18:41 +03:00
|
|
|
/* add extra pixel */
|
|
|
|
uiItem *last_item = litem->items.last;
|
|
|
|
extra_pixel = litem->w - (x - litem->x);
|
2017-03-12 02:40:04 +11:00
|
|
|
if (extra_pixel > 0 && litem->alignment == UI_LAYOUT_ALIGN_EXPAND &&
|
|
|
|
last_free_item && last_item && last_item->flag & UI_ITEM_FIXED)
|
|
|
|
{
|
2017-02-25 13:18:41 +03:00
|
|
|
ui_item_move(last_free_item, 0, extra_pixel);
|
|
|
|
for (item = last_free_item->next; item; item = item->next)
|
|
|
|
ui_item_move(item, extra_pixel, extra_pixel);
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = x - litem->x;
|
|
|
|
litem->h = litem->y - y;
|
|
|
|
litem->x = x;
|
|
|
|
litem->y = y;
|
2009-04-16 12:17:58 +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
|
|
|
/* single-column layout */
|
2017-03-26 18:02:11 +03:00
|
|
|
static void ui_litem_estimate_column(uiLayout *litem, bool is_box)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
|
|
|
uiItem *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
|
|
|
int itemw, itemh;
|
2017-03-28 00:07:31 +03:00
|
|
|
bool min_size_flag = true;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = 0;
|
|
|
|
litem->h = 0;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2017-03-28 00:07:31 +03:00
|
|
|
min_size_flag = min_size_flag && (item->flag & UI_ITEM_MIN);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = MAX2(litem->w, itemw);
|
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
|
|
|
litem->h += itemh;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2017-03-26 18:02:11 +03:00
|
|
|
if (item->next && (!is_box || item != litem->items.first))
|
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
|
|
|
litem->h += litem->space;
|
|
|
|
}
|
2017-03-28 00:07:31 +03:00
|
|
|
|
|
|
|
if (min_size_flag) {
|
|
|
|
litem->item.flag |= UI_ITEM_MIN;
|
|
|
|
}
|
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-03-13 13:38:41 +00:00
|
|
|
|
2017-03-26 18:02:11 +03:00
|
|
|
static void ui_litem_layout_column(uiLayout *litem, bool is_box)
|
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
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
int itemh, x, y;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
x = litem->x;
|
|
|
|
y = litem->y;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, NULL, &itemh);
|
|
|
|
|
|
|
|
y -= itemh;
|
|
|
|
ui_item_position(item, x, y, litem->w, itemh);
|
|
|
|
|
2017-03-26 18:02:11 +03:00
|
|
|
if (item->next && (!is_box || item != litem->items.first))
|
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
|
|
|
y -= litem->space;
|
2017-07-27 10:27:29 +03:00
|
|
|
|
2017-07-27 11:44:51 +02:00
|
|
|
if (is_box) {
|
2017-07-27 10:27:29 +03:00
|
|
|
item->flag |= UI_ITEM_BOX_ITEM;
|
2017-07-27 11:44:51 +02:00
|
|
|
}
|
2009-04-15 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->h = litem->y - y;
|
|
|
|
litem->x = x;
|
|
|
|
litem->y = y;
|
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
|
|
|
}
|
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
/* calculates the angle of a specified button in a radial menu,
|
|
|
|
* stores a float vector in unit circle */
|
|
|
|
static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum)
|
|
|
|
{
|
|
|
|
RadialDirection dir;
|
2015-05-26 12:08:29 +02:00
|
|
|
|
2016-02-16 14:50:26 +01:00
|
|
|
if (itemnum >= PIE_MAX_ITEMS) {
|
|
|
|
itemnum %= PIE_MAX_ITEMS;
|
|
|
|
printf("Warning: Pie menus with more than %i items are currently unsupported\n", PIE_MAX_ITEMS);
|
2015-05-26 12:08:29 +02:00
|
|
|
}
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
dir = ui_radial_dir_order[itemnum];
|
2014-08-13 15:11:19 +02:00
|
|
|
ui_but_pie_dir(dir, vec);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ui_item_is_radial_displayable(uiItem *item)
|
|
|
|
{
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == UI_BTYPE_LABEL))
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ui_item_is_radial_drawable(uiButtonItem *bitem)
|
|
|
|
{
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE))
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_litem_layout_radial(uiLayout *litem)
|
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
int itemh, itemw, x, y;
|
|
|
|
int itemnum = 0;
|
|
|
|
int totitems = 0;
|
|
|
|
|
|
|
|
/* For the radial layout we will use Matt Ebb's design
|
|
|
|
* for radiation, see http://mattebb.com/weblog/radiation/
|
|
|
|
* also the old code at http://developer.blender.org/T5103
|
|
|
|
*/
|
|
|
|
|
|
|
|
int pie_radius = U.pie_menu_radius * UI_DPI_FAC;
|
|
|
|
|
|
|
|
x = litem->x;
|
|
|
|
y = litem->y;
|
|
|
|
|
2016-03-05 09:09:05 +11:00
|
|
|
int minx = x, miny = y, maxx = x, maxy = y;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
/* first count total items */
|
|
|
|
for (item = litem->items.first; item; item = item->next)
|
|
|
|
totitems++;
|
|
|
|
|
|
|
|
if (totitems < 5)
|
|
|
|
litem->root->block->pie_data.flags |= UI_PIE_DEGREES_RANGE_LARGE;
|
|
|
|
|
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
|
|
|
/* not all button types are drawn in a radial menu, do filtering here */
|
|
|
|
if (ui_item_is_radial_displayable(item)) {
|
|
|
|
RadialDirection dir;
|
|
|
|
float vec[2];
|
2014-08-13 15:11:19 +02:00
|
|
|
float factor[2];
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
dir = ui_get_radialbut_vec(vec, itemnum);
|
2014-08-13 15:11:19 +02:00
|
|
|
factor[0] = (vec[0] > 0.01f) ? 0.0f : ((vec[0] < -0.01f) ? -1.0f : -0.5f);
|
|
|
|
factor[1] = (vec[1] > 0.99f) ? 0.0f : ((vec[1] < -0.99f) ? -1.0f : -0.5f);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
itemnum++;
|
|
|
|
|
|
|
|
if (item->type == ITEM_BUTTON) {
|
|
|
|
uiButtonItem *bitem = (uiButtonItem *) item;
|
|
|
|
|
|
|
|
bitem->but->pie_dir = dir;
|
|
|
|
/* scale the buttons */
|
|
|
|
bitem->but->rect.ymax *= 1.5f;
|
|
|
|
/* add a little bit more here to include number */
|
|
|
|
bitem->but->rect.xmax += 1.5f * UI_UNIT_X;
|
|
|
|
/* enable drawing as pie item if supported by widget */
|
2017-06-20 20:15:04 +03:00
|
|
|
if (ui_item_is_radial_drawable(bitem)) {
|
2014-11-09 21:20:40 +01:00
|
|
|
bitem->but->dt = UI_EMBOSS_RADIAL;
|
2017-06-20 20:15:04 +03:00
|
|
|
bitem->but->drawflag |= UI_BUT_ICON_LEFT;
|
|
|
|
}
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ui_item_size(item, &itemw, &itemh);
|
|
|
|
|
2014-08-13 15:11:19 +02:00
|
|
|
ui_item_position(item, x + vec[0] * pie_radius + factor[0] * itemw, y + vec[1] * pie_radius + factor[1] * itemh, itemw, itemh);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
minx = min_ii(minx, x + vec[0] * pie_radius - itemw / 2);
|
|
|
|
maxx = max_ii(maxx, x + vec[0] * pie_radius + itemw / 2);
|
|
|
|
miny = min_ii(miny, y + vec[1] * pie_radius - itemh / 2);
|
|
|
|
maxy = max_ii(maxy, y + vec[1] * pie_radius + itemh / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
litem->x = minx;
|
|
|
|
litem->y = miny;
|
|
|
|
litem->w = maxx - minx;
|
|
|
|
litem->h = maxy - miny;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* root layout */
|
2010-10-14 12:24:08 +00:00
|
|
|
static void ui_litem_estimate_root(uiLayout *UNUSED(litem))
|
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
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
static void ui_litem_layout_root_radial(uiLayout *litem)
|
|
|
|
{
|
|
|
|
/* first item is pie menu title, align on center of menu */
|
|
|
|
uiItem *item = litem->items.first;
|
|
|
|
|
|
|
|
if (item->type == ITEM_BUTTON) {
|
|
|
|
int itemh, itemw, x, y;
|
|
|
|
x = litem->x;
|
|
|
|
y = litem->y;
|
|
|
|
|
|
|
|
ui_item_size(item, &itemw, &itemh);
|
|
|
|
|
2014-08-13 15:11:19 +02:00
|
|
|
ui_item_position(item, x - itemw / 2, y + U.pixelsize * (U.pie_menu_threshold + 9.0f), itemw, itemh);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02: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
|
|
|
static void ui_litem_layout_root(uiLayout *litem)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (litem->root->type == UI_LAYOUT_HEADER)
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_litem_layout_row(litem);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
else if (litem->root->type == UI_LAYOUT_PIEMENU)
|
|
|
|
ui_litem_layout_root_radial(litem);
|
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
|
|
|
else
|
2017-03-26 18:02:11 +03:00
|
|
|
ui_litem_layout_column(litem, false);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* box layout */
|
|
|
|
static void ui_litem_estimate_box(uiLayout *litem)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiStyle *style = litem->root->style;
|
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
|
|
|
|
2017-03-26 18:02:11 +03:00
|
|
|
ui_litem_estimate_column(litem, true);
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w += 2 * style->boxspace;
|
2017-03-26 18:02:11 +03:00
|
|
|
litem->h += 2 * style->boxspace;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_litem_layout_box(uiLayout *litem)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayoutItemBx *box = (uiLayoutItemBx *)litem;
|
|
|
|
uiStyle *style = litem->root->style;
|
2009-05-21 15:34:09 +00:00
|
|
|
uiBut *but;
|
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
|
|
|
int w, h;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
w = litem->w;
|
|
|
|
h = litem->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
|
|
|
|
|
|
|
litem->x += style->boxspace;
|
2017-03-26 18:02:11 +03:00
|
|
|
litem->y -= style->boxspace;
|
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
|
|
|
if (w != 0) litem->w -= 2 * style->boxspace;
|
|
|
|
if (h != 0) litem->h -= 2 * style->boxspace;
|
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
|
|
|
|
2017-03-26 18:02:11 +03:00
|
|
|
ui_litem_layout_column(litem, true);
|
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
|
|
|
|
|
|
|
litem->x -= style->boxspace;
|
|
|
|
litem->y -= style->boxspace;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (w != 0) litem->w += 2 * style->boxspace;
|
2017-03-26 18:02:11 +03:00
|
|
|
if (h != 0) litem->h += 2 * style->boxspace;
|
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
|
|
|
|
|
|
|
/* roundbox around the sublayout */
|
2012-03-30 01:51:25 +00:00
|
|
|
but = box->roundbox;
|
2012-08-18 16:53:46 +00:00
|
|
|
but->rect.xmin = litem->x;
|
|
|
|
but->rect.ymin = litem->y;
|
|
|
|
but->rect.xmax = litem->x + litem->w;
|
|
|
|
but->rect.ymax = litem->y + litem->h;
|
2009-04-15 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
2009-04-11 01:52:27 +00:00
|
|
|
/* multi-column layout, automatically flowing to the next */
|
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
|
|
|
static void ui_litem_estimate_column_flow(uiLayout *litem)
|
2009-04-11 01:52:27 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiStyle *style = litem->root->style;
|
|
|
|
uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
|
2009-04-11 01:52:27 +00:00
|
|
|
uiItem *item;
|
2012-03-30 01:51:25 +00:00
|
|
|
int col, x, y, emh, emy, miny, itemw, itemh, maxw = 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
|
|
|
int toth, totitem;
|
2009-04-11 01:52:27 +00:00
|
|
|
|
|
|
|
/* compute max needed width and total height */
|
2012-03-30 01:51:25 +00:00
|
|
|
toth = 0;
|
|
|
|
totitem = 0;
|
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2012-03-30 01:51:25 +00:00
|
|
|
maxw = MAX2(maxw, itemw);
|
2009-04-16 12:17:58 +00:00
|
|
|
toth += itemh;
|
2009-04-11 01:52:27 +00:00
|
|
|
totitem++;
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flow->number <= 0) {
|
2009-04-11 01:52:27 +00:00
|
|
|
/* auto compute number of columns, not very good */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (maxw == 0) {
|
2012-03-30 01:51:25 +00:00
|
|
|
flow->totcol = 1;
|
2009-04-11 01:52:27 +00:00
|
|
|
return;
|
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-04-11 01:52:27 +00:00
|
|
|
|
2012-10-24 05:06:40 +00:00
|
|
|
flow->totcol = max_ii(litem->root->emw / maxw, 1);
|
|
|
|
flow->totcol = min_ii(flow->totcol, totitem);
|
2009-04-11 01:52:27 +00:00
|
|
|
}
|
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
flow->totcol = flow->number;
|
2009-04-11 01:52:27 +00:00
|
|
|
|
|
|
|
/* compute sizes */
|
2012-03-30 01:51:25 +00:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
emy = 0;
|
|
|
|
miny = 0;
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
maxw = 0;
|
|
|
|
emh = toth / flow->totcol;
|
2009-04-11 01:52:27 +00:00
|
|
|
|
|
|
|
/* create column per column */
|
2012-03-30 01:51:25 +00:00
|
|
|
col = 0;
|
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
|
|
|
|
|
|
|
y -= itemh + style->buttonspacey;
|
2012-11-07 12:31:05 +00:00
|
|
|
miny = min_ii(miny, y);
|
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
|
|
|
emy -= itemh;
|
2012-11-07 12:31:05 +00:00
|
|
|
maxw = max_ii(itemw, maxw);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
|
|
|
/* decide to go to next one */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (col < flow->totcol - 1 && emy <= -emh) {
|
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
|
|
|
x += maxw + litem->space;
|
2012-03-30 01:51:25 +00:00
|
|
|
maxw = 0;
|
|
|
|
y = 0;
|
2012-08-01 17:52:14 +00:00
|
|
|
emy = 0; /* need to reset height again for next column */
|
2009-04-11 01:52:27 +00:00
|
|
|
col++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = x;
|
|
|
|
litem->h = litem->y - miny;
|
2009-04-11 01:52: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
|
|
|
static void ui_litem_layout_column_flow(uiLayout *litem)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiStyle *style = litem->root->style;
|
|
|
|
uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
|
2009-03-13 13:38:41 +00:00
|
|
|
uiItem *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
|
|
|
int col, x, y, w, emh, emy, miny, itemw, itemh;
|
2016-10-12 21:28:11 +02:00
|
|
|
int toth, totitem;
|
2009-03-13 13:38: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
|
|
|
/* compute max needed width and total height */
|
2012-03-30 01:51:25 +00:00
|
|
|
toth = 0;
|
|
|
|
totitem = 0;
|
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
|
|
|
toth += itemh;
|
|
|
|
totitem++;
|
2009-03-13 13:38: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
|
|
|
/* compute sizes */
|
2012-03-30 01:51:25 +00:00
|
|
|
x = litem->x;
|
|
|
|
y = litem->y;
|
|
|
|
emy = 0;
|
|
|
|
miny = 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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
w = litem->w - (flow->totcol - 1) * style->columnspace;
|
|
|
|
emh = toth / flow->totcol;
|
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
|
|
|
|
|
|
|
/* create column per column */
|
2012-03-30 01:51:25 +00:00
|
|
|
col = 0;
|
2016-10-13 10:21:38 +02:00
|
|
|
w = (litem->w - (flow->totcol - 1) * style->columnspace) / flow->totcol;
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
2016-10-13 10:21:38 +02:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
|
|
|
|
|
|
|
itemw = (litem->alignment == UI_LAYOUT_ALIGN_EXPAND) ? w : min_ii(w, itemw);
|
|
|
|
|
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
|
|
|
y -= itemh;
|
|
|
|
emy -= itemh;
|
2016-10-12 21:28:11 +02:00
|
|
|
ui_item_position(item, x, y, itemw, itemh);
|
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
|
|
|
y -= style->buttonspacey;
|
2012-10-24 05:06:40 +00:00
|
|
|
miny = min_ii(miny, y);
|
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
|
|
|
|
|
|
|
/* decide to go to next one */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (col < flow->totcol - 1 && emy <= -emh) {
|
2016-10-13 10:21:38 +02:00
|
|
|
x += w + style->columnspace;
|
2012-03-30 01:51:25 +00:00
|
|
|
y = litem->y;
|
2012-08-01 17:52:14 +00:00
|
|
|
emy = 0; /* need to reset height again for next column */
|
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
|
|
|
col++;
|
2016-10-13 10:21:38 +02:00
|
|
|
|
|
|
|
/* (< remaining width > - < space between remaining columns >) / <remamining columns > */
|
|
|
|
w = ((litem->w - (x - litem->x)) - (flow->totcol - col - 1) * style->columnspace) / (flow->totcol - col);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->h = litem->y - miny;
|
|
|
|
litem->x = x;
|
|
|
|
litem->y = miny;
|
2009-03-13 13:38: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
|
|
|
/* free layout */
|
2009-10-09 10:45:11 +00:00
|
|
|
static void ui_litem_estimate_absolute(uiLayout *litem)
|
2009-03-13 13:38: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
|
|
|
uiItem *item;
|
|
|
|
int itemx, itemy, itemw, itemh, minx, miny;
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
minx = 1e6;
|
|
|
|
miny = 1e6;
|
|
|
|
litem->w = 0;
|
|
|
|
litem->h = 0;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_offset(item, &itemx, &itemy);
|
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-10-24 05:06:40 +00:00
|
|
|
minx = min_ii(minx, itemx);
|
|
|
|
miny = min_ii(miny, itemy);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = MAX2(litem->w, itemx + itemw);
|
|
|
|
litem->h = MAX2(litem->h, itemy + itemh);
|
2009-04-16 12:17:58 +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
|
|
|
litem->w -= minx;
|
|
|
|
litem->h -= miny;
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
|
|
|
|
2009-10-09 10:45:11 +00:00
|
|
|
static void ui_litem_layout_absolute(uiLayout *litem)
|
2009-04-16 12:17:58 +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
|
|
|
uiItem *item;
|
2012-03-30 01:51:25 +00:00
|
|
|
float scalex = 1.0f, scaley = 1.0f;
|
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
|
|
|
int x, y, newx, newy, itemx, itemy, itemh, itemw, minx, miny, totw, toth;
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
minx = 1e6;
|
|
|
|
miny = 1e6;
|
|
|
|
totw = 0;
|
|
|
|
toth = 0;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_offset(item, &itemx, &itemy);
|
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-10-24 05:06:40 +00:00
|
|
|
minx = min_ii(minx, itemx);
|
|
|
|
miny = min_ii(miny, itemy);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-10-24 05:06:40 +00:00
|
|
|
totw = max_ii(totw, itemx + itemw);
|
|
|
|
toth = max_ii(toth, itemy + itemh);
|
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-03-13 13:38: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
|
|
|
totw -= minx;
|
|
|
|
toth -= miny;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (litem->w && totw > 0)
|
2012-03-30 01:51:25 +00:00
|
|
|
scalex = (float)litem->w / (float)totw;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (litem->h && toth > 0)
|
2012-03-30 01:51:25 +00:00
|
|
|
scaley = (float)litem->h / (float)toth;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
x = litem->x;
|
|
|
|
y = litem->y - scaley * toth;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_offset(item, &itemx, &itemy);
|
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scalex != 1.0f) {
|
2012-03-30 01:51:25 +00:00
|
|
|
newx = (itemx - minx) * scalex;
|
|
|
|
itemw = (itemx - minx + itemw) * scalex - newx;
|
|
|
|
itemx = minx + newx;
|
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-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scaley != 1.0f) {
|
2012-03-30 01:51:25 +00:00
|
|
|
newy = (itemy - miny) * scaley;
|
|
|
|
itemh = (itemy - miny + itemh) * scaley - newy;
|
|
|
|
itemy = miny + newy;
|
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-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_item_position(item, x + itemx - minx, y + itemy - miny, itemw, itemh);
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = scalex * totw;
|
|
|
|
litem->h = litem->y - y;
|
|
|
|
litem->x = x + litem->w;
|
|
|
|
litem->y = y;
|
2009-03-13 13:38: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
|
|
|
/* split layout */
|
|
|
|
static void ui_litem_estimate_split(uiLayout *litem)
|
2009-04-22 18:39:44 +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
|
|
|
ui_litem_estimate_row(litem);
|
2017-03-06 16:35:56 +03:00
|
|
|
litem->item.flag &= ~UI_ITEM_MIN;
|
2009-04-22 18:39:44 +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
|
|
|
static void ui_litem_layout_split(uiLayout *litem)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayoutItemSplit *split = (uiLayoutItemSplit *)litem;
|
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
|
|
|
uiItem *item;
|
2017-03-06 16:35:56 +03:00
|
|
|
float percentage, extra_pixel = 0.0f;
|
2014-11-16 13:57:58 +01:00
|
|
|
const int tot = BLI_listbase_count(&litem->items);
|
2012-03-30 01:51:25 +00:00
|
|
|
int itemh, x, y, w, colw = 0;
|
2011-03-19 05:06:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tot == 0)
|
2011-03-19 05:06:06 +00:00
|
|
|
return;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
x = litem->x;
|
|
|
|
y = litem->y;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
|
2009-06-16 01:08:39 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
w = (litem->w - (tot - 1) * litem->space);
|
|
|
|
colw = w * percentage;
|
|
|
|
colw = MAX2(colw, 0);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_size(item, NULL, &itemh);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_item_position(item, x, y - itemh, colw, itemh);
|
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
|
|
|
x += colw;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->next) {
|
2017-03-06 16:35:56 +03:00
|
|
|
const float width = extra_pixel + (w - (int)(w * percentage)) / ((float)tot - 1);
|
|
|
|
extra_pixel = width - (int)width;
|
|
|
|
colw = (int)width;
|
2012-03-30 01:51:25 +00:00
|
|
|
colw = MAX2(colw, 0);
|
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
|
|
|
x += litem->space;
|
2009-06-07 13:20:41 +00:00
|
|
|
}
|
2009-04-22 18:39:44 +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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = x - litem->x;
|
|
|
|
litem->h = litem->y - y;
|
|
|
|
litem->x = x;
|
|
|
|
litem->y = y;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-10-21 20:58:10 +00:00
|
|
|
/* overlap layout */
|
|
|
|
static void ui_litem_estimate_overlap(uiLayout *litem)
|
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
int itemw, itemh;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = 0;
|
|
|
|
litem->h = 0;
|
2009-10-21 20:58:10 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
2009-10-21 20:58:10 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->w = MAX2(itemw, litem->w);
|
|
|
|
litem->h = MAX2(itemh, litem->h);
|
2009-10-21 20:58:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_litem_layout_overlap(uiLayout *litem)
|
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
int itemw, itemh, x, y;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
x = litem->x;
|
|
|
|
y = litem->y;
|
2009-10-21 20:58:10 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.first; item; item = item->next) {
|
2009-10-21 20:58:10 +00:00
|
|
|
ui_item_size(item, &itemw, &itemh);
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_item_position(item, x, y - itemh, litem->w, itemh);
|
2009-10-21 20:58:10 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->h = MAX2(litem->h, itemh);
|
2009-10-21 20:58:10 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->x = x;
|
|
|
|
litem->y = y - litem->h;
|
2009-10-21 20:58:10 +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
|
|
|
/* layout create functions */
|
|
|
|
uiLayout *uiLayoutRow(uiLayout *layout, int align)
|
2009-03-13 13:38: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
|
|
|
uiLayout *litem;
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
|
|
|
|
litem->item.type = ITEM_LAYOUT_ROW;
|
|
|
|
litem->root = layout->root;
|
|
|
|
litem->align = align;
|
2013-04-04 02:05:11 +00:00
|
|
|
litem->active = true;
|
|
|
|
litem->enabled = true;
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->context = layout->context;
|
|
|
|
litem->space = (align) ? 0 : layout->root->style->buttonspacex;
|
2013-02-28 07:13:33 +00:00
|
|
|
litem->redalert = layout->redalert;
|
2010-07-27 12:11:25 +00:00
|
|
|
litem->w = layout->w;
|
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
|
|
|
BLI_addtail(&layout->items, litem);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, litem);
|
2009-05-19 17:13:33 +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
|
|
|
return litem;
|
2009-03-13 13:38: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
|
|
|
uiLayout *uiLayoutColumn(uiLayout *layout, int align)
|
2009-04-15 15:09:36 +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
|
|
|
uiLayout *litem;
|
2009-04-15 15:09:36 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
|
|
|
|
litem->item.type = ITEM_LAYOUT_COLUMN;
|
|
|
|
litem->root = layout->root;
|
|
|
|
litem->align = align;
|
2013-04-04 02:05:11 +00:00
|
|
|
litem->active = true;
|
|
|
|
litem->enabled = true;
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->context = layout->context;
|
|
|
|
litem->space = (litem->align) ? 0 : layout->root->style->buttonspacey;
|
2013-02-28 07:13:33 +00:00
|
|
|
litem->redalert = layout->redalert;
|
2010-07-27 12:11:25 +00:00
|
|
|
litem->w = layout->w;
|
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
|
|
|
BLI_addtail(&layout->items, litem);
|
2009-04-15 15:09:36 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, litem);
|
2009-05-19 17:13:33 +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
|
|
|
return litem;
|
2009-04-15 15:09:36 +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
|
|
|
uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
|
2009-03-13 13:38: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
|
|
|
uiLayoutItemFlow *flow;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
|
|
|
|
flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW;
|
|
|
|
flow->litem.root = layout->root;
|
|
|
|
flow->litem.align = align;
|
2013-04-04 02:05:11 +00:00
|
|
|
flow->litem.active = true;
|
|
|
|
flow->litem.enabled = true;
|
2012-03-30 01:51:25 +00:00
|
|
|
flow->litem.context = layout->context;
|
|
|
|
flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace;
|
2013-02-28 07:13:33 +00:00
|
|
|
flow->litem.redalert = layout->redalert;
|
2010-07-27 12:11:25 +00:00
|
|
|
flow->litem.w = layout->w;
|
2012-03-30 01:51:25 +00:00
|
|
|
flow->number = number;
|
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
|
|
|
BLI_addtail(&layout->items, flow);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, &flow->litem);
|
2009-05-19 17:13:33 +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
|
|
|
return &flow->litem;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-10-21 20:58:10 +00:00
|
|
|
static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
|
2009-04-11 01:52: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
|
|
|
uiLayoutItemBx *box;
|
2009-04-11 01:52:27 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
box = MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
|
|
|
|
box->litem.item.type = ITEM_LAYOUT_BOX;
|
|
|
|
box->litem.root = layout->root;
|
|
|
|
box->litem.active = 1;
|
|
|
|
box->litem.enabled = 1;
|
|
|
|
box->litem.context = layout->context;
|
|
|
|
box->litem.space = layout->root->style->columnspace;
|
2013-02-28 07:13:33 +00:00
|
|
|
box->litem.redalert = layout->redalert;
|
2010-07-27 12:11:25 +00:00
|
|
|
box->litem.w = layout->w;
|
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
|
|
|
BLI_addtail(&layout->items, box);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, &box->litem);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
box->roundbox = uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
|
2009-05-21 15:34:09 +00:00
|
|
|
|
2009-10-21 20:58:10 +00:00
|
|
|
return box;
|
2009-04-11 01:52:27 +00:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
uiLayout *uiLayoutRadial(uiLayout *layout)
|
|
|
|
{
|
|
|
|
uiLayout *litem;
|
|
|
|
uiItem *item;
|
|
|
|
|
|
|
|
/* radial layouts are only valid for radial menus */
|
|
|
|
if (layout->root->type != UI_LAYOUT_PIEMENU)
|
|
|
|
return ui_item_local_sublayout(layout, layout, 0);
|
|
|
|
|
|
|
|
/* only one radial wheel per root layout is allowed, so check and return that, if it exists */
|
|
|
|
for (item = layout->root->layout->items.first; item; item = item->next) {
|
|
|
|
litem = (uiLayout *)item;
|
|
|
|
if (litem->item.type == ITEM_LAYOUT_RADIAL) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, litem);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
return litem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRadial");
|
|
|
|
litem->item.type = ITEM_LAYOUT_RADIAL;
|
|
|
|
litem->root = layout->root;
|
|
|
|
litem->active = true;
|
|
|
|
litem->enabled = true;
|
|
|
|
litem->context = layout->context;
|
|
|
|
litem->redalert = layout->redalert;
|
|
|
|
litem->w = layout->w;
|
|
|
|
BLI_addtail(&layout->root->layout->items, litem);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, litem);
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
|
|
|
|
return litem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
uiLayout *uiLayoutBox(uiLayout *layout)
|
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
return (uiLayout *)ui_layout_box(layout, UI_BTYPE_ROUNDBOX);
|
2009-07-21 01:26:17 +00:00
|
|
|
}
|
|
|
|
|
2015-05-31 14:20:03 +10:00
|
|
|
/**
|
|
|
|
* Check all buttons defined in this layout, and set any button flagged as UI_BUT_LIST_ITEM as active/selected.
|
2013-11-23 18:43:23 +01:00
|
|
|
* Needed to handle correctly text colors of active (selected) 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
|
|
|
void ui_layout_list_set_labels_active(uiLayout *layout)
|
|
|
|
{
|
|
|
|
uiButtonItem *bitem;
|
|
|
|
for (bitem = layout->items.first; bitem; bitem = bitem->item.next) {
|
2013-11-09 18:44:37 +00:00
|
|
|
if (bitem->item.type != ITEM_BUTTON) {
|
|
|
|
ui_layout_list_set_labels_active((uiLayout *)(&bitem->item));
|
|
|
|
}
|
2013-11-21 16:51:29 +01:00
|
|
|
else if (bitem->but->flag & UI_BUT_LIST_ITEM) {
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_enable(bitem->but, UI_SELECT);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-05 03:13:47 +10:00
|
|
|
uiLayout *uiLayoutListBox(
|
|
|
|
uiLayout *layout, uiList *ui_list, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *actptr,
|
|
|
|
PropertyRNA *actprop)
|
2009-07-21 01:26:17 +00:00
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
uiLayoutItemBx *box = ui_layout_box(layout, UI_BTYPE_LISTBOX);
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBut *but = box->roundbox;
|
2009-07-21 01:26:17 +00:00
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
but->custom_data = ui_list;
|
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
|
|
|
but->rnasearchpoin = *ptr;
|
|
|
|
but->rnasearchprop = prop;
|
|
|
|
but->rnapoin = *actptr;
|
|
|
|
but->rnaprop = actprop;
|
2009-10-21 20:58:10 +00:00
|
|
|
|
2013-07-09 23:40:53 +00:00
|
|
|
/* only for the undo string */
|
|
|
|
if (but->flag & UI_BUT_UNDO) {
|
|
|
|
but->tip = RNA_property_description(actprop);
|
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
return (uiLayout *)box;
|
2009-07-21 01:26:17 +00:00
|
|
|
}
|
|
|
|
|
2009-10-21 20:58:10 +00:00
|
|
|
uiLayout *uiLayoutAbsolute(uiLayout *layout, int align)
|
2009-03-13 13:38: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
|
|
|
uiLayout *litem;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem = MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
|
|
|
|
litem->item.type = ITEM_LAYOUT_ABSOLUTE;
|
|
|
|
litem->root = layout->root;
|
|
|
|
litem->align = align;
|
|
|
|
litem->active = 1;
|
|
|
|
litem->enabled = 1;
|
|
|
|
litem->context = layout->context;
|
2013-03-16 03:59:03 +00:00
|
|
|
litem->redalert = layout->redalert;
|
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
|
|
|
BLI_addtail(&layout->items, litem);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, litem);
|
2009-05-19 17:13:33 +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
|
|
|
return litem;
|
2009-04-16 12:17:58 +00:00
|
|
|
}
|
|
|
|
|
2009-10-09 10:45:11 +00:00
|
|
|
uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout)
|
2009-05-19 17:13:33 +00:00
|
|
|
{
|
|
|
|
uiBlock *block;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block = uiLayoutGetBlock(layout);
|
2014-01-04 17:16:19 +11:00
|
|
|
uiLayoutAbsolute(layout, false);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2009-10-21 20:58:10 +00:00
|
|
|
uiLayout *uiLayoutOverlap(uiLayout *layout)
|
|
|
|
{
|
|
|
|
uiLayout *litem;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
litem = MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
|
|
|
|
litem->item.type = ITEM_LAYOUT_OVERLAP;
|
|
|
|
litem->root = layout->root;
|
2013-04-04 02:05:11 +00:00
|
|
|
litem->active = true;
|
|
|
|
litem->enabled = true;
|
2012-03-30 01:51:25 +00:00
|
|
|
litem->context = layout->context;
|
2013-03-16 03:59:03 +00:00
|
|
|
litem->redalert = layout->redalert;
|
2009-10-21 20:58:10 +00:00
|
|
|
BLI_addtail(&layout->items, litem);
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, litem);
|
2009-10-21 20:58:10 +00:00
|
|
|
|
|
|
|
return litem;
|
|
|
|
}
|
|
|
|
|
2009-12-10 14:47:07 +00:00
|
|
|
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align)
|
2009-04-16 12:17:58 +00:00
|
|
|
{
|
2011-07-26 20:22:54 +00:00
|
|
|
uiLayoutItemSplit *split;
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
split = MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit");
|
|
|
|
split->litem.item.type = ITEM_LAYOUT_SPLIT;
|
|
|
|
split->litem.root = layout->root;
|
|
|
|
split->litem.align = align;
|
2013-04-04 02:05:11 +00:00
|
|
|
split->litem.active = true;
|
|
|
|
split->litem.enabled = true;
|
2012-03-30 01:51:25 +00:00
|
|
|
split->litem.context = layout->context;
|
|
|
|
split->litem.space = layout->root->style->columnspace;
|
2013-03-16 03:59:03 +00:00
|
|
|
split->litem.redalert = layout->redalert;
|
2012-03-30 01:51:25 +00:00
|
|
|
split->litem.w = layout->w;
|
|
|
|
split->percentage = percentage;
|
2009-06-07 13:20:41 +00:00
|
|
|
BLI_addtail(&layout->items, split);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_set_current(layout->root->block, &split->litem);
|
2009-04-16 12:17:58 +00:00
|
|
|
|
2009-06-07 13:20:41 +00:00
|
|
|
return &split->litem;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
void uiLayoutSetActive(uiLayout *layout, bool active)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->active = active;
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->enabled = enabled;
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->redalert = redalert;
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
void uiLayoutSetKeepAspect(uiLayout *layout, bool keepaspect)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->keepaspect = keepaspect;
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
void uiLayoutSetAlignment(uiLayout *layout, char alignment)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->alignment = alignment;
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 00:04:48 +00:00
|
|
|
void uiLayoutSetScaleX(uiLayout *layout, float scale)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->scale[0] = scale;
|
2009-06-03 00:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiLayoutSetScaleY(uiLayout *layout, float scale)
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->scale[1] = scale;
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool uiLayoutGetActive(uiLayout *layout)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return layout->active;
|
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool uiLayoutGetEnabled(uiLayout *layout)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return layout->enabled;
|
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool uiLayoutGetRedAlert(uiLayout *layout)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return layout->redalert;
|
|
|
|
}
|
|
|
|
|
2013-04-04 02:05:11 +00:00
|
|
|
bool uiLayoutGetKeepAspect(uiLayout *layout)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return layout->keepaspect;
|
|
|
|
}
|
|
|
|
|
|
|
|
int uiLayoutGetAlignment(uiLayout *layout)
|
|
|
|
{
|
|
|
|
return layout->alignment;
|
|
|
|
}
|
|
|
|
|
2009-08-16 13:01:40 +00:00
|
|
|
int uiLayoutGetWidth(uiLayout *layout)
|
|
|
|
{
|
|
|
|
return layout->w;
|
|
|
|
}
|
|
|
|
|
2009-06-03 00:04:48 +00:00
|
|
|
float uiLayoutGetScaleX(uiLayout *layout)
|
|
|
|
{
|
|
|
|
return layout->scale[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
float uiLayoutGetScaleY(uiLayout *layout)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2012-04-23 15:54:43 +00:00
|
|
|
return layout->scale[1];
|
2009-05-28 23:37:55 +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
|
|
|
/********************** Layout *******************/
|
|
|
|
|
2013-05-08 12:54:33 +00:00
|
|
|
static void ui_item_scale(uiLayout *litem, const float scale[2])
|
2009-06-03 00:04:48 +00:00
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
int x, y, w, h;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.last; item; item = item->prev) {
|
2009-06-03 00:04:48 +00:00
|
|
|
ui_item_size(item, &w, &h);
|
|
|
|
ui_item_offset(item, &x, &y);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scale[0] != 0.0f) {
|
2009-06-03 00:04:48 +00:00
|
|
|
x *= scale[0];
|
|
|
|
w *= scale[0];
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scale[1] != 0.0f) {
|
2009-06-03 00:04:48 +00:00
|
|
|
y *= scale[1];
|
|
|
|
h *= scale[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_item_position(item, x, y, w, 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
|
|
|
static void ui_item_estimate(uiItem *item)
|
2009-03-13 13:38: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
|
|
|
uiItem *subitem;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type != ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayout *litem = (uiLayout *)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
|
|
|
for (subitem = litem->items.first; subitem; subitem = subitem->next)
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ui_item_estimate(subitem);
|
|
|
|
|
2017-08-08 15:52:14 +03:00
|
|
|
if (BLI_listbase_is_empty(&litem->items)) {
|
|
|
|
litem->w = 0;
|
|
|
|
litem->h = 0;
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
2017-08-08 15:52:14 +03:00
|
|
|
}
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
|
2009-06-03 00:04:48 +00:00
|
|
|
ui_item_scale(litem, litem->scale);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (litem->item.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
|
|
|
case ITEM_LAYOUT_COLUMN:
|
2017-03-26 18:02:11 +03:00
|
|
|
ui_litem_estimate_column(litem, false);
|
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
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_COLUMN_FLOW:
|
|
|
|
ui_litem_estimate_column_flow(litem);
|
2009-04-16 12:17:58 +00:00
|
|
|
break;
|
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
|
|
|
case ITEM_LAYOUT_ROW:
|
|
|
|
ui_litem_estimate_row(litem);
|
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_BOX:
|
|
|
|
ui_litem_estimate_box(litem);
|
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_ROOT:
|
|
|
|
ui_litem_estimate_root(litem);
|
|
|
|
break;
|
2009-10-09 10:45:11 +00:00
|
|
|
case ITEM_LAYOUT_ABSOLUTE:
|
|
|
|
ui_litem_estimate_absolute(litem);
|
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
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_SPLIT:
|
|
|
|
ui_litem_estimate_split(litem);
|
2009-04-16 12:17:58 +00:00
|
|
|
break;
|
2009-10-21 20:58:10 +00:00
|
|
|
case ITEM_LAYOUT_OVERLAP:
|
|
|
|
ui_litem_estimate_overlap(litem);
|
|
|
|
break;
|
2009-04-16 12:17:58 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2011-10-03 01:01:01 +00:00
|
|
|
static void ui_item_align(uiLayout *litem, short nr)
|
2009-03-13 13:38: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
|
|
|
uiItem *item;
|
2009-05-19 17:13:33 +00:00
|
|
|
uiButtonItem *bitem;
|
2009-05-21 15:34:09 +00:00
|
|
|
uiLayoutItemBx *box;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.last; item; item = item->prev) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type == ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
bitem = (uiButtonItem *)item;
|
2015-11-06 18:39:56 +01:00
|
|
|
#ifndef USE_UIBUT_SPATIAL_ALIGN
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ui_but_can_align(bitem->but))
|
2015-11-06 18:39:56 +01:00
|
|
|
#endif
|
2015-11-07 17:36:10 +11:00
|
|
|
{
|
|
|
|
if (!bitem->but->alignnr) {
|
2012-03-30 01:51:25 +00:00
|
|
|
bitem->but->alignnr = nr;
|
2015-11-07 17:36:10 +11:00
|
|
|
}
|
|
|
|
}
|
2009-05-19 17:13:33 +00:00
|
|
|
}
|
2012-10-07 09:48:59 +00:00
|
|
|
else if (item->type == ITEM_LAYOUT_ABSOLUTE) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else if (item->type == ITEM_LAYOUT_OVERLAP) {
|
|
|
|
/* pass */
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (item->type == ITEM_LAYOUT_BOX) {
|
2012-03-30 01:51:25 +00:00
|
|
|
box = (uiLayoutItemBx *)item;
|
2017-03-26 18:02:11 +03:00
|
|
|
if (!box->roundbox->alignnr) {
|
|
|
|
box->roundbox->alignnr = nr;
|
|
|
|
}
|
2009-05-21 15:34:09 +00:00
|
|
|
}
|
2013-08-23 16:53:37 +00:00
|
|
|
else if (((uiLayout *)item)->align) {
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_item_align((uiLayout *)item, nr);
|
2013-08-23 16:53:37 +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
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 23:37:55 +00:00
|
|
|
static void ui_item_flag(uiLayout *litem, int flag)
|
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
uiButtonItem *bitem;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = litem->items.last; item; item = item->prev) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type == ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
bitem = (uiButtonItem *)item;
|
2009-05-28 23:37:55 +00:00
|
|
|
bitem->but->flag |= flag;
|
|
|
|
}
|
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_item_flag((uiLayout *)item, flag);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-27 00:03:49 +00:00
|
|
|
static void ui_item_layout(uiItem *item)
|
2009-03-13 13:38: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
|
|
|
uiItem *subitem;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type != ITEM_BUTTON) {
|
2012-03-30 01:51:25 +00:00
|
|
|
uiLayout *litem = (uiLayout *)item;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(&litem->items))
|
2009-05-19 17:13:33 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (litem->align)
|
2009-05-19 17:13:33 +00:00
|
|
|
ui_item_align(litem, ++litem->root->block->alignnr);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!litem->active)
|
2009-05-28 23:37:55 +00:00
|
|
|
ui_item_flag(litem, UI_BUT_INACTIVE);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!litem->enabled)
|
2009-05-28 23:37:55 +00:00
|
|
|
ui_item_flag(litem, UI_BUT_DISABLED);
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (litem->item.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
|
|
|
case ITEM_LAYOUT_COLUMN:
|
2017-03-26 18:02:11 +03:00
|
|
|
ui_litem_layout_column(litem, false);
|
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
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_COLUMN_FLOW:
|
|
|
|
ui_litem_layout_column_flow(litem);
|
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_ROW:
|
|
|
|
ui_litem_layout_row(litem);
|
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_BOX:
|
|
|
|
ui_litem_layout_box(litem);
|
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_ROOT:
|
|
|
|
ui_litem_layout_root(litem);
|
|
|
|
break;
|
2009-10-09 10:45:11 +00:00
|
|
|
case ITEM_LAYOUT_ABSOLUTE:
|
|
|
|
ui_litem_layout_absolute(litem);
|
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
|
|
|
break;
|
|
|
|
case ITEM_LAYOUT_SPLIT:
|
|
|
|
ui_litem_layout_split(litem);
|
|
|
|
break;
|
2009-10-21 20:58:10 +00:00
|
|
|
case ITEM_LAYOUT_OVERLAP:
|
|
|
|
ui_litem_layout_overlap(litem);
|
|
|
|
break;
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
case ITEM_LAYOUT_RADIAL:
|
|
|
|
ui_litem_layout_radial(litem);
|
|
|
|
break;
|
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
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2017-07-27 10:27:29 +03:00
|
|
|
for (subitem = litem->items.first; subitem; subitem = subitem->next) {
|
2017-07-27 11:44:51 +02:00
|
|
|
if (item->flag & UI_ITEM_BOX_ITEM) {
|
2017-07-27 10:27:29 +03:00
|
|
|
subitem->flag |= UI_ITEM_BOX_ITEM;
|
2017-07-27 11:44:51 +02:00
|
|
|
}
|
2009-05-27 00:03:49 +00:00
|
|
|
ui_item_layout(subitem);
|
2017-07-27 10:27:29 +03:00
|
|
|
}
|
2017-07-27 11:44:51 +02:00
|
|
|
}
|
|
|
|
else {
|
2017-07-27 10:27:29 +03:00
|
|
|
if (item->flag & UI_ITEM_BOX_ITEM) {
|
|
|
|
uiButtonItem *bitem = (uiButtonItem *)item;
|
|
|
|
bitem->but->drawflag |= UI_BUT_BOX_ITEM;
|
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
2009-04-11 01:52:27 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->root->handlefunc)
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_func_handle_set(block, layout->root->handlefunc, layout->root->argv);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-09-16 18:47:42 +00:00
|
|
|
ui_item_estimate(&layout->item);
|
|
|
|
ui_item_layout(&layout->item);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (x) *x = layout->x;
|
|
|
|
if (y) *y = layout->y;
|
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-04-22 18:39:44 +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
|
|
|
static void ui_layout_free(uiLayout *layout)
|
|
|
|
{
|
|
|
|
uiItem *item, *next;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = layout->items.first; item; item = next) {
|
|
|
|
next = item->next;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item->type == ITEM_BUTTON)
|
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(item);
|
|
|
|
else
|
2012-03-30 01:51:25 +00:00
|
|
|
ui_layout_free((uiLayout *)item);
|
2009-04-22 18:39:44 +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(layout);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2014-01-17 00:23:00 +01:00
|
|
|
static void ui_layout_add_padding_button(uiLayoutRoot *root)
|
|
|
|
{
|
|
|
|
if (root->padding) {
|
|
|
|
/* add an invisible button for padding */
|
|
|
|
uiBlock *block = root->block;
|
|
|
|
uiLayout *prev_layout = block->curlayout;
|
|
|
|
|
|
|
|
block->curlayout = root->layout;
|
2014-11-09 21:20:40 +01:00
|
|
|
uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, root->padding, root->padding, NULL, 0.0, 0.0, 0, 0, "");
|
2014-01-17 00:23:00 +01:00
|
|
|
block->curlayout = prev_layout;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, uiStyle *style)
|
2009-03-13 13:38: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
|
|
|
uiLayout *layout;
|
2009-05-19 17:13:33 +00:00
|
|
|
uiLayoutRoot *root;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
root = MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot");
|
|
|
|
root->type = type;
|
|
|
|
root->style = style;
|
|
|
|
root->block = block;
|
2014-01-17 00:23:00 +01:00
|
|
|
root->padding = padding;
|
2012-03-30 01:51:25 +00:00
|
|
|
root->opcontext = WM_OP_INVOKE_REGION_WIN;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
layout = MEM_callocN(sizeof(uiLayout), "uiLayout");
|
|
|
|
layout->item.type = ITEM_LAYOUT_ROOT;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->x = x;
|
|
|
|
layout->y = y;
|
|
|
|
layout->root = root;
|
|
|
|
layout->space = style->templatespace;
|
|
|
|
layout->active = 1;
|
|
|
|
layout->enabled = 1;
|
|
|
|
layout->context = NULL;
|
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
|
|
|
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU)
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->space = 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
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (dir == UI_LAYOUT_HORIZONTAL) {
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->h = size;
|
|
|
|
layout->root->emh = em * UI_UNIT_Y;
|
2009-05-19 17:13:33 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->w = size;
|
|
|
|
layout->root->emw = em * UI_UNIT_X;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block->curlayout = layout;
|
|
|
|
root->layout = layout;
|
2009-05-19 17:13:33 +00:00
|
|
|
BLI_addtail(&block->layouts, root);
|
2014-01-17 00:23:00 +01:00
|
|
|
|
|
|
|
ui_layout_add_padding_button(root);
|
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-05-19 17:13:33 +00:00
|
|
|
return layout;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 23:37:55 +00:00
|
|
|
uiBlock *uiLayoutGetBlock(uiLayout *layout)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
return layout->root->block;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-06-09 10:30:11 +00:00
|
|
|
int uiLayoutGetOperatorContext(uiLayout *layout)
|
|
|
|
{
|
|
|
|
return layout->root->opcontext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
block->curlayout = layout;
|
2009-03-13 13:38: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
|
|
|
void ui_layout_add_but(uiLayout *layout, uiBut *but)
|
2009-03-13 13:38: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
|
|
|
uiButtonItem *bitem;
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
bitem = MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
|
|
|
|
bitem->item.type = ITEM_BUTTON;
|
|
|
|
bitem->but = but;
|
2017-02-02 17:30:50 +03:00
|
|
|
|
|
|
|
int w, h;
|
|
|
|
ui_item_size((uiItem *)bitem, &w, &h);
|
|
|
|
/* XXX uiBut hasn't scaled yet
|
|
|
|
* we can flag the button as not expandable, depending on its size */
|
2017-08-12 11:00:19 +03:00
|
|
|
if (w <= 2 * UI_UNIT_X && (!but->str || but->str[0] == '\0')) {
|
2017-02-02 17:30:50 +03:00
|
|
|
bitem->item.flag |= UI_ITEM_MIN;
|
2017-08-12 11:00:19 +03:00
|
|
|
}
|
2017-02-02 17:30:50 +03: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
|
|
|
BLI_addtail(&layout->items, bitem);
|
2009-05-28 23:13:42 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (layout->context) {
|
2012-03-30 01:51:25 +00:00
|
|
|
but->context = layout->context;
|
2014-01-04 17:16:19 +11:00
|
|
|
but->context->used = true;
|
2009-05-28 23:13:42 +00:00
|
|
|
}
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 23:37:55 +00:00
|
|
|
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->root->opcontext = opcontext;
|
2009-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 23:37:55 +00:00
|
|
|
void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
layout->root->handlefunc = handlefunc;
|
|
|
|
layout->root->argv = argv;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
void UI_block_layout_resolve(uiBlock *block, int *x, int *y)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2009-05-19 17:13:33 +00:00
|
|
|
uiLayoutRoot *root;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2014-06-15 01:40:15 +10:00
|
|
|
BLI_assert(block->active);
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
if (x) *x = 0;
|
|
|
|
if (y) *y = 0;
|
2009-03-13 13:38:41 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
block->curlayout = NULL;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (root = block->layouts.first; root; root = root->next) {
|
2014-01-17 00:23:00 +01:00
|
|
|
ui_layout_add_padding_button(root);
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* NULL in advance so we don't interfere when adding button */
|
2009-09-16 18:47:42 +00:00
|
|
|
ui_layout_end(block, root->layout, x, y);
|
2009-05-19 17:13:33 +00:00
|
|
|
ui_layout_free(root->layout);
|
2009-03-29 19:44:39 +00:00
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
BLI_freelistN(&block->layouts);
|
|
|
|
|
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
|
|
|
/* XXX silly trick, interface_templates.c doesn't get linked
|
|
|
|
* because it's not used by other files in this module? */
|
|
|
|
{
|
2011-02-13 14:16:36 +00:00
|
|
|
UI_template_fix_linking();
|
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-03-13 13:38:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *ptr)
|
2009-03-13 13:38:41 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
|
|
|
layout->context = CTX_store_add(&block->contexts, name, ptr);
|
2009-03-29 19:44:39 +00:00
|
|
|
}
|
2009-03-25 14:34:17 +00:00
|
|
|
|
2012-04-03 15:18:59 +00:00
|
|
|
void uiLayoutContextCopy(uiLayout *layout, bContextStore *context)
|
|
|
|
{
|
2012-05-08 18:29:02 +00:00
|
|
|
uiBlock *block = layout->root->block;
|
|
|
|
layout->context = CTX_store_add_all(&block->contexts, context);
|
2012-04-03 15:18:59 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 18:19:11 +11:00
|
|
|
void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but)
|
|
|
|
{
|
|
|
|
if (but->opptr) {
|
|
|
|
uiLayoutSetContextPointer(layout, "button_operator", but->opptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (but->rnapoin.data && but->rnaprop) {
|
|
|
|
/* TODO: index could be supported as well */
|
|
|
|
PointerRNA ptr_prop;
|
|
|
|
RNA_pointer_create(NULL, &RNA_Property, but->rnaprop, &ptr_prop);
|
|
|
|
uiLayoutSetContextPointer(layout, "button_prop", &ptr_prop);
|
|
|
|
uiLayoutSetContextPointer(layout, "button_pointer", &but->rnapoin);
|
|
|
|
}
|
|
|
|
}
|
2009-11-28 17:45:23 +00:00
|
|
|
|
|
|
|
/* introspect funcs */
|
|
|
|
#include "BLI_dynstr.h"
|
|
|
|
|
|
|
|
static void ui_intro_button(DynStr *ds, uiButtonItem *bitem)
|
|
|
|
{
|
|
|
|
uiBut *but = bitem->but;
|
2014-04-13 11:26:31 +10:00
|
|
|
BLI_dynstr_appendf(ds, "'type':%d, ", (int)but->type);
|
2009-11-28 17:45:23 +00:00
|
|
|
BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr);
|
2012-08-19 10:41:27 +00:00
|
|
|
BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */
|
2009-11-28 17:45:23 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->optype) {
|
2013-11-26 08:59:14 +11:00
|
|
|
char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, true, but->optype, but->opptr);
|
2009-11-28 17:45:23 +00:00
|
|
|
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
|
|
|
|
MEM_freeN(opstr);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->rnaprop) {
|
2009-11-28 17:45:23 +00:00
|
|
|
BLI_dynstr_appendf(ds, "'rna':'%s.%s[%d]', ", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop), but->rnaindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_intro_items(DynStr *ds, ListBase *lb)
|
|
|
|
{
|
|
|
|
uiItem *item;
|
|
|
|
|
|
|
|
BLI_dynstr_append(ds, "[");
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
for (item = lb->first; item; item = item->next) {
|
2009-11-28 17:45:23 +00:00
|
|
|
|
|
|
|
BLI_dynstr_append(ds, "{");
|
|
|
|
|
|
|
|
/* could also use the INT but this is nicer*/
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (item->type) {
|
|
|
|
case ITEM_BUTTON: BLI_dynstr_append(ds, "'type':'BUTTON', "); break;
|
2014-11-09 21:20:40 +01:00
|
|
|
case ITEM_LAYOUT_ROW: BLI_dynstr_append(ds, "'type':'UI_BTYPE_ROW', "); break;
|
2012-03-30 01:51:25 +00:00
|
|
|
case ITEM_LAYOUT_COLUMN: BLI_dynstr_append(ds, "'type':'COLUMN', "); break;
|
|
|
|
case ITEM_LAYOUT_COLUMN_FLOW: BLI_dynstr_append(ds, "'type':'COLUMN_FLOW', "); break;
|
|
|
|
case ITEM_LAYOUT_ROW_FLOW: BLI_dynstr_append(ds, "'type':'ROW_FLOW', "); break;
|
|
|
|
case ITEM_LAYOUT_BOX: BLI_dynstr_append(ds, "'type':'BOX', "); break;
|
|
|
|
case ITEM_LAYOUT_ABSOLUTE: BLI_dynstr_append(ds, "'type':'ABSOLUTE', "); break;
|
|
|
|
case ITEM_LAYOUT_SPLIT: BLI_dynstr_append(ds, "'type':'SPLIT', "); break;
|
|
|
|
case ITEM_LAYOUT_OVERLAP: BLI_dynstr_append(ds, "'type':'OVERLAP', "); break;
|
|
|
|
case ITEM_LAYOUT_ROOT: BLI_dynstr_append(ds, "'type':'ROOT', "); break;
|
|
|
|
default: BLI_dynstr_append(ds, "'type':'UNKNOWN', "); break;
|
2009-11-28 17:45:23 +00:00
|
|
|
}
|
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
switch (item->type) {
|
|
|
|
case ITEM_BUTTON:
|
|
|
|
ui_intro_button(ds, (uiButtonItem *)item);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_dynstr_append(ds, "'items':");
|
|
|
|
ui_intro_items(ds, &((uiLayout *)item)->items);
|
|
|
|
break;
|
2009-11-28 17:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_dynstr_append(ds, "}");
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (item != lb->last)
|
2009-11-28 17:45:23 +00:00
|
|
|
BLI_dynstr_append(ds, ", ");
|
|
|
|
}
|
|
|
|
BLI_dynstr_append(ds, "], ");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_intro_uiLayout(DynStr *ds, uiLayout *layout)
|
|
|
|
{
|
|
|
|
ui_intro_items(ds, &layout->items);
|
|
|
|
}
|
|
|
|
|
2012-08-19 10:41:27 +00:00
|
|
|
static char *str = NULL; /* XXX, constant re-freeing, far from ideal. */
|
2010-11-17 09:45:45 +00:00
|
|
|
const char *uiLayoutIntrospect(uiLayout *layout)
|
2009-11-28 17:45:23 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
DynStr *ds = BLI_dynstr_new();
|
2009-11-28 17:45:23 +00:00
|
|
|
|
2012-01-21 22:00:40 +00:00
|
|
|
if (str) {
|
2009-11-28 17:45:23 +00:00
|
|
|
MEM_freeN(str);
|
2012-01-21 22:00:40 +00:00
|
|
|
}
|
2009-11-28 17:45:23 +00:00
|
|
|
|
|
|
|
ui_intro_uiLayout(ds, layout);
|
|
|
|
|
|
|
|
str = BLI_dynstr_get_cstring(ds);
|
|
|
|
BLI_dynstr_free(ds);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
2010-12-15 05:42:23 +00:00
|
|
|
|
2011-11-14 14:42:47 +00:00
|
|
|
/* this is a bit of a hack but best keep it in one place at least */
|
2014-11-09 21:20:40 +01:00
|
|
|
MenuType *UI_but_menutype_get(uiBut *but)
|
2011-11-14 14:42:47 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (but->menu_create_func == ui_item_menutype_func) {
|
2011-11-14 14:42:47 +00:00
|
|
|
return (MenuType *)but->poin;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2017-11-02 18:19:11 +11:00
|
|
|
|
2018-04-22 17:16:39 +02:00
|
|
|
/* this is a bit of a hack but best keep it in one place at least */
|
|
|
|
PanelType *UI_but_paneltype_get(uiBut *but)
|
|
|
|
{
|
|
|
|
if (but->menu_create_func == ui_item_paneltype_func) {
|
|
|
|
return (PanelType *)but->poin;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-02 18:19:11 +11:00
|
|
|
void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
|
|
|
|
{
|
|
|
|
Menu menu = {
|
|
|
|
.layout = layout,
|
|
|
|
.type = mt,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (G.debug & G_DEBUG_WM) {
|
|
|
|
printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layout->context) {
|
|
|
|
CTX_store_set(C, layout->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
mt->draw(C, &menu);
|
|
|
|
|
|
|
|
if (layout->context) {
|
|
|
|
CTX_store_set(C, NULL);
|
|
|
|
}
|
|
|
|
}
|