mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Improved DPI awareness on Windows.
Minor fix in Code Editor. Fixed Code Editor build with mingw32.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#define EE_SDL_VERSION_2
|
||||
#define EE_X11_PLATFORM
|
||||
#define EE_DEBUG
|
||||
#define EE_MEMORY_MANAGER
|
||||
#define EE_SHADERS_SUPPORTED
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
../../README.md
|
||||
../../bin/assets/colorschemes/colorschemes.conf
|
||||
../../bin/assets/ee.ini
|
||||
../../bin/assets/layouts/imported.css
|
||||
../../bin/assets/layouts/test.css
|
||||
@@ -63,6 +64,7 @@
|
||||
../../include/eepp/graphics/globalbatchrenderer.hpp
|
||||
../../include/eepp/graphics/globaltextureatlas.hpp
|
||||
../../include/eepp/graphics.hpp
|
||||
../../include/eepp/graphics/glyphdrawable.hpp
|
||||
../../include/eepp/graphics/image.hpp
|
||||
../../include/eepp/graphics/ninepatch.hpp
|
||||
../../include/eepp/graphics/ninepatchmanager.hpp
|
||||
@@ -322,6 +324,7 @@
|
||||
../../include/eepp/ui/doc/syntaxhighlighter.hpp
|
||||
../../include/eepp/ui/doc/syntaxtokenizer.hpp
|
||||
../../include/eepp/ui/doc/textdocument.hpp
|
||||
../../include/eepp/ui/doc/textdocumentline.hpp
|
||||
../../include/eepp/ui/doc/textposition.hpp
|
||||
../../include/eepp/ui/doc/textrange.hpp
|
||||
../../include/eepp/ui/doc/undostack.hpp
|
||||
@@ -334,12 +337,14 @@
|
||||
../../include/eepp/ui/uicheckbox.hpp
|
||||
../../include/eepp/ui/uicodeeditor.hpp
|
||||
../../include/eepp/ui/uicombobox.hpp
|
||||
../../include/eepp/ui/uicommondialog.hpp
|
||||
../../include/eepp/ui/uidropdownlist.hpp
|
||||
../../include/eepp/ui/uieventdispatcher.hpp
|
||||
../../include/eepp/ui/uifiledialog.hpp
|
||||
../../include/eepp/ui/uifontstyleconfig.hpp
|
||||
../../include/eepp/ui/uigridlayout.hpp
|
||||
../../include/eepp/ui/uihelper.hpp
|
||||
../../include/eepp/ui/uiicontheme.hpp
|
||||
../../include/eepp/ui/uiiconthememanager.hpp
|
||||
../../include/eepp/ui/uiimage.hpp
|
||||
../../include/eepp/ui/uiitemcontainer.hpp
|
||||
../../include/eepp/ui/uilayout.hpp
|
||||
@@ -348,9 +353,11 @@
|
||||
../../include/eepp/ui/uilistboxitem.hpp
|
||||
../../include/eepp/ui/uiloader.hpp
|
||||
../../include/eepp/ui/uimanager.hpp
|
||||
../../include/eepp/ui/uimenubar.hpp
|
||||
../../include/eepp/ui/uimenucheckbox.hpp
|
||||
../../include/eepp/ui/uimenu.hpp
|
||||
../../include/eepp/ui/uimenuitem.hpp
|
||||
../../include/eepp/ui/uimenuradiobutton.hpp
|
||||
../../include/eepp/ui/uimenuseparator.hpp
|
||||
../../include/eepp/ui/uimenusubmenu.hpp
|
||||
../../include/eepp/ui/uimessagebox.hpp
|
||||
@@ -369,6 +376,7 @@
|
||||
../../include/eepp/ui/uiskinstate.hpp
|
||||
../../include/eepp/ui/uislider.hpp
|
||||
../../include/eepp/ui/uispinbox.hpp
|
||||
../../include/eepp/ui/uisplitter.hpp
|
||||
../../include/eepp/ui/uisprite.hpp
|
||||
../../include/eepp/ui/uistate.hpp
|
||||
../../include/eepp/ui/uistyle.hpp
|
||||
@@ -389,7 +397,6 @@
|
||||
../../include/eepp/ui/uiwidgetcreator.hpp
|
||||
../../include/eepp/ui/uiwidget.hpp
|
||||
../../include/eepp/ui/uiwindow.hpp
|
||||
../../include/eepp/ui/uiwinmenu.hpp
|
||||
../../include/eepp/version.hpp
|
||||
../../include/eepp/window/base.hpp
|
||||
../../include/eepp/window/clipboard.hpp
|
||||
@@ -504,6 +511,7 @@
|
||||
../../src/eepp/graphics/framebuffermanager.hpp
|
||||
../../src/eepp/graphics/globalbatchrenderer.cpp
|
||||
../../src/eepp/graphics/globaltextureatlas.cpp
|
||||
../../src/eepp/graphics/glyphdrawable.cpp
|
||||
../../src/eepp/graphics/image.cpp
|
||||
../../src/eepp/graphics/ninepatch.cpp
|
||||
../../src/eepp/graphics/ninepatchmanager.cpp
|
||||
@@ -773,6 +781,7 @@
|
||||
../../src/eepp/ui/doc/syntaxtokenizer.cpp
|
||||
../../src/eepp/ui/doc/textdocument.cpp
|
||||
../../src/eepp/ui/doc/undostack.cpp
|
||||
../../src/eepp/ui/keyboardshortcut.cpp
|
||||
../../src/eepp/ui/tools/textureatlaseditor.cpp
|
||||
../../src/eepp/ui/tools/textureatlasnew.cpp
|
||||
../../src/eepp/ui/tools/textureatlasnew.hpp
|
||||
@@ -784,10 +793,12 @@
|
||||
../../src/eepp/ui/uicheckbox.cpp
|
||||
../../src/eepp/ui/uicodeeditor.cpp
|
||||
../../src/eepp/ui/uicombobox.cpp
|
||||
../../src/eepp/ui/uicommondialog.cpp
|
||||
../../src/eepp/ui/uidropdownlist.cpp
|
||||
../../src/eepp/ui/uieventdispatcher.cpp
|
||||
../../src/eepp/ui/uifiledialog.cpp
|
||||
../../src/eepp/ui/uigridlayout.cpp
|
||||
../../src/eepp/ui/uiicontheme.cpp
|
||||
../../src/eepp/ui/uiiconthememanager.cpp
|
||||
../../src/eepp/ui/uiimage.cpp
|
||||
../../src/eepp/ui/uilayout.cpp
|
||||
../../src/eepp/ui/uilinearlayout.cpp
|
||||
@@ -795,9 +806,11 @@
|
||||
../../src/eepp/ui/uilistboxitem.cpp
|
||||
../../src/eepp/ui/uiloader.cpp
|
||||
../../src/eepp/ui/uimanager.cpp
|
||||
../../src/eepp/ui/uimenubar.cpp
|
||||
../../src/eepp/ui/uimenucheckbox.cpp
|
||||
../../src/eepp/ui/uimenu.cpp
|
||||
../../src/eepp/ui/uimenuitem.cpp
|
||||
../../src/eepp/ui/uimenuradiobutton.cpp
|
||||
../../src/eepp/ui/uimenuseparator.cpp
|
||||
../../src/eepp/ui/uimenusubmenu.cpp
|
||||
../../src/eepp/ui/uimessagebox.cpp
|
||||
@@ -816,6 +829,7 @@
|
||||
../../src/eepp/ui/uiskinstate.cpp
|
||||
../../src/eepp/ui/uislider.cpp
|
||||
../../src/eepp/ui/uispinbox.cpp
|
||||
../../src/eepp/ui/uisplitter.cpp
|
||||
../../src/eepp/ui/uisprite.cpp
|
||||
../../src/eepp/ui/uistate.cpp
|
||||
../../src/eepp/ui/uistyle.cpp
|
||||
@@ -836,7 +850,6 @@
|
||||
../../src/eepp/ui/uiwidget.cpp
|
||||
../../src/eepp/ui/uiwidgetcreator.cpp
|
||||
../../src/eepp/ui/uiwindow.cpp
|
||||
../../src/eepp/ui/uiwinmenu.cpp
|
||||
../../src/eepp/window/backend/allegro5/cbackendal.hpp
|
||||
../../src/eepp/window/backend/allegro5/cclipboardal.cpp
|
||||
../../src/eepp/window/backend/allegro5/cclipboardal.hpp
|
||||
@@ -957,6 +970,7 @@
|
||||
../../src/thirdparty/SOIL2/src/SOIL2/stbi_pvr_c.h
|
||||
../../src/thirdparty/SOIL2/src/SOIL2/stbi_pvr.h
|
||||
../../src/tools/codeeditor/codeeditor.cpp
|
||||
../../src/tools/codeeditor/codeeditor.hpp
|
||||
../../src/tools/mapeditor/mapeditor.cpp
|
||||
../../src/tools/textureatlaseditor/textureatlaseditor.cpp
|
||||
../../src/tools/texturepacker/texturepacker.cpp
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <eepp/system/sys.hpp>
|
||||
#include <eepp/window/backend/SDL2/base.hpp>
|
||||
#include <eepp/window/backend/SDL2/displaymanagersdl2.hpp>
|
||||
|
||||
@@ -7,6 +8,24 @@
|
||||
|
||||
namespace EE { namespace Window { namespace Backend { namespace SDL2 {
|
||||
|
||||
static bool DISPLAY_REQUEST_DPI_AWARENESS = true;
|
||||
|
||||
void DisplayManagerSDL2::setDPIAwareness() {
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
if ( DISPLAY_REQUEST_DPI_AWARENESS ) {
|
||||
void* user32 = Sys::loadObject( "user32.dll" );
|
||||
if ( user32 ) {
|
||||
int (*SetProcessDPIAware)() =
|
||||
(int (*)()) Sys::loadFunction( user32, "SetProcessDPIAware" );
|
||||
if ( SetProcessDPIAware ) {
|
||||
SetProcessDPIAware();
|
||||
DISPLAY_REQUEST_DPI_AWARENESS = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
DisplaySDL2::DisplaySDL2( int index ) : Display( index ) {}
|
||||
|
||||
std::string DisplaySDL2::getName() {
|
||||
@@ -24,6 +43,7 @@ Float DisplaySDL2::getDPI() {
|
||||
#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
return 96.f * emscripten_get_device_pixel_ratio();
|
||||
#else
|
||||
DisplayManagerSDL2::setDPIAwareness();
|
||||
float ddpi, hdpi, vdpi;
|
||||
if ( 0 == SDL_GetDisplayDPI( 0, &ddpi, &hdpi, &vdpi ) )
|
||||
return ddpi;
|
||||
@@ -88,6 +108,7 @@ Rect DisplaySDL2::getUsableBounds() {
|
||||
}
|
||||
|
||||
int DisplayManagerSDL2::getDisplayCount() {
|
||||
setDPIAwareness();
|
||||
if ( !SDL_WasInit( SDL_INIT_VIDEO ) )
|
||||
SDL_Init( SDL_INIT_VIDEO );
|
||||
return SDL_GetNumVideoDisplays();
|
||||
|
||||
@@ -28,6 +28,10 @@ class EE_API DisplaySDL2 : public Display {
|
||||
|
||||
class EE_API DisplayManagerSDL2 : public DisplayManager {
|
||||
public:
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
static void setDPIAwareness();
|
||||
#endif
|
||||
|
||||
int getDisplayCount();
|
||||
|
||||
Display* getDisplayIndex( int index );
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <eepp/window/backend/SDL2/wminfo.hpp>
|
||||
#include <eepp/window/engine.hpp>
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
#include <eepp/window/backend/SDL2/displaymanagersdl2.hpp>
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || \
|
||||
defined( EE_X11_PLATFORM ) || EE_PLATFORM == EE_PLATFORM_IOS || \
|
||||
EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
@@ -211,6 +215,10 @@ WindowSDL::~WindowSDL() {
|
||||
}
|
||||
|
||||
bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) {
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN
|
||||
DisplayManagerSDL2::setDPIAwareness();
|
||||
#endif
|
||||
|
||||
if ( mWindow.Created )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -778,7 +778,9 @@ void App::onFileDropped( String file ) {
|
||||
Vector2f mousePos( mUISceneNode->getEventDispatcher()->getMousePosf() );
|
||||
Node* node = mUISceneNode->overFind( mousePos );
|
||||
UICodeEditor* codeEditor = mCurEditor;
|
||||
if ( node->isType( UI_TYPE_CODEEDITOR ) ) {
|
||||
if ( !node )
|
||||
node = codeEditor;
|
||||
if ( node && node->isType( UI_TYPE_CODEEDITOR ) ) {
|
||||
codeEditor = node->asType<UICodeEditor>();
|
||||
if ( !codeEditor->getDocument().isEmpty() ) {
|
||||
auto d = createCodeEditorInTabWidget( tabWidgetFromEditor( codeEditor ) );
|
||||
@@ -793,7 +795,7 @@ void App::onTextDropped( String text ) {
|
||||
Vector2f mousePos( mUISceneNode->getEventDispatcher()->getMousePosf() );
|
||||
Node* node = mUISceneNode->overFind( mousePos );
|
||||
UICodeEditor* codeEditor = mCurEditor;
|
||||
if ( node->isType( UI_TYPE_CODEEDITOR ) )
|
||||
if ( node && node->isType( UI_TYPE_CODEEDITOR ) )
|
||||
codeEditor = node->asType<UICodeEditor>();
|
||||
if ( codeEditor && !text.empty() ) {
|
||||
if ( text[text.size() - 1] != '\n' )
|
||||
@@ -927,7 +929,7 @@ void App::init( const std::string& file, const Float& pidelDensity ) {
|
||||
|
||||
if ( mWindow->isOpen() ) {
|
||||
mWindow->setCloseRequestCallback(
|
||||
[&]( auto* win ) -> bool { return onCloseRequestCallback( win ); } );
|
||||
[&]( EE::Window::Window* win ) -> bool { return onCloseRequestCallback( win ); } );
|
||||
|
||||
mWindow->getInput()->pushCallback( [&]( InputEvent* event ) {
|
||||
if ( event->Type == InputEvent::FileDropped ) {
|
||||
|
||||
Reference in New Issue
Block a user