Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5532: New ExpressionBinding class to help with expression display.
- Loading branch information
1 parent
c74c397
commit df45115
Showing
6 changed files
with
49 additions
and
24 deletions.
There are no files selected for viewing
File renamed without changes.
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,36 @@ | ||
#pragma once | ||
|
||
#include "Binding.h" | ||
#include "ishaderexpression.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
template<typename Source> | ||
class ExpressionBinding : | ||
public Binding<Source> | ||
{ | ||
private: | ||
wxTextCtrl* _textCtrl; | ||
std::function<shaders::IShaderExpressionPtr(const Source&)> _getExpression; | ||
|
||
public: | ||
ExpressionBinding(wxTextCtrl* textCtrl, const std::function<shaders::IShaderExpressionPtr(const Source&)> loadFunc) : | ||
_textCtrl(textCtrl), | ||
_getExpression(loadFunc) | ||
{} | ||
|
||
virtual void updateFromSource(const Source& source) override | ||
{ | ||
if (!source) | ||
{ | ||
_textCtrl->SetValue(""); | ||
return; | ||
} | ||
|
||
auto expression = _getExpression(source); | ||
_textCtrl->SetValue(expression ? expression->getExpressionString() : ""); | ||
} | ||
}; | ||
|
||
} |
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