use shared input max height value

This commit is contained in:
yggverse 2025-11-07 20:59:06 +02:00
parent 4905d55e8a
commit e813cdeafa
3 changed files with 23 additions and 6 deletions

View file

@ -61,7 +61,13 @@ impl Input {
title: Option<&str>, title: Option<&str>,
size_limit: Option<usize>, size_limit: Option<usize>,
) { ) {
self.update(Some(&gtk::Box::response(action, base, title, size_limit))); self.update(Some(&gtk::Box::response(
action,
base,
title,
size_limit,
MAX_CONTENT_HEIGHT,
)));
} }
pub fn set_new_sensitive( pub fn set_new_sensitive(
@ -75,6 +81,9 @@ impl Input {
} }
pub fn set_new_titan(&self, on_send: impl Fn(titan::Header, Bytes, Box<dyn Fn()>) + 'static) { pub fn set_new_titan(&self, on_send: impl Fn(titan::Header, Bytes, Box<dyn Fn()>) + 'static) {
self.update(Some(&gtk::Box::titan(on_send))); self.update(Some(&gtk::Box::titan(MAX_CONTENT_HEIGHT, on_send)));
} }
} }
/// @TODO optional, maybe relative to the current window height in %
const MAX_CONTENT_HEIGHT: i32 = 280;

View file

@ -23,6 +23,7 @@ pub trait Response {
base: Uri, base: Uri,
title: Option<&str>, title: Option<&str>,
size_limit: Option<usize>, size_limit: Option<usize>,
max_content_height: i32,
) -> Self; ) -> Self;
} }
@ -35,6 +36,7 @@ impl Response for Box {
base: Uri, base: Uri,
title: Option<&str>, title: Option<&str>,
size_limit: Option<usize>, size_limit: Option<usize>,
max_content_height: i32,
) -> Self { ) -> Self {
// Init components // Init components
let control = Rc::new(Control::build()); let control = Rc::new(Control::build());
@ -55,7 +57,7 @@ impl Response for Box {
g_box.append( g_box.append(
&gtk::ScrolledWindow::builder() &gtk::ScrolledWindow::builder()
.child(&text_view) .child(&text_view)
.max_content_height(320) .max_content_height(max_content_height)
.propagate_natural_height(true) .propagate_natural_height(true)
.build(), .build(),
); );

View file

@ -16,11 +16,17 @@ use tab::Tab;
use text::Text; use text::Text;
pub trait Titan { pub trait Titan {
fn titan(callback: impl Fn(Header, Bytes, Box<dyn Fn()>) + 'static) -> Self; fn titan(
max_content_height: i32,
callback: impl Fn(Header, Bytes, Box<dyn Fn()>) + 'static,
) -> Self;
} }
impl Titan for gtk::Box { impl Titan for gtk::Box {
fn titan(callback: impl Fn(Header, Bytes, Box<dyn Fn()>) + 'static) -> Self { fn titan(
max_content_height: i32,
callback: impl Fn(Header, Bytes, Box<dyn Fn()>) + 'static,
) -> Self {
use gtk::{Label, glib::uuid_string_random, prelude::ButtonExt}; use gtk::{Label, glib::uuid_string_random, prelude::ButtonExt};
use std::rc::Rc; use std::rc::Rc;
@ -38,7 +44,7 @@ impl Titan for gtk::Box {
notebook.append_page( notebook.append_page(
&gtk::ScrolledWindow::builder() &gtk::ScrolledWindow::builder()
.child(&text.text_view) .child(&text.text_view)
.max_content_height(320) .max_content_height(max_content_height)
.propagate_natural_height(true) .propagate_natural_height(true)
.build(), .build(),
Some(&Label::tab("Text")), Some(&Label::tab("Text")),