Blender V5.0
blender::ui::PreviewGridItem Class Reference

#include <UI_grid_view.hh>

Inherits blender::ui::AbstractGridViewItem.

Inherited by blender::ed::asset::shelf::AssetViewItem.

Public Types

using IsActiveFn = std::function<bool()>
using ActivateFn = std::function<void(bContext &C, PreviewGridItem &new_active)>

Public Member Functions

 PreviewGridItem (StringRef identifier, StringRef label, int preview_icon_id)
void build_grid_tile (const bContext &C, uiLayout &layout) const override
void build_grid_tile_button (uiLayout &layout, BIFIconID override_preview_icon_id=ICON_NONE) const
void set_on_activate_fn (ActivateFn fn)
void set_is_active_fn (IsActiveFn fn)
void hide_label ()
Public Member Functions inherited from blender::ui::AbstractGridViewItem
 ~AbstractGridViewItem () override=default
std::optional< std::string > debug_name () const override
AbstractGridViewget_view () const
Public Member Functions inherited from blender::ui::AbstractViewItem
virtual ~AbstractViewItem ()=default
virtual void build_context_menu (bContext &C, uiLayout &column) const
virtual bool set_state_active ()
virtual std::optional< bool > should_be_selected () const
virtual void set_selected (const bool select)
void activate (bContext &C)
void activate_for_context_menu (bContext &C)
void deactivate ()
virtual std::unique_ptr< AbstractViewItemDragControllercreate_drag_controller () const
AbstractViewget_view () const
uiButViewItemview_item_button () const
void disable_interaction ()
bool is_interactive () const
void disable_activatable ()
void select_on_click_set ()
bool is_select_on_click () const
void always_reactivate_on_click ()
void activate_for_context_menu_set ()
bool is_active () const
bool is_selected () const
bool is_search_highlight () const
virtual bool supports_renaming () const
virtual bool rename (const bContext &C, StringRefNull new_name)
virtual StringRef get_rename_string () const
bool is_renaming () const
void begin_renaming ()
void end_renaming ()
void rename_apply (const bContext &C)
virtual void delete_item (bContext *C)
virtual void on_filter_change ()
bool is_filtered_visible () const

Public Attributes

std::string label
int preview_icon_id = ICON_NONE

Protected Attributes

ActivateFn activate_fn_
IsActiveFn is_active_fn_
bool hide_label_ = false
Protected Attributes inherited from blender::ui::AbstractGridViewItem
std::string identifier_ {}
Protected Attributes inherited from blender::ui::AbstractViewItem
AbstractViewview_ = nullptr
uiButViewItemview_item_but_ = nullptr
bool is_activatable_ = true
bool is_interactive_ = true
bool is_active_ = false
bool is_selected_ = false
bool is_renaming_ = false
bool is_highlighted_search_ = false
bool is_filtered_visible_ = true
bool is_always_collapsible_ = false
bool select_on_click_ = false
bool reactivate_on_click_ = false
bool activate_for_context_menu_ = false

Additional Inherited Members

Protected Member Functions inherited from blender::ui::AbstractGridViewItem
 AbstractGridViewItem (StringRef identifier)
bool matches (const AbstractViewItem &other) const override
std::unique_ptr< DropTargetInterfacecreate_item_drop_target () final
virtual std::unique_ptr< GridViewItemDropTargetcreate_drop_target ()
Protected Member Functions inherited from blender::ui::AbstractViewItem
 AbstractViewItem ()=default
virtual void update_from_old (const AbstractViewItem &old)
virtual void change_state_delayed ()
void add_rename_button (uiBlock &block)
virtual bool should_be_filtered_visible (StringRefNull filter_string) const

Detailed Description

A grid item that shows preview image icons at a nicely readable size (multiple of the normal UI unit size).

Definition at line 194 of file UI_grid_view.hh.

Member Typedef Documentation

◆ ActivateFn

using blender::ui::PreviewGridItem::ActivateFn = std::function<void(bContext &C, PreviewGridItem &new_active)>

Definition at line 197 of file UI_grid_view.hh.

◆ IsActiveFn

using blender::ui::PreviewGridItem::IsActiveFn = std::function<bool()>

Definition at line 196 of file UI_grid_view.hh.

Constructor & Destructor Documentation

◆ PreviewGridItem()

blender::ui::PreviewGridItem::PreviewGridItem ( StringRef identifier,
StringRef label,
int preview_icon_id )

Member Function Documentation

◆ build_grid_tile()

void blender::ui::PreviewGridItem::build_grid_tile ( const bContext & C,
uiLayout & layout ) const
overridevirtual

Implements blender::ui::AbstractGridViewItem.

Definition at line 502 of file grid_view.cc.

References build_grid_tile_button().

◆ build_grid_tile_button()

◆ hide_label()

void blender::ui::PreviewGridItem::hide_label ( )

Definition at line 517 of file grid_view.cc.

References hide_label_.

Referenced by blender::ed::asset::shelf::AssetView::build_items().

◆ set_is_active_fn()

void blender::ui::PreviewGridItem::set_is_active_fn ( IsActiveFn fn)

Set a custom callback to check if this item should be active.

Definition at line 512 of file grid_view.cc.

References is_active_fn_.

◆ set_on_activate_fn()

void blender::ui::PreviewGridItem::set_on_activate_fn ( ActivateFn fn)

Set a custom callback to execute when activating this view item. This way users don't have to sub-class PreviewGridItem, just to implement custom activation behavior (a common thing to do).

Definition at line 507 of file grid_view.cc.

References activate_fn_.

Member Data Documentation

◆ activate_fn_

ActivateFn blender::ui::PreviewGridItem::activate_fn_
protected

See set_on_activate_fn()

Definition at line 201 of file UI_grid_view.hh.

Referenced by set_on_activate_fn().

◆ hide_label_

bool blender::ui::PreviewGridItem::hide_label_ = false
protected

Definition at line 204 of file UI_grid_view.hh.

Referenced by build_grid_tile_button(), and hide_label().

◆ is_active_fn_

IsActiveFn blender::ui::PreviewGridItem::is_active_fn_
protected

See set_is_active_fn()

Definition at line 203 of file UI_grid_view.hh.

Referenced by set_is_active_fn().

◆ label

std::string blender::ui::PreviewGridItem::label

◆ preview_icon_id

int blender::ui::PreviewGridItem::preview_icon_id = ICON_NONE

Definition at line 208 of file UI_grid_view.hh.

Referenced by build_grid_tile_button(), and PreviewGridItem().


The documentation for this class was generated from the following files: