Some im objects
This commit is contained in:
parent
f9566526b1
commit
df86e3b95c
|
@ -0,0 +1,29 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
abstract public class AbstractImComponentDataˣᴹᴵ implements ImComponentDataˣᴹᴵ {
|
||||
|
||||
private Function<Object, Object> dataExtractor;
|
||||
|
||||
@Override
|
||||
public void setDataExtractor(Function<Object, Object> dataExtractor) {
|
||||
this.dataExtractor = dataExtractor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<Object, Object> getDataExtractor() {
|
||||
return dataExtractor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBegin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderEnd() {
|
||||
}
|
||||
}
|
|
@ -1,8 +1,41 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import imgui.ImGui;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class ImButtonˣᴹᴵ {
|
||||
|
||||
public class ImButtonˣᴹᴵ extends AbstractImComponentˣᴹᴵ {
|
||||
|
||||
private String label;
|
||||
private Runnable callback;
|
||||
|
||||
public ImButtonˣᴹᴵ() {
|
||||
}
|
||||
|
||||
public ImButtonˣᴹᴵ(String label) {
|
||||
setLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderComponent() {
|
||||
if (ImGui.button(label) && callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Runnable getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(Runnable callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.type.ImInt;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class ImComboˣᴹᴵ extends AbstractImComponentˣᴹᴵ {
|
||||
|
||||
private String label;
|
||||
private final ImInt currentItem = new ImInt();
|
||||
private String[] items;
|
||||
private Runnable callback;
|
||||
|
||||
public ImComboˣᴹᴵ() {
|
||||
}
|
||||
|
||||
public ImComboˣᴹᴵ(String label) {
|
||||
setLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderComponent() {
|
||||
if (ImGui.combo(label, currentItem, items) && callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Runnable getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(Runnable callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public ImInt getCurrentItem() {
|
||||
return currentItem;
|
||||
}
|
||||
|
||||
public String[] getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(String[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public interface ImComponentDataˣᴹᴵ extends ImComponentˣᴹᴵ {
|
||||
|
||||
void setDataExtractor(Function<Object, Object> dataExtractor);
|
||||
|
||||
Function<Object, Object> getDataExtractor();
|
||||
|
||||
void setData(Object value);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import imgui.ImGui;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class ImSameLineˣᴹᴵ extends AbstractImComponentˣᴹᴵ {
|
||||
|
||||
public ImSameLineˣᴹᴵ() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderComponent() {
|
||||
ImGui.sameLine();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import imgui.ImGui;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class ImSeparatorˣᴹᴵ extends AbstractImComponentˣᴹᴵ {
|
||||
|
||||
public ImSeparatorˣᴹᴵ() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderComponent() {
|
||||
ImGui.separator();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiTableFlags;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class ImTableˣᴹᴵ extends AbstractImComponentˣᴹᴵ {
|
||||
|
||||
private String id;
|
||||
private int flags;
|
||||
private List<String> columns;
|
||||
private Supplier<List<Object>> dataSupplier;
|
||||
private List<ImComponentDataˣᴹᴵ> components = new ArrayList<>();
|
||||
|
||||
|
||||
public ImTableˣᴹᴵ() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public ImTableˣᴹᴵ(String id) {
|
||||
this.id = id;
|
||||
this.columns = new ArrayList<>();
|
||||
this.flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBegin() {
|
||||
ImGui.beginTable(id, columns.size(), flags);
|
||||
for (String column:columns) {
|
||||
ImGui.tableSetupColumn(column);
|
||||
}
|
||||
ImGui.tableHeadersRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderComponent() {
|
||||
List<Object> rows = dataSupplier.get();
|
||||
for (Object row:rows) {
|
||||
ImGui.tableNextRow();
|
||||
for (ImComponentDataˣᴹᴵ comp:getComponents()) {
|
||||
ImGui.tableNextColumn();
|
||||
comp.setData(row);
|
||||
comp.renderBegin();
|
||||
comp.renderComponent();
|
||||
comp.renderEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderEnd() {
|
||||
ImGui.endTable();
|
||||
}
|
||||
|
||||
public void addComponent(ImComponentDataˣᴹᴵ comp) {
|
||||
components.add(comp);
|
||||
}
|
||||
|
||||
public void removeComponent(ImComponentDataˣᴹᴵ comp) {
|
||||
components.remove(comp);
|
||||
}
|
||||
|
||||
public List<ImComponentDataˣᴹᴵ> getComponents() {
|
||||
return components;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package love.distributedrebirth.imxmi.lang;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import imgui.ImGui;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
|
||||
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
|
||||
public class ImTextDataˣᴹᴵ extends AbstractImComponentDataˣᴹᴵ {
|
||||
|
||||
private String text;
|
||||
|
||||
public ImTextDataˣᴹᴵ() {
|
||||
}
|
||||
|
||||
public ImTextDataˣᴹᴵ(Function<Object, Object> dataExtractor) {
|
||||
setDataExtractor(dataExtractor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderComponent() {
|
||||
ImGui.text(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Object value) {
|
||||
text = String.class.cast(getDataExtractor().apply(value));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue