[apps/code] Do not display varbox source name if it does not fit

This commit is contained in:
Léa Saviot
2020-04-29 10:16:47 +02:00
committed by Émilie Feral
parent 4fb0a7e467
commit d8cab18eb3
3 changed files with 23 additions and 7 deletions

View File

@@ -41,10 +41,19 @@ KDSize ScriptNodeCell::ScriptNodeView::minimalSizeForOptimalDisplay() const {
return KDSizeZero;
}
return KDSize(
Ion::Display::Width - Metric::PopUpLeftMargin - Metric::PopUpRightMargin,
k_optimalWidth,
m_scriptNode->description() == nullptr ? k_simpleItemHeight : k_complexItemHeight);
}
bool ScriptNodeCell::CanDisplayNameAndSource(int nameLength, const char * source) {
if (source == nullptr) {
return true;
}
assert(nameLength > 0);
const KDFont * font = ScriptNodeView::k_font;
return font->glyphSize().width()*(nameLength + 1) + font->stringSize(source).width() <= ScriptNodeView::k_optimalWidth; // + 1 for the separating space
}
void ScriptNodeCell::setScriptNode(ScriptNode * scriptNode) {
m_scriptNodeView.setScriptNode(scriptNode);
reloadCell();