From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id AE7651FF16B for ; Tue, 9 Sep 2025 10:17:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CE9B91870; Tue, 9 Sep 2025 10:17:04 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Tue, 9 Sep 2025 10:16:39 +0200 Message-ID: <20250909081701.946341-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-widget-toolkit 1/2] widget: data table: column: allow setting vertical align X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" by default the vertical align is set to 'baseline', which is good for text, but if we want to render something else in a column (e.g. a `Meter`) we must use 'middle' otherwise the element will be also aligned on the baseline making it not centered. Signed-off-by: Dominik Csapak --- src/widget/data_table/column.rs | 14 ++++++++++++++ src/widget/data_table/row.rs | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/widget/data_table/column.rs b/src/widget/data_table/column.rs index 1b95c3e..d702576 100644 --- a/src/widget/data_table/column.rs +++ b/src/widget/data_table/column.rs @@ -30,6 +30,9 @@ pub struct DataTableColumn { /// Horizontal table cell justification (start, end, left, center, right, justify). #[prop_or(AttrValue::Static("start"))] pub justify: AttrValue, + /// Vertical table cell align ("top", "bottom", "middle", "baseline"). + #[prop_or_default] + pub vertical_align: Option, // only internal, use `apply_render` instead render_cell: DataTableCellRenderer, @@ -196,6 +199,17 @@ impl DataTableColumn { self.justify = justify.into(); } + /// Builder style method to set the vertical cell alignment. + pub fn vertical_align(mut self, vertical_align: impl IntoPropValue>) -> Self { + self.set_vertical_align(vertical_align); + self + } + + /// Method to set the vertical cell alignment. + pub fn set_vertical_align(&mut self, vertical_align: impl IntoPropValue>) { + self.vertical_align = vertical_align.into_prop_value(); + } + /// Builder style method to set the render function. pub fn render(self, render: impl Into>) -> Self { let render = render.into(); diff --git a/src/widget/data_table/row.rs b/src/widget/data_table/row.rs index 2770eb9..34bbbdf 100644 --- a/src/widget/data_table/row.rs +++ b/src/widget/data_table/row.rs @@ -128,7 +128,11 @@ impl Component for PwtDataTableRow { continue; } - let vertical_align = props.vertical_align.to_owned().unwrap_or("baseline".into()); + let vertical_align = props + .vertical_align + .to_owned() + .or(column.vertical_align.clone()) + .unwrap_or("baseline".into()); let text_align = column.justify.to_owned(); let cell_active = match props.active_cell { -- 2.47.2 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel