For these functions, what should users of the library expect: to use a logical or physical coordinate space? Should they all be the same?
PuglRect puglGetFrame(const PuglView* view);
PuglStatus puglSetSize(PuglView* view, unsigned width, unsigned height);
puglSetSizeHint(PuglView* view, PuglSizeHint hint, PuglSpan width, PuglSpan height);
// and so on...
I assume logical since that's the natural way to think about geometry in GUI's, but that isn't what Pugl does in reality. The reason I wanted a puglGetScaleFactor is because PuglEvents received in LVTK widgets are in Physical pixels and need scaled if != 1.0. This could have changed in pugl, as I haven't tested LVTK with new code in pugl:main. Snippet of that code.. this is scaling to convert everything to Logical.
static PuglStatus expose (View& view, const PuglExposeEvent& ev) {
if (ev.flags & PUGL_IS_HINT) {
VIEW_DBG ("expose: hint");
return PUGL_SUCCESS;
}
auto x = (float) ev.x / view.scale_factor(); // "scale_factor" comes directly from puglGetScaleFactor
auto y = (float) ev.y / view.scale_factor();
auto w = (float) ev.width / view.scale_factor();
auto h = (float) ev.height / view.scale_factor();
auto r = Rectangle<float> { x, y, w, h }.as<int>();
VIEW_DBG3 ("expose: " << r.str());
// this initiates the drawing of the widget hierarchy which want Logical pixels.
view.owner.expose (r.intersection (view.owner.bounds().at (0)));
return PUGL_SUCCESS;
}
But I think it's important to make it clear what we're dealing with. I always assumed the coordinates were supposed to be physical for some reason because of the above. Again, I haven't tried the main branch in LVTK so I don't know if it's relevant anymore. I'm honestly asking now, what are they supposed to be? physical or logical?
Especially for puglSetSizeHint. And I'm sure you are well aware: nobody wants calculate the scaling factor of monitors, backing drawing contexts, and what not just to set a default size. We just want to say "set the size to 640x360 and always manifest it 640x360 visually regardless of backend graphics setup and monitors used.
So, with all that: the Cairo demo in main is setting a size hint defaulting @ 512x512. But when I run this on a 2x/4x monitor it displays as 256x256 in logical pixels. Running the same program on a 1x, normal, monitor it fills about half the vertical space which is what is to be expected. That's my thought process anyway.
I'm on board for whatever, and maybe some of the details need documented, so it's clear the expectations about coordinate space. I'm not tied to puglGetScaleFactor either BTW, but if the public pugl API is operating in physical pixels, this information is essential to have early for the next layer in the GUI chain: the UI toolkit level.. maybe even before puglRealize... IDK.
For these functions, what should users of the library expect: to use a logical or physical coordinate space? Should they all be the same?
I assume logical since that's the natural way to think about geometry in GUI's, but that isn't what Pugl does in reality. The reason I wanted a
puglGetScaleFactoris because PuglEvents received in LVTK widgets are in Physical pixels and need scaledif != 1.0. This could have changed in pugl, as I haven't tested LVTK with new code in pugl:main. Snippet of that code.. this is scaling to convert everything to Logical.But I think it's important to make it clear what we're dealing with. I always assumed the coordinates were supposed to be physical for some reason because of the above. Again, I haven't tried the main branch in LVTK so I don't know if it's relevant anymore. I'm honestly asking now, what are they supposed to be? physical or logical?
Especially for
puglSetSizeHint. And I'm sure you are well aware: nobody wants calculate the scaling factor of monitors, backing drawing contexts, and what not just to set a default size. We just want to say "set the size to 640x360 and always manifest it 640x360 visually regardless of backend graphics setup and monitors used.So, with all that: the Cairo demo in
mainis setting a size hint defaulting @ 512x512. But when I run this on a 2x/4x monitor it displays as 256x256 in logical pixels. Running the same program on a 1x, normal, monitor it fills about half the vertical space which is what is to be expected. That's my thought process anyway.I'm on board for whatever, and maybe some of the details need documented, so it's clear the expectations about coordinate space. I'm not tied to
puglGetScaleFactoreither BTW, but if the public pugl API is operating in physical pixels, this information is essential to have early for the next layer in the GUI chain: the UI toolkit level.. maybe even before puglRealize... IDK.