Ember
Loading...
Searching...
No Matches
EmberForge::NodeWidget Class Reference

Custom widget for rendering and interacting with behavior tree nodes. More...

#include <NodeWidget.h>

Inheritance diagram for EmberForge::NodeWidget:

Public Types

enum class  RenderStyle { Compact , Normal , Detailed , Debug }
 Node rendering styles. More...
enum class  InteractionState {
  Normal , Hovered , Selected , Dragging ,
  Editing
}
 Node interaction states. More...
using NodeClickCallback = std::function<void(NodeWidget *, EmberCore::Node *)>
using NodeDoubleClickCallback = std::function<void(NodeWidget *, EmberCore::Node *)>
using NodeDragCallback = std::function<void(NodeWidget *, const wxPoint &delta)>
using NodeEditCallback = std::function<void(NodeWidget *, const wxString &new_name)>

Public Member Functions

 NodeWidget (wxWindow *parent, EmberCore::Node *node, RenderStyle style=RenderStyle::Normal)
 Constructor.
virtual ~NodeWidget ()
 Destructor.
void SetNode (EmberCore::Node *node)
EmberCore::NodeGetNode () const
bool HasNode () const
RenderStyle GetRenderStyle () const
void SetRenderStyle (RenderStyle style)
InteractionState GetInteractionState () const
void SetInteractionState (InteractionState state)
bool IsSelected () const
void SetSelected (bool selected)
bool IsEditing () const
void StartEditing ()
void StopEditing (bool save_changes=true)
void UpdateFromNode ()
void SyncVisualState ()
wxSize GetPreferredSize () const
wxSize CalculateMinSize () const
void SetCustomSize (const wxSize &size)
void SetNodeColors (const wxColour &background, const wxColour &border, const wxColour &text)
void SetNodeFont (const wxFont &font)
void ResetToDefaultAppearance ()
void StartPulseAnimation ()
void StopPulseAnimation ()
void SetHighlighted (bool highlighted)
bool IsDraggable () const
void SetDraggable (bool draggable)
void SetNodeClickCallback (NodeClickCallback callback)
void SetNodeDoubleClickCallback (NodeDoubleClickCallback callback)
void SetNodeDragCallback (NodeDragCallback callback)
void SetNodeEditCallback (NodeEditCallback callback)

Protected Member Functions

virtual void OnPaint (wxPaintEvent &event)
virtual void OnSize (wxSizeEvent &event)
virtual void OnEraseBackground (wxEraseEvent &event)
virtual void OnMouseEnter (wxMouseEvent &event)
virtual void OnMouseLeave (wxMouseEvent &event)
virtual void OnMouseDown (wxMouseEvent &event)
virtual void OnMouseUp (wxMouseEvent &event)
virtual void OnMouseMove (wxMouseEvent &event)
virtual void OnMouseDoubleClick (wxMouseEvent &event)
virtual void OnRightClick (wxContextMenuEvent &event)
virtual void OnKeyDown (wxKeyEvent &event)
virtual void OnChar (wxKeyEvent &event)
virtual void OnSetFocus (wxFocusEvent &event)
virtual void OnKillFocus (wxFocusEvent &event)
void DrawNodeBackground (wxDC &dc, const wxRect &rect)
void DrawNodeBorder (wxDC &dc, const wxRect &rect)
void DrawNodeIcon (wxDC &dc, const wxRect &icon_rect)
void DrawNodeText (wxDC &dc, const wxRect &text_rect)
void DrawNodeStatus (wxDC &dc, const wxRect &status_rect)
void DrawConnectionPoints (wxDC &dc)
wxRect GetContentRect () const
wxRect GetIconRect () const
wxRect GetTextRect () const
wxRect GetStatusRect () const
std::vector< wxPoint > GetConnectionPoints () const
wxColour GetBackgroundColor () const
wxColour GetBorderColor () const
wxColour GetTextColor () const
wxBitmap GetNodeIcon () const
wxString GetDisplayText () const
void OnAnimationTimer (wxTimerEvent &event)
void UpdateAnimation ()

Private Member Functions

void InitializeWidget ()
void UpdateColors ()
void CreateEditControl ()
void DestroyEditControl ()
void ShowContextMenu (const wxPoint &position)

Private Attributes

