Search in sources :

Example 1 with ButtonSet

use of spacegraph.space2d.widget.tab.ButtonSet in project narchy by automenta.

the class Sketch2DBitmap method menu.

@Override
public Surface menu() {
    ButtonSet<ColorToggle> colorMenu = new ButtonSet<>(ButtonSet.Mode.One, // black
    new ColorToggle(0f, 0, 0), // red
    new ColorToggle(1f, 0, 0), // orange
    new ColorToggle(1f, 0.5f, 0), // yellow
    new ColorToggle(0.75f, 0.75f, 0), // green
    new ColorToggle(0f, 1, 0), // blue
    new ColorToggle(0f, 0, 1), // purple
    new ColorToggle(1f, 0, 1), // gray
    new ColorToggle(0.5f, 0.5f, 0.5f), // white
    new ColorToggle(1f, 1, 1));
    colorMenu.on((cc, e) -> {
        if (e) {
            color(cc.r, cc.g, cc.b);
        }
    });
    Surface toolMenu = grid(new XYSlider().on((_width, _alpha) -> {
        brushWidth = Util.lerp(_width, 0.1f, 3f);
        brushAlpha = Util.lerp(_alpha, 0.1f, 3f);
    }).set(0.5f, 0.75f));
    return grid(colorMenu, toolMenu);
}
Also used : ButtonSet(spacegraph.space2d.widget.tab.ButtonSet) XYSlider(spacegraph.space2d.widget.slider.XYSlider) ColorToggle(spacegraph.space2d.widget.button.ColorToggle) Surface(spacegraph.space2d.Surface)

Example 2 with ButtonSet

use of spacegraph.space2d.widget.tab.ButtonSet in project narchy by automenta.

the class AutoSurface method newSwitch.

private ButtonSet newSwitch(EnumParam x) {
    ToggleButton[] b = ((EnumSet<?>) EnumSet.allOf(x.klass)).stream().map(e -> {
        CheckBox tb = new CheckBox(e.name());
        tb.on((c, enabled) -> {
            if (enabled)
                x.set(e);
        });
        return tb;
    }).toArray(ToggleButton[]::new);
    ButtonSet s = new ButtonSet(ButtonSet.Mode.One, b);
    return s;
}
Also used : java.util(java.util) Surface(spacegraph.space2d.Surface) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Widget(spacegraph.space2d.widget.windo.Widget) IntSlider(spacegraph.space2d.widget.slider.IntSlider) ButtonSet(spacegraph.space2d.widget.tab.ButtonSet) Gridding(spacegraph.space2d.container.Gridding) ToggleButton(spacegraph.space2d.widget.button.ToggleButton) LabeledPane(spacegraph.space2d.widget.text.LabeledPane) FloatSlider(spacegraph.space2d.widget.slider.FloatSlider) PushButton(spacegraph.space2d.widget.button.PushButton) Ons(jcog.event.Ons) FasterList(jcog.list.FasterList) EnumParam(jcog.math.EnumParam) FloatRange(jcog.math.FloatRange) Service(jcog.Service) IntRange(jcog.math.IntRange) Field(java.lang.reflect.Field) Sets(com.google.common.collect.Sets) CheckBox(spacegraph.space2d.widget.button.CheckBox) Nullable(org.jetbrains.annotations.Nullable) SurfaceBase(spacegraph.space2d.SurfaceBase) SpaceGraph(spacegraph.SpaceGraph) Modifier(java.lang.reflect.Modifier) Services(jcog.Services) ToggleButton(spacegraph.space2d.widget.button.ToggleButton) ButtonSet(spacegraph.space2d.widget.tab.ButtonSet) CheckBox(spacegraph.space2d.widget.button.CheckBox)

Aggregations

Surface (spacegraph.space2d.Surface)2 ButtonSet (spacegraph.space2d.widget.tab.ButtonSet)2 Sets (com.google.common.collect.Sets)1 Field (java.lang.reflect.Field)1 Modifier (java.lang.reflect.Modifier)1 java.util (java.util)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Service (jcog.Service)1 Services (jcog.Services)1 Ons (jcog.event.Ons)1 FasterList (jcog.list.FasterList)1 EnumParam (jcog.math.EnumParam)1 FloatRange (jcog.math.FloatRange)1 IntRange (jcog.math.IntRange)1 Nullable (org.jetbrains.annotations.Nullable)1 SpaceGraph (spacegraph.SpaceGraph)1 SurfaceBase (spacegraph.space2d.SurfaceBase)1 Gridding (spacegraph.space2d.container.Gridding)1 CheckBox (spacegraph.space2d.widget.button.CheckBox)1 ColorToggle (spacegraph.space2d.widget.button.ColorToggle)1