This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/editors/include/UI_interface.hh
Dalai Felinto 84825e4ed2 UI: Icon number indicator for data-blocks
Adds the possibility of having a little number on top of icons.

At the moment this is used for:
* Outliner
* Node Editor bread-crumb
* Node Group node header

For the outliner there is almost no functional change. It is mostly a refactor
to handle the indicators as part of the icon shader instead of the outliner
draw code. (note that this was already recently changed in a5d3b648e3).

The difference is that now we use rounded border rectangle instead of
circles, and we can go up to 999 elements.

So for the outliner this shows the number of collapsed elements of a
certain type (e.g., mesh objects inside a collapsed collection).

For the node editors is being used to show the use count for the data-block.
This is important for the node editor, so users know whether the node-group
they are editing (or are about to edit) is used elsewhere. This is
particularly important when the Node Options are hidden, which is the
default for node groups appended from the asset libraries.

---

Note: This can be easily enabled for ID templates which can then be part
of T84669. It just need to call UI_but_icon_indicator_number_set in the
function template_add_button_search_menu.

---

Special thanks Clément Foucault for the help figuring out the shader,
Julian Eisel for the help navigating the UI code, and Pablo Vazquez for
the collaboration in this design solution.

For images showing the result check the Differential Revision.
Differential Revision: https://developer.blender.org/D16284
2022-10-20 16:46:54 +02:00

67 lines
1.7 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup editorui
*/
#pragma once
#include <memory>
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include "UI_resources.h"
namespace blender::nodes::geo_eval_log {
struct GeometryAttributeInfo;
}
struct StructRNA;
struct uiBlock;
struct uiSearchItems;
namespace blender::ui {
class AbstractGridView;
class AbstractTreeView;
/**
* An item in a breadcrumb-like context. Currently this struct is very simple, but more
* could be added to it in the future, to support interactivity or tooltips, for example.
*/
struct ContextPathItem {
/* Text to display in the UI. */
std::string name;
/* #BIFIconID */
int icon;
int icon_indicator_number;
};
void context_path_add_generic(Vector<ContextPathItem> &path,
StructRNA &rna_type,
void *ptr,
const BIFIconID icon_override = ICON_NONE);
void template_breadcrumbs(uiLayout &layout, Span<ContextPathItem> context_path);
void attribute_search_add_items(StringRefNull str,
bool can_create_attribute,
Span<const nodes::geo_eval_log::GeometryAttributeInfo *> infos,
uiSearchItems *items,
bool is_first);
} // namespace blender::ui
/**
* Override this for all available view types.
*/
blender::ui::AbstractGridView *UI_block_add_view(
uiBlock &block,
blender::StringRef idname,
std::unique_ptr<blender::ui::AbstractGridView> grid_view);
blender::ui::AbstractTreeView *UI_block_add_view(
uiBlock &block,
blender::StringRef idname,
std::unique_ptr<blender::ui::AbstractTreeView> tree_view);