mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Add parentheses after function names in Var.
Change-Id: I7e3e993d07139c40c6bd59fd5879b3ee091f5127
This commit is contained in:
69
apps/code/script_node_cell.cpp
Normal file
69
apps/code/script_node_cell.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "script_node_cell.h"
|
||||
#include <kandinsky/point.h>
|
||||
#include <escher/metric.h>
|
||||
|
||||
namespace Code {
|
||||
|
||||
constexpr char ScriptNodeCell::k_parentheses[];
|
||||
|
||||
ScriptNodeCell::ScriptNodeView::ScriptNodeView() :
|
||||
HighlightCell(),
|
||||
m_scriptNode(nullptr),
|
||||
m_scriptStore(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ScriptNodeCell::ScriptNodeView::setScriptNode(ScriptNode * scriptNode) {
|
||||
m_scriptNode = scriptNode;
|
||||
}
|
||||
|
||||
void ScriptNodeCell::ScriptNodeView::setScriptStore(ScriptStore * scriptStore) {
|
||||
m_scriptStore = scriptStore;
|
||||
}
|
||||
|
||||
void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->drawString(m_scriptNode->name(), KDPoint(0, Metric::TableCellLabelTopMargin), k_fontSize, KDColorBlack, isHighlighted()? Palette::Select : KDColorWhite);
|
||||
KDSize nameSize = KDText::stringSize(m_scriptNode->name(), k_fontSize);
|
||||
if (m_scriptNode->type() == ScriptNode::Type::Function) {
|
||||
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), Metric::TableCellLabelTopMargin), k_fontSize, KDColorBlack, isHighlighted()? Palette::Select : KDColorWhite);
|
||||
}
|
||||
ctx->drawString(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), KDPoint(0, Metric::TableCellLabelTopMargin + nameSize.height() + k_verticalMargin), k_fontSize, Palette::GreyDark, isHighlighted()? Palette::Select : KDColorWhite);
|
||||
}
|
||||
|
||||
KDSize ScriptNodeCell::ScriptNodeView::minimalSizeForOptimalDisplay() const {
|
||||
KDSize size1 = KDText::stringSize(m_scriptNode->name(), k_fontSize);
|
||||
KDSize size2 = KDText::stringSize(m_scriptStore->scriptAtIndex(m_scriptNode->scriptIndex()).name(), k_fontSize);
|
||||
KDSize size3 = KDSizeZero;
|
||||
if (m_scriptNode->type() == ScriptNode::Type::Function) {
|
||||
size3 = KDText::stringSize(ScriptNodeCell::k_parentheses, k_fontSize);
|
||||
}
|
||||
return KDSize(size1.width() + size3.width() > size2.width() ? size1.width() + size3.width() : size2.width(), Metric::TableCellLabelTopMargin + size1.width() + k_verticalMargin + size2.width());
|
||||
}
|
||||
|
||||
ScriptNodeCell::ScriptNodeCell() :
|
||||
TableCell(),
|
||||
m_scriptNodeView()
|
||||
{
|
||||
}
|
||||
|
||||
void ScriptNodeCell::setScriptNode(ScriptNode * scriptNode) {
|
||||
m_scriptNodeView.setScriptNode(scriptNode);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void ScriptNodeCell::setScriptStore(ScriptStore * scriptStore) {
|
||||
m_scriptNodeView.setScriptStore(scriptStore);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void ScriptNodeCell::setHighlighted(bool highlight) {
|
||||
TableCell::setHighlighted(highlight);
|
||||
m_scriptNodeView.setHighlighted(highlight);
|
||||
}
|
||||
|
||||
void ScriptNodeCell::reloadCell() {
|
||||
layoutSubviews();
|
||||
HighlightCell::reloadCell();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user