[themes] Color with pointers

This commit is contained in:
Laury
2022-02-11 18:41:00 +01:00
parent 84d88a3e8d
commit 63d1e0ee4e
175 changed files with 546 additions and 652 deletions

View File

@@ -40,7 +40,7 @@ ConsoleController::ConsoleController(Responder * parentResponder, App * pythonDe
#endif
{
m_selectableTableView.setMargins(0, Metric::CommonRightMargin, 0, Metric::TitleBarExternHorizontalMargin);
m_selectableTableView.setBackgroundColor(Palette::CodeBackground);
m_selectableTableView.setBackgroundColor(*Palette::CodeBackground);
m_editCell.setPrompt(sStandardPromptText);
for (int i = 0; i < k_numberOfLineCells; i++) {
m_cells[i].setParentResponder(&m_selectableTableView);

View File

@@ -18,8 +18,8 @@ void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::setLine(Consol
}
void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), Palette::CodeBackground);
ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? Palette::Select : Palette::BackgroundApps);
ctx->fillRect(bounds(), *Palette::CodeBackground);
ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? *Palette::Select : *Palette::BackgroundApps);
}
KDSize ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::minimalSizeForOptimalDisplay() const {

View File

@@ -53,7 +53,7 @@ private:
ConsoleLineView m_consoleLineView;
};
static KDColor textColor(ConsoleLine * line) {
return line->isFromCurrentSession() ? Palette::CodeText : Palette::SecondaryText;
return line->isFromCurrentSession() ? *Palette::CodeText : *Palette::SecondaryText;
}
MessageTextView m_promptView;
ScrollableConsoleLineView m_scrollableView;

View File

