GithubHelp home page GithubHelp logo

HiDPI support about orbtk HOT 4 CLOSED

redox-os avatar redox-os commented on August 16, 2024
HiDPI support

from orbtk.

Comments (4)

 avatar commented on August 16, 2024 4

Why was this closed? I can't find an upstream issue you hinted at.

from orbtk.

jackpot51 avatar jackpot51 commented on August 16, 2024

This is a good feature to implement. I am unsure where the features should go, that is, which library. My guess would be orbclient and orbfont

from orbtk.

FloVanGH avatar FloVanGH commented on August 16, 2024

orbclient and orbfont could be the right place, because then not only orbtk is benefits from HiDPI scaling.

from orbtk.

tangmi avatar tangmi commented on August 16, 2024

I tried out the orbtk examples on a macbook and noticed it didn't handle DPI scaling.

I think that orbtk and orbclient may need to both be aware of DPI scaling (orbfont, however, hopefully doesn't need to care, as orbtk can just request scaled font sizes to accommodate). I'll try and enumerate some of the things to consider when handling DPI, in case it helps orbtk in the future.

orbclient/orbtk_shell:

  • Window creation: orbtk needs to be able to request a window sized in logical pixels and a framebuffer sized in physical pixels.
    • It looks like the way to handle HiDPI in e.g. minifb is to pass a buffer larger than the window size to update_with_buffer (emoon/minifb#50). I'm sure each window library handles this slightly differently, while some might not expose the functionality at all!
    • For the web, the canvas should be sized based on physical pixels and have a CSS size in "points" (rust-windowing/winit#1233).
  • Window resize: orbclient/orbtk_shell would need to handle the dpi scale potentially changing as its own event and/or during resize. IIRC this is difficult to get right cross-platform without missing frames or jittering for a couple frames during the transition.
  • Note that the DPI scale factor isn't necessarily a whole number and can go below 1.0 on the web.

orbtk:

  • API coordinates: HiDPI scaling is just what happens when physical pixels and logical pixels are not equal, so we need to document which "pixels" each method takes (for user sanity, it should mostly be logical pixels).
    • Most user events/coordinates would be in "points" or "logical pixels" or "window pixels" (or whatever one wants to call it), which shouldn't pose much of an issue for existing users (I believe just redocumtening pixels to be points and adding DPI-specific APIs is how Apple initially transitioned devs onto the iPhone 4 retina screens.)
    • There should be some API to allow a stack of (image) resources at different scale factors and some logic for orbtk to pick the right one.
    • DPI scale factor needs to be queryable so that raw 2D/3D canvases can correctly handle different scale factors (alternately, raw canvases can apply a scale factor at the root and just really trust the rendering API to get it right)

from orbtk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.