Commit Graph

1133 Commits

Author SHA1 Message Date
Sergio Martins
a9d0ec3fdd Use a better strategy for size propagation when resizing via separator
Behaves like old kddockwidgets now.
When dragging a separator, only the immediate neighbours are resized.
Only when min-sizes are violated that it propagates.
2020-05-09 17:42:55 +01:00
Sergio Martins
ed6d5134b0 Implement Side1 and Side2 resizing strategies
to be used when dragging separators when mouse, as we don't want
a recursive resize dealing with percentages, as it doesn't need to be fair.
Items near the mouse/separator will suffer/benetif more from there resize.
Resize only propagates further when size-constraints come into action
2020-05-09 13:28:59 +01:00
Sergio Martins
1f2bdaf188 Factor out children resize logic into Item::resizeChildren()
as we'll have other stragies for resizing children
2020-05-09 12:49:03 +01:00
Sergio Martins
a9be454604 Item: Rename resize to setSize_recursive() 2020-05-09 12:14:08 +01:00
Sergio Martins
7c85c1eb0f Resize the layout after restoring
After restoring, we need to put the layout at the same size
as its widget. Most of the times this happens since we also restore
the widget's geometry. But really make sure, as something might happen
to the window geometry, like for example using RestoreOption_RelativeToMainWindow
which doesn't restore the main window geometries
2020-05-09 00:46:30 +01:00
Sergio Martins
addf436fd0 LayoutSaver: Don't load old serialization versions 2020-05-08 19:30:41 +01:00
Sergio Martins
ff6260a4dc tests: Add a failling test tst_invalidLayoutAfterRestore
And a JSON file that makes it fail
2020-05-08 18:40:23 +01:00
Sergio Martins
48f872f696 Remove extra semi 2020-05-08 18:01:28 +01:00
Sergio Martins
e3e31ca5ca Ensure kddockwidgets_layouting is STATIC
Otherwise we get errors as only kddockwidgets is exported. It's
not public API for now
2020-05-08 18:00:42 +01:00
Sergio Martins
4b05d4ddd7 Remove unused Item_p.h include 2020-05-08 17:02:58 +01:00
Sergio Martins
e6e63806f8 MultiSplitterLayout_p.h: Forward declare Frame and Item 2020-05-08 17:01:07 +01:00
Sergio Martins
d267b0e0dd LastPosition: Forward declare Layouting::Item 2020-05-08 16:46:42 +01:00
Sergio Martins
96ee076e9a Add pimpl to Separator 2020-05-08 16:43:03 +01:00
Sergio Martins
7e86a32a23 Readability++
let the reader know position isn't imported at this stage
2020-05-07 23:34:57 +01:00
Sergio Martins
09026fd312 Uncomment assert 2020-05-07 23:05:59 +01:00
Sergio Martins
d2dca56ce6 Implement lazy resize in the new engine
We're almost feature complete
2020-05-07 19:35:05 +01:00
Sergio Martins
3742e5ef9a example: No persistent central frame by default
This is old style, which we don't use anymore by default
2020-05-07 19:32:32 +01:00
Sergio Martins
7ed54631ac Item: unit-tests++ 2020-05-07 18:49:18 +01:00
Sergio Martins
3c1ab0126d Item: Clear and honour a bunch of TODOs 2020-05-07 18:49:00 +01:00
Sergio Martins
0df9943aa5 Fix fuzzer test 11.json and other tests that worked by luck
mapFrom/toRoot were wrong
2020-05-07 16:30:45 +01:00
Sergio Martins
d4cc9e85eb Add more sanity checks to Item
Checks that the parentContainer and hostWidget are correct
for each separator
2020-05-07 12:35:58 +01:00
Sergio Martins
5f7899f265 Item: Remove unused methods 2020-05-07 00:08:04 +01:00
Sergio Martins
61bedce278 Separators now are able to be moved by the user with mouse 2020-05-06 22:52:36 +01:00
Sergio Martins
cd053d0cc4 Unit-tests++ 2020-05-06 00:01:46 +01:00
Sergio Martins
06a7346281 Introduce ItemContainer::availableOnSide_recursive()
and use it for calculating the min/max position of a separator

The min/max position of a separator isn't local to its container,
but is recursive upwards until root
2020-05-05 23:16:57 +01:00
Sergio Martins
535a0c943c Remove some cruft, bunch of unused methods from old layouting engine 2020-05-04 23:37:04 +01:00
Sergio Martins
e298667351 Remove dead code about static separators
Before we had separators on the left,top,bottom,right margins
with 0 width. Now we don't have this concept anymore
2020-05-04 14:28:59 +01:00
Sergio Martins
0595448bba Replace Anchor with Separator
We don't have the concept of Anchors anymore. Code is now simpler
2020-05-04 13:10:38 +01:00
Sergio Martins
97c1ca30fd Layouting engine rewrite
The layouting was becoming too complex to maintain and to introduce
new features. Was even buggy, the fuzzer was constantly finding
bugs, which took hours to workaround.

Problem with the old layout engine is that there was a catch 22, between
Items driving the separators, and separators driving the anchors.