EmberCore::Nodenode_
RenderStyle render_style_
InteractionState interaction_state_
wxSize custom_size_
wxColour background_color_
wxColour border_color_
wxColour text_color_
wxFont node_font_
bool is_draggable_
bool is_highlighted_
wxPoint drag_start_pos_
wxPoint last_mouse_pos_
wxTimer * animation_timer_
double animation_phase_
bool is_animating_
wxTextCtrl * edit_control_
wxString original_name_
NodeClickCallback click_callback_
NodeDoubleClickCallback double_click_callback_
NodeDragCallback drag_callback_
NodeEditCallback edit_callback_

Static Private Attributes

static const int BORDER_WIDTH = 2
static const int PADDING = 6
static const int ICON_SIZE = 16
static const int MIN_WIDTH = 80
static const int MIN_HEIGHT = 32

Detailed Description

Custom widget for rendering and interacting with behavior tree nodes.

This widget provides a visual representation of a single behavior tree node with support for selection, editing, drag & drop, and visual state indication.

Definition at line 16 of file NodeWidget.h.

Member Typedef Documentation

◆ NodeClickCallback

Definition at line 97 of file NodeWidget.h.

◆ NodeDoubleClickCallback

Definition at line 98 of file NodeWidget.h.

◆ NodeDragCallback

using EmberForge::NodeWidget::NodeDragCallback = std::function<void(NodeWidget *, const wxPoint &delta)>

Definition at line 99 of file NodeWidget.h.

◆ NodeEditCallback

using EmberForge::NodeWidget::NodeEditCallback = std::function<void(NodeWidget *, const wxString &new_name)>

Definition at line 100 of file NodeWidget.h.

Member Enumeration Documentation

◆ InteractionState

Node interaction states.

Enumerator
Normal 
Hovered 
Selected 
Dragging 
Editing 

Definition at line 31 of file NodeWidget.h.

◆ RenderStyle

Node rendering styles.

Enumerator
Compact 
Normal 
Detailed 
Debug 

Definition at line 21 of file NodeWidget.h.

Constructor & Destructor Documentation

◆ NodeWidget()

EmberForge::NodeWidget::NodeWidget ( wxWindow * parent,
EmberCore::Node * node,
RenderStyle style = RenderStyle::Normal )

Constructor.

Parameters
parentParent window
nodeThe behavior tree node to represent
styleInitial render style

◆ ~NodeWidget()

EmberForge::NodeWidget::~NodeWidget ( )
virtual

Destructor.

Definition at line 35 of file NodeWidget.cpp.

Member Function Documentation

◆ CalculateMinSize()

wxSize EmberForge::NodeWidget::CalculateMinSize ( ) const

Definition at line 131 of file NodeWidget.cpp.

◆ CreateEditControl()

void EmberForge::NodeWidget::CreateEditControl ( )
private

Definition at line 579 of file NodeWidget.cpp.

◆ DestroyEditControl()

void EmberForge::NodeWidget::DestroyEditControl ( )
private

Definition at line 602 of file NodeWidget.cpp.

◆ DrawConnectionPoints()

void EmberForge::NodeWidget::DrawConnectionPoints ( wxDC & dc)
protected

Definition at line 416 of file NodeWidget.cpp.

◆ DrawNodeBackground()

void EmberForge::NodeWidget::DrawNodeBackground ( wxDC & dc,
const wxRect & rect )
protected

Definition at line 349 of file NodeWidget.cpp.

◆ DrawNodeBorder()

void EmberForge::NodeWidget::DrawNodeBorder ( wxDC & dc,
const wxRect & rect )
protected

Definition at line 363 of file NodeWidget.cpp.

◆ DrawNodeIcon()

void EmberForge::NodeWidget::DrawNodeIcon ( wxDC & dc,
const wxRect & icon_rect )
protected

Definition at line 371 of file NodeWidget.cpp.

◆ DrawNodeStatus()

void EmberForge::NodeWidget::DrawNodeStatus ( wxDC & dc,
const wxRect & status_rect )
protected

Definition at line 387 of file NodeWidget.cpp.

◆ DrawNodeText()

void EmberForge::NodeWidget::DrawNodeText ( wxDC & dc,
const wxRect & text_rect )
protected

Definition at line 378 of file NodeWidget.cpp.

◆ GetBackgroundColor()

wxColour EmberForge::NodeWidget::GetBackgroundColor ( ) const
protected

Definition at line 481 of file NodeWidget.cpp.

◆ GetBorderColor()

wxColour EmberForge::NodeWidget::GetBorderColor ( ) const
protected

Definition at line 496 of file NodeWidget.cpp.

◆ GetConnectionPoints()

