OpenToonz - An open-source full-featured 2D animation creation software
C
Main Window See Through Mode
justburnere9f26029a0b5
diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xmlindex c4654a226..7becfabcc 100644--- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml+++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml@@ -325,7 +325,8 @@<command>MI_OpenCustomPanels</command><separator/><command>MI_MaximizePanel</command>- <command>MI_FullScreenWindow</command>+ <command>MI_FullScreenWindow</command>+ <command>MI_SeeThroughWindow</command></menu><menu title="Help"><command>MI_OpenOnlineManual</command>diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txtindex ec2111359..06ee94973 100644--- a/toonz/sources/toonz/CMakeLists.txt+++ b/toonz/sources/toonz/CMakeLists.txt@@ -86,6 +86,7 @@ set(MOC_HEADERSsceneviewer.hsceneviewercontextmenu.hscriptconsolepanel.h+ seethroughwindowpopup.hseparatecolorspopup.hseparatecolorsswatch.hshortcutpopup.h@@ -287,6 +288,7 @@ set(SOURCESsceneviewercontextmenu.cppscenesettingspopup.cppscriptconsolepanel.cpp+ seethroughwindowpopup.cppshortcutpopup.cppsoundtrackexport.cppstartuppopup.cppdiff --git a/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_off.svg b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_off.svgnew file mode 100644index 000000000..dbae67bb4--- /dev/null+++ b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_off.svg@@ -0,0 +1,4 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg width="16px" height="16px" clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><style></style>+ <path transform="translate(-49,-371)" d="m50 373c0-0.552 0.448-1 1-1h12c0.552 0 1 0.448 1 1v12c0 0.552-0.448 1-1 1-4.4322-3e-3 -8.1442 7e-3 -12 0-0.5 2e-3 -1.002-0.5-1-1-0.0044-4.1294 0-7.8419 0-12zm1 12h12v-10h-12z" />+<path d="m14 4h-12v10h12z" fill-opacity=".4"/></svg>diff --git a/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_on.svg b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_on.svgnew file mode 100644index 000000000..bacaf0bc9--- /dev/null+++ b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_on.svg@@ -0,0 +1,4 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg width="16px" height="16px" clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><style></style>+ <path transform="translate(-49,-371)" d="m50 373c0-0.552 0.448-1 1-1h12c0.552 0 1 0.448 1 1v12c0 0.552-0.448 1-1 1-4.4322-3e-3 -8.1442 7e-3 -12 0-0.5 2e-3 -1.002-0.5-1-1-0.0044-4.1294 0-7.8419 0-12zm1 12h12v-10h-12z" fill-opacity=".5"/>+<path d="m14 4h-12v10h12z" fill-opacity=".2"/></svg>diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex 6381c6948..23a6059f7 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -15,6 +15,7 @@#include "startuppopup.h"#include "tooloptionsshortcutinvoker.h"#include "custompanelmanager.h"+#include "seethroughwindowpopup.h"// TnzTools includes#include "tools/toolcommandids.h"@@ -452,6 +453,7 @@ centralWidget->setLayout(centralWidgetLayout);*/setCommandHandler(MI_MaximizePanel, this, &MainWindow::maximizePanel);setCommandHandler(MI_FullScreenWindow, this, &MainWindow::fullScreenWindow);+ setCommandHandler(MI_SeeThroughWindow, this, &MainWindow::seeThroughWindow);setCommandHandler("MI_NewVectorLevel", this,&MainWindow::onNewVectorLevelButtonPressed);setCommandHandler("MI_NewToonzRasterLevel", this,@@ -1089,6 +1091,14 @@ void MainWindow::fullScreenWindow() {}}+void MainWindow::seeThroughWindow() {+ static SeeThroughWindowPopup *popup = nullptr;++ if (!popup) popup = new SeeThroughWindowPopup();++ popup->toggleMode();+}+//-----------------------------------------------------------------------------void MainWindow::onCurrentRoomChanged(int newRoomIndex) {@@ -2136,6 +2146,9 @@ void MainWindow::defineActions() {createMenuWindowsAction(MI_FullScreenWindow,QT_TR_NOOP("Toggle Main Window's Full Screen Mode"),"Ctrl+`", "toggle_fullscreen");+ createMenuWindowsAction(MI_SeeThroughWindow,+ QT_TR_NOOP("Toggle Main Window's See Through Mode"),+ "Alt+`", "toggle_seethroughwin_on");createMenuHelpAction(MI_About, QT_TR_NOOP("&About OpenToonz..."), "", "info");createMenuWindowsAction(MI_StartupPopup, QT_TR_NOOP("&Startup Popup..."),"Alt+S", "opentoonz");diff --git a/toonz/sources/toonz/mainwindow.h b/toonz/sources/toonz/mainwindow.hindex 3c56a20c7..50cf2a903 100644--- a/toonz/sources/toonz/mainwindow.h+++ b/toonz/sources/toonz/mainwindow.h@@ -92,6 +92,7 @@ public:void resetRoomsLayout();void maximizePanel();void fullScreenWindow();+ void seeThroughWindow();void autofillToggle();void onUpgradeTabPro();void onAbout();diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cppindex f82999150..2bbf9db6b 100644--- a/toonz/sources/toonz/menubar.cpp+++ b/toonz/sources/toonz/menubar.cpp@@ -1434,6 +1434,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {windowsMenu->addSeparator();addMenuItem(windowsMenu, MI_MaximizePanel);addMenuItem(windowsMenu, MI_FullScreenWindow);+ addMenuItem(windowsMenu, MI_SeeThroughWindow);// Menu' HELPQMenu *helpMenu = addMenu(tr("Help"), fullMenuBar);diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.hindex 4b2b05bb2..f71838d3a 100644--- a/toonz/sources/toonz/menubarcommandids.h+++ b/toonz/sources/toonz/menubarcommandids.h@@ -231,6 +231,7 @@#define MI_ResetRoomLayout "MI_ResetRoomLayout"#define MI_MaximizePanel "MI_MaximizePanel"#define MI_FullScreenWindow "MI_FullScreenWindow"+#define MI_SeeThroughWindow "MI_SeeThroughWindow"#define MI_OnionSkin "MI_OnionSkin"#define MI_ZeroThick "MI_ZeroThick"#define MI_CursorOutline "MI_CursorOutline"diff --git a/toonz/sources/toonz/seethroughwindowpopup.cpp b/toonz/sources/toonz/seethroughwindowpopup.cppnew file mode 100644index 000000000..8210eca14--- /dev/null+++ b/toonz/sources/toonz/seethroughwindowpopup.cpp@@ -0,0 +1,129 @@+#include "seethroughwindowpopup.h"++// Tnz6 includes+#include "tapp.h"+#include "tenv.h"++// TnzQt includes+#include "toonzqt/gutil.h"++#include <QApplication>+#include <QMainWindow>+#include <QToolTip>++TEnv::IntVar SeeThroughWindowOpacity("SeeThroughWindowOpacity", 50);++//-----------------------------------------------------------------------------++SeeThroughWindowPopup::SeeThroughWindowPopup()+ : Dialog(TApp::instance()->getMainWindow(), true, false, "SeeThroughWindow") {+ setWindowTitle(tr("See Through Mode"));+ setModal(false);++ m_bckValue = 50;++ beginHLayout();++ m_opacityLabel = new QLabel(tr("Opacity:"));+ m_opacityLabel->setMinimumHeight(25);+ addWidget(m_opacityLabel);++ m_opacitySlider = new QSlider(Qt::Horizontal);+ m_opacitySlider->setRange(1, 50);+ m_opacitySlider->setSingleStep(1);+ m_opacitySlider->setPageStep(5);+ setOpacitySlider(SeeThroughWindowOpacity);+ m_opacitySlider->setMinimumHeight(25);+ addWidget(m_opacitySlider);++ m_seeThroughIcon_off = createQIcon("toggle_seethroughwin_off");+ m_seeThroughIcon_on = createQIcon("toggle_seethroughwin_on");++ QString tooltip =+ tr("Quickly toggle semi-transparent and full opaque.") + "\n" ++ tr("Hold ALT while clicking to use full transparency instead.") + "\n" ++ tr("When slider is at 100% it acts as ALT is held.");++ m_opacityBtn = new QPushButton(m_seeThroughIcon_on, "");+ m_opacityBtn->setCheckable(true);+ m_opacityBtn->setToolTip(tooltip);+ m_opacityBtn->setFocusPolicy(Qt::NoFocus);+ m_opacityBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);+ m_opacityBtn->setFixedWidth(25);+ m_opacityBtn->setMinimumHeight(25);+ addWidget(m_opacityBtn);++ endHLayout();++ m_closeBtn = new QPushButton(tr("Disable See Through Mode"));+ m_closeBtn->setDefault(true);+ m_closeBtn->setFocusPolicy(Qt::NoFocus);++ bool ret = true;++ ret = ret && connect(m_opacitySlider, SIGNAL(valueChanged(int)), this,+ SLOT(sliderChanged(int)));+ ret = ret &&+ connect(m_opacityBtn, SIGNAL(clicked()), this, SLOT(opacityToggle()));+ ret = ret && connect(m_closeBtn, SIGNAL(clicked()), this, SLOT(accept()));+ assert(ret);++ addButtonBarWidget(m_closeBtn);+}++//-----------------------------------------------------------------------------++void SeeThroughWindowPopup::toggleMode() { setVisible(!isVisible()); }++//-----------------------------------------------------------------------------++void SeeThroughWindowPopup::showEvent(QShowEvent *e) {+ sliderChanged(m_opacitySlider->value());+}++//-----------------------------------------------------------------------------++void SeeThroughWindowPopup::hideEvent(QHideEvent *e) {+ SeeThroughWindowOpacity = getOpacitySlider();+ TApp::instance()->getMainWindow()->setWindowOpacity(1.0);+}++//-----------------------------------------------------------------------------++int SeeThroughWindowPopup::getOpacitySlider() {+ return m_opacitySlider->value() * 2;+}++//-----------------------------------------------------------------------------++int SeeThroughWindowPopup::setOpacitySlider(int opacity) {+ int value = std::min(std::max((int)opacity / 2, 1), 50);+ m_opacitySlider->setValue(value);+ return value;+}++//-----------------------------------------------------------------------------++void SeeThroughWindowPopup::sliderChanged(int value) {+ int opacity = getOpacitySlider();+ TApp::instance()->getMainWindow()->setWindowOpacity((double)opacity / 100);+ m_opacitySlider->setToolTip(QString::number(opacity) + "%");+ if (m_opacityBtn->isChecked()) {+ m_opacityBtn->setChecked(false);+ m_opacityBtn->setIcon(m_seeThroughIcon_on);+ }+}++//-----------------------------------------------------------------------------++void SeeThroughWindowPopup::opacityToggle() {+ if (m_opacityBtn->isChecked()) {+ bool altMod = (QApplication::keyboardModifiers() & Qt::AltModifier);+ if (m_opacitySlider->value() >= m_opacitySlider->maximum()) altMod = true;+ TApp::instance()->getMainWindow()->setWindowOpacity(altMod ? 0.0 : 1.0);+ m_opacityBtn->setIcon(altMod ? QIcon() : m_seeThroughIcon_off);+ } else {+ sliderChanged(m_opacitySlider->value());+ m_opacityBtn->setIcon(m_seeThroughIcon_on);+ }+}diff --git a/toonz/sources/toonz/seethroughwindowpopup.h b/toonz/sources/toonz/seethroughwindowpopup.hnew file mode 100644index 000000000..eba26b6e1--- /dev/null+++ b/toonz/sources/toonz/seethroughwindowpopup.h@@ -0,0 +1,37 @@+#pragma once++#include "toonzqt/dvdialog.h"++#include <QLabel>+#include <QSlider>+#include <QPushButton>++class SeeThroughWindowPopup final : public DVGui::Dialog {+ Q_OBJECT++ int m_bckValue;++ QLabel *m_opacityLabel;+ QSlider *m_opacitySlider;+ QPushButton *m_opacityBtn;+ QPushButton *m_closeBtn;++ QIcon m_seeThroughIcon_off;+ QIcon m_seeThroughIcon_on;++public:+ SeeThroughWindowPopup();++ void toggleMode();++private:+ void showEvent(QShowEvent *e) override;+ void hideEvent(QHideEvent *e) override;++ int getOpacitySlider();+ int setOpacitySlider(int opacity);++private slots:+ void sliderChanged(int value);+ void opacityToggle();+};diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrcindex 18daa3a86..0eb2e78ba 100644--- a/toonz/sources/toonz/toonz.qrc+++ b/toonz/sources/toonz/toonz.qrc@@ -488,6 +488,8 @@<file>icons/dark/actions/16/console.svg</file><file>icons/dark/actions/16/pickscreen.svg</file><file>icons/dark/actions/16/toggle_fullscreen.svg</file>+ <file>icons/dark/actions/16/toggle_seethroughwin_on.svg</file>+ <file>icons/dark/actions/16/toggle_seethroughwin_off.svg</file><file>icons/dark/actions/16/schematic.svg</file><file>icons/dark/actions/16/viewer.svg</file><file>icons/dark/actions/16/comboviewer.svg</file>