The new layout is much simpler, both in implementation and conceptually.
There's simply a recursive hierarchy of Item elements. An Item can either
have a QWidget to show, or be a ItemContainer, which contains Item children,
and so forth. Each ItemContainer is either vertical or horizontal. That's enough
to represent the "nested multi-splitter" concept which KDDW uses.

After each item insertion/deletion/resize, the separators are regenerated. They
are essentially dumb now.

TODO:
- Separators are drawn, but are not interactive yet
- There's 5 tests failing
- LayoutSaver scalling functionality
2020-05-04 00:02:03 +01:00
Sergio Martins
86d1a52bbf Fix unit-test
Was leaving window leftovers behind.
Delete them.
old_layouting_engine
2020-05-03 16:41:52 +01:00
Sergio Martins
2d007c558a Update .gitignore 2020-05-02 14:18:30 +01:00
Sergio Martins
dc4a1975ab Fix build with cmake < 3.12
3.12 is needed for HOMEPAGE_URL and DESCRIPTION support.

Bumped the minimum to 3.7, older fails.
Fixes: 43
2020-05-02 14:14:04 +01:00
Sergio Martins
144897e831 Fix namespaced build 2020-05-01 15:35:05 +01:00
Sergio Martins
e87f6d001e example: Fix duplicate command line argument switch 2020-05-01 13:09:27 +01:00
Sergio Martins
8cc53ca5bb Also build the example when building KDDW
No need to install the library anymore
Fixes: #42
2020-05-01 13:07:25 +01:00
Sergio Martins
1b337b5391 Merge pull request #41 from KDAB/float_action
Add test for dock floating action
2020-05-01 11:45:43 +01:00
Colin Ogilvie
e383bc797e Run tests with ctest 2020-04-30 18:12:35 +01:00
Colin Ogilvie
43a25ef93b Add test for foating action 2020-04-30 16:56:13 +01:00
Sergio Martins
19e519912b Merge pull request #40 from KDAB/float_action
Float action
2020-04-30 13:45:07 +01:00
Colin Ogilvie
68f0c64954 Add a DockWidgetBase::floatAction()
Helper action to allow docking/detaching
2020-04-30 13:39:02 +01:00
Sergio Martins
e8db004874 Windows: Fix maximized window size when using the maximize
When the maximize is triggered by Qt, we get the WM_GETMINMAXINFO
too soon, as QWindow already says it's maximized, while it's still
in process of being.

Just removed the condition, doesn't seem to have any bad side-effect
2020-04-20 20:55:11 +01:00
Sergio Martins
6ee3cfbb2d Introduce "Maximize/restore" title bar button support
As happens with other docking frameworks:
- Maximized/restore button only visible when window is floating
- floating button is never visible

Available by setting Flag_TitleBarHasMaximizeButton.
Added example too.

Fixes: #37
2020-04-20 19:55:51 +01:00
Sergio Martins
ab0fc1e328 Add DockWidget::Option_NonDockable
A dock widget with this option will always be floating and not be
able to dock into anything. Other widgets can't dock into it either.
2020-04-13 13:23:38 +01:00
Sergio Martins
899ca6af6a Merge pull request #34 from jcelerier/master
Add an include needed from Qt 5.15
2020-03-27 12:31:56 +00:00
Jean-Michaël Celerier
c8c56d293c Add an include needed from Qt 5.15 2020-03-26 23:27:23 +01:00
Sergio Martins
b236d744e3 Fix calculating main window scale 2020-03-25 15:56:19 +00:00
Sergio Martins
425d859f5b Merge pull request #33 from KDAB/fix_tabbarwidget_leak
Don't leak TabBarWidget's proxy style
2020-03-25 13:35:04 +00:00
Milian Wolff
d58abf170f Don't leak TabBarWidget's proxy style
Fixes leak reported by LSAN:

```
    #0 0x7f7b5687e968 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f7b2e5b1096 in KDDockWidgets::TabBarWidget::TabBarWidget(KDDockWidgets::TabWidget*) ../3rdParty/kddockwidgets/src/private/widgets/TabBarWidget.cpp:71
    #2 0x7f7b2e295ba4 in KDDockWidgets::DefaultWidgetFactory::createTabBar(KDDockWidgets::TabWidget*) const ../3rdParty/kddockwidgets/src/FrameworkWidgetFactory.cpp:71
    #3 0x7f7b2e5b8f54 in KDDockWidgets::TabWidgetWidget::TabWidgetWidget(KDDockWidgets::Frame*) ../3rdParty/kddockwidgets/src/private/widgets/TabWidgetWidget.cpp:38
```

The owernship rules for QProxyStyle <-> QStyle are pure madness.
We do not want to delete the proxy we use as a base. And we must
not ever create multiple proxy styles for the same style either.
So add a static singleton for the proxy style and set its parent
to the qApp. This seems to work fine, at least the leak is gone
and we also don't get a crash at shutdown...
2020-03-25 14:03:24 +01:00
Sergio Martins
225aa6a098 Add unit-test for DockWidget::raise()
and make it pass on offscreen platform too, as that QPA plugin
fails to keep z-order between order.
2020-03-24 22:36:21 +00:00
Sergio Martins
b0665cd003 When raising, also set current tab if it's floating
If the dock widget is in a FloatingWindow, but hidden by some
other tab, we not only need to raise the FloatingWindow but also
set our tab current
2020-03-24 22:12:28 +00:00