diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index 66726ff41..bfa02d80e 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -70,8 +70,8 @@ class WindowSettings { UseScreenKeyboard( EE_SCREEN_KEYBOARD_ENABLED ) {} Uint32 Style; - Uint32 Width; - Uint32 Height; + Uint32 Width; //! In screen coordinates (pixels * scale) + Uint32 Height; //! In screen coordinates (pixels * scale) Uint32 BitsPerPixel; std::string Icon; std::string Title; @@ -246,9 +246,14 @@ class EE_API Window { */ virtual void setSize( Uint32 Width, Uint32 Height, bool isWindowed ) = 0; - /** @return The window size */ + /** @return The window size in pixels */ virtual Sizei getSize(); + /** @return The window size in screen coordinates (screen coordinates is size in pixels / + * scale). + */ + virtual Sizei getSizeInScreenCoordinates(); + /** @return The window center point */ Vector2f getCenter(); @@ -306,7 +311,7 @@ class EE_API Window { virtual Rect getBorderSize(); /** @return The size of the pixel in screen coordinates. This is the device scale factor. */ - virtual Float getScale(); + virtual Float getScale() const; /** @return If the aplication is running returns true ( If you Init correctly the window and is * running ). */ @@ -493,9 +498,12 @@ class EE_API Window { * per second. */ const System::Time& getRenderTimePerSecond() const; - /** @return The last windowed size of the window */ + /** @return The last windowed size of the window in pixels */ const Sizei& getLastWindowedSize() const; + /** @return The last windowed size of the window in screen coordinates */ + Sizei getLastWindowedSizeInScreenCoordinates() const; + /** @return True if implements native message boxes */ virtual bool hasNativeMessageBox() const { return false; }; diff --git a/projects/macos/ee.includes b/projects/macos/ee.includes index ec993a379..138e0b17d 100644 --- a/projects/macos/ee.includes +++ b/projects/macos/ee.includes @@ -1,3 +1,4 @@ +/opt/homebrew/Cellar/sdl2/2.30.8/include ../../src/ ../../include/ ../../src/thirdparty @@ -14,3 +15,4 @@ ../../src/modules/physics/include/ ../../src/modules/physics/src/ ../../src/tools/ecode +../../src/modules/languages-syntax-highlighting/src diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index 108565ef5..b8f433614 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -841,7 +841,7 @@ Rect WindowSDL::getBorderSize() { return bordersSize; } -Float WindowSDL::getScale() { +Float WindowSDL::getScale() const { int realX, realY; int scaledX, scaledY; SDL_GL_GetDrawableSize( mSDLWindow, &realX, &realY ); diff --git a/src/eepp/window/backend/SDL2/windowsdl2.hpp b/src/eepp/window/backend/SDL2/windowsdl2.hpp index f41dc7261..ef1fc5e06 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.hpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.hpp @@ -83,7 +83,7 @@ class EE_API WindowSDL : public Window { virtual Rect getBorderSize(); - virtual Float getScale(); + virtual Float getScale() const; virtual bool hasNativeMessageBox() const; diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index 252acb907..4456ed62e 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -61,6 +61,12 @@ Sizei Window::getSize() { return Sizei( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ); } +Sizei Window::getSizeInScreenCoordinates() { + Float scale = getScale(); + return Sizei{ static_cast( mWindow.WindowConfig.Width / scale ), + static_cast( mWindow.WindowConfig.Height / scale ) }; +} + Vector2f Window::getCenter() { return Sizef( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height ) * 0.5f; } @@ -346,6 +352,12 @@ const Sizei& Window::getLastWindowedSize() const { return mLastWindowedSize; } +Sizei Window::getLastWindowedSizeInScreenCoordinates() const { + Float scale = getScale(); + return Sizei{ static_cast( mLastWindowedSize.getWidth() / scale ), + static_cast( mLastWindowedSize.getHeight() / scale ) }; +} + bool Window::showMessageBox( const MessageBoxType&, const std::string&, const std::string& ) { return false; } @@ -469,13 +481,13 @@ void Window::logSuccessfulInit( const std::string& BackendName ) { "%s\n\tPlatform: %s\n\tOS: %s\n\tArch: %s\n\tCPU Cores: %d\n\tProcess Path: %s\n\tCurrent " "Working Directory: %s\n\tHome Directory: %s\n\tDisk Free Space: %s\n\tWindow/Input " "Backend: %s\n\tGL Backend: %s\n\tGL Vendor: %s\n\tGL Renderer: %s\n\tGL Version: " - "%s\n\tGL Shading Language Version: %s\n\tResolution: %dx%d", + "%s\n\tGL Shading Language Version: %s\n\tResolution: %dx%d\n\tWindow scale: %.2f", Version::getVersionName(), Version::getCodename(), Version::getBuildTime(), Sys::getPlatform(), Sys::getOSName( true ), Sys::getOSArchitecture(), Sys::getCPUCount(), Sys::getProcessPath(), FileSystem::getCurrentWorkingDirectory(), Sys::getUserDirectory(), FileSystem::sizeToString( FileSystem::getDiskFreeSpace( Sys::getProcessPath() ) ), BackendName, GLi->versionStr(), GLi->getVendor(), GLi->getRenderer(), GLi->getVersion(), - GLi->getShadingLanguageVersion(), getWidth(), getHeight() ) ); + GLi->getShadingLanguageVersion(), getWidth(), getHeight(), getScale() ) ); #ifndef EE_SILENT Log::info( msg ); @@ -566,7 +578,7 @@ Rect Window::getBorderSize() { return Rect(); } -Float Window::getScale() { +Float Window::getScale() const { return 1.f; } diff --git a/src/tools/ecode/appconfig.cpp b/src/tools/ecode/appconfig.cpp index e99560c68..16539dd0c 100644 --- a/src/tools/ecode/appconfig.cpp +++ b/src/tools/ecode/appconfig.cpp @@ -238,7 +238,9 @@ void AppConfig::save( const std::vector& recentFiles, } editor.colorScheme = colorSchemeName; - windowState.size = win->getLastWindowedSize(); + windowState.size = Sys::getPlatformType() == Sys::PlatformType::macOS + ? win->getSizeInScreenCoordinates() + : win->getLastWindowedSizeInScreenCoordinates(); windowState.maximized = win->isMaximized(); windowState.displayIndex = win->getCurrentDisplayIndex(); windowState.position = win->getPosition(); diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 412416b9a..22ae58fbe 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -693,8 +693,6 @@ bool App::loadConfig( const LogLevel& logLevel, const Sizeu& displaySize, bool s } void App::saveConfig() { - if ( mIncognito ) - return; mConfig.save( mRecentFiles, mRecentFolders, mProjectSplitter ? mProjectSplitter->getSplitPartition().toString() : "15%", mMainSplitter ? mMainSplitter->getSplitPartition().toString() : "85%", mWindow, @@ -1866,7 +1864,7 @@ bool App::isUnlockedCommand( const std::string& command ) { } void App::saveProject( bool onlyIfNeeded, bool sessionSnapshotEnabled ) { - if ( !mIncognito && !mCurrentProject.empty() ) { + if ( !mCurrentProject.empty() ) { mConfig.saveProject( mCurrentProject, mSplitter, mConfigPath, mProjectDocConfig, mProjectBuildManager ? mProjectBuildManager->getConfig() : ProjectBuildConfiguration(), @@ -3476,6 +3474,8 @@ void App::init( const LogLevel& logLevel, std::string file, const Float& pidelDe if ( mConfig.windowState.maximized ) { #if EE_PLATFORM == EE_PLATFORM_LINUX mThreadPool->run( [this] { mWindow->maximize(); } ); +#elif EE_PLATFORM == EE_PLATFORM_MACOS + // Do no maximize since the result is not exactly maximized #else mWindow->maximize(); #endif @@ -3973,10 +3973,10 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) { parser, "portable", "Portable Mode (it will save the configuration files within the ecode main folder)", { 'p', "portable" } ); - args::Flag incognito( parser, "incognito", - "Disables saving any settings from this session (opened files and " - "folders, folders/project settings and editor settings)", - { 'i', "incognito" } ); + args::Flag incognito( + parser, "incognito", + "It will stop keeping track of the opened files or folders during the session", + { 'i', "incognito" } ); args::ValueFlag jobs( parser, "jobs", "Sets the number of background jobs that the application will spawn "