24
#include "NuxGraphics/GLTextureResourceManager.h"
25
#include "ActionItem.h"
29
IMPLEMENT_ROOT_OBJECT_TYPE(ActionItem);
31
ActionItem::ActionItem(const TCHAR* label, int UserValue)
36
, m_UserValue(UserValue)
41
ActionItem::~ActionItem()
46
void ActionItem::DrawAsMenuItem(GraphicsContext& GfxContext, CoreArea& area, bool is_highlighted, bool draw_icone)
48
Geometry geo = area.GetGeometry();
49
Geometry icon_geo(0, 0, 20, 20);
50
Geometry text_geo = geo;
52
text_geo.OffsetPosition(24, 2);
53
text_geo.OffsetSize(2 * 24, 2 * 2);
55
icon_geo.SetX(geo.x+ 2);
56
icon_geo.SetY(geo.y+ 2);
58
const TCHAR* label = GetLabel();
62
gPainter.Paint2DQuadColor(GfxContext, geo, Color(COLOR_FOREGROUND_SECONDARY));
65
gPainter.Draw2DTextureAligned(GfxContext, &m_Icon, icon_geo, TextureAlignmentStyle(eTACenter, eTACenter));
67
gPainter.PaintTextLineStatic(GfxContext, GFont, text_geo, std::string(label), Color(0xFF000000), eAlignTextLeft);
70
void ActionItem::DrawAsToolButton(GraphicsContext& GfxContext, CoreArea& area)
72
Geometry base = area.GetGeometry();
73
if(area.HasMouseFocus())
75
if(area.IsMouseInside())
77
gPainter.PaintShape(GfxContext, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
78
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
82
gPainter.PaintShape(GfxContext, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
83
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
88
if(area.IsMouseInside() && (!area.MouseFocusOnOtherArea()))
90
gPainter.PaintShape(GfxContext, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
91
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
95
gPainter.PaintShape(GfxContext, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
96
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
100
gPainter.Draw2DTextureAligned(GfxContext, &m_Icon, base, TextureAlignmentStyle(eTACenter, eTACenter));
103
void ActionItem::Activate(bool b)
108
void ActionItem::Trigger() const
113
void ActionItem::Enable(bool b)
118
bool ActionItem::isEnabled() const
123
void ActionItem::SetLabel(const TCHAR* label)
128
const TCHAR* ActionItem::GetLabel() const
130
return m_Label.GetTCharPtr();
133
void ActionItem::SetIcon(const NTexture2D& icon)
138
NTexture2D& ActionItem::GetIcon()
143
//void ActionItem::SetMenu(Menu* menu)
147
//Menu* ActionItem::GetMenu() const
24
#include "NuxGraphics/GLTextureResourceManager.h"
25
#include "ActionItem.h"
29
IMPLEMENT_ROOT_OBJECT_TYPE(ActionItem);
31
ActionItem::ActionItem(const TCHAR* label, int UserValue)
36
, m_UserValue(UserValue)
41
ActionItem::~ActionItem()
46
void ActionItem::DrawAsMenuItem(GraphicsContext& GfxContext, CoreArea& area, bool is_highlighted, bool draw_icone)
48
Geometry geo = area.GetGeometry();
49
Geometry icon_geo(0, 0, 20, 20);
50
Geometry text_geo = geo;
52
text_geo.OffsetPosition(24, 2);
53
text_geo.OffsetSize(2 * 24, 2 * 2);
55
icon_geo.SetX(geo.x+ 2);
56
icon_geo.SetY(geo.y+ 2);
58
const TCHAR* label = GetLabel();
62
gPainter.Paint2DQuadColor(GfxContext, geo, Color(COLOR_FOREGROUND_SECONDARY));
65
gPainter.Draw2DTextureAligned(GfxContext, &m_Icon, icon_geo, TextureAlignmentStyle(eTACenter, eTACenter));
67
gPainter.PaintTextLineStatic(GfxContext, GFont, text_geo, std::string(label), Color(0xFF000000), eAlignTextLeft);
70
void ActionItem::DrawAsToolButton(GraphicsContext& GfxContext, CoreArea& area)
72
Geometry base = area.GetGeometry();
73
if(area.HasMouseFocus())
75
if(area.IsMouseInside())
77
gPainter.PaintShape(GfxContext, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
78
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
82
gPainter.PaintShape(GfxContext, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
83
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
88
if(area.IsMouseInside() && (!area.MouseFocusOnOtherArea()))
90
gPainter.PaintShape(GfxContext, base, Color(COLOR_FOREGROUND_PRIMARY), eSHAPE_CORNER_ROUND2);
91
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
95
gPainter.PaintShape(GfxContext, base, Color(COLOR_BACKGROUND_SECONDARY), eSHAPE_CORNER_ROUND2);
96
gPainter.PaintShape(GfxContext, base, Color(COLOR_BLACK), eSTROKE_CORNER_ROUND2);
100
gPainter.Draw2DTextureAligned(GfxContext, &m_Icon, base, TextureAlignmentStyle(eTACenter, eTACenter));
103
void ActionItem::Activate(bool b)
108
void ActionItem::Trigger() const
113
void ActionItem::Enable(bool b)
118
bool ActionItem::isEnabled() const
123
void ActionItem::SetLabel(const TCHAR* label)
128
const TCHAR* ActionItem::GetLabel() const
130
return m_Label.GetTCharPtr();
133
void ActionItem::SetIcon(const NTexture2D& icon)
138
NTexture2D& ActionItem::GetIcon()
143
//void ActionItem::SetMenu(Menu* menu)
147
//Menu* ActionItem::GetMenu() const