Layer color labels in the timeline
ClosedPublic

Authored by WhaleKit on Jan 8 2017, 4:50 PM.

Details

Summary

Color labels shown in timeline.
TimelineFramesModel can now tell index of layer's color label.

Diff Detail

Repository
R37 Krita
Lint
Lint Skipped
Unit
Unit Tests Skipped
WhaleKit updated this revision to Diff 9866.Jan 8 2017, 4:50 PM
WhaleKit retitled this revision from to Layer color labels in the timeline.
WhaleKit updated this object.
WhaleKit edited the test plan for this revision. (Show Details)
WhaleKit added a reviewer: dkazakov.
WhaleKit set the repository for this revision to R37 Krita.
dkazakov requested changes to this revision.Jan 9 2017, 9:54 AM
dkazakov edited edge metadata.

Hi, @WhaleKit!

There is still a problem with painting the selection border over the colored item. A 1px colored line leaks through the selection border :) And I'm not sure if it is Linux specific bug, because your screenshots don't include a selected colored item :)

This revision now requires changes to proceed.Jan 9 2017, 9:54 AM

Codewise, the patch looks perfectly fine, except of a small Windows/Linux filenaming issue, which can be fixed with this small patch:

1diff --git a/plugins/dockers/animation/timeline_layers_header.cpp b/plugins/dockers/animation/timeline_layers_header.cpp
2index b596065..2be2722 100644
3--- a/plugins/dockers/animation/timeline_layers_header.cpp
4+++ b/plugins/dockers/animation/timeline_layers_header.cpp
5@@ -23,8 +23,8 @@
6 #include <QPainter>
7 #include <QHelpEvent>
8 #include <QToolTip>
9-#include <Qstring>
10-#include <Qstyle>
11+#include <QString>
12+#include <QStyle>
13 #include <QStyleOptionFrame>
14
15 #include "timeline_frames_model.h"

WhaleKit updated this revision to Diff 9932.Jan 9 2017, 4:48 PM
WhaleKit edited edge metadata.

Hi, @dkazakov!
Thank you for pointing at this flaw! It could be seen on windows too. Now, I believe I fixed it

.

Hi, @WhaleKit!

There is still a problem with painting the selection border over the colored item. A 1px colored line leaks through the selection border :) And I'm not sure if it is Linux specific bug, because your screenshots don't include a selected colored item :)

WhaleKit updated this revision to Diff 10075.Jan 11 2017, 8:16 PM
WhaleKit edited edge metadata.
WhaleKit updated this revision to Diff 10076.Jan 11 2017, 8:46 PM

Hi, @WhaleKit!

I have tested the patch. It looks nice, the bottom line is still a bit colored, but yes, as you said, we probably cannot do much about it without rewriting the drawControl(QStyle::CE_Header,...) entirely. One thing I found is that we can probably avoid forking of the QStyle by just returning a different background color from the model. Could you check this small hacky patch on Windows (on the top of your patch)?

A far as I can tell, returning a different color does the same thing as forking of paintSection(). At least here on Linux. If it works fine on Windows as well, I guess we should better stick to this approach and forget about that colored line that is still painted at the bottom :)

1diff --git a/plugins/dockers/animation/timeline_frames_model.cpp b/plugins/dockers/animation/timeline_frames_model.cpp
2index cf2d525..7e8adff 100644
3--- a/plugins/dockers/animation/timeline_frames_model.cpp
4+++ b/plugins/dockers/animation/timeline_frames_model.cpp
5@@ -377,6 +377,10 @@ bool TimelineFramesModel::setData(const QModelIndex &index, const QVariant &valu
6 return ModelWithExternalNotifications::setData(index, value, role);
7 }
8
9+#include "kis_node_view_color_scheme.h"
10+#include "krita_utils.h"
11+#include <QApplication>
12+
13 QVariant TimelineFramesModel::headerData(int section, Qt::Orientation orientation, int role) const
14 {
15 if(!m_d->dummiesFacade) return QVariant();
16@@ -438,6 +442,16 @@ QVariant TimelineFramesModel::headerData(int section, Qt::Orientation orientatio
17 int label = m_d->layerColorLabel(section);
18 return label > 0 ? label : QVariant();
19 }
20+ case Qt::BackgroundRole: {
21+ int label = m_d->layerColorLabel(section);
22+ if (label > 0) {
23+ KisNodeViewColorScheme scm;
24+ QColor color = scm.colorLabel(label);
25+ QPalette pal = qApp->palette();
26+ color = KritaUtils::blendColors(color, pal.color(QPalette::Button), 0.3);
27+ return QBrush(color);
28+ }
29+ }
30 }
31 }
32
33diff --git a/plugins/dockers/animation/timeline_layers_header.cpp b/plugins/dockers/animation/timeline_layers_header.cpp
34index 7c9b692..7861315 100644
35--- a/plugins/dockers/animation/timeline_layers_header.cpp
36+++ b/plugins/dockers/animation/timeline_layers_header.cpp
37@@ -146,7 +146,7 @@ void TimelineLayersHeader::paintSection(QPainter *painter, const QRect &rect, in
38 QColor color = scm.colorLabel(colorIndex);
39 QPalette plt = QWidget::palette();
40
41- if (color.alpha()>0){
42+ if (0 && color.alpha()>0){
43 QPalette::ColorRole rolesToChange[] = {QPalette::Light,QPalette::Midlight ,QPalette::Button,
44 QPalette::Dark ,QPalette::Mid};
45 QColor oldColor, newcolor;
46@@ -159,7 +159,8 @@ void TimelineLayersHeader::paintSection(QPainter *painter, const QRect &rect, in
47
48 }
49 painter->save();
50- paintSectionWithCustomPalette(painter, rect, logicalIndex, plt);
51+ QHeaderView::paintSection(painter, rect, logicalIndex);
52+ //paintSectionWithCustomPalette(painter, rect, logicalIndex, plt);
53 painter->restore();
54
55 bool isLayerActive = model()->headerData(logicalIndex, orientation(), TimelineFramesModel::ActiveLayerRole).toBool();

WhaleKit updated this revision to Diff 10563.Jan 25 2017, 6:04 PM

@dkazakov This approach using BackgroundRole is way more neat and works as well (on win8.1 at least). So, yeah, we totally should use it.

This revision was automatically updated to reflect the committed changes.