std::vector< wxPoint > EmberForge::NodeWidget::GetConnectionPoints ( ) const
protected

Definition at line 464 of file NodeWidget.cpp.

◆ GetContentRect()

wxRect EmberForge::NodeWidget::GetContentRect ( ) const
protected

Definition at line 428 of file NodeWidget.cpp.

◆ GetDisplayText()

wxString EmberForge::NodeWidget::GetDisplayText ( ) const
protected

Definition at line 542 of file NodeWidget.cpp.

◆ GetIconRect()

wxRect EmberForge::NodeWidget::GetIconRect ( ) const
protected

Definition at line 434 of file NodeWidget.cpp.

◆ GetInteractionState()

InteractionState EmberForge::NodeWidget::GetInteractionState ( ) const
inline

Definition at line 61 of file NodeWidget.h.

◆ GetNode()

EmberCore::Node * EmberForge::NodeWidget::GetNode ( ) const
inline

Definition at line 54 of file NodeWidget.h.

◆ GetNodeIcon()

wxBitmap EmberForge::NodeWidget::GetNodeIcon ( ) const
protected

Definition at line 536 of file NodeWidget.cpp.

◆ GetPreferredSize()

wxSize EmberForge::NodeWidget::GetPreferredSize ( ) const

Definition at line 109 of file NodeWidget.cpp.

◆ GetRenderStyle()

RenderStyle EmberForge::NodeWidget::GetRenderStyle ( ) const
inline

Definition at line 58 of file NodeWidget.h.

◆ GetStatusRect()

wxRect EmberForge::NodeWidget::GetStatusRect ( ) const
protected

Definition at line 455 of file NodeWidget.cpp.

◆ GetTextColor()

wxColour EmberForge::NodeWidget::GetTextColor ( ) const
protected

Definition at line 519 of file NodeWidget.cpp.

◆ GetTextRect()

wxRect EmberForge::NodeWidget::GetTextRect ( ) const
protected

Definition at line 443 of file NodeWidget.cpp.

◆ HasNode()

bool EmberForge::NodeWidget::HasNode ( ) const
inline

Definition at line 55 of file NodeWidget.h.

◆ InitializeWidget()

void EmberForge::NodeWidget::InitializeWidget ( )
private

Definition at line 564 of file NodeWidget.cpp.

◆ IsDraggable()

bool EmberForge::NodeWidget::IsDraggable ( ) const
inline

Definition at line 93 of file NodeWidget.h.

◆ IsEditing()

bool EmberForge::NodeWidget::IsEditing ( ) const
inline

Definition at line 69 of file NodeWidget.h.

◆ IsSelected()

bool EmberForge::NodeWidget::IsSelected ( ) const
inline

Definition at line 65 of file NodeWidget.h.

◆ OnAnimationTimer()

void EmberForge::NodeWidget::OnAnimationTimer ( wxTimerEvent & event)
protected

Definition at line 551 of file NodeWidget.cpp.

◆ OnChar()

void EmberForge::NodeWidget::OnChar ( wxKeyEvent & event)
protectedvirtual

Definition at line 333 of file NodeWidget.cpp.

◆ OnEraseBackground()

void EmberForge::NodeWidget::OnEraseBackground ( wxEraseEvent & event)
protectedvirtual

Definition at line 232 of file NodeWidget.cpp.

◆ OnKeyDown()

void EmberForge::NodeWidget::OnKeyDown ( wxKeyEvent & event)
protectedvirtual

Definition at line 310 of file NodeWidget.cpp.

◆ OnKillFocus()

void EmberForge::NodeWidget::OnKillFocus ( wxFocusEvent & event)
protectedvirtual

Definition at line 340 of file NodeWidget.cpp.

◆ OnMouseDoubleClick()

void EmberForge::NodeWidget::OnMouseDoubleClick ( wxMouseEvent & event)
protectedvirtual

Definition at line 298 of file NodeWidget.cpp.

◆ OnMouseDown()

void EmberForge::NodeWidget::OnMouseDown ( wxMouseEvent & event)
protectedvirtual

Definition at line 250 of file NodeWidget.cpp.

◆ OnMouseEnter()

void EmberForge::NodeWidget::OnMouseEnter ( wxMouseEvent & event)
protectedvirtual

Definition at line 236 of file NodeWidget.cpp.

◆ OnMouseLeave()

void EmberForge::NodeWidget::OnMouseLeave ( wxMouseEvent & event)
protectedvirtual

