2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edinterface
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2025-02-07 17:47:16 +01:00
|
|
|
#include "BKE_library.hh"
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2024-01-04 00:46:48 +01:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
#include "BLI_string_ref.hh"
|
2017-06-08 10:14:53 +02:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_fileselect.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2021-08-19 14:34:01 +02:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
2022-11-26 00:21:17 -06:00
|
|
|
#include "interface_intern.hh"
|
2025-01-07 16:21:07 +01:00
|
|
|
#include "interface_templates_intern.hh"
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2024-12-06 14:08:10 +01:00
|
|
|
using blender::StringRefNull;
|
2019-09-06 16:42:04 +10:00
|
|
|
|
2019-09-06 16:12:47 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Search Menu Helpers
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
int template_search_textbut_width(PointerRNA *ptr, PropertyRNA *name_prop)
|
2021-03-18 15:00:55 +01:00
|
|
|
{
|
|
|
|
|
char str[UI_MAX_DRAW_STR];
|
|
|
|
|
int buf_len = 0;
|
|
|
|
|
|
|
|
|
|
BLI_assert(RNA_property_type(name_prop) == PROP_STRING);
|
|
|
|
|
|
|
|
|
|
const char *name = RNA_property_string_get_alloc(ptr, name_prop, str, sizeof(str), &buf_len);
|
|
|
|
|
|
|
|
|
|
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
|
|
|
|
|
const int margin = UI_UNIT_X * 0.75f;
|
|
|
|
|
const int estimated_width = UI_fontstyle_string_width(fstyle, name) + margin;
|
|
|
|
|
|
|
|
|
|
if (name != str) {
|
|
|
|
|
MEM_freeN((void *)name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clamp to some min/max width. */
|
2024-01-23 21:10:33 +01:00
|
|
|
return std::clamp(
|
2024-03-08 21:49:12 +01:00
|
|
|
estimated_width, TEMPLATE_SEARCH_TEXTBUT_MIN_WIDTH, TEMPLATE_SEARCH_TEXTBUT_MIN_WIDTH * 4);
|
2021-03-18 15:00:55 +01:00
|
|
|
}
|
|
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
int template_search_textbut_height()
|
2021-03-18 15:00:55 +01:00
|
|
|
{
|
|
|
|
|
return TEMPLATE_SEARCH_TEXTBUT_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/**
|
|
|
|
|
* Add a block button for the search menu for templateID and templateSearch.
|
|
|
|
|
*/
|
2025-01-07 16:21:07 +01:00
|
|
|
void template_add_button_search_menu(const bContext *C,
|
|
|
|
|
uiLayout *layout,
|
|
|
|
|
uiBlock *block,
|
|
|
|
|
PointerRNA *ptr,
|
|
|
|
|
PropertyRNA *prop,
|
|
|
|
|
uiBlockCreateFunc block_func,
|
|
|
|
|
void *block_argN,
|
2025-02-14 15:12:48 -05:00
|
|
|
const std::optional<blender::StringRef> tip,
|
2025-01-07 16:21:07 +01:00
|
|
|
const bool use_previews,
|
|
|
|
|
const bool editable,
|
|
|
|
|
const bool live_icon,
|
|
|
|
|
uiButArgNFree func_argN_free_fn,
|
|
|
|
|
uiButArgNCopy func_argN_copy_fn)
|
2017-05-12 01:42:42 +02:00
|
|
|
{
|
2020-08-26 10:11:13 +10:00
|
|
|
const PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop);
|
2022-11-25 23:48:02 -06:00
|
|
|
ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ?
|
|
|
|
|
static_cast<ID *>(active_ptr.data) :
|
|
|
|
|
nullptr;
|
2019-08-23 09:52:12 +02:00
|
|
|
const ID *idfrom = ptr->owner_id;
|
2017-05-12 01:42:42 +02:00
|
|
|
const StructRNA *type = active_ptr.type ? active_ptr.type : RNA_property_pointer_type(ptr, prop);
|
|
|
|
|
uiBut *but;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
if (use_previews) {
|
|
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-18 21:13:22 +02:00
|
|
|
/* Ugly tool header exception. */
|
|
|
|
|
const bool use_big_size = (region->regiontype != RGN_TYPE_TOOL_HEADER);
|
2019-01-15 23:24:20 +11:00
|
|
|
/* Ugly exception for screens here,
|
|
|
|
|
* drawing their preview in icon size looks ugly/useless */
|
2017-05-12 01:42:42 +02:00
|
|
|
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
|
|
|
|
|
const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f);
|
2017-10-07 15:57:14 +11:00
|
|
|
const short height = UI_UNIT_Y * (use_big_size ? 6 : 1);
|
2022-11-25 23:48:02 -06:00
|
|
|
uiLayout *col = nullptr;
|
2019-11-26 19:43:36 +01:00
|
|
|
|
|
|
|
|
if (use_big_size) {
|
|
|
|
|
/* Assume column layout here. To be more correct, we should check if the layout passed to
|
|
|
|
|
* template_id is a column one, but this should work well in practice. */
|
|
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-08-27 15:35:18 +02:00
|
|
|
but = uiDefBlockButN(block,
|
|
|
|
|
block_func,
|
|
|
|
|
block_argN,
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
tip,
|
|
|
|
|
func_argN_free_fn,
|
|
|
|
|
func_argN_copy_fn);
|
2017-05-12 01:42:42 +02:00
|
|
|
if (use_preview_icon) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const int icon = id ? ui_id_icon_get(C, id, use_big_size) : RNA_struct_ui_icon(type);
|
2017-05-12 01:42:42 +02:00
|
|
|
ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ui_def_but_icon(but, RNA_struct_ui_icon(type), UI_HAS_ICON);
|
|
|
|
|
UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-05-16 14:53:09 +02:00
|
|
|
if ((idfrom && !ID_IS_EDITABLE(idfrom)) || !editable) {
|
2017-05-12 01:42:42 +02:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2017-05-12 01:42:42 +02:00
|
|
|
if (use_big_size) {
|
2019-11-26 19:43:36 +01:00
|
|
|
uiLayoutRow(col ? col : layout, true);
|
2017-05-12 01:42:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2024-08-27 15:35:18 +02:00
|
|
|
but = uiDefBlockButN(block,
|
|
|
|
|
block_func,
|
|
|
|
|
block_argN,
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 1.6,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
tip,
|
|
|
|
|
func_argN_free_fn,
|
|
|
|
|
func_argN_copy_fn);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
if (live_icon) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const int icon = id ? ui_id_icon_get(C, id, false) : RNA_struct_ui_icon(type);
|
2018-07-31 10:22:19 +02:00
|
|
|
ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ui_def_but_icon(but, RNA_struct_ui_icon(type), UI_HAS_ICON);
|
|
|
|
|
}
|
2017-05-12 01:42:42 +02:00
|
|
|
if (id) {
|
|
|
|
|
/* default dragging of icon for id browse buttons */
|
|
|
|
|
UI_but_drag_set_id(but, id);
|
|
|
|
|
}
|
|
|
|
|
UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-05-16 14:53:09 +02:00
|
|
|
if ((idfrom && !ID_IS_EDITABLE(idfrom)) || !editable) {
|
2017-05-12 01:42:42 +02:00
|
|
|
UI_but_flag_enable(but, UI_BUT_DISABLED);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2017-05-12 01:42:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
uiBlock *template_common_search_menu(const bContext *C,
|
|
|
|
|
ARegion *region,
|
|
|
|
|
uiButSearchUpdateFn search_update_fn,
|
|
|
|
|
void *search_arg,
|
|
|
|
|
uiButHandleFunc search_exec_fn,
|
|
|
|
|
void *active_item,
|
|
|
|
|
uiButSearchTooltipFn item_tooltip_fn,
|
|
|
|
|
const int preview_rows,
|
|
|
|
|
const int preview_cols,
|
|
|
|
|
float scale)
|
2017-05-12 01:42:42 +02:00
|
|
|
{
|
|
|
|
|
static char search[256];
|
|
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
uiBut *but;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/* clear initial search string, then all items show */
|
|
|
|
|
search[0] = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-04 22:44:19 -05:00
|
|
|
uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS);
|
2017-05-12 01:42:42 +02:00
|
|
|
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU);
|
2018-09-11 11:01:39 +10:00
|
|
|
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/* preview thumbnails */
|
|
|
|
|
if (preview_rows > 0 && preview_cols > 0) {
|
2018-07-31 10:22:19 +02:00
|
|
|
const int w = 4 * U.widget_unit * preview_cols * scale;
|
|
|
|
|
const int h = 5 * U.widget_unit * preview_rows * scale;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/* fake button, it holds space for search items */
|
2025-02-14 15:12:48 -05:00
|
|
|
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, nullptr, 0, 0, std::nullopt);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-02-29 21:49:22 -05:00
|
|
|
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y, "");
|
|
|
|
|
UI_but_search_preview_grid_size_set(but, preview_rows, preview_cols);
|
2017-05-12 01:42:42 +02:00
|
|
|
}
|
|
|
|
|
/* list view */
|
|
|
|
|
else {
|
2024-09-14 03:20:09 +02:00
|
|
|
const int searchbox_width = int(float(UI_searchbox_size_x()) * 1.4f);
|
2017-05-12 01:42:42 +02:00
|
|
|
const int searchbox_height = UI_searchbox_size_y();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/* fake button, it holds space for search items */
|
|
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
"",
|
|
|
|
|
10,
|
|
|
|
|
15,
|
|
|
|
|
searchbox_width,
|
|
|
|
|
searchbox_height,
|
2022-11-25 23:48:02 -06:00
|
|
|
nullptr,
|
2017-05-12 01:42:42 +02:00
|
|
|
0,
|
|
|
|
|
0,
|
2025-02-14 15:12:48 -05:00
|
|
|
std::nullopt);
|
2017-05-12 01:42:42 +02:00
|
|
|
but = uiDefSearchBut(block,
|
|
|
|
|
search,
|
|
|
|
|
0,
|
|
|
|
|
ICON_VIEWZOOM,
|
|
|
|
|
sizeof(search),
|
|
|
|
|
10,
|
|
|
|
|
0,
|
|
|
|
|
searchbox_width,
|
|
|
|
|
UI_UNIT_Y - 1,
|
|
|
|
|
"");
|
|
|
|
|
}
|
2020-04-14 18:46:13 +10:00
|
|
|
UI_but_func_search_set(but,
|
|
|
|
|
ui_searchbox_create_generic,
|
2020-05-07 23:16:05 +10:00
|
|
|
search_update_fn,
|
2020-04-14 18:46:13 +10:00
|
|
|
search_arg,
|
2021-04-14 11:11:51 -05:00
|
|
|
false,
|
2022-11-25 23:48:02 -06:00
|
|
|
nullptr,
|
2020-05-08 12:01:35 +10:00
|
|
|
search_exec_fn,
|
2020-04-14 18:46:13 +10:00
|
|
|
active_item);
|
2021-01-26 22:06:45 +01:00
|
|
|
UI_but_func_search_set_tooltip(but, item_tooltip_fn);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
UI_block_bounds_set_normal(block, 0.3f * U.widget_unit);
|
|
|
|
|
UI_block_direction_set(block, UI_DIR_DOWN);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
/* give search-field focus */
|
|
|
|
|
UI_but_focus_on_enter_event(win, but);
|
|
|
|
|
/* this type of search menu requires undo */
|
|
|
|
|
but->flag |= UI_BUT_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-12 01:42:42 +02:00
|
|
|
return block;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 16:12:47 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2025-01-07 16:21:07 +01:00
|
|
|
/** \name Header Template
|
2019-09-06 16:12:47 +10:00
|
|
|
* \{ */
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
void uiTemplateHeader(uiLayout *layout, bContext *C)
|
2009-06-11 17:21:27 +00:00
|
|
|
{
|
2025-01-07 16:21:07 +01:00
|
|
|
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
|
|
|
|
ED_area_header_switchbutton(C, block, 0);
|
2009-06-11 17:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-06 16:12:47 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2025-01-07 16:21:07 +01:00
|
|
|
/** \name RNA Path Builder Template
|
2019-09-06 16:12:47 +10:00
|
|
|
* \{ */
|
|
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
void uiTemplatePathBuilder(uiLayout *layout,
|
|
|
|
|
PointerRNA *ptr,
|
|
|
|
|
const StringRefNull propname,
|
|
|
|
|
PointerRNA * /*root_ptr*/,
|
|
|
|
|
const std::optional<StringRefNull> text)
|
2022-03-08 15:51:08 +01:00
|
|
|
{
|
2025-01-07 16:21:07 +01:00
|
|
|
/* check that properties are valid */
|
|
|
|
|
PropertyRNA *propPath = RNA_struct_find_property(ptr, propname.c_str());
|
|
|
|
|
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
|
|
|
|
|
RNA_warning(
|
|
|
|
|
"path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname.c_str());
|
2022-03-08 15:51:08 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2010-12-24 10:15:57 +00:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
/* Start drawing UI Elements using standard defines */
|
|
|
|
|
uiLayout *row = uiLayoutRow(layout, true);
|
2022-07-07 18:14:05 +02:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
/* Path (existing string) Widget */
|
|
|
|
|
uiItemR(row, ptr, propname, UI_ITEM_NONE, text, ICON_RNA);
|
2022-07-07 18:14:05 +02:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
/* TODO: attach something to this to make allow
|
|
|
|
|
* searching of nested properties to 'build' the path */
|
2012-11-23 15:33:44 +00:00
|
|
|
}
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
/** \} */
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Node Socket Icon Template
|
|
|
|
|
* \{ */
|
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
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
void uiTemplateNodeSocket(uiLayout *layout, bContext * /*C*/, const float color[4])
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
{
|
2021-02-17 16:59:50 -06:00
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_begin(block);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-07 16:21:07 +01:00
|
|
|
/* XXX using explicit socket colors is not quite ideal.
|
|
|
|
|
* Eventually it should be possible to use theme colors for this purpose,
|
|
|
|
|
* but this requires a better design for extendable color palettes in user preferences. */
|
|
|
|
|
uiBut *but = uiDefBut(
|
|
|
|
|
block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr, 0, 0, "");
|
|
|
|
|
rgba_float_to_uchar(but->col, color);
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_align_end(block);
|
2013-03-18 16:34:57 +00:00
|
|
|
}
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
|
2019-09-06 16:12:47 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name FileSelectParams Path Button Template
|
|
|
|
|
* \{ */
|
2019-09-06 01:22:35 +02:00
|
|
|
|
|
|
|
|
void uiTemplateFileSelectPath(uiLayout *layout, bContext *C, FileSelectParams *params)
|
|
|
|
|
{
|
|
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
|
|
|
|
SpaceFile *sfile = CTX_wm_space_file(C);
|
|
|
|
|
|
|
|
|
|
ED_file_path_button(screen, sfile, params, uiLayoutGetBlock(layout));
|
|
|
|
|
}
|
2019-09-06 16:12:47 +10:00
|
|
|
|
|
|
|
|
/** \} */
|