use cocoanut::prelude::*;
fn main() -> Result<()> {
event::register(1, || println!("✓ Segmented Control changed"));
event::register(2, || println!("✓ Search field updated"));
event::register(3, || println!("✓ Stepper value changed"));
app("Native Cocoa Features")
.size(900.0, 700.0)
.build()
.root(
View::vstack()
.child(
View::text("Enhanced Native Cocoa Features")
.bold()
.font_size(24.0)
.alignment(Alignment::Center),
)
.child(View::spacer())
.child(
View::group_box("Auto Layout & Styling").child(
View::vstack()
.child(
View::text(
"This view has shadow, corner radius, and layer backing",
)
.padding(10.0)
.shadow(5.0, 0.5, 2.0, 2.0)
.corner_radius(8.0)
.background("#f0f0f0")
.wants_layer(true),
)
.child(
View::button("Button with Custom Styling")
.shadow(3.0, 0.3, 0.0, 2.0)
.corner_radius(12.0),
),
),
)
.child(View::spacer())
.child(
View::group_box("Additional Native Controls").child(
View::vstack()
.child(View::text("Segmented Control:"))
.child(
View::segmented_control(vec!["Option 1", "Option 2", "Option 3"])
.on_click(1),
)
.child(View::spacer())
.child(View::text("Search Field:"))
.child(View::search_field("Type to search...").on_change(2))
.child(View::spacer())
.child(View::text("Combo Box:"))
.child(View::combo_box(vec!["Apple", "Banana", "Cherry", "Date"]))
.child(View::spacer())
.child(
View::hstack()
.child(View::text("Stepper:"))
.child(View::stepper(0.0, 100.0, 50.0).on_change(3)),
)
.child(View::spacer())
.child(View::text("Level Indicator:"))
.child(View::level_indicator(0.0, 100.0, 75.0)),
),
)
.child(View::spacer())
.child(
View::group_box("Advanced Features").child(
View::vstack()
.child(View::text("• Auto Layout support with NSLayoutConstraint"))
.child(View::text(
"• Native view properties (alpha, shadows, layers)",
))
.child(View::text("• Responder chain management"))
.child(View::text("• Animation support"))
.child(View::text("• Pasteboard (clipboard) operations"))
.child(View::text("• Delegate patterns for TableView and more")),
),
)
.child(View::spacer()),
)
.run()
}