* [pve-devel] [PATCH installer] tui: fix incorrect scrolling of form view contents
@ 2023-07-06 12:27 Christoph Heiss
2023-07-13 13:54 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Heiss @ 2023-07-06 12:27 UTC (permalink / raw)
To: pve-devel
See the inline comment for what & why.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
proxmox-tui-installer/src/views/mod.rs | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/proxmox-tui-installer/src/views/mod.rs b/proxmox-tui-installer/src/views/mod.rs
index b1a1a13..3426294 100644
--- a/proxmox-tui-installer/src/views/mod.rs
+++ b/proxmox-tui-installer/src/views/mod.rs
@@ -4,7 +4,7 @@ use cursive::{
event::{Event, EventResult},
view::{Resizable, ViewWrapper},
views::{EditView, LinearLayout, NamedView, ResizedView, SelectView, TextView},
- View,
+ Rect, Vec2, View,
};
use crate::utils::CidrAddress;
@@ -367,6 +367,22 @@ impl FormView {
impl ViewWrapper for FormView {
cursive::wrap_impl!(self.view: LinearLayout);
+
+ fn wrap_important_area(&self, size: Vec2) -> Rect {
+ // This fixes scrolling on small screen when many elements are present, e.g. bootdisk/RAID
+ // list. Without this, scrolling completely down and then back up would not properly
+ // display the currently selected form element.
+ // tl;dr: For whatever reason, the inner `LinearLayout` calculates the rect with a line
+ // height of 2. So e.g. if the first form element is selected, the y-coordinate is 2, if
+ // the second is selected it is 4 and so on. Knowing that, this can fortunately be quite
+ // easy fixed by just dividing the y-coordinate by 2 and adjusting the size of the area
+ // rectanglo to 1.
+
+ let inner = self.view.important_area(size);
+ let top_left = inner.top_left().map_y(|y| y / 2);
+
+ Rect::from_size(top_left, (inner.width(), 1))
+ }
}
pub struct CidrAddressEditView {
--
2.41.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH installer] tui: fix incorrect scrolling of form view contents
2023-07-06 12:27 [pve-devel] [PATCH installer] tui: fix incorrect scrolling of form view contents Christoph Heiss
@ 2023-07-13 13:54 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-07-13 13:54 UTC (permalink / raw)
To: Proxmox VE development discussion, Christoph Heiss
Am 06/07/2023 um 14:27 schrieb Christoph Heiss:
> See the inline comment for what & why.
>
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
> proxmox-tui-installer/src/views/mod.rs | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-13 13:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-06 12:27 [pve-devel] [PATCH installer] tui: fix incorrect scrolling of form view contents Christoph Heiss
2023-07-13 13:54 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox