package openonyx.ui.internal; import java.util.function.Consumer; import openonyx.render.Render2D; import openonyx.render.group_d.ColorAnimation; import openonyx.render.group_e.FontStyle; import openonyx.theme.Fonts; import openonyx.theme.ThemeManager; import openonyx.ui.RenderContext; import openonyx.ui.UiSupport_545; public class SearchField extends TextInput { private final UiSupport_545 uiSupport_545 = new UiSupport_545(); private Runnable runnable; private static final float L = 11.0F; private static final float j = 2.0F; public static final float m = 40.0F; private static final float h = 1.0F; private static final float l = 12.0F; private static final float I = 9.0F; private Consumer stringConsumer; private static final float H = 12.0F; private final String e; @Override protected float l() { return this.f + 12.0F; } @Override public void update(RenderContext renderContext) { super.update(renderContext); this.uiSupport_545.L(renderContext.i, this.h, false); } public void L(Consumer consumer) { this.stringConsumer = consumer; } public SearchField(String string) { this.e = string; this.i = 40.0F; this.textEditor.L(string -> { if (this.stringConsumer != null) { this.stringConsumer.accept(stringx); } }); this.textEditor.d(() -> { if (this.runnable != null) { this.runnable.run(); } }); this.textEditor.L(() -> this.D(false)); } @Override protected FontStyle L() { return Fonts.getFontstylE15(); } public void L(Runnable runnable) { this.runnable = runnablex; } @Override protected float h() { return this.f + this.e - 12.0F; } @Override public void render(RenderContext renderContext) { Render2D render2D = renderContext.render2D; float f = this.animation.getValue(); boolean bl = this.i() || !this.textEditor.L(); render2D.roundedRect(this.f, this.d, this.e, this.i, 4.0F, renderContext.palette().surfaceContainerHighest()); this.uiSupport_545.L(render2D, this.f, this.d, this.e, this.i, 4.0F, renderContext.palette().onSurface()); render2D.roundedOutline( this.f, this.d, this.e, this.i, 4.0F, 1.0F + 1.0F * f, ColorAnimation.L(renderContext.palette().outline(), renderContext.palette().primary(), f) ); SearchField searchField1; if (bl) { render2D.drawTextVCentered( Fonts.getFontstylE2(), this.e, this.l(), this.d + 9.0F, f > 0.5F ? renderContext.palette().primary() : renderContext.palette().onSurfaceVariant() ); searchField1 = this; } else { render2D.drawTextVCentered( this.L(), this.e, this.l(), this.d + this.i / 2.0F, ThemeManager.withAlpha(renderContext.palette().onSurfaceVariant(), 0.7F) ); searchField1 = this; } searchField1.L(renderContext, bl ? this.d + this.i - 11.0F : this.d + this.i / 2.0F, 12.0F, renderContext.palette().onSurface()); if (this.h) { render2D.useTextCursor(); } } }