Derive more traits for widgets

This commit is contained in:
Joscha 2023-04-08 15:40:14 +02:00
parent 77e72de9ad
commit 007493f136
6 changed files with 10 additions and 1 deletions

View file

@ -90,7 +90,7 @@ impl StackFrame {
}
}
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct Buffer {
size: Size,
data: Vec<Cell>,

View file

@ -20,6 +20,7 @@ fn wrap(widthdb: &mut WidthDb, text: &str, width: usize) -> Vec<usize> {
// State //
///////////
#[derive(Debug, Clone)]
pub struct EditorState {
text: String,
@ -339,6 +340,7 @@ impl Default for EditorState {
// Widget //
////////////
#[derive(Debug)]
pub struct Editor<'a> {
state: &'a mut EditorState,
highlighted: Styled,

View file

@ -229,6 +229,7 @@ fn shrink(mut segments: Vec<&mut Segment>, mut available: u16) {
}
}
#[derive(Debug, Clone, Copy)]
pub struct JoinSegment<I> {
pub inner: I,
weight: f32,
@ -353,6 +354,7 @@ fn sum_major_max_minor(segments: &[Segment]) -> (u16, u16) {
(major, minor)
}
#[derive(Debug, Clone)]
pub struct Join<I> {
horizontal: bool,
segments: Vec<JoinSegment<I>>,
@ -511,6 +513,7 @@ macro_rules! mk_join {
$( pub $arg:ident: $type:ident [$n:expr], )+
}
) => {
#[derive(Debug, Clone, Copy)]
pub struct $name< $($type),+ >{
horizontal: bool,
$( pub $arg: JoinSegment<$type>, )+

View file

@ -2,6 +2,7 @@ use async_trait::async_trait;
use crate::{AsyncWidget, Frame, Size, Widget, WidthDb};
#[derive(Debug, Clone)]
pub struct Layer<I> {
layers: Vec<I>,
}
@ -73,6 +74,7 @@ macro_rules! mk_layer {
$( pub $arg:ident: $type:ident, )+
}
) => {
#[derive(Debug, Clone, Copy)]
pub struct $name< $($type),+ >{
$( pub $arg: $type, )+
}

View file

@ -5,6 +5,7 @@ use async_trait::async_trait;
use crate::buffer::Buffer;
use crate::{AsyncWidget, Frame, Pos, Size, Style, Styled, Widget, WidthDb};
#[derive(Debug, Clone)]
pub struct Predrawn {
buffer: Buffer,
}

View file

@ -2,6 +2,7 @@ use async_trait::async_trait;
use crate::{AsyncWidget, Frame, Size, Widget, WidthDb};
#[derive(Debug, Clone, Copy)]
pub struct Resize<I> {
pub inner: I,
pub min_width: Option<u16>,