From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E0B07C3C9 for ; Thu, 6 Jul 2023 14:28:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C23491EDC5 for ; Thu, 6 Jul 2023 14:28:09 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 6 Jul 2023 14:28:09 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1AC0846991 for ; Thu, 6 Jul 2023 14:28:09 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Thu, 6 Jul 2023 14:27:50 +0200 Message-ID: <20230706122801.253855-1-c.heiss@proxmox.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.067 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer] tui: fix incorrect scrolling of form view contents X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jul 2023 12:28:09 -0000 See the inline comment for what & why. Signed-off-by: Christoph Heiss --- 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