mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-18 21:40:46 +00:00
Adapt code to the new os::Display -> os::Window refactor
This commit is contained in:
parent
017a7320f9
commit
5d31314cdb
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 858e39c5eee871d940bba47edaf81c19b5976474
|
||||
Subproject commit 417ace74134d994db8223d91b6b13518cb4519f0
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -60,10 +60,10 @@
|
||||
#include "base/split_string.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
#include "os/display.h"
|
||||
#include "os/error.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "render/render.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/ui.h"
|
||||
@ -359,7 +359,7 @@ void App::run()
|
||||
if (isGui()) {
|
||||
#ifdef _WIN32
|
||||
// How to interpret one finger on Windows tablets.
|
||||
ui::Manager::getDefault()->getDisplay()
|
||||
ui::Manager::getDefault()->nativeWindow()
|
||||
->setInterpretOneFingerGestureAsMouseMovement(
|
||||
preferences().experimental.oneFingerAsMouseMovement());
|
||||
#endif
|
||||
@ -367,7 +367,7 @@ void App::run()
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
// Setup app icon for Linux window managers
|
||||
try {
|
||||
os::Display* display = os::instance()->defaultDisplay();
|
||||
os::Window* window = os::instance()->defaultWindow();
|
||||
os::SurfaceList icons;
|
||||
|
||||
for (const int size : { 32, 64, 128 }) {
|
||||
@ -380,7 +380,7 @@ void App::run()
|
||||
}
|
||||
}
|
||||
|
||||
display->setIcons(icons);
|
||||
window->setIcons(icons);
|
||||
}
|
||||
catch (const std::exception&) {
|
||||
// Just ignore the exception, we couldn't change the app icon, no
|
||||
@ -666,7 +666,7 @@ void App::updateDisplayTitleBar()
|
||||
}
|
||||
|
||||
title += defaultTitle;
|
||||
os::instance()->defaultDisplay()->setTitle(title);
|
||||
os::instance()->defaultWindow()->setTitle(title);
|
||||
}
|
||||
|
||||
InputChain& App::inputChain()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -14,8 +14,8 @@
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "os/display.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -35,7 +35,7 @@ void initialize_color_spaces(Preferences& pref)
|
||||
|
||||
os::ColorSpaceRef get_screen_color_space()
|
||||
{
|
||||
return os::instance()->defaultDisplay()->colorSpace();
|
||||
return os::instance()->defaultWindow()->colorSpace();
|
||||
}
|
||||
|
||||
os::ColorSpaceRef get_current_color_space()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -14,8 +14,8 @@
|
||||
#include "app/commands/command.h"
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/context.h"
|
||||
#include "os/display.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -43,13 +43,13 @@ void FullscreenModeCommand::onExecute(Context* ctx)
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
os::Display* display = manager->getDisplay();
|
||||
ASSERT(display);
|
||||
if (!display)
|
||||
os::Window* window = manager->nativeWindow();
|
||||
ASSERT(window);
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
display->setFullscreen(
|
||||
!display->isFullscreen());
|
||||
window->setFullscreen(
|
||||
!window->isFullscreen());
|
||||
}
|
||||
|
||||
Command* CommandFactory::createFullscreenModeCommand()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -38,8 +38,8 @@
|
||||
#include "base/version.h"
|
||||
#include "doc/image.h"
|
||||
#include "fmt/format.h"
|
||||
#include "os/display.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "render/render.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
@ -645,7 +645,7 @@ public:
|
||||
|
||||
if (j == winCs) {
|
||||
name = gfxCs->name();
|
||||
os::instance()->setDisplaysColorSpace(cs);
|
||||
os::instance()->setWindowsColorSpace(cs);
|
||||
break;
|
||||
}
|
||||
++j;
|
||||
@ -655,7 +655,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_displays_color_profile_from_preferences();
|
||||
update_windows_color_profile_from_preferences();
|
||||
|
||||
// Change sprite grid bounds
|
||||
if (m_context && m_context->activeDocument()) {
|
||||
@ -725,7 +725,7 @@ public:
|
||||
m_pref.tablet.api(tabletStr);
|
||||
m_pref.experimental.loadWintabDriver(wintabState);
|
||||
|
||||
manager()->getDisplay()
|
||||
manager()->nativeWindow()
|
||||
->setInterpretOneFingerGestureAsMouseMovement(
|
||||
oneFingerAsMouseMovement()->isSelected());
|
||||
|
||||
@ -845,10 +845,10 @@ private:
|
||||
|
||||
void updateScreenScaling() {
|
||||
ui::Manager* manager = ui::Manager::getDefault();
|
||||
os::Display* display = manager->getDisplay();
|
||||
os::Window* window = manager->nativeWindow();
|
||||
os::instance()->setGpuAcceleration(m_pref.general.gpuAcceleration());
|
||||
display->setScale(m_pref.general.screenScale());
|
||||
manager->setDisplay(display);
|
||||
window->setScale(m_pref.general.screenScale());
|
||||
manager->setNativeWindow(window);
|
||||
}
|
||||
|
||||
void onApply() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -25,8 +25,8 @@
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
#include "os/display.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/alert.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/scale.h"
|
||||
@ -69,8 +69,8 @@ void ScreenshotCommand::onExecute(Context* ctx)
|
||||
app::ResourceFinder rf(false);
|
||||
rf.includeDesktopDir("");
|
||||
|
||||
os::Display* display = ui::Manager::getDefault()->getDisplay();
|
||||
os::Surface* surface = display->surface();
|
||||
os::Window* window = ui::Manager::getDefault()->nativeWindow();
|
||||
os::Surface* surface = window->surface();
|
||||
std::string fn;
|
||||
|
||||
if (params().save()) {
|
||||
@ -89,7 +89,7 @@ void ScreenshotCommand::onExecute(Context* ctx)
|
||||
surface->width(),
|
||||
surface->height(),
|
||||
0, // Mask color
|
||||
display->colorSpace()->gfxColorSpace());
|
||||
window->colorSpace()->gfxColorSpace());
|
||||
|
||||
doc::Sprite* spr = doc::Sprite::MakeStdSprite(spec);
|
||||
static_cast<doc::LayerImage*>(spr->firstLayer())->configureAsBackground();
|
||||
@ -122,7 +122,7 @@ void ScreenshotCommand::onExecute(Context* ctx)
|
||||
// Get image again (cmd::convert_color_profile() might have changed it)
|
||||
img = cel->image();
|
||||
|
||||
const int scale = display->scale();
|
||||
const int scale = window->scale();
|
||||
base::buffer rgbBuffer(3*w*h*scale*scale);
|
||||
int c = 0;
|
||||
doc::LockImageBits<RgbTraits> bits(img);
|
||||
|
@ -123,7 +123,7 @@ Console::Console(Context* ctx)
|
||||
(App::instance() &&
|
||||
App::instance()->isGui() &&
|
||||
Manager::getDefault() &&
|
||||
Manager::getDefault()->getDisplay());
|
||||
Manager::getDefault()->nativeWindow());
|
||||
|
||||
if (!m_withUI)
|
||||
return;
|
||||
|
@ -30,11 +30,11 @@
|
||||
#include "doc/mask.h"
|
||||
#include "doc/mask_boundaries.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/slice.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "doc/tag.h"
|
||||
#include "doc/slice.h"
|
||||
#include "os/display.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/system.h"
|
||||
|
||||
#include <limits>
|
||||
@ -612,8 +612,8 @@ void Doc::updateOSColorSpace(bool appWideSignal)
|
||||
auto system = os::instance();
|
||||
if (system) {
|
||||
m_osColorSpace = system->makeColorSpace(sprite()->colorSpace());
|
||||
if (!m_osColorSpace && system->defaultDisplay())
|
||||
m_osColorSpace = system->defaultDisplay()->colorSpace();
|
||||
if (!m_osColorSpace && system->defaultWindow())
|
||||
m_osColorSpace = system->defaultWindow()->colorSpace();
|
||||
}
|
||||
|
||||
if (appWideSignal &&
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -14,9 +14,9 @@
|
||||
#include "app/app.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/file_selector.h"
|
||||
#include "os/display.h"
|
||||
#include "os/native_dialogs.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -59,7 +59,7 @@ bool show_file_selector(
|
||||
if (!defExtension.empty())
|
||||
dlg->setDefaultExtension(defExtension);
|
||||
|
||||
bool res = dlg->show(os::instance()->defaultDisplay());
|
||||
bool res = dlg->show(os::instance()->defaultWindow());
|
||||
if (res) {
|
||||
if (type == FileSelectorType::OpenMultiple)
|
||||
dlg->getMultipleFileNames(output);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -19,9 +19,9 @@
|
||||
|
||||
#include "base/fs.h"
|
||||
#include "base/string.h"
|
||||
#include "os/display.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
@ -455,7 +455,8 @@ const FileItemList& FileItem::children()
|
||||
ULONG c, fetched;
|
||||
|
||||
// Get the interface to enumerate subitems
|
||||
hr = pFolder->EnumObjects(reinterpret_cast<HWND>(os::instance()->defaultDisplay()->nativeHandle()),
|
||||
hr = pFolder->EnumObjects(
|
||||
reinterpret_cast<HWND>(os::instance()->defaultWindow()->nativeHandle()),
|
||||
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnum);
|
||||
|
||||
if (hr == S_OK && pEnum != NULL) {
|
||||
|
@ -42,10 +42,10 @@
|
||||
#include "base/memory.h"
|
||||
#include "base/string.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "os/display.h"
|
||||
#include "os/error.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
@ -97,7 +97,7 @@ protected:
|
||||
void saveLayout(Widget* widget, const std::string& str) override;
|
||||
};
|
||||
|
||||
static os::DisplayRef main_display = nullptr;
|
||||
static os::WindowRef main_window = nullptr;
|
||||
static CustomizedGuiManager* manager = nullptr;
|
||||
static Theme* gui_theme = nullptr;
|
||||
|
||||
@ -109,7 +109,7 @@ static void load_gui_config(int& w, int& h, bool& maximized,
|
||||
std::string& windowLayout);
|
||||
static void save_gui_config();
|
||||
|
||||
static bool create_main_display(bool gpuAccel,
|
||||
static bool create_main_window(bool gpuAccel,
|
||||
bool& maximized,
|
||||
std::string& lastError)
|
||||
{
|
||||
@ -125,44 +125,44 @@ static bool create_main_display(bool gpuAccel,
|
||||
|
||||
try {
|
||||
if (w > 0 && h > 0) {
|
||||
main_display = os::instance()->makeDisplay(
|
||||
main_window = os::instance()->makeWindow(
|
||||
w, h, (scale == 0 ? 2: base::clamp(scale, 1, 4)));
|
||||
}
|
||||
}
|
||||
catch (const os::DisplayCreationException& e) {
|
||||
catch (const os::WindowCreationException& e) {
|
||||
lastError = e.what();
|
||||
}
|
||||
|
||||
if (!main_display) {
|
||||
if (!main_window) {
|
||||
for (int c=0; try_resolutions[c].width; ++c) {
|
||||
try {
|
||||
main_display =
|
||||
os::instance()->makeDisplay(
|
||||
main_window =
|
||||
os::instance()->makeWindow(
|
||||
try_resolutions[c].width,
|
||||
try_resolutions[c].height,
|
||||
(scale == 0 ? try_resolutions[c].scale: scale));
|
||||
break;
|
||||
}
|
||||
catch (const os::DisplayCreationException& e) {
|
||||
catch (const os::WindowCreationException& e) {
|
||||
lastError = e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (main_display) {
|
||||
if (main_window) {
|
||||
// Change the scale value only in the first run (this will be
|
||||
// saved when the program is closed).
|
||||
if (scale == 0)
|
||||
Preferences::instance().general.screenScale(main_display->scale());
|
||||
Preferences::instance().general.screenScale(main_window->scale());
|
||||
|
||||
if (!windowLayout.empty()) {
|
||||
main_display->setLayout(windowLayout);
|
||||
if (main_display->isMinimized())
|
||||
main_display->maximize();
|
||||
main_window->setLayout(windowLayout);
|
||||
if (main_window->isMinimized())
|
||||
main_window->maximize();
|
||||
}
|
||||
}
|
||||
|
||||
return (main_display != nullptr);
|
||||
return (main_window != nullptr);
|
||||
}
|
||||
|
||||
// Initializes GUI.
|
||||
@ -173,40 +173,40 @@ int init_module_gui()
|
||||
std::string lastError = "Unknown error";
|
||||
bool gpuAccel = pref.general.gpuAcceleration();
|
||||
|
||||
if (!create_main_display(gpuAccel, maximized, lastError)) {
|
||||
// If we've created the display with hardware acceleration,
|
||||
if (!create_main_window(gpuAccel, maximized, lastError)) {
|
||||
// If we've created the native window with hardware acceleration,
|
||||
// now we try to do it without hardware acceleration.
|
||||
if (gpuAccel &&
|
||||
(int(os::instance()->capabilities()) &
|
||||
int(os::Capabilities::GpuAccelerationSwitch)) == int(os::Capabilities::GpuAccelerationSwitch)) {
|
||||
if (create_main_display(false, maximized, lastError)) {
|
||||
if (create_main_window(false, maximized, lastError)) {
|
||||
// Disable hardware acceleration
|
||||
pref.general.gpuAcceleration(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!main_display) {
|
||||
if (!main_window) {
|
||||
os::error_message(
|
||||
("Unable to create a user-interface display.\nDetails: "+lastError+"\n").c_str());
|
||||
("Unable to create a user-interface window.\nDetails: "+lastError+"\n").c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create the default-manager
|
||||
manager = new CustomizedGuiManager();
|
||||
manager->setDisplay(main_display.get());
|
||||
manager->setNativeWindow(main_window.get());
|
||||
|
||||
// Setup the GUI theme for all widgets
|
||||
gui_theme = new SkinTheme;
|
||||
ui::set_theme(gui_theme, pref.general.uiScale());
|
||||
|
||||
if (maximized)
|
||||
main_display->maximize();
|
||||
main_window->maximize();
|
||||
|
||||
// Handle live resize too redraw the entire manager, dispatch the UI
|
||||
// messages, and flip the display.
|
||||
main_display->handleResize =
|
||||
[](os::Display* display) {
|
||||
// messages, and flip the window.
|
||||
main_window->handleResize =
|
||||
[](os::Window* window) {
|
||||
manager->invalidate();
|
||||
|
||||
Message* msg = new Message(kResizeDisplayMessage);
|
||||
@ -221,7 +221,7 @@ int init_module_gui()
|
||||
// Set graphics options for next time
|
||||
save_gui_config();
|
||||
|
||||
update_displays_color_profile_from_preferences();
|
||||
update_windows_color_profile_from_preferences();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -238,10 +238,10 @@ void exit_module_gui()
|
||||
delete gui_theme;
|
||||
|
||||
// This should be the last unref() of the display to delete it.
|
||||
main_display.reset();
|
||||
main_window.reset();
|
||||
}
|
||||
|
||||
void update_displays_color_profile_from_preferences()
|
||||
void update_windows_color_profile_from_preferences()
|
||||
{
|
||||
auto system = os::instance();
|
||||
|
||||
@ -253,10 +253,10 @@ void update_displays_color_profile_from_preferences()
|
||||
|
||||
switch (windowProfile) {
|
||||
case gen::WindowColorProfile::MONITOR:
|
||||
system->setDisplaysColorSpace(nullptr);
|
||||
system->setWindowsColorSpace(nullptr);
|
||||
break;
|
||||
case gen::WindowColorProfile::SRGB:
|
||||
system->setDisplaysColorSpace(
|
||||
system->setWindowsColorSpace(
|
||||
system->makeColorSpace(gfx::ColorSpace::MakeSRGB()));
|
||||
break;
|
||||
case gen::WindowColorProfile::SPECIFIC: {
|
||||
@ -270,7 +270,7 @@ void update_displays_color_profile_from_preferences()
|
||||
auto gfxCs = cs->gfxColorSpace();
|
||||
if (gfxCs->type() == gfx::ColorSpace::ICC &&
|
||||
gfxCs->name() == name) {
|
||||
system->setDisplaysColorSpace(cs);
|
||||
system->setWindowsColorSpace(cs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ void update_displays_color_profile_from_preferences()
|
||||
static void load_gui_config(int& w, int& h, bool& maximized,
|
||||
std::string& windowLayout)
|
||||
{
|
||||
gfx::Size defSize = os::instance()->defaultNewDisplaySize();
|
||||
gfx::Size defSize = os::instance()->defaultNewWindowSize();
|
||||
|
||||
w = get_config_int("GfxMode", "Width", defSize.w);
|
||||
h = get_config_int("GfxMode", "Height", defSize.h);
|
||||
@ -292,13 +292,13 @@ static void load_gui_config(int& w, int& h, bool& maximized,
|
||||
|
||||
static void save_gui_config()
|
||||
{
|
||||
os::Display* display = manager->getDisplay();
|
||||
if (display) {
|
||||
set_config_bool("GfxMode", "Maximized", display->isMaximized());
|
||||
set_config_int("GfxMode", "Width", display->originalWidth());
|
||||
set_config_int("GfxMode", "Height", display->originalHeight());
|
||||
os::Window* window = manager->nativeWindow();
|
||||
if (window) {
|
||||
set_config_bool("GfxMode", "Maximized", window->isMaximized());
|
||||
set_config_int("GfxMode", "Width", window->originalWidth());
|
||||
set_config_int("GfxMode", "Height", window->originalHeight());
|
||||
|
||||
std::string windowLayout = display->getLayout();
|
||||
std::string windowLayout = window->getLayout();
|
||||
if (!windowLayout.empty())
|
||||
set_config_string("GfxMode", "WindowLayout", windowLayout.c_str());
|
||||
}
|
||||
@ -575,8 +575,8 @@ bool CustomizedGuiManager::onProcessDevModeKeyDown(KeyMessage* msg)
|
||||
if (msg->ctrlPressed() &&
|
||||
msg->scancode() == kKeyF1) {
|
||||
try {
|
||||
os::Display* display = getDisplay();
|
||||
int screenScale = display->scale();
|
||||
os::Window* window = nativeWindow();
|
||||
int screenScale = window->scale();
|
||||
int uiScale = ui::guiscale();
|
||||
|
||||
if (msg->shiftPressed()) {
|
||||
@ -611,9 +611,9 @@ bool CustomizedGuiManager::onProcessDevModeKeyDown(KeyMessage* msg)
|
||||
if (uiScale != ui::guiscale()) {
|
||||
ui::set_theme(ui::get_theme(), uiScale);
|
||||
}
|
||||
if (screenScale != display->scale()) {
|
||||
display->setScale(screenScale);
|
||||
setDisplay(display);
|
||||
if (screenScale != window->scale()) {
|
||||
window->setScale(screenScale);
|
||||
setWindow(window);
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
@ -659,7 +659,7 @@ void CustomizedGuiManager::onNewDisplayConfiguration()
|
||||
save_gui_config();
|
||||
|
||||
// TODO Should we provide a more generic way for all ui::Window to
|
||||
// detect the ui::Display (or UI Screen Scaling) change?
|
||||
// detect the os::Window (or UI Screen Scaling) change?
|
||||
Console::notifyNewDisplayConfiguration();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -35,7 +35,7 @@ namespace app {
|
||||
int init_module_gui();
|
||||
void exit_module_gui();
|
||||
|
||||
void update_displays_color_profile_from_preferences();
|
||||
void update_windows_color_profile_from_preferences();
|
||||
void update_screen_for_document(const Doc* document);
|
||||
|
||||
void load_window_pos(ui::Widget* window, const char* section,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -39,7 +39,6 @@
|
||||
#include "doc/layer.h"
|
||||
#include "doc/primitives.h"
|
||||
#include "gfx/rect_io.h"
|
||||
#include "os/display.h"
|
||||
#include "render/render.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/system.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -61,7 +61,6 @@
|
||||
#include "doc/slice.h"
|
||||
#include "fmt/format.h"
|
||||
#include "os/color_space.h"
|
||||
#include "os/display.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "render/rasterize.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -16,7 +17,7 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "os/display.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/system.h"
|
||||
@ -66,7 +67,7 @@ bool ZoomingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
||||
bool ZoomingState::onMouseMove(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
gfx::Point pt = (msg->position() - m_startPos);
|
||||
int threshold = 8 * guiscale() * editor->manager()->getDisplay()->scale();
|
||||
int threshold = 8 * guiscale() * editor->manager()->nativeWindow()->scale();
|
||||
|
||||
if (m_moved || std::sqrt(pt.x*pt.x + pt.y*pt.y) > threshold) {
|
||||
m_moved = true;
|
||||
|
@ -39,8 +39,8 @@
|
||||
#include "app/ui/workspace_tabs.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/fs.h"
|
||||
#include "os/display.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/splitter.h"
|
||||
#include "ui/system.h"
|
||||
@ -78,9 +78,9 @@ public:
|
||||
ui::set_theme(ui::get_theme(), newUIScale);
|
||||
|
||||
Manager* manager = Manager::getDefault();
|
||||
os::Display* display = manager->getDisplay();
|
||||
display->setScale(newScreenScale);
|
||||
manager->setDisplay(display);
|
||||
os::Window* window = manager->nativeWindow();
|
||||
window->setScale(newScreenScale);
|
||||
manager->setNativeWindow(window);
|
||||
}
|
||||
};
|
||||
|
||||
@ -370,9 +370,9 @@ void MainWindow::onResize(ui::ResizeEvent& ev)
|
||||
{
|
||||
app::gen::MainWindow::onResize(ev);
|
||||
|
||||
os::Display* display = manager()->getDisplay();
|
||||
if ((display) &&
|
||||
(display->scale()*ui::guiscale() > 2) &&
|
||||
os::Window* window = manager()->nativeWindow();
|
||||
if ((window) &&
|
||||
(window->scale()*ui::guiscale() > 2) &&
|
||||
(!m_scalePanic) &&
|
||||
(ui::display_w()/ui::guiscale() < 320 ||
|
||||
ui::display_h()/ui::guiscale() < 260)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -22,8 +22,8 @@
|
||||
#include "doc/palette_io.h"
|
||||
#include "doc/tileset_io.h"
|
||||
#include "gfx/size.h"
|
||||
#include "os/display.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/alert.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -37,8 +37,8 @@ using namespace base::serialization::little_endian;
|
||||
namespace {
|
||||
clip::format custom_image_format = 0;
|
||||
|
||||
void* native_display_handle() {
|
||||
return os::instance()->defaultDisplay()->nativeHandle();
|
||||
void* native_window_handle() {
|
||||
return os::instance()->defaultWindow()->nativeHandle();
|
||||
}
|
||||
|
||||
void custom_error_handler(clip::ErrorCode code) {
|
||||
@ -70,7 +70,7 @@ bool Clipboard::setNativeBitmap(const doc::Image* image,
|
||||
const doc::Palette* palette,
|
||||
const doc::Tileset* tileset)
|
||||
{
|
||||
clip::lock l(native_display_handle());
|
||||
clip::lock l(native_window_handle());
|
||||
if (!l.locked())
|
||||
return false;
|
||||
|
||||
@ -177,7 +177,7 @@ bool Clipboard::getNativeBitmap(doc::Image** image,
|
||||
*palette = nullptr;
|
||||
*tileset = nullptr;
|
||||
|
||||
clip::lock l(native_display_handle());
|
||||
clip::lock l(native_window_handle());
|
||||
if (!l.locked())
|
||||
return false;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2018-2020 Igara Studio S.A.
|
||||
Copyright (c) 2018-2021 Igara Studio S.A.
|
||||
Copyright (c) 2001-2018 David Capello
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -19,11 +19,11 @@
|
||||
#include "gfx/rect.h"
|
||||
#include "gfx/region.h"
|
||||
#include "gfx/size.h"
|
||||
#include "os/display.h"
|
||||
#include "os/draw_text.h"
|
||||
#include "os/font.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/scale.h"
|
||||
#include "ui/theme.h"
|
||||
@ -45,7 +45,7 @@ Graphics::~Graphics()
|
||||
{
|
||||
// If we were drawing in the screen surface, we mark these regions
|
||||
// as dirty for the final flip.
|
||||
if (m_surface == os::instance()->defaultDisplay()->surface())
|
||||
if (m_surface == os::instance()->defaultWindow()->surface())
|
||||
Manager::getDefault()->dirtyRect(m_dirtyBounds);
|
||||
}
|
||||
|
||||
@ -612,7 +612,7 @@ void Graphics::dirty(const gfx::Rect& bounds)
|
||||
// ScreenGraphics
|
||||
|
||||
ScreenGraphics::ScreenGraphics()
|
||||
: Graphics(AddRef(os::instance()->defaultDisplay()->surface()), 0, 0)
|
||||
: Graphics(AddRef(os::instance()->defaultWindow()->surface()), 0, 0)
|
||||
{
|
||||
setFont(AddRef(get_theme()->getDefaultFont()));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -22,11 +22,11 @@
|
||||
#include "base/concurrent_queue.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "base/time.h"
|
||||
#include "os/display.h"
|
||||
#include "os/event.h"
|
||||
#include "os/event_queue.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
@ -162,7 +162,7 @@ bool Manager::widgetAssociatedToManager(Widget* widget)
|
||||
|
||||
Manager::Manager()
|
||||
: Widget(kManagerWidget)
|
||||
, m_display(nullptr)
|
||||
, m_window(nullptr)
|
||||
, m_eventQueue(nullptr)
|
||||
, m_lockedWindow(nullptr)
|
||||
, m_mouseButton(kButtonNone)
|
||||
@ -226,13 +226,13 @@ Manager::~Manager()
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::setDisplay(os::Display* display)
|
||||
void Manager::setNativeWindow(os::Window* window)
|
||||
{
|
||||
base::ScopedValue<bool> lock(
|
||||
auto_window_adjustment, false,
|
||||
auto_window_adjustment);
|
||||
|
||||
m_display = display;
|
||||
m_window = window;
|
||||
m_eventQueue = os::instance()->eventQueue();
|
||||
|
||||
onNewDisplayConfiguration();
|
||||
@ -255,7 +255,7 @@ void Manager::run()
|
||||
|
||||
void Manager::flipDisplay()
|
||||
{
|
||||
if (!m_display)
|
||||
if (!m_window)
|
||||
return;
|
||||
|
||||
OverlayManager* overlays = OverlayManager::instance();
|
||||
@ -271,7 +271,7 @@ void Manager::flipDisplay()
|
||||
gfx::Region(gfx::Rect(0, 0, ui::display_w(), ui::display_h())));
|
||||
|
||||
if (!m_dirtyRegion.isEmpty()) {
|
||||
m_display->invalidateRegion(m_dirtyRegion);
|
||||
m_window->invalidateRegion(m_dirtyRegion);
|
||||
m_dirtyRegion.clear();
|
||||
}
|
||||
}
|
||||
@ -385,7 +385,7 @@ void Manager::generateMessagesFromOSEvents()
|
||||
break;
|
||||
}
|
||||
|
||||
case os::Event::CloseDisplay: {
|
||||
case os::Event::CloseWindow: {
|
||||
Message* msg = new Message(kCloseDisplayMessage);
|
||||
msg->setRecipient(this);
|
||||
msg->setPropagateToChildren(true);
|
||||
@ -393,7 +393,7 @@ void Manager::generateMessagesFromOSEvents()
|
||||
break;
|
||||
}
|
||||
|
||||
case os::Event::ResizeDisplay: {
|
||||
case os::Event::ResizeWindow: {
|
||||
Message* msg = new Message(kResizeDisplayMessage);
|
||||
msg->setRecipient(this);
|
||||
msg->setPropagateToChildren(true);
|
||||
@ -888,7 +888,7 @@ void Manager::setCapture(Widget* widget)
|
||||
widget->enableFlags(HAS_CAPTURE);
|
||||
capture_widget = widget;
|
||||
|
||||
m_display->captureMouse();
|
||||
m_window->captureMouse();
|
||||
}
|
||||
|
||||
// Sets the focus to the "magnetic" widget inside the window
|
||||
@ -928,7 +928,7 @@ void Manager::freeCapture()
|
||||
capture_widget->disableFlags(HAS_CAPTURE);
|
||||
capture_widget = nullptr;
|
||||
|
||||
m_display->releaseMouse();
|
||||
m_window->releaseMouse();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1309,8 +1309,8 @@ void Manager::onInitTheme(InitThemeEvent& ev)
|
||||
gfx::Rect bounds = window->bounds();
|
||||
bounds *= newUIScale;
|
||||
bounds /= oldUIScale;
|
||||
bounds.x = base::clamp(bounds.x, 0, m_display->width() - bounds.w);
|
||||
bounds.y = base::clamp(bounds.y, 0, m_display->height() - bounds.h);
|
||||
bounds.x = base::clamp(bounds.x, 0, m_window->width() - bounds.w);
|
||||
bounds.y = base::clamp(bounds.y, 0, m_window->height() - bounds.h);
|
||||
window->setBounds(bounds);
|
||||
}
|
||||
}
|
||||
@ -1324,16 +1324,16 @@ LayoutIO* Manager::onGetLayoutIO()
|
||||
|
||||
void Manager::onNewDisplayConfiguration()
|
||||
{
|
||||
if (m_display) {
|
||||
int w = m_display->width() / m_display->scale();
|
||||
int h = m_display->height() / m_display->scale();
|
||||
if (m_window) {
|
||||
int w = m_window->width() / m_window->scale();
|
||||
int h = m_window->height() / m_window->scale();
|
||||
if ((bounds().w != w ||
|
||||
bounds().h != h)) {
|
||||
setBounds(gfx::Rect(0, 0, w, h));
|
||||
}
|
||||
}
|
||||
|
||||
_internal_set_mouse_display(m_display);
|
||||
_internal_set_mouse_window(m_window);
|
||||
invalidate();
|
||||
flushRedraw();
|
||||
}
|
||||
@ -1500,7 +1500,7 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
||||
// Restore overlays in the region that we're going to paint.
|
||||
OverlayManager::instance()->restoreOverlappedAreas(paintMsg->rect());
|
||||
|
||||
os::Surface* surface = m_display->surface();
|
||||
os::Surface* surface = m_window->surface();
|
||||
surface->saveClip();
|
||||
|
||||
if (surface->clipRect(paintMsg->rect())) {
|
||||
@ -1519,10 +1519,10 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
|
||||
surface->fillRect(gfx::rgba(0, 0, 255), paintMsg->rect());
|
||||
}
|
||||
|
||||
if (m_display) {
|
||||
m_display->invalidateRegion(
|
||||
if (m_window) {
|
||||
m_window->invalidateRegion(
|
||||
gfx::Region(gfx::Rect(0, 0, display_w(), display_h())));
|
||||
// TODO m_display->update() ??
|
||||
// TODO m_window->update() ??
|
||||
}
|
||||
|
||||
base::this_thread::sleep_for(0.002);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -17,8 +17,8 @@
|
||||
#include "ui/widget.h"
|
||||
|
||||
namespace os {
|
||||
class Display;
|
||||
class EventQueue;
|
||||
class Window;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
@ -35,9 +35,8 @@ namespace ui {
|
||||
Manager();
|
||||
~Manager();
|
||||
|
||||
os::Display* getDisplay() { return m_display; }
|
||||
|
||||
void setDisplay(os::Display* display);
|
||||
os::Window* nativeWindow() { return m_window; }
|
||||
void setNativeWindow(os::Window* window);
|
||||
|
||||
// Executes the main message loop.
|
||||
void run();
|
||||
@ -168,7 +167,7 @@ namespace ui {
|
||||
static gfx::Region m_dirtyRegion;
|
||||
|
||||
WidgetsList m_garbage;
|
||||
os::Display* m_display;
|
||||
os::Window* m_window;
|
||||
os::EventQueue* m_eventQueue;
|
||||
gfx::Region m_invalidRegion; // Invalid region (we didn't receive paint messages yet for this).
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,9 +11,9 @@
|
||||
|
||||
#include "ui/manager.h"
|
||||
|
||||
#include "os/display.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/overlay_manager.h"
|
||||
|
||||
#include <vector>
|
||||
@ -24,9 +24,9 @@ using namespace gfx;
|
||||
|
||||
void move_region(Manager* manager, const Region& region, int dx, int dy)
|
||||
{
|
||||
os::Display* display = manager->getDisplay();
|
||||
ASSERT(display);
|
||||
if (!display)
|
||||
os::Window* window = manager->nativeWindow();
|
||||
ASSERT(window);
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
auto overlays = ui::OverlayManager::instance();
|
||||
@ -34,7 +34,7 @@ void move_region(Manager* manager, const Region& region, int dx, int dy)
|
||||
bounds |= gfx::Rect(bounds).offset(dx, dy);
|
||||
overlays->restoreOverlappedAreas(bounds);
|
||||
|
||||
os::Surface* surface = display->surface();
|
||||
os::Surface* surface = window->surface();
|
||||
os::SurfaceLock lock(surface);
|
||||
|
||||
// Fast path, move one rectangle.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -11,8 +11,8 @@
|
||||
|
||||
#include "ui/overlay_manager.h"
|
||||
|
||||
#include "os/display.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/overlay.h"
|
||||
|
||||
@ -86,11 +86,11 @@ void OverlayManager::drawOverlays()
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
os::Surface* displaySurface = manager->getDisplay()->surface();
|
||||
os::SurfaceLock lock(displaySurface);
|
||||
os::Surface* windowSurface = manager->nativeWindow()->surface();
|
||||
os::SurfaceLock lock(windowSurface);
|
||||
|
||||
for (auto& overlay : *this)
|
||||
overlay->captureOverlappedArea(displaySurface);
|
||||
overlay->captureOverlappedArea(windowSurface);
|
||||
|
||||
for (auto& overlay : *this)
|
||||
overlay->drawOverlay();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -13,11 +13,11 @@
|
||||
|
||||
#include "base/thread.h"
|
||||
#include "gfx/point.h"
|
||||
#include "os/display.h"
|
||||
#include "os/event.h"
|
||||
#include "os/event_queue.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/clipboard_delegate.h"
|
||||
#include "ui/cursor.h"
|
||||
#include "ui/intern.h"
|
||||
@ -40,7 +40,7 @@ base::thread::native_id_type main_gui_thread;
|
||||
static CursorType mouse_cursor_type = kOutsideDisplay;
|
||||
static const Cursor* mouse_cursor_custom = nullptr;
|
||||
static const Cursor* mouse_cursor = nullptr;
|
||||
static os::Display* mouse_display = nullptr;
|
||||
static os::Window* mouse_window = nullptr;
|
||||
static OverlayRef mouse_cursor_overlay = nullptr;
|
||||
static bool use_native_mouse_cursor = true;
|
||||
static bool support_native_custom_cursor = false;
|
||||
@ -83,20 +83,20 @@ static bool update_custom_native_cursor(const Cursor* cursor)
|
||||
|
||||
// Check if we can use a custom native mouse in this platform
|
||||
if (support_native_custom_cursor &&
|
||||
mouse_display) {
|
||||
mouse_window) {
|
||||
if (cursor) {
|
||||
result = mouse_display->setNativeMouseCursor(
|
||||
result = mouse_window->setNativeMouseCursor(
|
||||
// The surface is already scaled by guiscale()
|
||||
cursor->getSurface().get(),
|
||||
cursor->getFocus(),
|
||||
// We scale the cursor by the os::Display scale
|
||||
mouse_display->scale() * mouse_cursor_scale);
|
||||
mouse_window->scale() * mouse_cursor_scale);
|
||||
}
|
||||
else if (mouse_cursor_type == kOutsideDisplay) {
|
||||
result = mouse_display->setNativeMouseCursor(os::kArrowCursor);
|
||||
result = mouse_window->setNativeMouseCursor(os::kArrowCursor);
|
||||
}
|
||||
else {
|
||||
result = mouse_display->setNativeMouseCursor(os::kNoCursor);
|
||||
result = mouse_window->setNativeMouseCursor(os::kNoCursor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,8 +146,8 @@ static void update_mouse_cursor()
|
||||
}
|
||||
|
||||
// Set native cursor
|
||||
if (mouse_display) {
|
||||
bool ok = mouse_display->setNativeMouseCursor(nativeCursor);
|
||||
if (mouse_window) {
|
||||
bool ok = mouse_window->setNativeMouseCursor(nativeCursor);
|
||||
|
||||
// It looks like the specific native cursor is not supported,
|
||||
// so we can should use the internal overlay (even when we
|
||||
@ -207,7 +207,7 @@ UISystem::~UISystem()
|
||||
|
||||
details::exitWidgets();
|
||||
|
||||
_internal_set_mouse_display(nullptr);
|
||||
_internal_set_mouse_window(nullptr);
|
||||
if (!update_custom_native_cursor(nullptr))
|
||||
update_mouse_overlay(nullptr);
|
||||
|
||||
@ -215,27 +215,27 @@ UISystem::~UISystem()
|
||||
g_instance = nullptr;
|
||||
}
|
||||
|
||||
void _internal_set_mouse_display(os::Display* display)
|
||||
void _internal_set_mouse_window(os::Window* window)
|
||||
{
|
||||
CursorType cursor = get_mouse_cursor();
|
||||
set_mouse_cursor(kNoCursor);
|
||||
mouse_display = display;
|
||||
if (display)
|
||||
mouse_window = window;
|
||||
if (window)
|
||||
set_mouse_cursor(cursor); // Restore mouse cursor
|
||||
}
|
||||
|
||||
int display_w()
|
||||
{
|
||||
if (mouse_display)
|
||||
return mouse_display->width() / mouse_display->scale();
|
||||
if (mouse_window)
|
||||
return mouse_window->width() / mouse_window->scale();
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
int display_h()
|
||||
{
|
||||
if (mouse_display)
|
||||
return mouse_display->height() / mouse_display->scale();
|
||||
if (mouse_window)
|
||||
return mouse_window->height() / mouse_window->scale();
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
@ -331,8 +331,8 @@ const gfx::Point& get_mouse_position()
|
||||
|
||||
void set_mouse_position(const gfx::Point& newPos)
|
||||
{
|
||||
if (mouse_display)
|
||||
mouse_display->setMousePosition(newPos);
|
||||
if (mouse_window)
|
||||
mouse_window->setMousePosition(newPos);
|
||||
|
||||
_internal_set_mouse_position(newPos);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -16,7 +16,7 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace os { class Display; }
|
||||
namespace os { class Window; }
|
||||
|
||||
namespace ui {
|
||||
|
||||
@ -61,7 +61,7 @@ namespace ui {
|
||||
void hide_mouse_cursor();
|
||||
void show_mouse_cursor();
|
||||
|
||||
void _internal_set_mouse_display(os::Display* display);
|
||||
void _internal_set_mouse_window(os::Window* window);
|
||||
void _internal_no_mouse_position();
|
||||
void _internal_set_mouse_position(const gfx::Point& newPos);
|
||||
|
||||
|
@ -16,10 +16,10 @@
|
||||
#include "base/clamp.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/string.h"
|
||||
#include "os/display.h"
|
||||
#include "os/font.h"
|
||||
#include "os/surface.h"
|
||||
#include "os/system.h"
|
||||
#include "os/window.h"
|
||||
#include "ui/init_theme_event.h"
|
||||
#include "ui/intern.h"
|
||||
#include "ui/layout_io.h"
|
||||
@ -28,9 +28,9 @@
|
||||
#include "ui/message.h"
|
||||
#include "ui/move_region.h"
|
||||
#include "ui/paint_event.h"
|
||||
#include "ui/size_hint_event.h"
|
||||
#include "ui/resize_event.h"
|
||||
#include "ui/save_layout_event.h"
|
||||
#include "ui/size_hint_event.h"
|
||||
#include "ui/system.h"
|
||||
#include "ui/theme.h"
|
||||
#include "ui/view.h"
|
||||
@ -1158,7 +1158,7 @@ public:
|
||||
|
||||
void operator()(Graphics* graphics) {
|
||||
{
|
||||
os::Surface* dst = os::instance()->defaultDisplay()->surface();
|
||||
os::Surface* dst = os::instance()->defaultWindow()->surface();
|
||||
os::SurfaceLock lockSrc(m_surface.get());
|
||||
os::SurfaceLock lockDst(dst);
|
||||
m_surface->blitTo(
|
||||
@ -1178,7 +1178,7 @@ GraphicsPtr Widget::getGraphics(const gfx::Rect& clip)
|
||||
{
|
||||
GraphicsPtr graphics;
|
||||
os::SurfaceRef surface;
|
||||
os::Surface* defaultSurface = os::instance()->defaultDisplay()->surface();
|
||||
os::Surface* defaultSurface = os::instance()->defaultWindow()->surface();
|
||||
|
||||
// In case of double-buffering, we need to create the temporary
|
||||
// buffer only if the default surface is the screen.
|
||||
|
Loading…
x
Reference in New Issue
Block a user