Commit Graph

723 Commits

Author SHA1 Message Date
Sergio Martins
83f6bb8daf Remove some sanity checks, no longer needed
Silenced a false-positive warning about anchor visibility.
It was invisible because we're within a main window show()

It will be checked by the unit-tests and fuzzer anyway. No need to
do it in production.
2019-10-22 15:28:50 +01:00
Sergio Martins
38949fac2a Fix build without find_package()
Some of our projects have kddockwidgets directly in their build
2019-10-21 14:30:04 +01:00
Sergio Martins
de42a4a33c Remove some asserts that aren't needed anymore
They were useful during development.
They have a warning anyway, so the tests and fuzzer will still fail
if something bad happens
2019-10-20 20:32:35 +01:00
Sergio Martins
787f7802be Move the private code into a private/ folder
It's nice to have a similar include hierarchy at build time and install
time.

It also makes things more explicit
2019-10-20 19:24:54 +01:00
Sergio Martins
6a9b02ea63 Fix ensureMinSize_recursive
It doesn't make sense to only grow one side, as sometimes the item
must grow in both sizes, as the right side might now have enough
to acomodate its needs.

This also allows us to not use Anchor::ensureBounded(), as separators
being within their bounds doesn't imply min sizes being respected, while
the inverse is true

fuzzer testcase 10.json now passes
2019-10-20 16:57:52 +01:00
Sergio Martins
9ce22848f4 Factor out some code into a Item::ensureMinSize_recursive() function
So we can reuse this function in other places.
2019-10-19 19:43:33 +01:00
Sergio Martins
d189506a8c Fix separators sometimes not being visible
When a separator is following other it becomes invisible. But if the
followee is deleted we weren't detecting that.

Connect to the followee's QObject::destroyed() signal so we stop following
and show this separator
2019-10-18 18:31:09 +01:00
Sergio Martins
71287fb916 Improve debug 2019-10-17 23:58:36 +01:00
Sergio Martins
f9c2283ff5 Dont shift separator if there's other visible items still
When hidding a dockwidget we shift the left separator 50% and the right one
50%, instead of left 100%, so it's fair. But if the separator has other
visible dock widgets then no shifting should happen.
2019-10-17 23:57:13 +01:00
Sergio Martins
00ae23d80b Add Anchors::followers() 2019-10-17 23:53:27 +01:00
Sergio Martins
ffa61abeb8 Debug++ 2019-10-17 18:29:41 +01:00
Sergio Martins
9d0a69c1a6 Relax warning about AnchorGroup being small
When adjusting the vertical separators we should only check if
the group has enough width. It's height is adjusted in ensureAnchorsBounded().
(And vice-versa)

Found via fuzzer's test-case 9.json. Passes now.
2019-10-17 18:12:51 +01:00
Sergio Martins
bb7f5e51c6 Relax warning in Anchor::setPosition()
Can happen with normal separators too.
They'll be fixed ensureAnchorsBounded() anyway.
2019-10-17 17:50:59 +01:00
Sergio Martins
545b61988f Fix propagating item geometry
If the anchorThatMoved actually increased size then we were
calculating the signess wrong and the item would shrink.

Just check if the anchor is a side1 anchor in the group, if yes
then position must decrease so group grows
2019-10-17 17:40:28 +01:00
Sergio Martins
8f886b8eff Remove sanity checks from Anchor.cpp
As they might be running on an incomplete state, during some
operation.

Instead move it to MultiSplitterLayout::checkSanity() which is
run at the end of operations
2019-10-17 16:42:02 +01:00
Sergio Martins
27cae066a6 Fix Anchor::cumulativeMinLength
We don't want to count the size of separators that are following
others, but we might be in the middle of an operation that will
change which separators are following, like when restoring a placeholder.

So query the actual separators that will follow.

Fixes fuzzer 8.json and 2.json
2019-10-17 13:30:31 +01:00
Sergio Martins
fd7e849e99 Don't checkSanity() in the middle of restoring a placeholder
state isn't stable yet
2019-10-17 12:57:41 +01:00
Sergio Martins
8491224b73 Debug++ 2019-10-17 09:22:03 +01:00
Sergio Martins
1493f904ab Export Draggable 2019-10-16 19:52:55 +01:00
Sergio Martins
7b5dc02022 Fix anchors out of bounds when redistributing space
In the above case:

+--------+---+
| 1      | 6 |
|        |   |
+---+----|   |
| 2 | 8  |   |
|   |    |   |
+---+----+---+

