feat: removed centerbox widget

This commit is contained in:
Byson94
2025-10-03 18:25:04 +05:30
parent 881910f1b3
commit ed15ddfaaa
7 changed files with 1 additions and 113 deletions

View File

@@ -21,7 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- X11 communication and x11 based window handling.
- Daemon GTK main loop.
- Application of sticky and stacking propery of window on X11.
- Centerbox widget rendering logic.
- The full implementation of eventbox widget.
- GTK controller/signal handling.
- Initialization logic of window.
@@ -37,9 +36,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- `transform`, `graph`, and `circular_progress` widget (temporarily).
- Application of css class on the window.
- Legacy GTK3 related code.
### Deprecated
- Centerbox widget.
## [0.2.0] - 2025-09-29

View File

@@ -41,9 +41,6 @@ fn build_gtk_widget_from_node(
let gtk_widget = match root_node {
WidgetNode::Box { props, children } => build_gtk_box(props, children, widget_reg)?.upcast(),
WidgetNode::CenterBox { props, children } => {
build_center_box(props, children, widget_reg)?.upcast()
}
WidgetNode::EventBox { props, children } => {
build_event_box(props, children, widget_reg)?.upcast()
}

View File

@@ -348,91 +348,6 @@ pub(super) fn build_tooltip(
Ok(gtk_widget)
}
pub(super) fn build_center_box(
props: &Map,
children: &Vec<WidgetNode>,
widget_registry: &mut WidgetRegistry,
) -> Result<gtk4::Box> {
let orientation = props
.get("orientation")
.and_then(|v| v.clone().try_cast::<String>())
.map(|s| parse_orientation(&s))
.transpose()?
.unwrap_or(gtk4::Orientation::Horizontal);
let count = children.len();
if count < 3 {
bail!("centerbox must contain exactly 3 children");
} else if count > 3 {
bail!("centerbox must contain exactly 3 children, but got more");
}
let first = build_gtk_widget(
&WidgetInput::Node(children.get(0).cloned().ok_or_else(|| anyhow!("missing child 0"))?),
widget_registry,
)?;
let center = build_gtk_widget(
&WidgetInput::Node(children.get(1).cloned().ok_or_else(|| anyhow!("missing child 1"))?),
widget_registry,
)?;
let end = build_gtk_widget(
&WidgetInput::Node(children.get(2).cloned().ok_or_else(|| anyhow!("missing child 2"))?),
widget_registry,
)?;
let gtk_widget = gtk4::Box::new(orientation, 0);
first.set_hexpand(true);
first.set_halign(gtk4::Align::Start);
center.set_hexpand(true);
center.set_halign(gtk4::Align::Center);
end.set_hexpand(true);
end.set_halign(gtk4::Align::End);
gtk_widget.append(&first);
gtk_widget.append(&center);
gtk_widget.append(&end);
let gtk_widget_clone = gtk_widget.clone();
let update_fn: UpdateFn = Box::new(move |props: &Map| {
let orientation = match props
.get("orientation")
.and_then(|v| v.clone().try_cast::<String>())
.map(|s| parse_orientation(&s))
.transpose()
{
Ok(opt) => opt.unwrap_or(gtk4::Orientation::Horizontal),
Err(e) => {
eprintln!("Error parsing orientation: {:?}", e);
gtk4::Orientation::Horizontal
}
};
gtk_widget_clone.set_orientation(orientation);
// now re-apply generic widget attrs
if let Err(err) =
resolve_rhai_widget_attrs(&gtk_widget_clone.clone().upcast::<gtk4::Widget>(), &props)
{
eprintln!("Failed to update widget attrs: {:?}", err);
}
});
let id = hash_props_and_type(&props, "CenterBox");
widget_registry
.widgets
.insert(id, WidgetEntry { update_fn, widget: gtk_widget.clone().upcast() });
resolve_rhai_widget_attrs(&gtk_widget.clone().upcast::<gtk4::Widget>(), &props)?;
Ok(gtk_widget)
}
struct EventBoxCtrlData {
// hover controller data
onhover_cmd: String,

View File

@@ -8,7 +8,6 @@ use std::hash::{Hash, Hasher};
pub enum WidgetNode {
Label { props: Map },
Box { props: Map, children: Vec<WidgetNode> },
CenterBox { props: Map, children: Vec<WidgetNode> },
Button { props: Map },
Image { props: Map },
Icon { props: Map },
@@ -73,20 +72,6 @@ pub fn get_id_to_widget_info<'a>(
get_id_to_widget_info(child, id_to_props, Some(id))?;
}
}
WidgetNode::CenterBox { props, children } => {
let id = hash_props_and_type(props, "CenterBox");
insert_wdgt_info(
node,
props,
"CenterBox",
children.as_slice(),
parent_id,
id_to_props,
)?;
for child in children {
get_id_to_widget_info(child, id_to_props, Some(id))?;
}
}
WidgetNode::EventBox { props, children } => {
let id = hash_props_and_type(props, "EventBox");
insert_wdgt_info(node, props, "EventBox", children.as_slice(), parent_id, id_to_props)?;

View File

@@ -67,7 +67,6 @@ pub fn register_all_widgets(engine: &mut Engine, all_nodes: &Rc<RefCell<Vec<Widg
}
register_with_children!("box", Box);
register_with_children!("centerbox", CenterBox);
register_with_children!("expander", Expander);
register_with_children!("revealer", Revealer);
register_with_children!("scroll", Scroll);

View File

@@ -39,10 +39,6 @@ impl WidgetNode {
props: with_dyn_id(props.clone(), parent_path),
children: process_children(children, parent_path, "box"),
},
WidgetNode::CenterBox { props, children } => WidgetNode::CenterBox {
props: with_dyn_id(props.clone(), parent_path),
children: process_children(children, parent_path, "centerbox"),
},
WidgetNode::Expander { props, children } => WidgetNode::Expander {
props: with_dyn_id(props.clone(), parent_path),
children: process_children(children, parent_path, "expander"),

View File

@@ -1,5 +1,5 @@
fn bar(music_var, volume, time) {
return centerbox(#{ orientation: "h" }, [
return box(#{ orientation: "h" }, [
workspaces(),
music(music_var),
sidestuff(volume, time),