mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
use shared input max height value
This commit is contained in:
parent
4905d55e8a
commit
e813cdeafa
3 changed files with 23 additions and 6 deletions
|
|
@ -61,7 +61,13 @@ impl Input {
|
|||
title: Option<&str>,
|
||||
size_limit: Option<usize>,
|
||||
) {
|
||||
self.update(Some(>k::Box::response(action, base, title, size_limit)));
|
||||
self.update(Some(>k::Box::response(
|
||||
action,
|
||||
base,
|
||||
title,
|
||||
size_limit,
|
||||
MAX_CONTENT_HEIGHT,
|
||||
)));
|
||||
}
|
||||
|
||||
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) {
|
||||
self.update(Some(>k::Box::titan(on_send)));
|
||||
self.update(Some(>k::Box::titan(MAX_CONTENT_HEIGHT, on_send)));
|
||||
}
|
||||
}
|
||||
|
||||
/// @TODO optional, maybe relative to the current window height in %
|
||||
const MAX_CONTENT_HEIGHT: i32 = 280;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ pub trait Response {
|
|||
base: Uri,
|
||||
title: Option<&str>,
|
||||
size_limit: Option<usize>,
|
||||
max_content_height: i32,
|
||||
) -> Self;
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ impl Response for Box {
|
|||
base: Uri,
|
||||
title: Option<&str>,
|
||||
size_limit: Option<usize>,
|
||||
max_content_height: i32,
|
||||
) -> Self {
|
||||
// Init components
|
||||
let control = Rc::new(Control::build());
|
||||
|
|
@ -55,7 +57,7 @@ impl Response for Box {
|
|||
g_box.append(
|
||||
>k::ScrolledWindow::builder()
|
||||
.child(&text_view)
|
||||
.max_content_height(320)
|
||||
.max_content_height(max_content_height)
|
||||
.propagate_natural_height(true)
|
||||
.build(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,11 +16,17 @@ use tab::Tab;
|
|||
use text::Text;
|
||||
|
||||
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 {
|
||||
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 std::rc::Rc;
|
||||
|
||||
|
|
@ -38,7 +44,7 @@ impl Titan for gtk::Box {
|
|||
notebook.append_page(
|
||||
>k::ScrolledWindow::builder()
|
||||
.child(&text.text_view)
|
||||
.max_content_height(320)
|
||||
.max_content_height(max_content_height)
|
||||
.propagate_natural_height(true)
|
||||
.build(),
|
||||
Some(&Label::tab("Text")),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue