Fix a bug that was fixed in b5c8d0dbb4 and reintroduced in
e7907c494f. Here is the original commit message:
The range for a one-bin chart is [-0.5,0.5], thus the range
in an n-bin chart is [-0.5,n-0.5], not [-0.5,n+0.5].
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The code was wrong, because it deleted the ChartItems in the
main UI thread, not the render thread. This would delete the
QSG nodes in the UI thread and then crash on mobile.
Therefore refactor this part of the code by adding the
items to be deleted to a list that will be deleted by the
render thread.
As a drop in replacement of std::unique_ptr, implement
a silly ChartItemPtr class, which auto-initializes to null.
This turns the deterministic and easily controlled memory
management into a steaming pile of insanity. Obviously,
this can be made much more elegant, but this has to do for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These values were used for items on the QGraphicsScene and
have been replaced by integer values used on the QSG scene.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is trivial, since everything is there already:
Replace the QGraphicsSimpleTextItem with a ChartTextItem.
Only few functions have to be renamed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All series are converted to QSG. Thus, the pointer to the
QGraphicsView can be removed from the common base class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since there are no disk-segment QSG primitives (one could draw
a triangle fan, but that doesn't seem optimal), this draws
into a pixmap and blits that as a QSG node.
Since this is the only series without axis, it needs a function
that returns the size of the plot area. This didn't exist, so
add it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The original plan to reuse the ChartPixmapItem for the
scatteritems was dumped, because it is unclear if the
textures are shared if generated for each item.
Instead, a new ChartScatterItem was created, where all
items share the same textures (one for highlighted,
one for non-highlighted). This means that the rendering
of the scatter items is now done in the chartitem.cpp
file, which feels like a layering violation. Not good,
but the easiest for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is lazy: Derive from the bar chart item and add whiskers
in the subclassed render() function. The code is ugly, because
the base class function clears the dirty flags and therefore
the derived class has to remember them. Oh well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To replace the QGraphicsScene, we need the possibility of
showing and hiding items.
Turns out, the QSG API is completely insane.
Whether an item should be shown is queried by the virtual
function isSubtreeBlocked(), which is supposed to be
overriden by the derived classes.
However, the common nodes for rectangles and pixmaps are
supposed to be created by QQuickWindow, for hardware
optimization. This gives nodes that cannot be derived
from and therefore whether the item is shown or not cannot
be controlled.
There are therefore two distinct cases to consider: The
node is allocated by the code directly or indirectly by
QQuickWindow.
In the latter case, we use a proxy node with the only
purpose of having a "visible" flag and add the obtained
node as a child.
This madness is performed with template trickery to get
unified code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To this end, two new ChartItems were added: A "bar" (a rectangle
with a border) and a "text" (multiple lines of text).
It turns out that the text on the bars now looks atrocious.
The reason appears to be that the antialiasing of the font-rendering
does not blend into the alpha channel, but into a supposed
background color? This will have to be investigated.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Render the confidence area and the regression line into a pixmap
and show that using a QSGNode.
It is unclear whether it is preferred to do it this way or to
triangulate the confidence area into triangles to be drawn by
the shader.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
So far the items to be recalculated in the drawing thread
had a "dirty" flag and were kept in one array par z-level.
Once the series are implemented in terms of QSGNodes, there
may lots of these items. To make this more efficient when
only one or two of these items change (e.g. highlighting due
to mouseover), keep the dirty items in a linked list.
Of course, this makes the draw first version of the chart
less efficient.
There are more fancy ways of implementing the double-linked
list, but the few ns gained in the render thread are hardly
worth it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Render the labels and the title into a pixmap and render
the ticks and the base line using individual QSGNodes.
Attempting to render the ticks likewise into the pixmap
gave horrible results, because (quite obviously) rendering
with QPainter and the QSG shader gives non-matching ticks
and grid lines.
The memory management had to be changed a bit: The ChartItems
were collected in the root QSGNode. However, the axes are added
before the first plotting, so this node might not exist.
Therefore, store the axes in the StatsView object.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Turn the background grid into QSGNodes. Each grid line is
represented by a QSG line item. An alternative would be
drawing the grid into a QImage and blasting that onto the
screen. It is unclear which one is preferred.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, the background was drawn as solid color onto
the chart-scene. This is of course incompatible with doing
the grid as QSGNodes. Therefore, make the scene image
transparent and use a QSGRectangle as background color.
We could also simply omit the background and show the
widget's background. However, that would mean setting
the background color in two seperate code paths
(desktop and mobile). I found no way of directly setting
the background of the QQuickItem.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Slowly converting the QGraphicsScene items to QSGNodes to
avoid full replot of the scene.
This adds a new abstraction for line-nodes. Since the render()
function here is fundamentally different from the pixmap-nodes
we had so far, this has to be made virtual.
Also, move the quartile markers to their own source file,
since the StatsView source file is quite huge already.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The position of the legend was reset when resizing. This was
OK as long as the legend wasn't movable.
To avoid resetting the position, store the center position
of the legend relatively to the size of the canvas. On
resize restore the center to the same relative size.
To avoid code duplication, move the sanitizing of the
coordinates from the StatsView to the Legend.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The chart items were drawn in order of creation. To control this,
add a notion of Z-value. In contrast to QGraphicsScene, make
this a small integer value.
To controll order of drawing, a plain QSGNode is created for
every possible Z-Value and items are added to these nodes.
Thus, items are rendered by Z-value and if the Z-value is equal
by order of creation.
Likewise split the list of chart-items into Z-values, so that
items can be quickly unregistered: The items that will be
removed individually will usuall be part of Z-levels with only
few items (e.g. legend, infobox). Z-levels with many items
(notably the series) will always be fully rebuilt.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A small step in converting from QGraphicsScene to QQuickItem.
This is the second item to be converted (after the legend)
and for now items are drawn in order of creation, which means
that the infobox is on top of the legend. This will have
to be made deterministic in follow-up commits.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The series were passed a pointer to the QGraphicsScene to add
their item. In the future these items will be replaced by
QSGNodes. To add these, the series need a reference to the StatsView.
Therefore pass it in the constructor. Once everything is
replaces by QSGNodes, remove the QGraphicsScene member.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Catch mouse move events and move the legend accordingly.
Currently, this is the only item that can be dragged and
therefore there is no need of doing some kind of fancy
interface. Simply keep a pointer to the legend if it is
dragged.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In order not to waste CPU by constantly rerendering the chart,
we must use these weird OpenGL QSGNode things. The interface
is appallingly low-level and unfriendly.
As a first test, try to convert the legend. Create a wrapper
class that represents a rectangular item with a texture
and that will certainly need some (lots of) optimization.
Make sure that all low-level QSG-objects are only accessed
in the rendering thread. This means that the wrapper has
to maintain a notion of "dirtiness" of the state. I.e.
which part of the QSG-objects have to be modified.
From the low-level wrapper derive a class that draws a rounded
rectangle for every resize. The child class of that must then
paint on the rectangle after every resize.
That looks all not very fortunate, but it displays a
legend and will make it possible to move the legend
without and drawing operations, only shifting around
an OpenGL surface.
The render thread goes through all chart-items and
rerenders them if dirty. Currently, on deletion
of these items, this list is not reset. I.e. currently
it is not supported to remove individual items.
Only the full scene can be cleared!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Simply force it to use the default font, which is bound to the
application font, which we SHOULD be updating when changing the regular
font size for the app, anyway.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Sometimes (and it's unclear why that happens) after rotation the stats
widget is blank. Setting the first variable back to itself appears
enough to ensure that the statistics view is redrawn. Try to do that
programatically after a short delay.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The statistics themselves still are in a light theme, but at least the
rest of the UI now works in both regular and dark themes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we have a button on the notification to trigger an action, we need to
make sure there's space for that button.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is fun... with just a tiny bit of 'magic text parsing' we can allow
the backend code to add a button to the notification that will open the
context menu that will make it super obvious to the user how they can
undo an operation.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we save after every operation in the mobile app, this allows us to
tell the user what we actually saved - and we can remind the user that
they can undo/redo the last operation.
The code gets more complicated because in the case that the operation
that triggered this change was an undo, we need to show the redo text to
describe what we are saving, and must point the user to the redo
operation.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This isn't really useful for normal users and with the new 'multiple
notifications stay visible' feature in Kirigami it creates a really
weird and distracting user experience.
We should show the user a summart of what we did instead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In commit 24eac8df87 ("mobile: remove overwriting of line special case
in ui-notification") the code doing the line replacement was removed,
but the comment above that code wasn't updated.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to get the undo stack information into the commit message, we
need to actually call Command::init() to set up the callback.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Having this as the right action button (same one used for 'cancel' in
the edit screen) made it too likely to inadvertantly delete a dive. And
outside of testing, wanting to delete a dive really shouldn't be all
that common an operation. So remove the function from the action button
and place it into the context menu instead, right next to the undo
action so the user also is aware that there is an undo option.
Suggested-by: Peter Zaal <peter.zaal@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The filler element was placed incorrectly (in a position already used)
and worse the logic for its sizing was wrong.
This gets rid of a warning and creates the intended layout.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And wow isn't that a nice improvement in the code.
Also has the benefit of actually doing the right thing and not creating
unwanted white space for missing cylinders. And does away with all these
warnings about coercion (after all, we were checking against the wrong
value.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In commit 622e5aab69 ("mobile/cleanup: remove more noisy debug output")
I had good intentions, but missed the fact that in order to access the
'verbose' variable from QML I needed to use manager.verboseEnabled. The
resulting syntax error went unnoticed and broke the screen repositioning
when the keyboard opens on mobile devices.
Worse, I called a non existing method to do the logging of debug
information.
And to top it all off, when I fixed the positioning algorithm in commit
765c4f9704 ("mobile/UI: fix the logic to keep input visible"), I forgot
to fix the near identical logic for the TextArea for the notes.
Fail on so many levels.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This feels much more responsive to various screen widths to me.
Instead of a fixed grid this is now a Flow that is tries to make much
better use of the space available on the user's device. It's not always
perfect, but to me at least a massive improvement.
The commit is almost unreadable because of the re-indentation and the
move of a block of fields to earlier in the form (as that made it much
easier to flow everything). But with show -w you can get a better idea.
We have a Flow around all the fields, we pair each label with the
corresponding input field, and then have a few additional Flows to
ensure that the cylinders always start in the first column.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes the TextFields (and the editable ComboBoxes with them) have a
tighter visual experience.
It also moves the indicater closer to the right edge in the ComboBox and
doesn't use preferredWidth for the slim combo box as that implies a
maximum width which could lead to unnecessary clipping.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QML and Kirigami trigger a change of our application window size if we
manually override the gridUnit. Which of course is NOT what we want, so
immediately undo that after changing the gridUnit to prevent bad side
effects.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The fact that the rescaling in the settings gave different results from
what we got after a restart really should have been a dead giveaway that
the code was fundamentally flawed.
With this, if the user picks smaller, regular, or larger they now always
get the same, consistent values for gridUnit and font sizes.
This also gives up on the idea that we can just force the gridUnit to be
smaller to make things work if the font (which drives the gridUnit) is
too big for a screen. That fundamentally cannot work and gives a
horrible UI experience. So instead simply warn the user and continue
with matching font / gridUnit, which will still give a bad experience,
but at least we told the user about it and didn't pretend this was ok or
fixable.
Finally, this gets the factors right when switching from smaller to
larger or back, without stopping at regular on the way.
One odd side effect of this code is that under certain conditions
(number of columns changes) the display window when running mobile on
desktop will resize. That's kind of odd, but as that is not /really/ our
target platform, for now I'd consider it acceptable. But it does deserve
more investigation.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Android appears to set its default font in pixels, not points. So guess
the point size based on the font metric information. This is not
perfect, but creates results that are good enough.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need to do this before the preferences are loaded, or the system
default size is lost. Given that our other sizes are all relative to
this value, that would be a problem.
With this we can now ensure that we always have the right font size for
smaller, regular, and larger theme settings.
Also removes some obsolete commented out code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As it turns out, we used to get the font scaling completely wrong. As a
result we got got ~72% and ~132% instead of the intended 85% and 115%.
So now people have both options, in each case with matching gridUnit
(and therefore visual spacing), and font size.
Also visualize the font size by rendering the button text accordingly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The mobile scale code had a fundamental flaw: we applied the scale
factor once to gridUnit, but twice to the font size. So effectively we
had font sizes of 72% and 132% (all of course then rounded to integers
for no good reason) instead of the intended 85% and 115%.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This seems harmless and obvious, but it shows that for the last however
many years our smaller/regular/larger font change was bogus and broken.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>