All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Yordan Karadzhov <ykaradzhov@vmware.com>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH v2 02/23] kernel-shark-qt: Add Dual Marker for KernelShark GUI.
Date: Fri, 19 Oct 2018 10:41:09 +0300	[thread overview]
Message-ID: <6f403643-8a97-5dd8-6da2-72aefba3a98f@gmail.com> (raw)
In-Reply-To: <20181018220305.5036eedf@vmware.local.home>



On 19.10.2018 05:03, Steven Rostedt wrote:
> On Tue, 16 Oct 2018 15:52:58 +0000
> Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
> 
>> +
>> +/** @brief Create a Dual Marker State Machine. */
>> +KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
>> +: QWidget(parent),
>> +  _buttonA("Marker A", this),
>> +  _buttonB("Marker B", this),
>> +  _labelDeltaDescr("    A,B Delta: ", this),
>> +  _markA(DualMarkerState::A, Qt::darkGreen),
>> +  _markB(DualMarkerState::B, Qt::darkCyan),
>> +  _scCtrlA(this),
>> +  _scCtrlB(this)
>> +{
>> +	QString styleSheetA, styleSheetB;
>> +
>> +	_buttonA.setFixedWidth(STRING_WIDTH(" Marker A "));
>> +	_buttonB.setFixedWidth(STRING_WIDTH(" Marker B "));
>> +
>> +	for (auto const &l: {&_labelMA, &_labelMB, &_labelDelta}) {
>> +		l->setFrameStyle(QFrame::Panel | QFrame::Sunken);
>> +		l->setStyleSheet("QLabel {background-color : white;}");
>> +		l->setTextInteractionFlags(Qt::TextSelectableByMouse);
>> +		l->setFixedWidth(FONT_WIDTH * 16);
> 
> As a general rule, no "magic numbers". Why 16?
> 

> 
> Don't resend this patch (I'm going to just take it). Send a patch on
> top that just replaces the hard coded numbers with meaningful macros.
> 

Hi Steven,

This is one of these cases when I disagree with you.
I don't see anything wrong with the line

l->setFixedWidth(FONT_WIDTH * 16);

or the many other lines in the code which are similar to this one.
It sets the width of the label to be 16 times the width of a typical 
character shown by Qt at the particular resolution of your screen.
The line is perfectly self-explanatory. And there is nothing magic in 
the number 16. It is just a normal number that everyone can understand 
end modify if this is necessary. Why 16? Because I tried different sizes 
and I found that this particular one looks nicer to me. If you find this 
size ugly, it is absolutist trivial to change it.

Now let's look in the alternative that you suggest (if I understand 
correctly):

l->setFixedWidth(DUAL_MARKER_TOOLBAR_LABEL_WIDTH);

This line is a magic word, because it tells you absolutist nothing about 
the actual size of this label. And if we apply this rule everywhere, we 
will need a ton of macros, with very long and in the same time very 
similar names. This will also make the geometry of the GUI completely 
hard-coded and will eliminate any possibility of making these sizes 
configurable via the Json I/O.

I do not believe in "general rules". Each rule has a field of 
applicability. When you program GUIs you need to apply fine tuning. I 
don't think we can avoid this.
Thanks!

Yordan

> Thanks!
> 
> -- Steve
> 

  reply	other threads:[~2018-10-19 15:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 15:52 [PATCH v2 00/23] Add Qt-based GUI for KernelShark Yordan Karadzhov
2018-10-16 15:52 ` [PATCH v2 01/23] kernel-shark-qt: Fix a simple bug in KsDataStore::_freeData() Yordan Karadzhov
2018-10-16 15:52 ` [PATCH v2 02/23] kernel-shark-qt: Add Dual Marker for KernelShark GUI Yordan Karadzhov
2018-10-19  2:03   ` Steven Rostedt
2018-10-19  7:41     ` Yordan Karadzhov (VMware) [this message]
2018-10-19  2:05   ` Steven Rostedt
2018-10-16 15:52 ` [PATCH v2 03/23] kernel-shark-qt: Add model for showing trace data in a text format Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 04/23] kernel-shark-qt: Add Trace Viewer widget Yordan Karadzhov
2018-10-19  2:20   ` Steven Rostedt
2018-10-19  2:24   ` Steven Rostedt
2018-10-16 15:53 ` [PATCH v2 05/23] kernel-shark-qt: Add visualization (graph) model Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 06/23] kernel-shark-qt: Add widget for OpenGL rendering Yordan Karadzhov
2018-10-19  2:33   ` Steven Rostedt
2018-10-16 15:53 ` [PATCH v2 07/23] kernel-shark-qt: Add Trace Graph widget Yordan Karadzhov
2018-10-19  2:38   ` Steven Rostedt
2018-10-16 15:53 ` [PATCH v2 08/23] kernel-shark-qt: Add dialog for Advanced filtering Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 09/23] kernel-shark-qt: Add a manager class for GUI sessions Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 10/23] kernel-shark-qt: Add Main Window widget for the KernelShark GUI Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 11/23] kernel-shark-qt: Add KernelShark GUI executable Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 12/23] kernel-shark-qt: Add "File exists" dialog Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 13/23] kernel-shark-qt: Fix the glitches in the preemption time visualization Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 14/23] kernel-shark-qt: Add dialog for of trace data recording Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 15/23] kernel-shark-qt: Add kshark-record executable Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 16/23] kernel-shark-qt: Instruct CMake to search for "pkexec" Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 17/23] kernel-shark-qt: Add PolicyKit Configuration for kshark-record Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 19/23] kernel-shark-qt: Add kernelshark.desktop file Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 20/23] kernel-shark-qt: Add make install Yordan Karadzhov
2018-10-19 15:52   ` Steven Rostedt
2018-10-19 17:13     ` [PATCH v3] " Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 21/23] kernel-shark-qt: Add Record dialog to KS GUI Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 22/23] kernel-shark-qt: Workaround for running as Root on Wayland Yordan Karadzhov
2018-10-16 15:53 ` [PATCH v2 23/23] kernel-shark-qt: Version 0.9.0 Yordan Karadzhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f403643-8a97-5dd8-6da2-72aefba3a98f@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=ykaradzhov@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.