Actor Editor: pretty colours

This was SVN commit r2026.
This commit is contained in:
Ykkrosh 2005-03-20 00:46:39 +00:00
parent d0146135c4
commit 06d6cd17f5
8 changed files with 69 additions and 24 deletions

View File

@ -72,6 +72,8 @@ public:
AtIter& operator ++ ();
// Return whether this iterator has an AtObj to point to
bool defined() const;
// Return whether this iterator is pointing to a non-contentless AtObj
bool hasContent() const;
// Return an iterator to the children matching 'key'. (That is, children
// of the AtObj currently pointed to by this iterator)
@ -110,7 +112,7 @@ public:
bool isNull() const { return !p; }
// Check recursively whether there's actually any non-empty data in the object
bool isContentless() const;
bool hasContent() const;
// Add or set a child. The wchar_t* versions create a new AtObj with
// the appropriate string value, then use that as the child.

View File

@ -75,6 +75,14 @@ bool AtIter::defined() const
return (p != NULL);
}
bool AtIter::hasContent() const
{
if (p == NULL)
return false;
return p->iter->second->hasContent();
}
//////////////////////////////////////////////////////////////////////////
const AtIter AtObj::operator [] (const char* key) const
@ -130,12 +138,12 @@ void AtObj::set(const char* key, const wchar_t* value)
p = p->setChild(key, AtNode::Ptr(o));
}
bool AtObj::isContentless() const
bool AtObj::hasContent() const
{
if (! p)
return true;
return ! p->hasContent();
return p->hasContent();
}
//////////////////////////////////////////////////////////////////////////
@ -187,4 +195,4 @@ const AtNode::Ptr AtNode::addChild(const char* key, const AtNode::Ptr &data) con
AtNode* newNode = new AtNode(this);
newNode->children.insert(AtNode::child_pairtype(key, data));
return AtNode::Ptr(newNode);
}
}

View File

@ -9,6 +9,18 @@ ActorEditorListCtrl::ActorEditorListCtrl(wxWindow* parent)
: DraggableListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL)
{
#define COLOUR(name, c0, c1) \
m_ListItemAttr_##name[0].SetBackgroundColour(wxColour c0); \
m_ListItemAttr_##name[1].SetBackgroundColour(wxColour c1)
const int f=0xFF, e=0xEE, c=0xCC;
COLOUR(Model, (f,f,e), (f,f,c));
COLOUR(Texture, (f,e,e), (f,c,c));
COLOUR(Anim, (e,f,e), (c,f,c));
COLOUR(Prop, (e,e,f), (c,c,f));
#undef COLOUR
AddColumnType(_("Variant"), 100, "name", new FieldEditCtrl_Text());
AddColumnType(_("Freq"), 50, "frequency", new FieldEditCtrl_Text());
AddColumnType(_("Model"), 160, "mesh", new FieldEditCtrl_Text());
@ -55,3 +67,25 @@ void ActorEditorListCtrl::Export(AtObj& out)
if (! group.isNull())
out.add("group", group);
}
wxListItemAttr* ActorEditorListCtrl::OnGetItemAttr(long item) const
{
if (item >= 0 && item < (int)m_ListData.size())
{
AtObj row (m_ListData[item]);
// Colour-code the row, depending on the first non-empty column,
// and also alternate between light/dark.
if (row["mesh"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Model[item%2]);
else if (row["texture"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Texture[item%2]);
else if (row["animations"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Anim[item%2]);
else if (row["props"].hasContent())
return const_cast<wxListItemAttr*>(&m_ListItemAttr_Prop[item%2]);
}
return const_cast<wxListItemAttr*>(&m_ListItemAttr[item%2]);
}

View File

@ -13,7 +13,14 @@ public:
void OnUpdate(wxCommandEvent& event);
wxListItemAttr* OnGetItemAttr(long item) const;
private:
void Import(AtObj& in);
void Export(AtObj& out);
};
wxListItemAttr m_ListItemAttr_Model[2];
wxListItemAttr m_ListItemAttr_Texture[2];
wxListItemAttr m_ListItemAttr_Anim[2];
wxListItemAttr m_ListItemAttr_Prop[2];
};

View File

@ -12,8 +12,8 @@
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
OutputDirectory="..\..\..\..\binaries\system"
IntermediateDirectory="..\..\..\..\build\_atlas\Debug"
ConfigurationType="1"
CharacterSet="1">
<Tool
@ -63,8 +63,8 @@
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
OutputDirectory="..\..\..\..\binaries\system"
IntermediateDirectory="..\..\..\..\build\_atlas\Release"
ConfigurationType="1"
CharacterSet="1">
<Tool

View File

@ -5,8 +5,6 @@
#include "AtlasWindowCommandProc.h"
#include "DraggableListCtrlCommands.h"
//DEFINE_EVENT_TYPE(wxEVT_LISTCTRL_UPDATED);
const int ScrollSpeed = 8; // when dragging off the top or bottom of the control
DraggableListCtrl::DraggableListCtrl(wxWindow *parent,

View File

@ -17,6 +17,9 @@ EditableListCtrl::EditableListCtrl(wxWindow *parent,
const wxString& name)
: wxListCtrl(parent, id, pos, size, style | wxLC_VIRTUAL, validator, name)
{
m_ListItemAttr[0].SetBackgroundColour(wxColour(0xff, 0xff, 0xff));
m_ListItemAttr[1].SetBackgroundColour(wxColour(0xee, 0xee, 0xee));
wxASSERT_MSG(style & wxLC_REPORT, _T("EditableListCtrl must be LC_REPORT"));
UpdateDisplay();
}
@ -113,7 +116,7 @@ void EditableListCtrl::GetCellRect(long row, int col, wxRect& rect)
bool EditableListCtrl::IsRowBlank(int n)
{
return m_ListData[n].isContentless();
return ! m_ListData[n].hasContent();
}
void EditableListCtrl::TrimBlankEnds()
@ -217,19 +220,10 @@ wxString EditableListCtrl::OnGetItemText(long item, long column) const
return GetCellString(item, column);
}
wxListItemAttr* EditableListCtrl::OnGetItemAttr(long WXUNUSED(item)) const
wxListItemAttr* EditableListCtrl::OnGetItemAttr(long item) const
{
// if (item > (int)m_ListData.size()-BlanksAtEnd)
// {
// static wxListItemAttr attr;
// static int attr_init = 0;
// if (attr_init++ == 0)
// attr.SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
//
// return &attr;
// }
// else
return NULL;
// Make the background colours of rows alternate
return const_cast<wxListItemAttr*>(&m_ListItemAttr[item%2]);
}

View File

@ -76,6 +76,8 @@ protected:
bool IsRowBlank(int n);
wxListItemAttr m_ListItemAttr[2]; // standard+alternate colours
DECLARE_EVENT_TABLE();
};