Blender V4.3
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 std::unique_ptr< AbstractViewItemDragControllercreate_drag_controller () const
 
AbstractViewget_view () const
 
uiButViewItemview_item_button () const
 
void disable_interaction ()
 
bool is_interactive () const
 
void disable_activatable ()
 
bool is_active () const
 
bool is_search_highlight () const
 
void activate (bContext &C)
 
void deactivate ()
 
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)
 
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
StringRef 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_renaming_ = false
 
bool is_highlighted_search_ = false
 
bool is_filtered_visible_ = true
 

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 ()
 
virtual bool set_state_active ()
 
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 192 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 195 of file UI_grid_view.hh.

◆ IsActiveFn

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

Definition at line 194 of file UI_grid_view.hh.

Constructor & Destructor Documentation

◆ PreviewGridItem()

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

Definition at line 475 of file grid_view.cc.

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 516 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 531 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 526 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 521 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 199 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 202 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 201 of file UI_grid_view.hh.

Referenced by set_is_active_fn().

◆ label

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

Definition at line 205 of file UI_grid_view.hh.

Referenced by build_grid_tile_button().

◆ preview_icon_id

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

Definition at line 206 of file UI_grid_view.hh.

Referenced by build_grid_tile_button().


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