mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Update toolwindowmanager to 9b0b99a
This commit is contained in:
+10
-3
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
#include "ToolWindowManager.h"
|
||||
#include "ToolWindowManagerArea.h"
|
||||
#include "ToolWindowManagerSplitter.h"
|
||||
#include "ToolWindowManagerWrapper.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
@@ -908,9 +909,15 @@ void ToolWindowManager::updateDragPosition() {
|
||||
m_previewOverlay->setGeometry(g);
|
||||
m_previewTabOverlay->setGeometry(QRect());
|
||||
} else {
|
||||
bool allowFloat = m_allowFloatingWindow;
|
||||
|
||||
for (QWidget *w : m_draggedToolWindows)
|
||||
allowFloat &= !(toolWindowProperties(w) & DisallowFloatWindow);
|
||||
|
||||
// no hotspot highlighted, draw geometry for a float window if previewing a tear-off, or draw
|
||||
// nothing if we're dragging a float window as it moves itself.
|
||||
if (m_draggedWrapper) {
|
||||
// we also don't render any preview tear-off when floating windows are disallowed
|
||||
if (m_draggedWrapper || !allowFloat) {
|
||||
m_previewOverlay->setGeometry(QRect());
|
||||
} else {
|
||||
QRect r;
|
||||
@@ -974,7 +981,7 @@ void ToolWindowManager::finishDrag() {
|
||||
for (QWidget *w : draggedToolWindows)
|
||||
allowFloat &= !(toolWindowProperties(w) & DisallowFloatWindow);
|
||||
|
||||
if (m_allowFloatingWindow)
|
||||
if (allowFloat)
|
||||
{
|
||||
QRect r;
|
||||
for (QWidget *w : draggedToolWindows) {
|
||||
@@ -1159,7 +1166,7 @@ void ToolWindowManager::windowTitleChanged(const QString &) {
|
||||
}
|
||||
|
||||
QSplitter *ToolWindowManager::createSplitter() {
|
||||
QSplitter* splitter = new QSplitter();
|
||||
QSplitter* splitter = new ToolWindowManagerSplitter();
|
||||
splitter->setChildrenCollapsible(false);
|
||||
return splitter;
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ void ToolWindowManagerArea::addToolWindows(const QList<QWidget *> &toolWindows,
|
||||
foreach(QWidget* toolWindow, toolWindows) {
|
||||
index = insertTab(insertIndex, toolWindow, toolWindow->windowIcon(), toolWindow->windowTitle());
|
||||
insertIndex = index+1;
|
||||
if(m_manager->toolWindowProperties(toolWindow) & ToolWindowManager::HideCloseButton) {
|
||||
showCloseButton(tabBar(), index, false);
|
||||
}
|
||||
}
|
||||
setCurrentIndex(index);
|
||||
for (int i=0; i < count(); i++) {
|
||||
updateToolWindow(widget(i));
|
||||
}
|
||||
m_manager->m_lastUsedArea = this;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#include "ToolWindowManagerSplitter.h"
|
||||
#include <QChildEvent>
|
||||
#include <QDebug>
|
||||
|
||||
ToolWindowManagerSplitter::ToolWindowManagerSplitter(QWidget *parent) :
|
||||
QSplitter(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ToolWindowManagerSplitter::~ToolWindowManagerSplitter() {
|
||||
}
|
||||
|
||||
void ToolWindowManagerSplitter::childEvent(QChildEvent *event) {
|
||||
QList<int> s = sizes();
|
||||
|
||||
QWidget *w = qobject_cast<QWidget*>(event->child());
|
||||
int idx = -1;
|
||||
if (w)
|
||||
idx = indexOf(w);
|
||||
|
||||
QSplitter::childEvent(event);
|
||||
|
||||
if (event->type() == QEvent::ChildRemoved && idx >= 0 && idx < s.count()) {
|
||||
int removedSize = s[idx];
|
||||
|
||||
s.removeAt(idx);
|
||||
|
||||
// if we removed an item at one extreme or another, the new end should get all the space
|
||||
// (unless the list is now empty)
|
||||
if (idx == 0) {
|
||||
if(!s.isEmpty())
|
||||
s[0] += removedSize;
|
||||
} else if (idx == s.count()) {
|
||||
if(!s.isEmpty())
|
||||
s[s.count()-1] += removedSize;
|
||||
} else {
|
||||
// we removed an item in the middle, share the space between its previous neighbours, now in
|
||||
// [idx-1] and [idx], and we know they're valid since if there were only two elements before
|
||||
// the removal one or the other case above would have matched. So there are at least two
|
||||
// elements now and idx > 0
|
||||
|
||||
s[idx-1] += removedSize/2;
|
||||
s[idx] += removedSize/2;
|
||||
}
|
||||
|
||||
setSizes(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#ifndef TOOLWINDOWMANAGERSPLITTER_H
|
||||
#define TOOLWINDOWMANAGERSPLITTER_H
|
||||
|
||||
#include <QSplitter>
|
||||
|
||||
/*!
|
||||
* \brief The ToolWindowManagerSplitter class is a splitter that tweaks how sizes are allocated in
|
||||
* children when a child is removed.
|
||||
*/
|
||||
class ToolWindowManagerSplitter : public QSplitter {
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! Creates new tab bar.
|
||||
explicit ToolWindowManagerSplitter(QWidget *parent = 0);
|
||||
//! Destroys the tab bar.
|
||||
virtual ~ToolWindowManagerSplitter();
|
||||
|
||||
protected:
|
||||
//! Reimplemented from QSplitter to share excess space differently.
|
||||
void childEvent(QChildEvent *) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // TOOLWINDOWMANAGERSPLITTER_H
|
||||
@@ -22,6 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#include "ToolWindowManager.h"
|
||||
#include "ToolWindowManagerTabBar.h"
|
||||
#include "ToolWindowManagerArea.h"
|
||||
#include "ToolWindowManagerWrapper.h"
|
||||
@@ -147,6 +148,14 @@ void ToolWindowManagerTabBar::paintEvent(QPaintEvent *event) {
|
||||
buttonOpt.rect = m_pin.rect;
|
||||
buttonOpt.icon = m_pin.icon;
|
||||
|
||||
ToolWindowManager::ToolWindowProperty props =
|
||||
m_area->m_manager->toolWindowProperties(m_area->widget(0));
|
||||
|
||||
bool tabClosable = (props & ToolWindowManager::HideCloseButton) == 0;
|
||||
|
||||
if (!tabClosable)
|
||||
buttonOpt.rect = m_close.rect;
|
||||
|
||||
QStyle::State prevState = buttonOpt.state;
|
||||
|
||||
if(m_pin.clicked)
|
||||
@@ -160,7 +169,7 @@ void ToolWindowManagerTabBar::paintEvent(QPaintEvent *event) {
|
||||
|
||||
style()->drawComplexControl(QStyle::CC_ToolButton, &buttonOpt, &p, this);
|
||||
|
||||
if (m_tabsClosable) {
|
||||
if (m_tabsClosable && tabClosable) {
|
||||
buttonOpt.rect = m_close.rect;
|
||||
buttonOpt.icon = m_close.icon;
|
||||
|
||||
@@ -213,14 +222,27 @@ void ToolWindowManagerTabBar::mousePressEvent(QMouseEvent *event) {
|
||||
ButtonData prevPin = m_pin;
|
||||
ButtonData prevClose = m_close;
|
||||
|
||||
if (m_pin.rect.contains(mapFromGlobal(QCursor::pos())) &&
|
||||
ToolWindowManager::ToolWindowProperty props =
|
||||
m_area->m_manager->toolWindowProperties(m_area->widget(0));
|
||||
|
||||
bool tabClosable = (props & ToolWindowManager::HideCloseButton) == 0;
|
||||
|
||||
QRect pinRect = m_pin.rect;
|
||||
QRect closeRect = m_close.rect;
|
||||
|
||||
if (!tabClosable) {
|
||||
pinRect = closeRect;
|
||||
closeRect = QRect();
|
||||
}
|
||||
|
||||
if (pinRect.contains(mapFromGlobal(QCursor::pos())) &&
|
||||
event->buttons() & Qt::LeftButton) {
|
||||
m_pin.clicked = true;
|
||||
} else {
|
||||
m_pin.clicked = false;
|
||||
}
|
||||
|
||||
if (m_close.rect.contains(mapFromGlobal(QCursor::pos())) &&
|
||||
if (closeRect.contains(mapFromGlobal(QCursor::pos())) &&
|
||||
event->buttons() & Qt::LeftButton) {
|
||||
m_close.clicked = true;
|
||||
} else {
|
||||
@@ -242,7 +264,20 @@ void ToolWindowManagerTabBar::mouseMoveEvent(QMouseEvent *event) {
|
||||
ButtonData prevPin = m_pin;
|
||||
ButtonData prevClose = m_close;
|
||||
|
||||
if (m_pin.rect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
ToolWindowManager::ToolWindowProperty props =
|
||||
m_area->m_manager->toolWindowProperties(m_area->widget(0));
|
||||
|
||||
bool tabClosable = (props & ToolWindowManager::HideCloseButton) == 0;
|
||||
|
||||
QRect pinRect = m_pin.rect;
|
||||
QRect closeRect = m_close.rect;
|
||||
|
||||
if (!tabClosable) {
|
||||
pinRect = closeRect;
|
||||
closeRect = QRect();
|
||||
}
|
||||
|
||||
if (pinRect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
m_pin.hover = true;
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
m_pin.clicked = true;
|
||||
@@ -251,7 +286,7 @@ void ToolWindowManagerTabBar::mouseMoveEvent(QMouseEvent *event) {
|
||||
m_pin.clicked = false;
|
||||
}
|
||||
|
||||
if (m_close.rect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
if (closeRect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
m_close.hover = true;
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
m_close.clicked = true;
|
||||
@@ -270,7 +305,20 @@ void ToolWindowManagerTabBar::mouseReleaseEvent(QMouseEvent *event) {
|
||||
if (count() > 1 || floatingWindowChild())
|
||||
return;
|
||||
|
||||
if (m_pin.rect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
ToolWindowManager::ToolWindowProperty props =
|
||||
m_area->m_manager->toolWindowProperties(m_area->widget(0));
|
||||
|
||||
bool tabClosable = (props & ToolWindowManager::HideCloseButton) == 0;
|
||||
|
||||
QRect pinRect = m_pin.rect;
|
||||
QRect closeRect = m_close.rect;
|
||||
|
||||
if (!tabClosable) {
|
||||
pinRect = closeRect;
|
||||
closeRect = QRect();
|
||||
}
|
||||
|
||||
if (pinRect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
// process a pin of these tabs
|
||||
|
||||
m_pin.clicked = false;
|
||||
@@ -280,7 +328,7 @@ void ToolWindowManagerTabBar::mouseReleaseEvent(QMouseEvent *event) {
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (m_close.rect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
if (closeRect.contains(mapFromGlobal(QCursor::pos()))) {
|
||||
if (m_area)
|
||||
m_area->tabCloseRequested(0);
|
||||
|
||||
|
||||
@@ -155,7 +155,13 @@ void ToolWindowManagerWrapper::closeEvent(QCloseEvent *) {
|
||||
toolWindows << tabWidget->toolWindows();
|
||||
}
|
||||
}
|
||||
m_manager->moveToolWindows(toolWindows, ToolWindowManager::NoArea);
|
||||
|
||||
foreach(QWidget* toolWindow, toolWindows) {
|
||||
if(m_manager->toolWindowProperties(toolWindow) & ToolWindowManager::HideOnClose)
|
||||
m_manager->hideToolWindow(toolWindow);
|
||||
else
|
||||
m_manager->removeToolWindow(toolWindow);
|
||||
}
|
||||
}
|
||||
|
||||
bool ToolWindowManagerWrapper::eventFilter(QObject *object, QEvent *event) {
|
||||
|
||||
Reference in New Issue
Block a user