use std::{collections::HashSet, rc::Rc}; use gpui::{ AnyElement, App, Div, ElementId, Entity, InteractiveElement, IntoElement, MouseButton, ParentElement, Pixels, Rems, ScrollHandle, SharedString, Stateful, StatefulInteractiveElement, Styled, Window, div, prelude::*, transparent_black, }; use super::{Align, Column, Row, cell::draw, model::tint, table::View}; use crate::{ forms::{CheckState, Editing, Input, check_mark}, layout::on_axis, lists::Pick, primitives::Disclosure, theme::{ActiveTheme, ControlSize, TextSize}, }; pub(super) type Select = Rc; pub(super) type Detail = Rc AnyElement>; pub(super) type OnEdit = Rc; /// Gives a cell its column's width: fixed, or a share of what is left. pub(super) fn sized(cell: E, column: &Column, narrowest: Rems) -> E { let cell = match column.width { Some(width) => cell.w(width).flex_none(), None => cell.flex_1().min_w(narrowest), }; if column.align == Align::End { cell.justify_end() } else { cell } } /// A box a table's columns scroll sideways in, tracked by `handle`; a plain wheel passes to the page. pub(super) fn sideways(id: &ElementId, handle: &ScrollHandle) -> Stateful
{ on_axis( div() .id((id.clone(), "sideways")) .overflow_x_scroll() .track_scroll(handle), ) } /// What the body draws, one after another. #[derive(Clone, Debug, PartialEq)] pub(super) enum Line { Group { name: SharedString, count: usize, folded: bool, }, Row { ix: usize, position: usize, }, Detail { ix: usize, }, } /// What drawing lines needs, shared by pages and by a long table's list. pub(super) struct Body { pub id: ElementId, pub view: Entity, pub columns: Rc>, pub widths: Rc>>, pub rows: Rc>, pub lines: Rc>, pub selected: Option>>, pub select: Option