Preview
Loading GPUI
Install
cargo add evilbuttonsUsage
use evilbuttons::DemonicButton;
use gpui::{div, prelude::*, Context, IntoElement, Render, Window};
use std::time::Duration;
struct ButtonDemo;
impl Render for ButtonDemo {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().child(
DemonicButton::new("corrupt")
.label("Corrupt the World")
.hold_duration(Duration::from_millis(1800))
.on_summon(|_, _| println!("Summoned")),
)
}
}Variants
Quick summon
Shorten hold_duration for a faster ritual.
Loading GPUI
DemonicButton::new("sell-soul")
.hold_duration(Duration::from_millis(900))
.label("Sell Soul")Props
DemonicButton is a GPUI RenderOnce builder; its charge and fire are keyed by id.
| Method | Type | Default | Description |
|---|---|---|---|
new(id) | impl Into<ElementId> | - | Unique id for the charge and fire state. |
label(s) | impl Into<SharedString> | "Summon" | Button label. |
hold_duration(d) | Duration | 2200ms | How long the hold takes to fully summon. |
on_summon(f) | Fn(&mut Window, &mut App) | - | Fired once each time the charge reaches 100%. |
disabled(bool) | bool | false | Dims the button and ignores input. |
Good to know
- The fire is a particle system simulated every frame; each particle is a Gaussian-blurred disc standing in for the original's radial-gradient sprites.
- The horns are the original SVG paths, painted as GPUI paths; their four-stop gradient is drawn as thin bands.
- Release early and the charge drains 2.4× faster than it filled. Hold Space or Enter to summon from the keyboard.