Part of T98560. See https://wiki.blender.org/wiki/Source/Interface/Views Adds all the basic functionality needed for grid views. They display items in a grid of rows and columns, typically with a preview image and a label underneath. Think of the main region in the Asset Browser. Current features: - Active item - Notifier listening (also added this to the tree view) - Performance: Skip adding buttons that are not scrolled into view (solves performance problems for big asset libraries, for example). - Custom item size - Preview items (items that draw a preview with a label underneath) - Margins between items scale so the entire region width is filled with column, rather than leaving a big empty block at the right if there's not enough space for another column (like the File and current Asset Browser does it). - "Data-View Item" theme colors. Not shown in the UI yet. No user visible changes expected since the grid views aren't used for anything yet. This was developed as part of a rewrite of the Asset Browser UI (`asset-browser-grid-view` branch), see T95653. There's no reason to keep this part in a branch, continuing development in master makes things easier. Grid and tree views have a lot of very similar code, so I'm planning to unify them to a degree. I kept things separate for the start to first find out how much and what exactly makes sense to override.
67 lines
1.6 KiB
C++
67 lines
1.6 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::geometry_nodes_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;
|
|
};
|
|
|
|
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 is_output,
|
|
Span<const nodes::geometry_nodes_eval_log::GeometryAttributeInfo *> infos,
|
|
uiSearchItems *items,
|
|
bool is_first);
|
|
|
|
} // namespace blender::ui
|
|
|
|
/**
|
|
* Override this for all available tree types.
|
|
*/
|
|
blender::ui::AbstractGridView *UI_block_add_view(
|
|
uiBlock &block,
|
|
blender::StringRef idname,
|
|
std::unique_ptr<blender::ui::AbstractGridView> tree_view);
|
|
blender::ui::AbstractTreeView *UI_block_add_view(
|
|
uiBlock &block,
|
|
blender::StringRef idname,
|
|
std::unique_ptr<blender::ui::AbstractTreeView> tree_view);
|