Supposing 8 is hidden (it's a placeholder), then the separator between 2
and 8 is following the big vertical one between 1 and 6. Now, if the size constraints
of the widget hosted by 2 increases, which might lead to the main window having to increase,
then we have to move that big separator. Problem was it was only honouring the min size of widget 1
because 8 was hidden.
2019-10-16 17:35:39 +01:00
Sergio Martins
be7e9caf15 Debug++ 2019-10-16 17:34:43 +01:00
Sergio Martins
618a62d0c5 Fix anchors out of bounds warning while restoring placeholder
ensureAnchorsBounded() shouldn't be run while in an inconsistent
state. And it's already run at the end of restoring placeholders.

Fixes fuzzer test case 2.json
2019-10-16 12:44:52 +01:00
Sergio Martins
dd7b0b27d1 Don't move the static separators when restoring a placeholder
Fixes fuzzer testcase 6.json
2019-10-15 19:15:11 +01:00
Sergio Martins
855e9ab884 Minor rename 2019-10-15 18:20:02 +01:00
Sergio Martins
f44d63f4c3 DebugDialog: Add button to updateAnchorFollowing() 2019-10-15 18:17:22 +01:00
Sergio Martins
d0c7c9eb99 Fix Item and Frame geometry getting out of sync 2019-10-15 16:37:08 +01:00
Sergio Martins
7a6d2a1f6d Fix cases where ensureAnchorsBounded() wasn't called
It wasn't called because the min size decreased, so setSize()
was a no-op, so ensureAnchorsBounded() was skipped.

But the internal widgets constraints can change, so still call ensureAnchorsBounded().
2019-10-15 14:52:48 +01:00
Sergio Martins
92bbe4d4f7 Remove a dock widget from the layout before adding as tab
So the layout can grow first and not complain there's not enough
space.

Fixes fuzzer test-case 3.json.
The warning was: "Constraints not honoured" in Item::onLayoutRequest()
2019-10-15 12:51:49 +01:00
Sergio Martins
50f6ac62fa Fix off-by-one when adjusting the separator's end
It was intersecting with the Item by 1 pixel.

This fixes fuzzer test 1.json.

The warning would look like:
MultiSplitterLayout::checkSanity: Widget <item> with rect <rect> intersects anchor <anchor>
2019-10-15 11:16:07 +01:00
Sergio Martins
69d61198a2 debug++ 2019-10-15 10:10:47 +01:00
Sergio Martins
5633d09ced Fix Items not having an object name
Now debugging is easier
2019-10-15 10:10:20 +01:00
Sergio Martins
5da338c185 fuzzer: Run MultisplitterLayout::checkSanity() after each operation 2019-10-14 23:22:45 +01:00
Sergio Martins
a49ffe54c7 docs++ 2019-10-13 18:13:52 +01:00
Sergio Martins
5a5e6f3762 Add Q_DECLARE_OPERATORS_FOR_FLAGS for FrameOptions 2019-10-08 18:01:11 +01:00
Sergio Martins
ac313c5a24 Don't save floating geometry on clear()
clear() shouldn't save anything.
Fixes floating dockwidgets not having proper geometry when shown
after clear() was called.
2019-10-08 14:59:31 +01:00
Sergio Martins
58e90bd7c4 Make MainWindow_None the default, instead of MainWindow_HasCentralFrame
Central Frame is the old Qt way. With KDDockWidgets everwhere
is fair game to dock and undock.
2019-10-07 14:02:30 +01:00
Sergio Martins
511a035df1 Install more missing _p.h headers to private/
The custom separator example is disabled for now, as we're not
installing the multisplitters headers yet
2019-10-07 13:55:09 +01:00
Sergio Martins
a0d05b4e2b Move Frame::Options enum to KDDockWidgets.h
So we can forward declare Frame and not include private headers
in FrameworkWidgetFactory.h
2019-10-07 13:43:48 +01:00
Sergio Martins
21579f2743 Minor method renames 2019-10-07 00:16:16 +01:00
Sergio Martins
01249374e9 Install the *_p.h headers into a private/ folder
As the API is not stable
2019-10-06 23:43:01 +01:00
Sergio Martins
ea75b84af3 cmake: Install missing headers 2019-10-06 23:05:01 +01:00
Sergio Martins
a0787f1488 examples: Move custom_titlebar code into kddockwidgets_example
Guarded with a command line switch, no need to have two examples
2019-10-06 22:26:09 +01:00
Sergio Martins
b5fad9a601 docs++ 2019-10-05 12:54:25 +01:00
Sergio Martins
eb96288534 docs: Improved @file docs 2019-10-04 17:33:42 +01:00
Sergio Martins
3c482e743a Fix invalid downcast detected by ASAN
~Frame() triggers MultiSplitterLayout to emit visibleWidgetCountChanged()
which the Frame being destroyed is connected to. So disconnect before
~QWidget runs.
2019-10-02 12:53:27 +01:00
Sergio Martins
8663e02614 Minor indentation fix 2019-10-02 12:06:34 +01:00
Albert Astals Cid
262d57b890 Add a few const &
as suggested by clang-tidy
2019-09-30 15:57:03 +02:00
Sergio Martins
c5149ab13c Fix title bar being visible with Flag_HideTitleBarWhenTabsVisible
Frame::updateTitleBarVisibility() was bailing out early. That
guard looks like some leftover, m_dropArea isn't even dereferenced
there, so just remove the guard.
2019-09-30 11:00:38 +01:00
Sergio Martins
cf90980094 Fix toggleAction() not emitting its signals
User might connect to it.
Use a less violent way of guarding against recursion
2019-09-24 22:08:57 +01:00
Sergio Martins
b5d83e68a2 Unit-test the state of toggleAction() ttoo 2019-09-24 18:35:03 +01:00