ui: Added second line marker color to better highlight hovered and local symbols

This commit is contained in:
Eberhard Graether
2017-09-06 16:16:39 +02:00
parent d86adce7ea
commit a9ca7f1223
6 changed files with 75 additions and 32 deletions
+4 -1
View File
@@ -111,7 +111,10 @@
<text>#D4D4D4</text>
<inactive_text>#A0A0A0</inactive_text>
<background>#494949</background>
<marker>#D4D4D4</marker>
<marker>
<active>#807F80</active>
<focus>#D4D4D4</focus>
</marker>
</line_number>
<syntax>
+5 -2
View File
@@ -7,7 +7,7 @@
<button>
<normal>#D0D0D0</normal>
<hover>#A2A2A2</hover>
<press>#525252</press>
<press>#727272</press>
<disabled>#F2F2F2</disabled>
<icon>white</icon>
<icon_disabled>#CECECE</icon_disabled>
@@ -111,7 +111,10 @@
<text>black</text>
<inactive_text>#A0A0A0</inactive_text>
<background>white</background>
<marker>#A0A0A0</marker>
<marker>
<active>#D0D0D0</active>
<focus>#727272</focus>
</marker>
</line_number>
<syntax>
+4 -1
View File
@@ -111,7 +111,10 @@
<text>#F7F7F7</text>
<inactive_text>#A0A0A0</inactive_text>
<background>#272728</background>
<marker>#969696</marker>
<marker>
<active>#797979</active>
<focus>#F7F7F7</focus>
</marker>
</line_number>
<syntax>
+61 -22
View File
@@ -144,13 +144,66 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event)
int top = static_cast<int>(blockBoundingGeometry(block).translated(contentOffset()).top());
int bottom = top + static_cast<int>(blockBoundingRect(block).height());
std::set<int> activeLineNumbers = getActiveLineNumbers();
std::set<int> activeLineNumbers;
std::set<int> focusedLineNumbers;
std::set<Id> activeSymbolIds = m_navigator->getActiveTokenIds();
for (const Annotation& annotation : m_annotations)
{
bool focus = false;
bool active = false;
switch (annotation.locationType)
{
case LOCATION_LOCAL_SYMBOL:
if (annotation.isActive || annotation.isFocused)
{
focus = true;
}
break;
case LOCATION_TOKEN:
case LOCATION_SCOPE:
if (annotation.isFocused && utility::shareElement(activeSymbolIds, annotation.tokenIds))
{
active = true;
}
default:
if (annotation.isActive)
{
active = true;
}
else if (annotation.isFocused)
{
focus = true;
}
break;
}
if (active || focus)
{
for (int i = annotation.startLine; i <= annotation.endLine; i++)
{
if (active)
{
activeLineNumbers.insert(i);
}
else
{
focusedLineNumbers.insert(i);
}
}
}
}
ColorScheme* scheme = ColorScheme::getInstance().get();
QColor textColor(scheme->getColor("code/snippet/line_number/text").c_str());
QColor inactiveTextColor(scheme->getColor("code/snippet/line_number/inactive_text").c_str());
QColor markerColor(scheme->getColor("code/snippet/line_number/marker").c_str());
QColor activeMarkerColor(scheme->getColor("code/snippet/line_number/marker/active").c_str());
QColor focusedMarkerColor(scheme->getColor("code/snippet/line_number/marker/focus").c_str());
QPen p = painter.pen();
@@ -162,9 +215,13 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event)
p.setColor(textColor);
if (activeLineNumbers.find(number) != activeLineNumbers.end())
if (focusedLineNumbers.find(number) != focusedLineNumbers.end())
{
painter.fillRect(m_lineNumberArea->width() - 8, top, 3, fontMetrics().height() + 1, markerColor);
painter.fillRect(m_lineNumberArea->width() - 8, top, 3, fontMetrics().height() + 1, focusedMarkerColor);
}
else if (activeLineNumbers.find(number) != activeLineNumbers.end())
{
painter.fillRect(m_lineNumberArea->width() - 8, top, 3, fontMetrics().height() + 1, activeMarkerColor);
}
else if (!m_isActiveFile)
{
@@ -561,24 +618,6 @@ void QtCodeArea::annotateText()
}
}
std::set<int> QtCodeArea::getActiveLineNumbers() const
{
std::set<int> activeLineNumbers;
for (const Annotation& annotation : m_annotations)
{
if (annotation.isActive || annotation.isFocused)
{
for (int i = annotation.startLine; i <= annotation.endLine; i++)
{
activeLineNumbers.insert(i);
}
}
}
return activeLineNumbers;
}
void QtCodeArea::createActions()
{
m_setIDECursorPositionAction = new QAction(tr("Set IDE Cursor"), this);
-2
View File
@@ -107,8 +107,6 @@ private:
void annotateText();
std::set<int> getActiveLineNumbers() const;
void createActions();
QtCodeNavigator* m_navigator;
+1 -4
View File
@@ -286,10 +286,7 @@ bool QtCodeField::annotateText(
activeLocationIds.find(annotation.locationId) != activeLocationIds.end()
);
if (!annotation.isActive)
{
annotation.isFocused = utility::shareElement(focusedSymbolIds, annotation.tokenIds);
}
annotation.isFocused = utility::shareElement(focusedSymbolIds, annotation.tokenIds);
if (wasFocused != annotation.isFocused || wasActive != annotation.isActive)
{