[Bf-blender-cvs] [293405b6535] property-search-ui-v2: Merge branch 'master' into property-search-ui-v2
Hans Goudey
noreply at git.blender.org
Mon Aug 31 05:36:30 CEST 2020
Commit: 293405b653582534a46e903b9e9fe93b22951566
Author: Hans Goudey
Date: Sun Aug 30 22:36:20 2020 -0500
Branches: property-search-ui-v2
https://developer.blender.org/rB293405b653582534a46e903b9e9fe93b22951566
Merge branch 'master' into property-search-ui-v2
===================================================================
===================================================================
diff --cc source/blender/editors/interface/interface_panel.c
index 40f65f5c88e,ade77e96bf9..5d5b41d53ef
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@@ -69,23 -71,18 +71,19 @@@
#define ANIMATION_TIME 0.30
#define ANIMATION_INTERVAL 0.02
-#define PNL_LAST_ADDED 1
-#define PNL_ACTIVE 2
-#define PNL_WAS_ACTIVE 4
-#define PNL_ANIM_ALIGN 8
-#define PNL_NEW_ADDED 16
-#define PNL_FIRST 32
+#define PNL_LAST_ADDED (1 << 0)
+#define PNL_ACTIVE (1 << 1)
+#define PNL_WAS_ACTIVE (1 << 2)
+#define PNL_ANIM_ALIGN (1 << 3)
+#define PNL_NEW_ADDED (1 << 4)
+#define PNL_FIRST (1 << 5)
+#define PNL_SEARCH_FILTER_MATCHES (1 << 6)
- /* only show pin header button for pinned panels */
- #define USE_PIN_HIDDEN
-
/* the state of the mouse position relative to the panel */
typedef enum uiPanelMouseState {
- PANEL_MOUSE_OUTSIDE, /* mouse is not in the panel */
- PANEL_MOUSE_INSIDE_CONTENT, /* mouse is in the actual panel content */
- PANEL_MOUSE_INSIDE_HEADER, /* mouse is in the panel header */
- PANEL_MOUSE_INSIDE_SCALE, /* mouse is inside panel scale widget */
+ PANEL_MOUSE_OUTSIDE, /** Mouse is not in the panel. */
+ PANEL_MOUSE_INSIDE_CONTENT, /** Mouse is in the actual panel content. */
+ PANEL_MOUSE_INSIDE_HEADER, /** Mouse is in the panel header. */
} uiPanelMouseState;
typedef enum uiHandlePanelState {
@@@ -122,13 -119,18 +120,19 @@@ static bool panel_type_context_poll(ARe
const PanelType *panel_type,
const char *context);
+ /** \} */
+
+ /* -------------------------------------------------------------------- */
+ /** \name Local Functions
+ * \{ */
+
-static void panel_title_color_get(bool show_background, uchar color[4])
+static void panel_title_color_get(const Panel *panel,
+ const bool show_background,
+ const bool use_search_color,
+ const bool region_search_filter_active,
+ uchar r_color[4])
{
- if (show_background) {
- UI_GetThemeColor4ubv(TH_TITLE, color);
- }
- else {
+ if (!show_background) {
/* Use menu colors for floating panels. */
bTheme *btheme = UI_GetTheme();
const uiWidgetColors *wcol = &btheme->tui.wcol_menu_back;
@@@ -822,56 -814,11 +833,60 @@@ static void ui_offset_panel_block(uiBlo
block->rect.xmin = block->rect.ymin = 0.0;
}
+void ui_panel_set_search_filter_match(struct Panel *panel, const bool value)
+{
+ SET_FLAG_FROM_TEST(panel->runtime_flag, value, PNL_SEARCH_FILTER_MATCHES);
+ // SET_FLAG_FROM_TEST(panel->flag, !value, PNL_CLOSED);
+}
+
+static void panel_matches_search_filter_recursive(const Panel *panel, bool *filter_matches)
+{
+ *filter_matches |= panel->runtime_flag & PNL_SEARCH_FILTER_MATCHES;
+
+ /* If the panel is filtered (removed) we need to check that its children are too. */
+ if (!*filter_matches) {
+ LISTBASE_FOREACH (const Panel *, child_panel, &panel->children) {
+ panel_matches_search_filter_recursive(child_panel, filter_matches);
+ }
+ }
+}
+
+/**
+ * Find whether a panel or any of its subpanels contain a property that matches the search filter.
+ */
+bool UI_panel_matches_search_filter(const Panel *panel)
+{
+ bool search_filter_matches = false;
+ panel_matches_search_filter_recursive(panel, &search_filter_matches);
+ return search_filter_matches;
+}
+
+/**
+ * Returns whether a panel is currently active (displayed).
+ */
+bool UI_panel_is_active(const Panel *panel)
+{
+ return panel->runtime_flag & PNL_ACTIVE;
+}
+
+/**
+ * Uses the panel's search filter flag to set its expansion,
+ * activating animation if it was closed or opened.
+ */
+void UI_panel_set_expansion_from_seach_filter(const bContext *C, Panel *panel)
+{
+ short start_flag = panel->flag;
+ SET_FLAG_FROM_TEST(panel->flag, !UI_panel_matches_search_filter(panel), PNL_CLOSED);
+ if (start_flag != panel->flag) {
+ panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
+ }
+}
+
- /**************************** drawing *******************************/
+ /** \} */
+
+ /* -------------------------------------------------------------------- */
+ /** \name Drawing
+ * \{ */
/* triangle 'icon' for panel header */
void UI_draw_icon_tri(float x, float y, char dir, const float color[4])
@@@ -1037,15 -982,10 +1054,10 @@@ void ui_draw_aligned_panel(const uiStyl
immUnbindProgram();
}
- /* draw optional pin icon */
- #ifdef USE_PIN_HIDDEN
- if (show_pin && (block->panel->flag & PNL_PIN))
- #else
- if (show_pin)
- #endif
- {
+ /* draw optional pin icon */
+ if (show_pin && (block->panel->flag & PNL_PIN)) {
uchar col_title[4];
- panel_title_color_get(show_background, col_title);
+ panel_title_color_get(panel, show_background, false, region_search_filter_active, col_title);
GPU_blend(GPU_BLEND_ALPHA);
UI_icon_draw_ex(headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect),
@@@ -1064,11 -1004,10 +1076,11 @@@
if (is_subpanel) {
titlerect.xmin += (0.7f * UI_UNIT_X) / block->aspect + 0.001f;
}
- ui_draw_aligned_panel_header(style, block, &titlerect, show_background);
+ ui_draw_aligned_panel_header(
+ style, block, &titlerect, show_background, region_search_filter_active);
if (show_drag) {
- /* itemrect smaller */
+ /* Make `itemrect` smaller. */
const float scale = 0.7;
rctf itemrect;
itemrect.xmax = headrect.xmax - (0.2f * UI_UNIT_X);
@@@ -2032,338 -1873,433 +1946,435 @@@ void UI_panels_end(const bContext *C, A
}
}
- if (use_highlight && !use_shadow) {
- imm_buf_append(
- vbuf, cbuf, minx, miny + rad, highlight_fade ? col : highlight_fade, &buf_index);
+ if (panel_first) {
+ panel_first->runtime_flag |= PNL_FIRST;
}
- else {
- /* corner left-bottom */
- if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
- imm_buf_append(vbuf, cbuf, minx, miny + rad, col, &buf_index);
- for (int a = 0; a < 4; a++) {
- imm_buf_append(vbuf, cbuf, minx + vec[a][1], miny + rad - vec[a][0], col, &buf_index);
- }
- imm_buf_append(vbuf, cbuf, minx + rad, miny, col, &buf_index);
- }
- else {
- imm_buf_append(vbuf, cbuf, minx, miny, col, &buf_index);
- }
- /* corner right-bottom */
- if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
- imm_buf_append(vbuf, cbuf, maxx - rad, miny, col, &buf_index);
- for (int a = 0; a < 4; a++) {
- imm_buf_append(vbuf, cbuf, maxx - rad + vec[a][0], miny + vec[a][1], col, &buf_index);
- }
- imm_buf_append(vbuf, cbuf, maxx, miny + rad, col, &buf_index);
- }
- else {
- imm_buf_append(vbuf, cbuf, maxx, miny, col, &buf_index);
- }
- }
+ /* compute size taken up by panel */
+ ui_panels_size(region, r_x, r_y);
+ }
- if (use_flip_x) {
- const float midx = (minx + maxx) / 2.0f;
- for (int i = 0; i < buf_index; i++) {
- vbuf[i][0] = midx - (vbuf[i][0] - midx);
+ void UI_panels_draw(const bContext *C, ARegion *region)
+ {
+ /* Draw panels, selected on top. Also in reverse order, because
+ * UI blocks are added in reverse order and we need child panels
+ * to draw on top. */
+ LISTBASE_FOREACH_BACKWARD (uiBlock *, block, ®ion->uiblocks) {
- if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
++ if (block->active && block->panel && !(block->panel->flag & PNL_SELECT) &&
++ !UI_block_is_search_only(block)) {
+ UI_block_draw(C, block);
}
}
- GPUVertFormat *format = immVertexFormat();
- const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- uint color = GPU_vertformat_attr_add(
- format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
- immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len);
- for (int i = 0; i < buf_index; i++) {
- immAttr3ubv(color, cbuf[i]);
- immVertex2fv(pos, vbuf[i]);
+ LISTBASE_FOREACH_BACKWARD (uiBlock *, block, ®ion->uiblocks) {
- if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
++ if (block->active && block->panel && (block->panel->flag & PNL_SELECT) &&
++ !UI_block_is_search_only(block)) {
+ UI_block_draw(C, block);
+ }
}
- immEnd();
- immUnbindProgram();
}
- /**
- * Draw vertical tabs on the left side of the region,
- * one tab per category.
- */
- void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
+ void UI_panels_scale(ARegion *region, float new_width)
{
- /* no tab outlines for */
- // #define USE_FLAT_INACTIVE
- const bool is_left = RGN_ALIGN_ENUM_FROM_MASK(region->alignment != RGN_ALIGN_RIGHT);
- View2D *v2d = ®ion->v2d;
- const uiStyle *style = UI_style_get();
- const uiFontStyle *fstyle = &style->widget;
- const int fontid = fstyle->uifont_id;
- short fstyle_points = fstyle->points;
- const float aspect = ((uiBlock *)region->uiblocks.first)->aspect;
- const float zoom = 1.0f / aspect;
- const int px = max_ii(1, round_fl_to_int(U.pixelsize));
- const int px_x_sign = is_left ? px : -px;
- const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);
- const float dpi_fac = UI_DPI_FAC;
- /* padding of tabs around text */
- const int tab_v_pad_text = round_fl_to_int((2 + ((px * 3) * dpi_fac)) * zoom);
- /* padding between tabs */
- const int tab_v_pad = round_fl_to_int((4 + (2 * px * dpi_fac)) * zoom);
- const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom;
- /* We flip the tab drawing, so always use these flags. */
- const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT;
- bool is_alpha;
- bool do_scaletabs = false;
- #ifdef USE_FLAT_INACTIVE
- bool is_active_prev = false;
- #endif
- float scaletabs = 1.0f;
- /* same for all tabs */
- /* intentionally dont scale by 'px' */
- const int rct_xmin = is_left ? v2d->mask
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list