mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-11 22:14:31 +00:00
Add a "panic" button to reset screen/UI scaling options
This commit is contained in:
parent
68fa996cc6
commit
52260c466d
@ -15,6 +15,7 @@
|
|||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/ini_file.h"
|
#include "app/ini_file.h"
|
||||||
#include "app/modules/editors.h"
|
#include "app/modules/editors.h"
|
||||||
|
#include "app/notification_delegate.h"
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
#include "app/ui/color_bar.h"
|
#include "app/ui/color_bar.h"
|
||||||
#include "app/ui/context_bar.h"
|
#include "app/ui/context_bar.h"
|
||||||
@ -35,6 +36,7 @@
|
|||||||
#include "app/ui/workspace_tabs.h"
|
#include "app/ui/workspace_tabs.h"
|
||||||
#include "app/ui_context.h"
|
#include "app/ui_context.h"
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
#include "she/display.h"
|
||||||
#include "ui/message.h"
|
#include "ui/message.h"
|
||||||
#include "ui/splitter.h"
|
#include "ui/splitter.h"
|
||||||
#include "ui/system.h"
|
#include "ui/system.h"
|
||||||
@ -44,10 +46,51 @@ namespace app {
|
|||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
class ScreenScalePanic : public INotificationDelegate {
|
||||||
|
public:
|
||||||
|
std::string notificationText() override {
|
||||||
|
return "Reset Scale!";
|
||||||
|
}
|
||||||
|
|
||||||
|
void notificationClick() override {
|
||||||
|
auto& pref = Preferences::instance();
|
||||||
|
|
||||||
|
const int newScreenScale = 2;
|
||||||
|
const int newUIScale = 1;
|
||||||
|
bool needsRestart = false;
|
||||||
|
|
||||||
|
if (pref.general.screenScale() != newScreenScale)
|
||||||
|
pref.general.screenScale(newScreenScale);
|
||||||
|
|
||||||
|
if (pref.general.uiScale() != newUIScale) {
|
||||||
|
pref.general.uiScale(newUIScale);
|
||||||
|
needsRestart = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pref.save();
|
||||||
|
|
||||||
|
// If the UI scale is greater than 100%, we would like to avoid
|
||||||
|
// setting the Screen Scale to 200% right now to avoid a worse
|
||||||
|
// effect to the user. E.g. If the UI Scale is 400% and Screen
|
||||||
|
// Scale is 100%, and the user choose to reset the scale, we
|
||||||
|
// cannot change the Screen Scale to 200% (we're going to
|
||||||
|
// increase the problem), so we change the Screen Scale to 100%
|
||||||
|
// just to show the "restart" message.
|
||||||
|
Manager* manager = Manager::getDefault();
|
||||||
|
she::Display* display = manager->getDisplay();
|
||||||
|
display->setScale(ui::guiscale() > newUIScale ? 1: newScreenScale);
|
||||||
|
manager->setDisplay(display);
|
||||||
|
|
||||||
|
if (needsRestart)
|
||||||
|
Alert::show("Aseprite<<Restart the program.||&OK");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
: m_mode(NormalMode)
|
: m_mode(NormalMode)
|
||||||
, m_homeView(nullptr)
|
, m_homeView(nullptr)
|
||||||
, m_devConsoleView(nullptr)
|
, m_devConsoleView(nullptr)
|
||||||
|
, m_scalePanic(nullptr)
|
||||||
{
|
{
|
||||||
// Load all menus by first time.
|
// Load all menus by first time.
|
||||||
AppMenus::instance()->reload();
|
AppMenus::instance()->reload();
|
||||||
@ -104,6 +147,8 @@ MainWindow::MainWindow()
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
delete m_scalePanic;
|
||||||
|
|
||||||
if (m_devConsoleView) {
|
if (m_devConsoleView) {
|
||||||
if (m_devConsoleView->parent())
|
if (m_devConsoleView->parent())
|
||||||
m_workspace->removeView(m_devConsoleView);
|
m_workspace->removeView(m_devConsoleView);
|
||||||
@ -251,6 +296,20 @@ void MainWindow::onSaveLayout(SaveLayoutEvent& ev)
|
|||||||
Window::onSaveLayout(ev);
|
Window::onSaveLayout(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onResize(ui::ResizeEvent& ev)
|
||||||
|
{
|
||||||
|
app::gen::MainWindow::onResize(ev);
|
||||||
|
|
||||||
|
she::Display* display = manager()->getDisplay();
|
||||||
|
if ((display) &&
|
||||||
|
(display->scale()*ui::guiscale() > 2) &&
|
||||||
|
(!m_scalePanic) &&
|
||||||
|
(ui::display_w()/ui::guiscale() < 320 ||
|
||||||
|
ui::display_h()/ui::guiscale() < 260)) {
|
||||||
|
showNotification(m_scalePanic = new ScreenScalePanic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When the active view is changed from methods like
|
// When the active view is changed from methods like
|
||||||
// Workspace::splitView(), this function is called, and we have to
|
// Workspace::splitView(), this function is called, and we have to
|
||||||
// inform to the UIContext that the current view has changed.
|
// inform to the UIContext that the current view has changed.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2016 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -95,6 +95,7 @@ namespace app {
|
|||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(ui::Message* msg) override;
|
bool onProcessMessage(ui::Message* msg) override;
|
||||||
void onSaveLayout(ui::SaveLayoutEvent& ev) override;
|
void onSaveLayout(ui::SaveLayoutEvent& ev) override;
|
||||||
|
void onResize(ui::ResizeEvent& ev) override;
|
||||||
void onActiveViewChange();
|
void onActiveViewChange();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -115,6 +116,7 @@ namespace app {
|
|||||||
HomeView* m_homeView;
|
HomeView* m_homeView;
|
||||||
DevConsoleView* m_devConsoleView;
|
DevConsoleView* m_devConsoleView;
|
||||||
Notifications* m_notifications;
|
Notifications* m_notifications;
|
||||||
|
INotificationDelegate* m_scalePanic;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user