Fixed placing of drop overlay cross, resizing of floating widget to drop

area rectangle size prior to insertion
This commit is contained in:
Uwe Kindler 2017-04-11 23:26:33 +02:00
parent 051c379e4a
commit bc37a2788e
8 changed files with 970 additions and 895 deletions

View File

@ -34,6 +34,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/demo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QTDIR}/include&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.preprocessor.def.56223209" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1318830536" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.base.389117097" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.base">
@ -42,6 +43,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QTDIR}/include&quot;"/>
</option>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.806805509" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1568363924" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1734874312" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>

View File

@ -2,13 +2,13 @@
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(g?cc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-797032510223863550" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-853214798705706782" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD -std=c++14 &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(g?cc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>

View File

@ -3,6 +3,8 @@
#include <QApplication>
#include <QDebug>
#include <memory>
#include "mainwindow.h"
@ -33,6 +35,7 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
int main(int argc, char *argv[])
{
std::shared_ptr<int> b;
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true);
qInstallMessageHandler(myMessageOutput);

View File

@ -201,6 +201,7 @@ struct DockOverlayPrivate
DockWidgetArea LastLocation = InvalidDockWidgetArea;
bool DropPreviewEnabled = true;
CDockOverlay::eMode Mode = CDockOverlay::ModeDockAreaOverlay;
QRect DropAreaRect;
/**
* Private data constructor
@ -246,12 +247,6 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) :
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_TranslucentBackground);
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
l->setSpacing(0);
setLayout(l);
l->setContentsMargins(QMargins(0, 0, 0, 0));
l->addWidget(d->Cross);
d->Cross->setupOverlayCross(Mode);
d->Cross->setVisible(false);
setVisible(false);
@ -330,6 +325,7 @@ DockWidgetArea CDockOverlay::showOverlay(QWidget* target)
QPoint TopLeft = target->mapToGlobal(target->rect().topLeft());
move(TopLeft);
show();
d->Cross->updatePosition();
return dropAreaUnderCursor();
}
@ -359,13 +355,12 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
// Draw rect based on location
if (!d->DropPreviewEnabled)
{
d->DropAreaRect = QRect();
return;
}
QRect r = rect();
const DockWidgetArea da = dropAreaUnderCursor();
//std::cout << "CursorLocation: " << dropAreaUnderCursor() << std::endl;
double Factor = (CDockOverlay::ModeContainerOverlay == d->Mode) ?
3 : 2;
@ -383,6 +378,14 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
Color.setAlpha(64);
painter.setPen(Qt::NoPen);
painter.fillRect(r, Color);
d->DropAreaRect = r;
}
//============================================================================
QRect CDockOverlay::dropOverlayRect() const
{
return d->DropAreaRect;
}
@ -569,6 +572,13 @@ DockWidgetArea CDockOverlayCross::cursorLocation() const
//============================================================================
void CDockOverlayCross::showEvent(QShowEvent*)
{
this->updatePosition();
}
//============================================================================
void CDockOverlayCross::updatePosition()
{
resize(d->DockOverlay->size());
QPoint TopLeft = d->DockOverlay->pos();

View File

@ -95,6 +95,11 @@ public:
*/
void enableDropPreview(bool Enable);
/**
* The drop overlay rectangle for the target area
*/
QRect dropOverlayRect() const;
protected:
virtual void paintEvent(QPaintEvent *e) override;
virtual void showEvent(QShowEvent* e) override;
@ -144,6 +149,11 @@ public:
*/
void reset();
/**
* Updates the current position
*/
void updatePosition();
protected:
virtual void showEvent(QShowEvent* e) override;
void setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& widgets);

View File

@ -8,17 +8,48 @@
//============================================================================
// INCLUDES
//============================================================================
#include <DockSplitter.h>
#include "DockSplitter.h"
#include <QDebug>
#include <QChildEvent>
#include "DockAreaWidget.h"
namespace ads
{
/**
* Private dock splitter data
*/
struct DockSplitterPrivate
{
CDockSplitter* _this;
int VisibleContentCount = 0;
DockSplitterPrivate(CDockSplitter* _public) : _this(_public) {}
};
//============================================================================
CDockSplitter::CDockSplitter(QWidget *parent)
: QSplitter(parent),
d(new DockSplitterPrivate(this))
{
}
//============================================================================
CDockSplitter::CDockSplitter(Qt::Orientation orientation, QWidget *parent)
: QSplitter(orientation, parent),
d(new DockSplitterPrivate(this))
{
}
//============================================================================
CDockSplitter::~CDockSplitter()
{
qDebug() << "~CDockSplitter";
delete d;
}

View File

@ -14,6 +14,7 @@
namespace ads
{
struct DockSplitterPrivate;
/**
* Splitter used internally instead of QSplitter
@ -21,8 +22,13 @@ namespace ads
class CDockSplitter : public QSplitter
{
Q_OBJECT
private:
DockSplitterPrivate* d;
friend class DockSplitterPrivate;
public:
using QSplitter::QSplitter;
CDockSplitter(QWidget *parent = Q_NULLPTR);
CDockSplitter(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
/**
* Prints debug info

View File

@ -43,6 +43,7 @@
#include "DockWidget.h"
#include "DockOverlay.h"
#include <iostream>
namespace ads
{
@ -91,6 +92,18 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
return;
}
// Resize the floating widget to the size of the highlighted drop area
// rectangle
QRect Rect = DockManager->containerOverlay()->dropOverlayRect();
if (!Rect.isValid())
{
Rect = DockManager->dockAreaOverlay()->rect();
}
if (Rect.isValid())
{
_this->resize(Rect.size());
}
DropContainer->dropFloatingWidget(_this, QCursor::pos());
DockManager->containerOverlay()->hideOverlay();
DockManager->dockAreaOverlay()->hideOverlay();