-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #1127 #1457
Fixes #1127 #1457
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting up this change again! I have some additional comments for you though. :-)
We really need a closed eye icon on the invisible layers. Otherwise you would not even guess that you can click on that empty area to make the layer visible again.
The eye is not centered and way too small on HiDpi screens:
What you could do here is just draw the icon larger depending on the DPI, though of course that won't look very nice either. Use QPaintDevice::devicePixelRatio
to determine an appropriate scale factor. Ideally, we'll have a more detailed icon to use instead for high-resolution screens (I'll be looking at using the new icons done for GIMP).
Finally, we'll eventually need a different solution than overriding the drawCheck
function, because there will be two check states: visible and locked. This doesn't mean we can't use this method for drawing the eye icon for now though.
src/tiled/layervisibilitydelegate.h
Outdated
|
||
protected: | ||
void drawCheck(QPainter *painter, const QStyleOptionViewItem &option, | ||
const QRect &rect, Qt::CheckState state) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark this virtual function override with the C++11 override
keyword.
@bjorn, the image is not exactly visible. Can you update the link? And I'll try to make the changes requested :) |
Hmm, the image is uploaded to GitHub and is displaying fine for me. What do you mean with "not exactly visible"? |
It's now visible, I don't know it wasn't visible to me few hours back. |
@bjorn 've marked the function with the |
And instead of drawing a larger icon, won't it be alright if we could just shift the origin of the icon a bit down? That'll look pretty good and won't seem odd. |
Yes, centering the icon will be fine for now as well, though it'll need to be scaled properly before the next release. But I can do this later. Can you look into also using this eye icon in the Objects view? It also features checkboxes to toggle visibility. |
src/tiled/layervisibilitydelegate.h
Outdated
const QRect &rect, Qt::CheckState state) const override; | ||
|
||
private: | ||
QPixmap visiblePixmap, invisiblePixmap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use:
QPixmap mVisiblePixmap;
QPixmap mInvisiblePixmap;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry about that, I totally forgot!
Okay, I'll make the changes 👍 |
I've added the eye icon in object dock as well. I'll try to fix the origin thing, but I'm not sure how to reproduce it so it'll take some time. Apart from this, is everything else fine? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some final (I hope) comments on the code. :-)
src/tiled/eyevisibilitydelegate.cpp
Outdated
*/ | ||
|
||
#include "layerdock.h" | ||
#include "eyevisibilitydelegate.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention, but a cpp file should always include its own header first. This is mainly to make sure all headers include their own dependencies.
src/tiled/eyevisibilitydelegate.cpp
Outdated
{ | ||
Q_UNUSED(option) | ||
if (state == Qt::Checked) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coding style: Please don't use {
and }
for single-line bodies (also for multi-line bodies, they should not be on their own line, except for functions).
src/tiled/eyevisibilitydelegate.h
Outdated
class QAbstractProxyModel; | ||
class QLabel; | ||
class QModelIndex; | ||
class QUndoStack; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean up the includes and forward declarations. You do not need mapdocument.h
, QDockWidget
, etc.
@bjorn can you look into the icon problem now? I think changing the size of icon from |
I'll give the patch another try in the evening. Sorry to be nitpicking, but I think you can also remove includes for |
If it's a learning experience for me, then it's not nitpicking 😄 |
@bjorn did you take a look into the patch? |
Sorry, a lot of things came up yesterday evening, I'll try it again this evening! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screenshot on my machine at 96 DPI shows two problems:
-
The icon is cut off, because by default the space available for the check is only 14x14px (see
qfusionstyle.cpp
line 3133 (values forPM_IndicatorWidth
andPM_IndicatorHeight
end up as the size of the rectangle passed intodrawCheck
). -
The icon is barely visible for selected rows. I like the new icon (did you do it yourself?), but I think the eye does need the white part to be opaque (or the color of the icon should follow the text color).
I think also it would be nice if for the invisible layers, the eye icon was faded out a little (not the red line). I wonder if we can have the line in black then, since red is not going to work nicely in combination with a red selection color.
See also my inline comments.
src/tiled/eyevisibilitydelegate.cpp
Outdated
* Copyright 2008-2017, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | ||
* Copyright 2010, Andrew G. Crowell <overkill9999@gmail.com> | ||
* Copyright 2010, Jeff Bland <jksb@member.fsf.org> | ||
* Copyright 2011, Stefan Beller <stefanbeller@googlemail.com> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a clean list of authors here, this list makes no sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/tiled/eyevisibilitydelegate.h
Outdated
/* | ||
* eyevisibilitydelegate.h | ||
* Copyright 2008-2013, Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | ||
* Copyright 2010, Andrew G. Crowell <overkill9999@gmail.com> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix list of authors here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/tiled/eyevisibilitydelegate.cpp
Outdated
if (state == Qt::Checked) | ||
painter->drawPixmap(rect, mVisiblePixmap, QRect(0, 0, rect.width(), rect.height())); | ||
else if (state == Qt::Unchecked) | ||
painter->drawPixmap(rect, mInvisiblePixmap, QRect(0, 0, rect.width(), rect.height())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For drawPixmap
, the second rectangle you pass in is the source rectangle. This has nothing to do with rect
and should always just be the full image (which means you can just remove it, and rely on the drawImage
overload the only specifies the target rectangle instead). The icon should automatically render larger at a higher DPI then, and it would also fix this "cut off" problem, meaning that you can probably keep the 16x16px icon you have now (though it may look blurry when drawn scaled to 14x14px).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that was a stupid mistake :/
src/tiled/tiled.pro
Outdated
@@ -236,7 +236,8 @@ SOURCES += aboutdialog.cpp \ | |||
utils.cpp \ | |||
varianteditorfactory.cpp \ | |||
variantpropertymanager.cpp \ | |||
zoomable.cpp | |||
zoomable.cpp \ | |||
eyevisibilitydelegate.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this list of files sorted alphabetically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I took the icon from the Noun Project, they've a great bunch of icons! I didn't realise my mistake in |
Alright, I've merged this, but I did spend some time looking for an alternative icon because I wasn't very happy with this one. Eventually I went with the Tango icon used by Inkscape. I also added a higher resolution one, because a 14x14px scaled one didn't look so great on my screen. See change 6db4285. Thanks for your efforts! |
The icon looks better, and I didn't know about |
I've added the eye feature as mentioned in #1127
I took reference from what @IMMZ had previously done and fixed some additional requests that @bjorn made. I've attached a screenshot of what I've done and the eye is symmetric vertically.