@@ -57,8 +57,8 @@ void EditorView::layoutSubviews(bool force) {
/* EditorView::GutterView */
void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const {
KDColor textColor = Palette::PrimaryText;
KDColor backgroundColor = Palette::CodeGutterViewBackground;
KDColor textColor = *Palette::PrimaryText;
KDColor backgroundColor = *Palette::CodeGutterViewBackground;
ctx->fillRect(rect, backgroundColor);

View File

@@ -14,22 +14,12 @@ extern "C" {
namespace Code {
constexpr KDColor CommentColor = Palette::CodeComment;
constexpr KDColor NumberColor = Palette::CodeNumber;
constexpr KDColor KeywordColor = Palette::CodeKeyword;
// constexpr KDColor BuiltinColor = KDColor::RGB24(0x0086B3);
constexpr KDColor OperatorColor = Palette::CodeOperator;
constexpr KDColor StringColor = Palette::CodeString;
constexpr KDColor BackgroundColor = Palette::CodeBackground;
constexpr KDColor HighlightColor = Palette::CodeBackgroundSelected;
constexpr KDColor AutocompleteColor = KDColor::RGB24(0xC6C6C6); // TODO Palette change
static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
if (tokenKind == MP_TOKEN_STRING) {
return StringColor;
return *Palette::CodeString;
}
if (tokenKind == MP_TOKEN_INTEGER || tokenKind == MP_TOKEN_FLOAT_OR_IMAG) {
return NumberColor;
return *Palette::CodeNumber;
}
static_assert(MP_TOKEN_ELLIPSIS + 1 == MP_TOKEN_KW_FALSE
&& MP_TOKEN_KW_FALSE + 1 == MP_TOKEN_KW_NONE
@@ -69,7 +59,7 @@ static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
&& MP_TOKEN_KW_YIELD + 1 == MP_TOKEN_OP_TILDE,
"MP_TOKEN order changed, so Code::PythonTextArea::TokenColor might need to change too.");
if (tokenKind >= MP_TOKEN_KW_FALSE && tokenKind <= MP_TOKEN_KW_YIELD) {
return KeywordColor;
return *Palette::CodeKeyword;
}
static_assert(MP_TOKEN_OP_TILDE + 1 == MP_TOKEN_OP_LESS
&& MP_TOKEN_OP_LESS + 1 == MP_TOKEN_OP_MORE
@@ -121,9 +111,9 @@ static inline KDColor TokenColor(mp_token_kind_t tokenKind) {
|| tokenKind == MP_TOKEN_DEL_EQUAL
|| tokenKind == MP_TOKEN_DEL_MINUS_MORE)
{
return OperatorColor;
return *Palette::CodeOperator;
}
return Palette::CodeText;
return *Palette::CodeText;
}
static inline size_t TokenLength(mp_lexer_t * lex, const char * tokenPosition) {
@@ -216,7 +206,7 @@ void PythonTextArea::ContentView::unloadSyntaxHighlighter() {
}
void PythonTextArea::ContentView::clearRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, BackgroundColor);
ctx->fillRect(rect, *Palette::CodeBackground);
}
#define LOG_DRAWING 0
@@ -246,11 +236,11 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
fromColumn,
spacesStart,
std::min(text + byteLength, firstNonSpace) - spacesStart,
StringColor,
BackgroundColor,
*Palette::CodeString,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
if (UTF8Helper::CodePointIs(firstNonSpace, UCodePointNull)) {
return;
@@ -276,17 +266,17 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenEnd),
tokenEnd,
std::min(text + byteLength, tokenFrom) - tokenEnd,
StringColor,
BackgroundColor,
*Palette::CodeString,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
tokenLength = TokenLength(lex, tokenFrom);
tokenEnd = tokenFrom + tokenLength;
// If the token is being autocompleted, use DefaultColor
KDColor color = (tokenFrom <= autocompleteStart && autocompleteStart < tokenEnd) ? Palette::CodeText : TokenColor(lex->tok_kind);
KDColor color = (tokenFrom <= autocompleteStart && autocompleteStart < tokenEnd) ? *Palette::CodeText : TokenColor(lex->tok_kind);
LOG_DRAW("Draw \"%.*s\" for token %d\n", tokenLength, tokenFrom, lex->tok_kind);
drawStringAt(ctx, line,
@@ -294,10 +284,10 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
tokenFrom,
tokenLength,
color,
BackgroundColor,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
mp_lexer_to_next(lex);
LOG_DRAW("Pop token %d\n", lex->tok_kind);
@@ -305,18 +295,18 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
tokenFrom += tokenLength;
// Even if the token is being autocompleted, use CommentColor
// Even if the token is being autocompleted, use *Palette::CodeComment
if (tokenFrom < text + byteLength) {
LOG_DRAW("Draw comment \"%.*s\" from %d\n", byteLength - (tokenFrom - text), firstNonSpace, tokenFrom);
drawStringAt(ctx, line,
UTF8Helper::GlyphOffsetAtCodePoint(text, tokenFrom),
tokenFrom,
text + byteLength - tokenFrom,
CommentColor,
BackgroundColor,
*Palette::CodeComment,
*Palette::CodeBackground,
selectionStart,
selectionEnd,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
mp_lexer_free(lex);
@@ -332,11 +322,11 @@ void PythonTextArea::ContentView::drawLine(KDContext * ctx, int line, const char
UTF8Helper::GlyphOffsetAtCodePoint(text, autocompleteStart),
autocompleteStart,
std::min(text + byteLength, m_autocompletionEnd) - autocompleteStart,
AutocompleteColor,
BackgroundColor,
KDColor::RGB24(0xC6C6C6),
*Palette::CodeBackground,
nullptr,
nullptr,
HighlightColor);
*Palette::CodeBackgroundSelected);
}
}

View File

@@ -9,7 +9,7 @@ namespace Code {
SandboxController::SandboxController(Responder * parentResponder) :
ViewController(parentResponder),
m_solidColorView(Palette::CodeBackground)
m_solidColorView(*Palette::CodeBackground)
{
}

View File

@@ -8,12 +8,12 @@ constexpr char ScriptNodeCell::k_parentheses[];
constexpr char ScriptNodeCell::k_parenthesesWithEmpty[];
void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) const {
const KDColor backgroundColor = isHighlighted()? Palette::CodeBackgroundSelected : Palette::CodeBackground;
const KDColor backgroundColor = isHighlighted()? *Palette::CodeBackgroundSelected : *Palette::CodeBackground;
// If it exists, draw the description name.
const char * descriptionName = m_scriptNode->description();
if (descriptionName != nullptr) {
ctx->drawString(descriptionName, KDPoint(0, m_frame.height() - k_bottomMargin - k_font->glyphSize().height()), k_font, Palette::GrayDark, backgroundColor);
ctx->drawString(descriptionName, KDPoint(0, m_frame.height() - k_bottomMargin - k_font->glyphSize().height()), k_font, *Palette::GrayDark, backgroundColor);
}
// Draw the node name
@@ -21,10 +21,10 @@ void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) cons
const int nodeNameLength = m_scriptNode->nameLength();
KDSize nameSize = k_font->stringSize(nodeName, nodeNameLength);
const KDCoordinate nodeNameY = k_topMargin;
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, Palette::PrimaryText, backgroundColor, nodeNameLength);
ctx->drawString(nodeName, KDPoint(0, nodeNameY), k_font, *Palette::PrimaryText, backgroundColor, nodeNameLength);
// If it is needed, draw the parentheses
if (m_scriptNode->type() == ScriptNode::Type::WithParentheses) {
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, Palette::PrimaryText, backgroundColor);
ctx->drawString(ScriptNodeCell::k_parentheses, KDPoint(nameSize.width(), nodeNameY), k_font, *Palette::PrimaryText, backgroundColor);
}
/* If it exists, draw the source name. If it did not fit, we would have put
@@ -32,7 +32,7 @@ void ScriptNodeCell::ScriptNodeView::drawRect(KDContext * ctx, KDRect rect) cons
const char * sourceName = m_scriptNode->nodeSourceName();
if (sourceName != nullptr) {
KDSize sourceNameSize = k_font->stringSize(sourceName);
ctx->drawString(sourceName, KDPoint(m_frame.width() - sourceNameSize.width(), nodeNameY), k_font, Palette::CodeText, backgroundColor);
ctx->drawString(sourceName, KDPoint(m_frame.width() - sourceNameSize.width(), nodeNameY), k_font, *Palette::CodeText, backgroundColor);
}
}

View File

@@ -100,7 +100,7 @@ void ScriptParameterController::willDisplayCellForIndex(HighlightCell * cell, in
MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)cell;
GetScriptSize(myCell);
myCell->setAccessoryFont(KDFont::SmallFont);
myCell->setAccessoryTextColor(Palette::SecondaryText);
myCell->setAccessoryTextColor(*Palette::SecondaryText);
}
}

View File

@@ -37,9 +37,9 @@ namespace Code {
}
void toolboxIonKeys::toolboxIonView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, Palette::WallScreen);
ctx->strokeRect(rect, Palette::ListCellBorder);
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20),KDFont::LargeFont,Palette::PrimaryText,Palette::WallScreen);
ctx->fillRect(rect, *Palette::WallScreen);
ctx->strokeRect(rect, *Palette::ListCellBorder);
ctx->drawString(I18n::translate(I18n::Message::PressAKey),KDPoint(rect.left()+80, rect.top()+20),KDFont::LargeFont,*Palette::PrimaryText,*Palette::WallScreen);
}

View File

@@ -44,8 +44,8 @@ VariableBoxController::VariableBoxController(ScriptStore * scriptStore) :
m_importedNodesCount(0)
{
for (int i = 0; i < k_scriptOriginsCount; i++) {
m_subtitleCells[i].setBackgroundColor(Palette::WallScreen);
m_subtitleCells[i].setTextColor(Palette::SecondaryText);
m_subtitleCells[i].setBackgroundColor(*Palette::WallScreen);
m_subtitleCells[i].setTextColor(*Palette::SecondaryText);
}
}