fixed maximize panel implementation

This commit is contained in:
itsmattkc
2019-09-26 04:00:41 +10:00
parent 56e3fd41e5
commit 00d3932194
10 changed files with 49 additions and 5 deletions
+3
View File
@@ -23,6 +23,9 @@
NodePanel::NodePanel(QWidget *parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("NodePanel");
// Create NodeView widget
node_view_ = new NodeView(this);
+11
View File
@@ -50,6 +50,17 @@ PanelWidget *PanelManager::CurrentlyFocused() const
return focus_history_.first();
}
PanelWidget *PanelManager::CurrentlyHovered() const
{
foreach (PanelWidget* panel, focus_history_) {
if (panel->underMouse()) {
return panel;
}
}
return nullptr;
}
bool PanelManager::ArePanelsLocked()
{
return locked_;
+9
View File
@@ -63,9 +63,18 @@ public:
/**
* @brief Return the currently focused widget, or nullptr if nothing is focused
*
* This result == CurrentlyFocused() if HoverFocus is true
*/
PanelWidget* CurrentlyFocused() const;
/**
* @brief Return the widget that the mouse is currently hovering over, or nullptr if nothing is hovered over
*
* This result == CurrentlyFocused() if HoverFocus is true
*/
PanelWidget* CurrentlyHovered() const;
template<class T>
/**
* @brief Get most recently focused panel of a certain type
+3
View File
@@ -23,6 +23,9 @@
ParamPanel::ParamPanel(QWidget* parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("ParamPanel");
view_ = new NodeParamView(this);
setWidget(view_);
+3
View File
@@ -30,6 +30,9 @@
ProjectPanel::ProjectPanel(QWidget *parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("ProjectPanel");
// Create main widget and its layout
QWidget* central_widget = new QWidget(this);
QVBoxLayout* layout = new QVBoxLayout(central_widget);
+3
View File
@@ -25,6 +25,9 @@
TaskManagerPanel::TaskManagerPanel(QWidget* parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("TaskManagerPanel");
// Create task view
view_ = new TaskView(this);
+3
View File
@@ -26,6 +26,9 @@
TimelinePanel::TimelinePanel(QWidget *parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("TimelinePanel");
QWidget* main = new QWidget(this);
setWidget(main);
+3
View File
@@ -26,6 +26,9 @@
ToolPanel::ToolPanel(QWidget *parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("ToolPanel");
Toolbar* t = new Toolbar(this);
t->SetTool(olive::core.tool());
+3
View File
@@ -23,6 +23,9 @@
ViewerPanel::ViewerPanel(QWidget *parent) :
PanelWidget(parent)
{
// FIXME: This won't work if there's ever more than one of this panel
setObjectName("ViewerPanel");
// QObject system handles deleting this
viewer_ = new ViewerWidget(this);
connect(viewer_, SIGNAL(TimeChanged(const rational&)), this, SIGNAL(TimeChanged(const rational&)));
+8 -5
View File
@@ -66,16 +66,19 @@ void olive::MainWindow::SetFullscreen(bool fullscreen)
void olive::MainWindow::ToggleMaximizedPanel()
{
qDebug() << "Hello!";
if (premaximized_state_.isEmpty()) {
// Assume nothing is maximized at the moment
// Find the currently focused panel
PanelWidget* currently_focused = olive::panel_manager->CurrentlyFocused();
PanelWidget* currently_hovered = olive::panel_manager->CurrentlyHovered();
// If no panel is hovered, do nothing
if (currently_hovered == nullptr) {
return;
}
// If this panel is not actually on the main window, this is a no-op
if (currently_focused->isFloating()) {
if (currently_hovered->isFloating()) {
return;
}
@@ -84,7 +87,7 @@ void olive::MainWindow::ToggleMaximizedPanel()
// For every other panel that is on the main window, hide it
foreach (PanelWidget* panel, olive::panel_manager->panels()) {
if (!panel->isFloating() && panel != currently_focused) {
if (!panel->isFloating() && panel != currently_hovered) {
panel->setVisible(false);
}
}