mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Window size fixes on macOS.
Changes for SpartanJ/ecode/#373
This commit is contained in:
@@ -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; };
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -83,7 +83,7 @@ class EE_API WindowSDL : public Window {
|
||||
|
||||
virtual Rect getBorderSize();
|
||||
|
||||
virtual Float getScale();
|
||||
virtual Float getScale() const;
|
||||
|
||||
virtual bool hasNativeMessageBox() const;
|
||||
|
||||
|
||||
@@ -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<int>( mWindow.WindowConfig.Width / scale ),
|
||||
static_cast<int>( 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<int>( mLastWindowedSize.getWidth() / scale ),
|
||||
static_cast<int>( 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,9 @@ void AppConfig::save( const std::vector<std::string>& 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();
|
||||
|
||||
@@ -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<size_t> jobs(
|
||||
parser, "jobs",
|
||||
"Sets the number of background jobs that the application will spawn "
|
||||
|
||||
Reference in New Issue
Block a user