Add ability to change thumbnail size on layers docker

Authored by scottpetrovic on Aug 16 2018, 3:36 AM.


Group Reviewers

I am in the process of updating my book. When explaining some of the concepts with how layers interact with things like inherit alpha, it is harder to show what is going on with how small the layer thumbnails are.

This patch adds a slider to the layers docker by opacity that allows people to change the thumbnail size.

I also added a compressor to is so it doesn't update too often.

I struggled a bit for a good way to for the layout to refresh. I got something working with resizing that does the layout update, but maybe there is a better way to do it.

The setting also saves to the kritarc using the normal KisConfig path

Test Plan

Create new document

used the slider on the layers docker to resize thumbnails.

Left Krita and came back. the thumbnail size was remembered from my last session.

Diff Detail

R37 Krita
Lint Skipped
Unit Tests Skipped
scottpetrovic created this revision.Aug 16 2018, 3:36 AM
Restricted Application added a project: Krita. · View Herald TranscriptAug 16 2018, 3:36 AM
scottpetrovic requested review of this revision.Aug 16 2018, 3:36 AM
scottpetrovic edited the summary of this revision. (Show Details)Aug 16 2018, 3:39 AM

Hi, @scottpetrovic!

The patch seem to work fine. Though I cannot understand, what is the line to the right of the slider caption label? Is it intended to be here? It looks a bit weirdly

dkazakov requested changes to this revision.Aug 17 2018, 9:24 AM

The patch looks nice, except of a few minor problem in the code (see comments)


It should be KisConfig cfg(true). You need read-only access only.


Why have you remove 'const' everywhere? Is it just by mistake?


It should be KisConfig cfg(false). Sorry for the weird naming of the parameter. I'm going to refactor that soon.

This revision now requires changes to proceed.Aug 17 2018, 9:24 AM
scottpetrovic added a comment.EditedAug 17 2018, 3:05 PM


I can switch those KisConfig flags.

For removing a lot of the const references...There were a few references that were expecting the thumbnailSize() to be const. Since it is not any longer, I had to update those so they are ok with the thumbnail size being different. I pretty much kept changing them until all my compiler errors disappeared.

For the line by the "Thumbnail Size". That is a section line. That is a convention we used in a few places so I just used it there too. See how the Brush presets options work for reference.

I switched out the arguments for those two KisConfigs

I think the only thing remaining was @dkazakov was going to check out if those const references were still needed at all

dkazakov accepted this revision.Aug 20 2018, 8:06 AM

Hi, @scottpetrovic!

I have simply added const to all the methods and it still compiles fine. I think you had some temporary problem just because of some refactoring happening in the meantime.

Here is the patch I applied:

1diff --git a/libs/ui/kis_node_view_color_scheme.cpp b/libs/ui/kis_node_view_color_scheme.cpp
2index 7f402c1..d4b59af 100644
3--- a/libs/ui/kis_node_view_color_scheme.cpp
4+++ b/libs/ui/kis_node_view_color_scheme.cpp
5@@ -87,7 +87,7 @@ int KisNodeViewColorScheme::visibilityMargin() const
6 }
9-int KisNodeViewColorScheme::thumbnailSize()
10+int KisNodeViewColorScheme::thumbnailSize() const
11 {
12 KisConfig cfg(true);
13 return cfg.layerThumbnailSize(false);
14@@ -130,7 +130,7 @@ int KisNodeViewColorScheme::border() const
15 return 1;
16 }
18-int KisNodeViewColorScheme::rowHeight()
19+int KisNodeViewColorScheme::rowHeight() const
20 {
21 return border() + 2 * thumbnailMargin() + thumbnailSize();
22 }
23@@ -142,14 +142,14 @@ int KisNodeViewColorScheme::visibilityColumnWidth() const
24 border();
25 }
27-int KisNodeViewColorScheme::indentation()
28+int KisNodeViewColorScheme::indentation() const
29 {
30 return
31 2 * thumbnailMargin() + thumbnailSize() +
32 border();
33 }
35-QRect KisNodeViewColorScheme::relThumbnailRect()
36+QRect KisNodeViewColorScheme::relThumbnailRect() const
37 {
38 return QRect(-indentation(),
39 border(),
40@@ -165,7 +165,7 @@ QRect KisNodeViewColorScheme::relDecorationRect() const
41 decorationSize());
42 }
44-QRect KisNodeViewColorScheme::relExpandButtonRect()
45+QRect KisNodeViewColorScheme::relExpandButtonRect() const
46 {
47 const int newY = rowHeight() - decorationMargin() - decorationSize();
48 QRect rc = relDecorationRect();
49diff --git a/libs/ui/kis_node_view_color_scheme.h b/libs/ui/kis_node_view_color_scheme.h
50index c290a89..ef96293 100644
51--- a/libs/ui/kis_node_view_color_scheme.h
52+++ b/libs/ui/kis_node_view_color_scheme.h
53@@ -41,7 +41,7 @@ public:
54 int visibilitySize() const;
55 int visibilityMargin() const;
57- int thumbnailSize();
58+ int thumbnailSize() const;
59 int thumbnailMargin() const;
61 int decorationSize() const;
62@@ -54,13 +54,13 @@ public:
64 int border() const;
66- int rowHeight();
67+ int rowHeight() const;
68 int visibilityColumnWidth() const;
69- int indentation();
70+ int indentation() const;
72- QRect relThumbnailRect();
73+ QRect relThumbnailRect() const;
74 QRect relDecorationRect() const;
75- QRect relExpandButtonRect();
76+ QRect relExpandButtonRect() const;
78 QColor colorLabel(int index) const;
79 QVector<QColor> allColorLabels() const;

Please apply this patch and push! :)

This revision is now accepted and ready to land.Aug 20 2018, 8:06 AM

updated the const references and it still works! thanks dmitry. Pushed it out to master. Update your KisConfig update whenever