Implement reconfigure() of PixmapPresenter

This commit is contained in:
Elias Batek 2024-01-07 23:52:26 +01:00
parent 9f792bdfeb
commit 9ad00cafd4
1 changed files with 33 additions and 3 deletions

View File

@ -952,10 +952,38 @@ final class PixmapPresenter {
alias framebuffer = pixmap;
/++
Updates the configuration of the presenter
Updates the configuration of the presenter.
Params:
resizeWindow = if false, `config.window.size` will be ignored.
+/
void reconfigure(const PresenterConfig config) {
assert(false, "Not implemented");
void reconfigure(PresenterConfig config, const bool resizeWindow = false) {
// override requested window-size to current size if no resize requested
if (!resizeWindow) {
config.window.size = _poc.config.window.size;
}
this.reconfigureImpl(config);
}
private void reconfigureImpl(const ref PresenterConfig config) {
_poc.window.title = config.window.title;
if (config.renderer.resolution != _poc.config.renderer.resolution) {
_poc.framebuffer.size = config.renderer.resolution;
}
immutable resize = (config.window.size != _poc.config.window.size);
// update stored configuration
_poc.config = config;
if (resize) {
_poc.window.resize(config.window.size.width, config.window.size.height);
// resize-handler will call `_renderer.reconfigure()`
} else {
_renderer.reconfigure();
}
}
/++
@ -1039,6 +1067,8 @@ final class PixmapPresenter {
_poc.config.window.size = newSize;
_renderer.reconfigure();
// ↑ In case this call gets removed, update `reconfigure()`.
// Current implementation takes advantage of the `_renderer.reconfigure()` call here.
if (_onWindowResize !is null) {
_onWindowResize(newSize);