Definition at line 243 of file NodeWidget.cpp.

◆ OnMouseMove()

void EmberForge::NodeWidget::OnMouseMove ( wxMouseEvent & event)
protectedvirtual

Definition at line 280 of file NodeWidget.cpp.

◆ OnMouseUp()

void EmberForge::NodeWidget::OnMouseUp ( wxMouseEvent & event)
protectedvirtual

Definition at line 268 of file NodeWidget.cpp.

◆ OnPaint()

void EmberForge::NodeWidget::OnPaint ( wxPaintEvent & event)
protectedvirtual

Definition at line 185 of file NodeWidget.cpp.

◆ OnRightClick()

void EmberForge::NodeWidget::OnRightClick ( wxContextMenuEvent & event)
protectedvirtual

Definition at line 308 of file NodeWidget.cpp.

◆ OnSetFocus()

void EmberForge::NodeWidget::OnSetFocus ( wxFocusEvent & event)
protectedvirtual

Definition at line 335 of file NodeWidget.cpp.

◆ OnSize()

void EmberForge::NodeWidget::OnSize ( wxSizeEvent & event)
protectedvirtual

Definition at line 223 of file NodeWidget.cpp.

◆ ResetToDefaultAppearance()

void EmberForge::NodeWidget::ResetToDefaultAppearance ( )

Definition at line 150 of file NodeWidget.cpp.

◆ SetCustomSize()

void EmberForge::NodeWidget::SetCustomSize ( const wxSize & size)

Definition at line 133 of file NodeWidget.cpp.

◆ SetDraggable()

void EmberForge::NodeWidget::SetDraggable ( bool draggable)
inline

Definition at line 94 of file NodeWidget.h.

◆ SetHighlighted()

void EmberForge::NodeWidget::SetHighlighted ( bool highlighted)

Definition at line 176 of file NodeWidget.cpp.

◆ SetInteractionState()

void EmberForge::NodeWidget::SetInteractionState ( InteractionState state)

Definition at line 54 of file NodeWidget.cpp.

◆ SetNode()

void EmberForge::NodeWidget::SetNode ( EmberCore::Node * node)

Definition at line 43 of file NodeWidget.cpp.

◆ SetNodeClickCallback()

void EmberForge::NodeWidget::SetNodeClickCallback ( NodeClickCallback callback)
inline

Definition at line 102 of file NodeWidget.h.

◆ SetNodeColors()

void EmberForge::NodeWidget::SetNodeColors ( const wxColour & background,
const wxColour & border,
const wxColour & text )

Definition at line 138 of file NodeWidget.cpp.

◆ SetNodeDoubleClickCallback()

void EmberForge::NodeWidget::SetNodeDoubleClickCallback ( NodeDoubleClickCallback callback)
inline

Definition at line 103 of file NodeWidget.h.

◆ SetNodeDragCallback()

void EmberForge::NodeWidget::SetNodeDragCallback ( NodeDragCallback callback)
inline

Definition at line 104 of file NodeWidget.h.

◆ SetNodeEditCallback()

void EmberForge::NodeWidget::SetNodeEditCallback ( NodeEditCallback callback)
inline

Definition at line 105 of file NodeWidget.h.

◆ SetNodeFont()

void EmberForge::NodeWidget::SetNodeFont ( const wxFont & font)

Definition at line 145 of file NodeWidget.cpp.

◆ SetRenderStyle()

void EmberForge::NodeWidget::SetRenderStyle ( RenderStyle style)

Definition at line 49 of file NodeWidget.cpp.

◆ SetSelected()

void EmberForge::NodeWidget::SetSelected ( bool selected)

Definition at line 62 of file NodeWidget.cpp.

◆ ShowContextMenu()

void EmberForge::NodeWidget::ShowContextMenu ( const wxPoint & position)
private

Definition at line 609 of file NodeWidget.cpp.

◆ StartEditing()

void EmberForge::NodeWidget::StartEditing ( )

Definition at line 66 of file NodeWidget.cpp.

◆ StartPulseAnimation()

void EmberForge::NodeWidget::StartPulseAnimation ( )

Definition at line 158 of file NodeWidget.cpp.

◆ StopEditing()

void EmberForge::NodeWidget::StopEditing ( bool save_changes = true)

Definition at line 75 of file NodeWidget.cpp.

◆ StopPulseAnimation()

void EmberForge::NodeWidget::StopPulseAnimation ( )

Definition at line 168 of file NodeWidget.cpp.

