Fixed hardcoded child frame height + no mouse

This commit is contained in:
Willem Cazander 2022-03-26 13:43:24 +01:00
parent 30a4d6919d
commit 909b39f519
4 changed files with 13 additions and 10 deletions

View file

@ -5,6 +5,7 @@ import java.util.ResourceBundle;
import imgui.ImGui;
import imgui.flag.ImGuiStyleVar;
import imgui.flag.ImGuiTableFlags;
import imgui.flag.ImGuiWindowFlags;
import imgui.type.ImBoolean;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4Unicode4DService;
@ -61,13 +62,10 @@ public class DemoUnicodePlaneDeskApp extends AbstractDeskApp implements DeskAppR
ImGui.text(buf.toString());
} else {
ImGui.pushStyleVar(ImGuiStyleVar.ItemSpacing, 0f, 0f);
DrawCharacter drawChar2 = unicode4DService.getCharacterForUnicode(' ');
if (drawChar2 != null) {
ImCharacter.render(drawChar2);
ImGui.sameLine(); // print before beginChild to fix row height of table
}
int offset = 33;
ImGui.beginChild("row"+plane.name()); // workaround for error; Too many vertices in ImDrawList using 16-bit indices.
// workaround for error; Too many vertices in ImDrawList using 16-bit indices.
// hard coded height to fix line height and row0 height + no scoll to disable mouse scroll
ImGui.beginChild("row"+plane.name(), 0f, ImCharacter.HEIGHT, false, ImGuiWindowFlags.NoScrollWithMouse);
for (int i=plane.getStart()+offset;i<plane.getStart()+33+offset;i++) {
DrawCharacter drawChar = unicode4DService.getCharacterForUnicode(i);
if (drawChar != null) {

View file

@ -10,8 +10,10 @@ import love.distributedrebirth.unicode4d.draw.DrawGlyphPath.ImGlyphQuadCurveTo;
public class ImCharacter {
public static final float HEIGHT = 26f;
public static void render(DrawCharacter drawChar) {
ImVec2 size = new ImVec2(22f, 26f);
ImVec2 size = new ImVec2(22f, HEIGHT);
ImGui.invisibleButton("canvas", size.x, size.y);
ImVec2 p0 = ImGui.getItemRectMin();
ImVec2 p1 = ImGui.getItemRectMax(); // p1 = p0 + size

View file

@ -15,6 +15,7 @@ import imgui.flag.ImGuiBackendFlags;
import imgui.gl3.ImGuiImplGl3;
import imgui.glfw.ImGuiImplGlfw;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.unicode4d.draw.ImCharacter;
/**
* Create and shutdown of ImGui and font activations.
@ -57,10 +58,11 @@ public class ImGuiSetup {
addRangeUnicodePlane0(fontBuilder);
final short[] glyphRanges = fontBuilder.buildRanges();
float fontSize = ImCharacter.HEIGHT;
boolean first = true;
for (File font: fonts) {
logger.accept("Load font: "+font);
io.getFonts().addFontFromMemoryTTF(Gdx.files.absolute(font.getAbsolutePath()).readBytes(), 22, fontConfig, glyphRanges);
io.getFonts().addFontFromMemoryTTF(Gdx.files.absolute(font.getAbsolutePath()).readBytes(), fontSize, fontConfig, glyphRanges);
if (first) {
fontConfig.setMergeMode(true);
first = false;

View file

@ -3,6 +3,7 @@ package love.distributedrebirth.gdxapp4d.vrgem4.view;
import com.badlogic.gdx.InputProcessor;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.unicode4d.draw.ImCharacter;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class DeskAppInputProcessor implements InputProcessor {
@ -23,8 +24,8 @@ public class DeskAppInputProcessor implements InputProcessor {
}
private boolean isFilterMenu(int screenY) {
// font22 + margin top-bottom = 26px
if (screenY <= 26) {
// font + margin top-bottom = 4px
if (screenY <= ImCharacter.HEIGHT+4) {
return true;
}
return false;