Change byte display gradient in Hex Edit#328
Change byte display gradient in Hex Edit#328janczer wants to merge 6 commits intocodilime:masterfrom
Conversation
mkow
left a comment
There was a problem hiding this comment.
- This gradient has very poor readability on my monitor. IMO it would be better to lighten the color for high byte values (looking from dark theme perspective). If you want you can create two totally separate gradient scales for both themes, our
colorInvertedIfDark()don't give good results here. - Default color for the dark theme should be more greenish (green is much more readable on dark background than blue).
- Current scale is much too flat: 00 is not too different than FF.
The effect which I'd like to achieve is the same text readability (including contrast with background) than we currently have, but at the same time the hex view should allow easier spotting of structures and patterns in the bytes. For example, see this comparison between Veles (left) and Hexplorer (right): (click to enlarge)
Our current color scheme is much prettier than the one in Hexplorer, but it's harder to see patterns in it (because, for example, 00 is brighter than 50 in current scale). The scheme in Hexplorer isn't perfect, so you don't have to use exactly the same scale as they use ;) Just play a bit with different settings and try to find something good.
| void accept() override; | ||
|
|
||
| private: | ||
| QColorDialog* color_dialog; |
There was a problem hiding this comment.
Should be color_dialog_ (see https://google.github.io/styleguide/cppguide.html#Variable_Names).
include/util/settings/hexedit.h
Outdated
| bool resizeColumnsToWindowWidth(); | ||
| void setResizeColumnsToWindowWidth(bool on); | ||
| QColor colorOfText(); | ||
| void setColorOfText(QColor color); |
There was a problem hiding this comment.
This name is IMO misleading, it's not a color of a text in a hex view (e.g. it doesn't change the color of addresses). Maybe something like ColorOfBytes or ColorOfByteValues would be better?
There was a problem hiding this comment.
color should be passed by const ref: setColorOfText(const QColor& color)
There was a problem hiding this comment.
I changed it to colorOfBytes and setColorOfBytes.
| * | ||
| */ | ||
| #include "include/ui/optionsdialog.h" | ||
| #include <QColorDialog> |
There was a problem hiding this comment.
Please add a newline before QColorDialog (see https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes).
src/ui/optionsdialog.cc
Outdated
|
|
||
| connect(ui->colorHexEdit, &QPushButton::clicked, color_dialog, | ||
| &QColorDialog::show); | ||
|
|
src/ui/optionsdialog.cc
Outdated
|
|
||
| connect(color_dialog, &QColorDialog::colorSelected, this, | ||
| &OptionsDialog::updateColorButton); | ||
|
|
src/ui/optionsdialog.ui
Outdated
| <item> | ||
| <widget class="QLabel" name="labelHexEditWidgetColors"> | ||
| <property name="text"> | ||
| <string>Color</string> |
There was a problem hiding this comment.
This should be placed under "HexEdit" group in options dialog. When doing this, please change "HexEdit defaults" to "HexEdit" and "Columns" to "Default columns".
There was a problem hiding this comment.
Also: "Color" -> "Byte color"
src/ui/optionsdialog.ui
Outdated
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QPushButton" name="colorHexEdit"> |
There was a problem hiding this comment.
colorHexEdit -> byteColorHexEdit
| * | ||
| */ | ||
| #include "util/settings/hexedit.h" | ||
| #include <QColor> |
src/util/settings/hexedit.cc
Outdated
|
|
||
| QColor colorOfText() { | ||
| QSettings settings; | ||
| auto v = settings.value("hexedit.colorOfText", QColor(10, 10, 255)); |
There was a problem hiding this comment.
I changed it. Also I changed how it's store in settings. I changed from QColor to QRgb. I'm not sure if it's ok. Maybe will be better store it like separate red, green and blue channels?
There was a problem hiding this comment.
I think it's better to store it as QColor. Are there any pros of using QRgb?
There was a problem hiding this comment.
More pretty Veles.conf:
Stored QRgb:
hexedit.colorOfBytes=4278190592
and stored QColor:
hexedit.colorOfBytes=@Variant(\0\0\0\x43\x1\xff\xff\x87\x87\x62\x62\xff\xff\0\0)
There was a problem hiding this comment.
I'd prefer the previous version (without QRgb). colorOfBytes=4278190592 is still not too readable nor useful for users. They are also not expected to change config files manually. QColor(10, 10, 255) is much more readable in the code: you see separate values for each of RGB channels and you can easily change each of them.
src/util/settings/theme.cc
Outdated
|
|
||
| return colorInvertedIfDark(QColor(red, green, blue)); | ||
| QColor color = util::settings::hexedit::colorOfText(); | ||
| color.setAlpha(byte / 2 + 127); |
There was a problem hiding this comment.
Please don't use setAlpha - we don't want to blend it with the color of the background (which is not always dark/white). IMO we should use a constant color gradient (independent of the background), the current version is hard to read when there are some chunks added (they change byte background).
Just decide on the gradient parameters and calculate the color ;) Doing this should be quite easy using getHsv/setHsv methods (or getHsl/setHsl). Or just use QColor::lighter / QColor::darker which does the same.
There was a problem hiding this comment.
I'm still working on this.
There was a problem hiding this comment.
Ok, I'll wait for the rest and then do next review iteration
There was a problem hiding this comment.
I changed setAlpha to QColor::darker it's allow choose color with max brightness.
|
Fixes #325. |
src/util/settings/theme.cc
Outdated
|
|
||
| return colorInvertedIfDark(QColor(red, green, blue)); | ||
| QColor color = util::settings::hexedit::colorOfBytes(); | ||
| return color.darker(100 + (byte ^ 0xFF) * 200 / 255); |
There was a problem hiding this comment.
It may not be obvious for a reader that byte ^ 0xFF preserves correct ordering of the values, IMO 0x100 - byte is more readable.
|
I was playing with representation color of bytes and @mkow proposed use I'm not sure what option choose. |
f16b1bd to
fddeba0
Compare
…dering of the values
fddeba0 to
4de9994
Compare
|
I did some more experiments and it seems that:
Some technical remarks:
|
|
Also: the third scheme suggested by @janczer also looks well on the black background with disabled anti-aliasing. |






Also I added color picker to option. #255
This change is