-
Notifications
You must be signed in to change notification settings - Fork 119
Change byte display gradient in Hex Edit #328
base: master
Are you sure you want to change the base?
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.
- 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.
include/ui/optionsdialog.h
Outdated
|
||
public slots: | ||
void accept() override; | ||
|
||
private: | ||
QColorDialog* color_dialog; |
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.
Should be color_dialog_
(see https://google.github.io/styleguide/cppguide.html#Variable_Names).
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.
Fixed it.
include/util/settings/hexedit.h
Outdated
@@ -25,6 +27,8 @@ int columnsNumber(); | |||
void setColumnsNumber(int number); | |||
bool resizeColumnsToWindowWidth(); | |||
void setResizeColumnsToWindowWidth(bool on); | |||
QColor colorOfText(); | |||
void setColorOfText(QColor color); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color
should be passed by const ref: setColorOfText(const QColor& color)
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 changed it to colorOfBytes
and setColorOfBytes
.
src/ui/optionsdialog.cc
Outdated
@@ -15,6 +15,8 @@ | |||
* | |||
*/ | |||
#include "include/ui/optionsdialog.h" | |||
#include <QColorDialog> |
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 add a newline before QColorDialog (see https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes).
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.
Fixed it.
src/ui/optionsdialog.cc
Outdated
|
||
connect(ui->colorHexEdit, &QPushButton::clicked, color_dialog, | ||
&QColorDialog::show); | ||
|
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.
remove this empty line
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.
Fixed it.
src/ui/optionsdialog.cc
Outdated
|
||
connect(color_dialog, &QColorDialog::colorSelected, this, | ||
&OptionsDialog::updateColorButton); | ||
|
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.
ditto
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.
Fixed it.
src/ui/optionsdialog.ui
Outdated
<item> | ||
<widget class="QLabel" name="labelHexEditWidgetColors"> | ||
<property name="text"> | ||
<string>Color</string> |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: "Color" -> "Byte color"
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 changed it.
src/ui/optionsdialog.ui
Outdated
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="colorHexEdit"> |
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.
colorHexEdit
-> byteColorHexEdit
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 changed it.
src/util/settings/hexedit.cc
Outdated
@@ -15,6 +15,7 @@ | |||
* | |||
*/ | |||
#include "util/settings/hexedit.h" | |||
#include <QColor> |
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.
newline before QColor
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.
Fixed it.
src/util/settings/hexedit.cc
Outdated
@@ -42,6 +43,17 @@ void setResizeColumnsToWindowWidth(bool on) { | |||
settings.setValue("hexedit.resizeColumnsToWindowWidth", on); | |||
} | |||
|
|||
QColor colorOfText() { | |||
QSettings settings; | |||
auto v = settings.value("hexedit.colorOfText", QColor(10, 10, 255)); |
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.
colorOfText
-> colorOfBytes
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to store it as QColor. Are there any pros of using QRgb?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still working on this.
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.
Ok, I'll wait for the rest and then do next review iteration
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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