[Bf-blender-cvs] [caa40c93eba] temp-library-overrides-outliner: Display buttons for properies in the Outliner Library Overrides mode
Julian Eisel
noreply at git.blender.org
Fri Feb 25 20:16:21 CET 2022
Commit: caa40c93eba71f1e310108df4f2db52a4142014b
Author: Julian Eisel
Date: Fri Feb 25 20:14:29 2022 +0100
Branches: temp-library-overrides-outliner
https://developer.blender.org/rBcaa40c93eba71f1e310108df4f2db52a4142014b
Display buttons for properies in the Outliner Library Overrides mode
Part of T95802.
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_utils.c
M source/blender/editors/space_outliner/outliner_draw.cc
M source/blender/editors/space_outliner/outliner_intern.hh
M source/blender/editors/space_outliner/outliner_select.cc
M source/blender/editors/space_outliner/outliner_utils.cc
M source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M source/blender/editors/space_outliner/tree/tree_element_overrides.hh
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 060c9dc33d6..a223eac3000 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1610,6 +1610,14 @@ uiBut *uiDefAutoButR(uiBlock *block,
int y,
int width,
int height);
+void uiDefAutoButsArrayR(uiBlock *block,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ const int icon,
+ const int x,
+ const int y,
+ const int tot_width,
+ const int height);
/**
* \a check_prop callback filters functions to avoid drawing certain properties,
* in cases where PROP_HIDDEN flag can't be used for a property.
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 814bd956096..728d42a9353 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -320,6 +320,7 @@ uiBut *uiDefAutoButR(uiBlock *block,
-1,
-1,
NULL);
+ ui_but_add_search(but, ptr, prop, NULL, NULL);
break;
}
case PROP_COLLECTION: {
@@ -338,6 +339,29 @@ uiBut *uiDefAutoButR(uiBlock *block,
return but;
}
+void uiDefAutoButsArrayR(uiBlock *block,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ const int icon,
+ const int x,
+ const int y,
+ const int tot_width,
+ const int height)
+{
+ const int len = RNA_property_array_length(ptr, prop);
+ if (len == 0) {
+ return;
+ }
+
+ const int item_width = tot_width / len;
+
+ UI_block_align_begin(block);
+ for (int i = 0; i < len; i++) {
+ uiDefAutoButR(block, ptr, prop, i, "", icon, x + i * item_width, y, item_width, height);
+ }
+ UI_block_align_end(block);
+}
+
eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
PointerRNA *ptr,
bool (*check_prop)(PointerRNA *ptr,
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index bc58ad226ee..183bc925497 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -65,6 +65,7 @@
#include "outliner_intern.hh"
#include "tree/tree_display.hh"
#include "tree/tree_element.hh"
+#include "tree/tree_element_overrides.hh"
#include "tree/tree_element_rna.hh"
using namespace blender::ed::outliner;
@@ -1081,7 +1082,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
BLI_assert((restrict_column_offset * UI_UNIT_X + V2D_SCROLL_WIDTH) ==
- outliner_restrict_columns_width(space_outliner));
+ outliner_right_columns_width(space_outliner));
/* Create buttons. */
uiBut *bt;
@@ -1717,7 +1718,7 @@ static void outliner_draw_userbuts(uiBlock *block,
LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
- if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
+ if (outliner_is_element_in_view(te, ®ion->v2d)) {
if (tselem->type == TSE_SOME_ID) {
uiBut *bt;
ID *id = tselem->id;
@@ -1778,18 +1779,71 @@ static void outliner_draw_userbuts(uiBlock *block,
}
}
-static bool outliner_draw_overrides_buts(uiBlock *block,
- ARegion *region,
- SpaceOutliner *space_outliner,
- ListBase *lb,
- const bool is_open)
+static void outliner_draw_overrides_rna_buts(uiBlock *block,
+ const ARegion *region,
+ const SpaceOutliner *space_outliner,
+ const ListBase *lb,
+ const int x)
+{
+ LISTBASE_FOREACH (const TreeElement *, te, lb) {
+ const TreeStoreElem *tselem = TREESTORE(te);
+ if (TSELEM_OPEN(tselem, space_outliner)) {
+ outliner_draw_overrides_rna_buts(block, region, space_outliner, &te->subtree, x);
+ }
+
+ if (!outliner_is_element_in_view(te, ®ion->v2d)) {
+ continue;
+ }
+ if (tselem->type != TSE_LIBRARY_OVERRIDE) {
+ continue;
+ }
+
+ TreeElementOverridesProperty &override_elem = *tree_element_cast<TreeElementOverridesProperty>(
+ te);
+
+ PointerRNA *ptr = &override_elem.override_rna_ptr;
+ PropertyRNA *prop = &override_elem.override_rna_prop;
+ const PropertyType prop_type = RNA_property_type(prop);
+
+ const float pad_x = 1 * UI_DPI_FAC;
+ const float max_width = OL_RNA_COL_SIZEX - 2 * pad_x;
+ const float height = UI_UNIT_Y - U.pixelsize;
+
+ uiBut *auto_but = uiDefAutoButR(block,
+ ptr,
+ prop,
+ -1,
+ (prop_type == PROP_ENUM) ? nullptr : "",
+ ICON_NONE,
+ x + pad_x,
+ te->ys,
+ max_width,
+ height);
+ /* Added the button successfully, nothing else to do. Otherwise, cases for multiple buttons
+ * need to be handled. */
+ if (auto_but) {
+ continue;
+ }
+
+ if (!auto_but) {
+ /* TODO what if the array is longer, and doesn't fit nicely? What about multi-dimension
+ * arrays? */
+ uiDefAutoButsArrayR(block, ptr, prop, ICON_NONE, x, te->ys, max_width, height);
+ }
+ }
+}
+
+static bool outliner_draw_overrides_warning_buts(uiBlock *block,
+ ARegion *region,
+ SpaceOutliner *space_outliner,
+ ListBase *lb,
+ const bool is_open)
{
bool any_item_has_warnings = false;
LISTBASE_FOREACH (TreeElement *, te, lb) {
bool item_has_warnings = false;
- const bool do_draw = (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin &&
- te->ys <= region->v2d.cur.ymax);
+ const bool do_draw = outliner_is_element_in_view(te, ®ion->v2d);
int but_flag = UI_BUT_DRAG_LOCK;
const char *tip = nullptr;
@@ -1829,7 +1883,7 @@ static bool outliner_draw_overrides_buts(uiBlock *block,
break;
}
- const bool any_child_has_warnings = outliner_draw_overrides_buts(
+ const bool any_child_has_warnings = outliner_draw_overrides_warning_buts(
block,
region,
space_outliner,
@@ -1863,28 +1917,20 @@ static bool outliner_draw_overrides_buts(uiBlock *block,
return any_item_has_warnings;
}
-static void outliner_draw_rnacols(ARegion *region, int sizex)
+static void outliner_draw_separator(ARegion *region, const int x)
{
View2D *v2d = ®ion->v2d;
- float miny = v2d->cur.ymin;
- if (miny < v2d->tot.ymin) {
- miny = v2d->tot.ymin;
- }
-
GPU_line_width(1.0f);
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColorShadeAlpha(TH_BACK, -15, -200);
- immBegin(GPU_PRIM_LINES, 4);
-
- immVertex2f(pos, sizex, v2d->cur.ymax);
- immVertex2f(pos, sizex, miny);
+ immBegin(GPU_PRIM_LINES, 2);
- immVertex2f(pos, sizex + OL_RNA_COL_SIZEX, v2d->cur.ymax);
- immVertex2f(pos, sizex + OL_RNA_COL_SIZEX, miny);
+ immVertex2f(pos, x, v2d->cur.ymax);
+ immVertex2f(pos, x, v2d->cur.ymin);
immEnd();
@@ -1899,7 +1945,7 @@ static void outliner_draw_rnabuts(
LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
- if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
+ if (outliner_is_element_in_view(te, ®ion->v2d)) {
if (TreeElementRNAProperty *te_rna_prop = tree_element_cast<TreeElementRNAProperty>(te)) {
ptr = te_rna_prop->getPointerRNA();
prop = te_rna_prop->getPropertyRNA();
@@ -3671,7 +3717,7 @@ static void outliner_draw_tree(bContext *C,
const TreeViewContext *tvc,
ARegion *region,
SpaceOutliner *space_outliner,
- const float restrict_column_width,
+ const float right_column_width,
const bool use_mode_column,
const bool use_warning_column,
TreeElement **te_edit)
@@ -3706,8 +3752,8 @@ static void outliner_draw_tree(bContext *C,
/* Set scissor so tree elements or lines can't overlap restriction icons. */
int scissor[4] = {0};
- if (restrict_column_width > 0.0f) {
- int mask_x = BLI_rcti_size_x(®ion->v2d.mask) - (int)restrict_column_width + 1;
+ if (right_column_width > 0.0f) {
+ int mask_x = BLI_rcti_size_x(®ion->v2d.mask) - (int)right_column_width + 1;
CLAMP_MIN(mask_x, 0);
GPU_scissor_get(scissor);
@@ -3733,11 +3779,11 @@ static void outliner_draw_tree(bContext *C,
(te->flag & TE_DRAGGING) != 0,
startx,
&starty,
- restrict_column_width,
+ right_column_width,
te_edit);
}
- if (restrict_column_width > 0.0f) {
+ if (right_column_width > 0.0f) {
/* Reset scissor. */
GPU_scissor(UNPACK4(scissor));
}
@@ -3788,21 +3834,21 @@ st
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list