diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xml index c4654a2..7becfab 100644 --- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml +++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml @@ -325,7 +325,8 @@ MI_OpenCustomPanels MI_MaximizePanel - MI_FullScreenWindow + MI_FullScreenWindow + MI_SeeThroughWindow MI_OpenOnlineManual diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt index ec21113..06ee949 100644 --- a/toonz/sources/toonz/CMakeLists.txt +++ b/toonz/sources/toonz/CMakeLists.txt @@ -86,6 +86,7 @@ set(MOC_HEADERS sceneviewer.h sceneviewercontextmenu.h scriptconsolepanel.h + seethroughwindowpopup.h separatecolorspopup.h separatecolorsswatch.h shortcutpopup.h @@ -287,6 +288,7 @@ set(SOURCES sceneviewercontextmenu.cpp scenesettingspopup.cpp scriptconsolepanel.cpp + seethroughwindowpopup.cpp shortcutpopup.cpp soundtrackexport.cpp startuppopup.cpp diff --git a/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_off.svg b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_off.svg new file mode 100644 index 0000000..dbae67b --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_off.svg @@ -0,0 +1,4 @@ + + + + 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.svg new file mode 100644 index 0000000..bacaf0b --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/toggle_seethroughwin_on.svg @@ -0,0 +1,4 @@ + + + + diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index 6381c69..23a6059 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.h index 3c56a20..50cf2a9 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.cpp index f829991..2bbf9db 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' HELP QMenu *helpMenu = addMenu(tr("Help"), fullMenuBar); diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h index 4b2b05b..f71838d 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.cpp new file mode 100644 index 0000000..8210eca --- /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 +#include +#include + +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.h new file mode 100644 index 0000000..eba26b6 --- /dev/null +++ b/toonz/sources/toonz/seethroughwindowpopup.h @@ -0,0 +1,37 @@ +#pragma once + +#include "toonzqt/dvdialog.h" + +#include +#include +#include + +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.qrc index 18daa3a..0eb2e78 100644 --- a/toonz/sources/toonz/toonz.qrc +++ b/toonz/sources/toonz/toonz.qrc @@ -488,6 +488,8 @@ icons/dark/actions/16/console.svg icons/dark/actions/16/pickscreen.svg icons/dark/actions/16/toggle_fullscreen.svg + icons/dark/actions/16/toggle_seethroughwin_on.svg + icons/dark/actions/16/toggle_seethroughwin_off.svg icons/dark/actions/16/schematic.svg icons/dark/actions/16/viewer.svg icons/dark/actions/16/comboviewer.svg