◆ SyncVisualState()

void EmberForge::NodeWidget::SyncVisualState ( )

Definition at line 107 of file NodeWidget.cpp.

◆ UpdateAnimation()

void EmberForge::NodeWidget::UpdateAnimation ( )
protected

Definition at line 553 of file NodeWidget.cpp.

◆ UpdateColors()

void EmberForge::NodeWidget::UpdateColors ( )
private

Definition at line 575 of file NodeWidget.cpp.

◆ UpdateFromNode()

void EmberForge::NodeWidget::UpdateFromNode ( )

Definition at line 92 of file NodeWidget.cpp.

Member Data Documentation

◆ animation_phase_

double EmberForge::NodeWidget::animation_phase_
private

Definition at line 177 of file NodeWidget.h.

◆ animation_timer_

wxTimer* EmberForge::NodeWidget::animation_timer_
private

Definition at line 176 of file NodeWidget.h.

◆ background_color_

wxColour EmberForge::NodeWidget::background_color_
private

Definition at line 164 of file NodeWidget.h.

◆ border_color_

wxColour EmberForge::NodeWidget::border_color_
private

Definition at line 165 of file NodeWidget.h.

◆ BORDER_WIDTH

const int EmberForge::NodeWidget::BORDER_WIDTH = 2
staticprivate

Definition at line 198 of file NodeWidget.h.

◆ click_callback_

NodeClickCallback EmberForge::NodeWidget::click_callback_
private

Definition at line 185 of file NodeWidget.h.

◆ custom_size_

wxSize EmberForge::NodeWidget::custom_size_
private

Definition at line 163 of file NodeWidget.h.

◆ double_click_callback_

NodeDoubleClickCallback EmberForge::NodeWidget::double_click_callback_
private

Definition at line 186 of file NodeWidget.h.

◆ drag_callback_

NodeDragCallback EmberForge::NodeWidget::drag_callback_
private

Definition at line 187 of file NodeWidget.h.

◆ drag_start_pos_

wxPoint EmberForge::NodeWidget::drag_start_pos_
private

Definition at line 172 of file NodeWidget.h.

◆ edit_callback_

NodeEditCallback EmberForge::NodeWidget::edit_callback_
private

Definition at line 188 of file NodeWidget.h.

◆ edit_control_

wxTextCtrl* EmberForge::NodeWidget::edit_control_
private

Definition at line 181 of file NodeWidget.h.

◆ ICON_SIZE

const int EmberForge::NodeWidget::ICON_SIZE = 16
staticprivate

Definition at line 200 of file NodeWidget.h.

◆ interaction_state_

InteractionState EmberForge::NodeWidget::interaction_state_
private

Definition at line 160 of file NodeWidget.h.

◆ is_animating_

bool EmberForge::NodeWidget::is_animating_
private

Definition at line 178 of file NodeWidget.h.

◆ is_draggable_

bool EmberForge::NodeWidget::is_draggable_
private

Definition at line 170 of file NodeWidget.h.

◆ is_highlighted_

bool EmberForge::NodeWidget::is_highlighted_
private

Definition at line 171 of file NodeWidget.h.

◆ last_mouse_pos_

wxPoint EmberForge::NodeWidget::last_mouse_pos_
private

Definition at line 173 of file NodeWidget.h.

◆ MIN_HEIGHT

const int EmberForge::NodeWidget::MIN_HEIGHT = 32
staticprivate

Definition at line 202 of file NodeWidget.h.

◆ MIN_WIDTH

const int EmberForge::NodeWidget::MIN_WIDTH = 80
staticprivate

Definition at line 201 of file NodeWidget.h.

◆ node_

EmberCore::Node* EmberForge::NodeWidget::node_
private

Definition at line 158 of file NodeWidget.h.

◆ node_font_

wxFont EmberForge::NodeWidget::node_font_
private

Definition at line 167 of file NodeWidget.h.

◆ original_name_

wxString EmberForge::NodeWidget::original_name_
private

Definition at line 182 of file NodeWidget.h.

◆ PADDING

const int EmberForge::NodeWidget::PADDING = 6
staticprivate

Definition at line 199 of file NodeWidget.h.

◆ render_style_

RenderStyle EmberForge::NodeWidget::render_style_
private

Definition at line 159 of file NodeWidget.h.

◆ text_color_

wxColour EmberForge::NodeWidget::text_color_
private

Definition at line 166 of file NodeWidget.h.


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