From 69a41cff402682ce5cb3432a81be3b4bffa8c3a9 Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Sun, 24 Dec 2023 10:51:30 +0000 Subject: [PATCH] Add method to set inline height --- src/Display/Display.php | 19 +++++++++++++++++++ src/Display/Viewport/Inline.php | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Display/Display.php b/src/Display/Display.php index 4aaab98e..2f820eed 100644 --- a/src/Display/Display.php +++ b/src/Display/Display.php @@ -101,6 +101,25 @@ public function viewportArea(): Area return $this->viewportArea; } + /** + * Set the height of an inline viewport. If the current viewport is not inline + * this has no effect. + * @param int<0,max> $height + */ + public function setInlineHeight(int $height): void + { + if (!$this->viewport instanceof Inline) { + return; + } + + if ($height === $this->viewportArea->height) { + return; + } + + $this->viewport->height = $height; + $this->resize($this->lastKnownSize); + } + /** * Render a widget before the current inline viewport. This has no effect when the * viewport is fullscreen. diff --git a/src/Display/Viewport/Inline.php b/src/Display/Viewport/Inline.php index b67e943e..2e193520 100644 --- a/src/Display/Viewport/Inline.php +++ b/src/Display/Viewport/Inline.php @@ -23,7 +23,7 @@ public function __construct( * Height of the viewport * @var int<0,max> */ - public readonly int $height + public int $height ) { }