From 45fa4b27745fe868b768d82b91f920bee9b1c36c Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Sun, 23 Nov 2025 12:53:50 +0300 Subject: [PATCH] Added display scaling and updated flatpak info --- .../com.infinipaint.infinipaint.metainfo.xml | 17 +++++++++++++++- linuxinstall/com.infinipaint.infinipaint.yml | 4 ++-- src/MainProgram.cpp | 9 +++++++++ src/MainProgram.hpp | 4 ++++ src/Toolbar.cpp | 8 ++++++-- src/main.cpp | 20 +++++++++---------- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/linuxinstall/com.infinipaint.infinipaint.metainfo.xml b/linuxinstall/com.infinipaint.infinipaint.metainfo.xml index e3abcd9..df48c9c 100644 --- a/linuxinstall/com.infinipaint.infinipaint.metainfo.xml +++ b/linuxinstall/com.infinipaint.infinipaint.metainfo.xml @@ -49,7 +49,8 @@
  • Place bookmarks on the canvas to jump to later
  • Undo/Redo
  • Screenshot to export parts of the canvas to a picture (can export to raster formats or SVG)
  • -
  • Other tools such as: Textbox tool, Rectangle select tool, Lasso select tool, Color picker tool, Grid tool, Square and Ellipse tools
  • +
  • Place text boxes with formatting
  • +
  • Other tools such as: Rectangle select tool, Lasso select tool, Color picker tool, Grid tool, Square and Ellipse tools
  • Copy and paste objects on the canvas, and between different canvases
  • Insert images and files on the canvas
  • @@ -58,6 +59,20 @@ com.infinipaint.infinipaint.desktop + + +

    Major update:

    +
      +
    • Unicode support across the entire app
    • +
    • Text boxes now have many more formatting options
    • +
    • UI theme changed
    • +
    • Drag and drop direct URLs to images to download them onto the canvas
    • +
    • Images/Resources that are being downloaded will show download progress
    • +
    • Downloading resources won't completely stop other types of data from being sent
    • +
    • VSync and display scaling options added
    • +
    +
    +

    Minor update:

    diff --git a/linuxinstall/com.infinipaint.infinipaint.yml b/linuxinstall/com.infinipaint.infinipaint.yml index ae6f8d9..7585395 100644 --- a/linuxinstall/com.infinipaint.infinipaint.yml +++ b/linuxinstall/com.infinipaint.infinipaint.yml @@ -74,8 +74,8 @@ modules: - '*' sources: - type: archive - url: https://github.com/google/skia/archive/f4ed99d2443962782cf5f8b4dd27179f131e7cbe.zip - sha256: 2e00dcdb54942c1da7b2f6cfd9fef8c4899115206d940931f6c040bac08b6b79 + url: https://github.com/google/skia/archive/da51f0d60ea2b14e845a823dc11b405dbeef42d8.zip + sha256: 1f5140d5908031d8cdd06429a633a1583b12fc43dc1c768374ed1e91ab9fa596 - name: infinipaint-x86_64 buildsystem: cmake-ninja builddir: true diff --git a/src/MainProgram.cpp b/src/MainProgram.cpp index 98fee9e..56e3063 100755 --- a/src/MainProgram.cpp +++ b/src/MainProgram.cpp @@ -265,6 +265,15 @@ void MainProgram::set_vsync_value(int vsyncValue) { window.vsyncValue = vsyncValue; } +void MainProgram::update_scale_and_density() { + window.scale = window.applyDisplayScale ? SDL_GetWindowDisplayScale(window.sdlWindow) : 1.0f; + window.density = SDL_GetWindowPixelDensity(window.sdlWindow); +} + +float MainProgram::get_scale_and_density_factor_gui() { + return window.scale * window.density; +} + void MainProgram::draw(SkCanvas* canvas) { canvas->clear(transparentBackground ? SkColor4f{0.0f, 0.0f, 0.0f, 0.0f} : world->canvasTheme.backColor); world->draw(canvas); diff --git a/src/MainProgram.hpp b/src/MainProgram.hpp index 4224911..f049f42 100644 --- a/src/MainProgram.hpp +++ b/src/MainProgram.hpp @@ -43,7 +43,9 @@ class MainProgram { SkAlphaType defaultAlphaType; int vsyncValue = 1; + float density = 1.0f; float scale = 1.0f; + bool applyDisplayScale = true; int defaultMSAASampleCount = 0; SkSurfaceProps defaultMSAASurfaceProps; @@ -94,6 +96,8 @@ class MainProgram { void init_net_library(); void set_vsync_value(int vsyncValue); + void update_scale_and_density(); + float get_scale_and_density_factor_gui(); std::filesystem::path homePath; std::filesystem::path configPath; diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index 52b45d6..dffd59d 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -254,6 +254,7 @@ nlohmann::json Toolbar::get_config_json() { toRet["dragZoomSpeed"] = dragZoomSpeed; toRet["scrollZoomSpeed"] = scrollZoomSpeed; toRet["vsync"] = main.window.vsyncValue; + toRet["applyDisplayScale"] = main.window.applyDisplayScale; toRet["showPerformance"] = showPerformance; toRet["displayName"] = main.displayName; toRet["useNativeFilePicker"] = useNativeFilePicker; @@ -313,6 +314,7 @@ void Toolbar::set_config_json(const nlohmann::json& j, VersionNumber version) { catch(...) { main.set_vsync_value(1); } + try{j.at("applyDisplayScale").get_to(main.window.applyDisplayScale);} catch(...) {} try{j.at("guiScale").get_to(guiScale);} catch(...) {} try{j.at("showPerformance").get_to(showPerformance);} catch(...) {} try{j.at("useNativeFilePicker").get_to(useNativeFilePicker);} catch(...) {} @@ -1450,7 +1452,7 @@ void Toolbar::options_menu() { gui.checkbox_field("flip zoom tool direction", "Flip zoom tool direction", &flipZoomToolDirection); gui.input_scalar_field("jump transition time", "Jump transition time", &jumpTransitionTime, 0.01f, 1000.0f, 2); gui.checkbox_field("changebrushwidthwithspeed", "Change brush size with mouse speed", &velocityAffectsBrushWidth); - gui.input_scalar_field("Max GUI Scale", "Max GUI Scale", &guiScale, 0.5f, 3.0f, 1); + gui.input_scalar_field("Max GUI Scale", "Max GUI Scale", &guiScale, 0.5f, 5.0f, 1); gui.text_label("VSync:"); if(gui.radio_button_field("Vsync On", "On", main.window.vsyncValue == 1)) @@ -1460,6 +1462,8 @@ void Toolbar::options_menu() { if(gui.radio_button_field("Vsync Adaptive", "Adaptive", main.window.vsyncValue == -1)) main.set_vsync_value(-1); + gui.checkbox_field("apply display scale", "Apply display scale", &main.window.applyDisplayScale); + gui.pop_id(); break; } @@ -1986,7 +1990,7 @@ void Toolbar::calculate_final_gui_scale() { } float Toolbar::final_gui_scale_not_fit() { - return guiScale * main.window.scale; + return guiScale * main.get_scale_and_density_factor_gui(); } void Toolbar::end_gui() { diff --git a/src/main.cpp b/src/main.cpp index 641bf88..7bf9fa9 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -438,7 +438,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) { mS.m->configPath = mS.configPath; mS.m->homePath = mS.homePath; mS.m->window.sdlWindow = mS.window; - mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window); + mS.m->update_scale_and_density(); #ifdef __EMSCRIPTEN__ emscripten_set_beforeunload_callback((void*)mSPtr, emscripten_before_unload); #else @@ -554,7 +554,7 @@ SDL_AppResult SDL_AppIterate(void *appstate) { #ifdef NDEBUG try { #endif - mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window); + mS.m->update_scale_and_density(); #ifdef __EMSCRIPTEN__ if(emscriptenFilesystemReadReady && !emscriptenFilesystemLoadConfigDone) { @@ -655,12 +655,12 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) { mS.m->window.maximized = false; break; case SDL_EVENT_MOUSE_MOTION: - mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window); + mS.m->update_scale_and_density(); #ifdef _WIN32 if(!mS.m->toolbar.tabletOptions.ignoreMouseMovementWhenPenInProximity || !mS.m->input.pen.inProximity) #endif { - mS.m->input.mouse.set_pos({event->motion.x * mS.m->window.scale, event->motion.y * mS.m->window.scale}); + mS.m->input.mouse.set_pos({event->motion.x * mS.m->window.density, event->motion.y * mS.m->window.density}); } break; case SDL_EVENT_MOUSE_BUTTON_UP: @@ -700,16 +700,16 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) { mS.m->input.text.add_text_to_textbox(event->text.text); break; case SDL_EVENT_DROP_FILE: - mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window); + mS.m->update_scale_and_density(); mS.m->input.droppedItems.emplace_back(InputManager::DroppedItem{ - .pos = Vector2f{event->drop.x, event->drop.y} * mS.m->window.scale, + .pos = Vector2f{event->drop.x, event->drop.y} * mS.m->window.density, .dataPath = std::u8string_view(reinterpret_cast(event->drop.data)) }); break; case SDL_EVENT_DROP_TEXT: - mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window); + mS.m->update_scale_and_density(); mS.m->input.droppedItems.emplace_back(InputManager::DroppedItem{ - .pos = Vector2f{event->drop.x, event->drop.y} * mS.m->window.scale, + .pos = Vector2f{event->drop.x, event->drop.y} * mS.m->window.density, .dataText = event->drop.data }); break; @@ -722,9 +722,9 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) { break; } case SDL_EVENT_PEN_MOTION: { - mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window); + mS.m->update_scale_and_density(); mS.m->input.pen.isEraser = event->pmotion.pen_state & SDL_PEN_INPUT_ERASER_TIP; - mS.m->input.mouse.set_pos({event->pmotion.x * mS.m->window.scale, event->pmotion.y * mS.m->window.scale}); + mS.m->input.mouse.set_pos({event->pmotion.x * mS.m->window.density, event->pmotion.y * mS.m->window.density}); break; } case SDL_EVENT_PEN_DOWN: {