Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6021: Add syntax highlighting for modelDefs. Move DeclarationSourceV…
…iew implementation to .cpp file
- Loading branch information
1 parent
8352d67
commit 5ecaebe
Showing
7 changed files
with
140 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#include "DeclarationSourceView.h" | ||
|
||
#include "i18n.h" | ||
#include "fmt/format.h" | ||
|
||
#include "SourceView.h" | ||
|
||
// Some X11 headers are defining this | ||
#ifdef None | ||
#undef None | ||
#endif | ||
|
||
namespace wxutil | ||
{ | ||
|
||
DeclarationSourceView::DeclarationSourceView(wxWindow* parent) : | ||
DefinitionView("", parent), | ||
_activeSourceViewType(decl::Type::Undetermined) | ||
{ | ||
updateSourceView(); | ||
} | ||
|
||
DeclarationSourceView::~DeclarationSourceView() | ||
{ | ||
_declChangedConn.disconnect(); | ||
} | ||
|
||
void DeclarationSourceView::setDeclaration(const decl::IDeclaration::Ptr& decl) | ||
{ | ||
_declChangedConn.disconnect(); | ||
|
||
_decl = decl; | ||
|
||
if (_decl) | ||
{ | ||
_declChangedConn = _decl->signal_DeclarationChanged().connect( | ||
sigc::mem_fun(*this, &DeclarationSourceView::update) | ||
); | ||
} | ||
|
||
updateSourceView(); | ||
update(); | ||
updateTitle(); | ||
} | ||
|
||
void DeclarationSourceView::setDeclaration(decl::Type type, const std::string& declName) | ||
{ | ||
setDeclaration(GlobalDeclarationManager().findDeclaration(type, declName)); | ||
} | ||
|
||
bool DeclarationSourceView::isEmpty() const | ||
{ | ||
return !_decl; | ||
} | ||
|
||
std::string DeclarationSourceView::getDeclName() | ||
{ | ||
return _decl ? _decl->getDeclName() : ""; | ||
} | ||
|
||
std::string DeclarationSourceView::getDeclFileName() | ||
{ | ||
return _decl ? _decl->getDeclFilePath() : ""; | ||
} | ||
|
||
std::string DeclarationSourceView::getDefinition() | ||
{ | ||
return _decl ? _decl->getBlockSyntax().contents : ""; | ||
} | ||
|
||
void DeclarationSourceView::updateTitle() | ||
{ | ||
SetTitle(fmt::format(_("Declaration Source: {0}"), !isEmpty() ? _decl->getDeclName() : "")); | ||
} | ||
|
||
void DeclarationSourceView::updateSourceView() | ||
{ | ||
auto newType = _decl ? _decl->getDeclType() : decl::Type::None; | ||
|
||
if (newType == _activeSourceViewType) return; | ||
|
||
_activeSourceViewType = newType; | ||
|
||
// Pick the correct source view control based on the active type | ||
switch (newType) | ||
{ | ||
case decl::Type::SoundShader: | ||
setSourceView(new D3SoundShaderSourceViewCtrl(getMainPanel())); | ||
break; | ||
case decl::Type::Material: | ||
setSourceView(new D3MaterialSourceViewCtrl(getMainPanel())); | ||
break; | ||
case decl::Type::Particle: | ||
setSourceView(new D3ParticleSourceViewCtrl(getMainPanel())); | ||
break; | ||
case decl::Type::ModelDef: | ||
setSourceView(new D3ModelDefSourceViewCtrl(getMainPanel())); | ||
break; | ||
default: | ||
setSourceView(new D3DeclarationViewCtrl(getMainPanel())); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters