use serde::{Deserialize, Serialize};
use super::*;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(tag = "kind", rename_all = "snake_case")]
#[non_exhaustive]
#[cfg_attr(feature = "schema", schemars(description = "A widget in the spec tree."))]
pub enum WidgetSpec {
Label {
text: String,
size: f32,
tone: String,
strong: bool,
},
Button {
id: String,
label: String,
variant: String,
enabled: bool,
},
TextField {
id: String,
label: String,
value: String,
hint: String,
},
Checkbox {
id: String,
label: String,
checked: bool,
},
Switch {
id: String,
label: String,
on: bool,
},
Select {
id: String,
label: String,
options: Vec<String>,
selected: usize,
},
Slider {
id: String,
label: String,
min: f64,
max: f64,
value: f64,
step: f64,
},
Separator,
Spacer {
height: f32,
},
Row {
children: Vec<WidgetSpec>,
gap: f32,
},
Column {
children: Vec<WidgetSpec>,
gap: f32,
},
Card {
title: String,
children: Vec<WidgetSpec>,
},
Tabs {
id: String,
tabs: Vec<String>,
active: usize,
children: Vec<Vec<WidgetSpec>>,
},
Tree {
id: String,
nodes: Vec<TreeSpec>,
selected: Option<String>,
},
DataGrid {
id: String,
dataset: String,
height: f32,
},
Plot {
id: String,
title: String,
series: Vec<SeriesSpec>,
height: f32,
renderer: String,
},
Custom {
widget: String,
props: serde_json::Value,
},
}