Skip to content

Commit 72951b4

Browse files
committed
Comments about GlyphExtraSpacing
ocornut/imgui@41f9442
1 parent 1b1126d commit 72951b4

File tree

9 files changed

+58
-52
lines changed

9 files changed

+58
-52
lines changed

src/main/kotlin/imgui/enums.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ infix fun Int.hasnt(b: WindowFlags) = (this and b.i) == 0
7474
enum class InputTextFlags(val i: Int) {
7575

7676
// Default: 0
77-
77+
Null(0),
7878
/** Allow 0123456789 . + - * / */
7979
CharsDecimal(1 shl 0),
8080
/** Allow 0123456789ABCDEFabcdef */

src/main/kotlin/imgui/font.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class FontConfig {
3838
/** Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default
3939
* font. If enabled, you can set OversampleH/V to 1. */
4040
var pixelSnapH = false
41-
/** Extra spacing (in pixels) between glyphs */
41+
/** Extra spacing (in pixels) between glyphs. Only X axis is supported for now. */
4242
var glyphExtraSpacing = Vec2()
4343
/** Offset all glyphs from this font input */
4444
var glyphOffset = Vec2()

src/main/kotlin/imgui/helpers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Storage {
8888

8989
fun clear() = data.clear()
9090

91-
fun intaa(key: Int, defaultVal: Int = 0) = data[key] ?: defaultVal // TODO rename back
91+
fun intaaa(key: Int, defaultVal: Int = 0) = data[key] ?: defaultVal // TODO rename back
9292

9393
operator fun set(key: Int, value: Int) {
9494
data[key] = value

src/main/kotlin/imgui/imgui/demoDebugInfo.kt

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ import imgui.internal.Window
105105
import java.util.*
106106
import imgui.Context as g
107107
import glm_.vec2.operators.div
108+
import imgui.ImGui.inputTextMultiline
108109
import imgui.ImGui.isMouseDoubleClicked
109110
import imgui.ImGui.newLine
110111

@@ -383,9 +384,9 @@ interface imgui_demoDebugInfo {
383384
}
384385
offset += 4
385386
treeNode("Rendering more text into the same block") {
386-
selectable("main.c", selected, offset+0); sameLine(300f); text(" 2,345 bytes")
387-
selectable("Hello.cpp", selected, offset+1); sameLine(300f); text("12,345 bytes")
388-
selectable("Hello.h", selected, offset+2); sameLine(300f); text(" 2,345 bytes")
387+
selectable("main.c", selected, offset + 0); sameLine(300f); text(" 2,345 bytes")
388+
selectable("Hello.cpp", selected, offset + 1); sameLine(300f); text("12,345 bytes")
389+
selectable("Hello.h", selected, offset + 2); sameLine(300f); text(" 2,345 bytes")
389390
}
390391
offset += 3
391392
treeNode("In columns") {
@@ -416,7 +417,7 @@ interface imgui_demoDebugInfo {
416417
}
417418

418419
treeNode("Filtered Text Input TODO") {
419-
// static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
420+
// static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
420421
// static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
421422
// static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
422423
// static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
@@ -430,28 +431,14 @@ interface imgui_demoDebugInfo {
430431
// ImGui::SameLine(); ShowHelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
431432
// ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
432433
}
433-
//
434-
// if (ImGui::TreeNode("Multi-line Text Input"))
435-
// {
436-
// static bool read_only = false;
437-
// static char text[1024*16] =
438-
// "/*\n"
439-
// " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
440-
// " the hexadecimal encoding of one offending instruction,\n"
441-
// " more formally, the invalid operand with locked CMPXCHG8B\n"
442-
// " instruction bug, is a design flaw in the majority of\n"
443-
// " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
444-
// " processors (all in the P5 microarchitecture).\n"
445-
// "*/\n\n"
446-
// "label:\n"
447-
// "\tlock cmpxchg8b eax\n";
448-
//
449-
// ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
450-
// ImGui::Checkbox("Read-only", &read_only);
451-
// ImGui::PopStyleVar();
452-
// ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), ImGuiInputTextFlags_AllowTabInput | (read_only ? ImGuiInputTextFlags_ReadOnly : 0));
453-
// ImGui::TreePop();
454-
// }
434+
435+
treeNode("Multi-line Text Input TODO") {
436+
withStyleVar(StyleVar.FramePadding, Vec2()) {
437+
checkbox("Read-only", readOnly)
438+
}
439+
val flags = InputTextFlags.AllowTabInput or if(readOnly[0]) InputTextFlags.ReadOnly else InputTextFlags.Null
440+
// inputTextMultiline("##source", textMultiline, Vec2(-1f, textLineHeight * 16), flags)
441+
}
455442
//
456443
// static bool a=false;
457444
// if (ImGui::Button("Button")) { printf("Clicked\n"); a ^= 1; }
@@ -2168,7 +2155,21 @@ interface imgui_demoDebugInfo {
21682155

21692156
val selected = BooleanArray(4 + 3 + 16 + 16, { it == 1 || it == 23 + 0 || it == 23 + 5 || it == 23 + 10 || it == 23 + 15 })
21702157

2171-
// { true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, true };
2158+
val readOnly = booleanArrayOf(false)
2159+
2160+
val textMultiline = CharArray(1024 * 16).also {
2161+
("""/*
2162+
The Pentium F00F bug, shorthand for F0 0F C7 C8,
2163+
the hexadecimal encoding of one offending instruction,
2164+
more formally, the invalid operand with locked CMPXCHG8B
2165+
instruction bug, is a design flaw in the majority of
2166+
Intel Pentium, Pentium MMX, and Pentium OverDrive
2167+
processors (all in the P5 microarchitecture).
2168+
*/
2169+
2170+
label""".trimMargin() +
2171+
"\tlock cmpxchg8b eax\n").toCharArray(it)
2172+
}
21722173
}
21732174

21742175
/** Demonstrating creating a simple console window, with scrolling, filtering, completion and history.

src/main/kotlin/imgui/imgui/internal.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ interface imgui_internal {
16201620
} else {
16211621
/* We treat ImGuiSetCondition_Once and ImGuiSetCondition_FirstUseEver the same because tree node state
16221622
are not saved persistently. */
1623-
val storedValue = storage.intaa(id, -1)
1623+
val storedValue = storage.intaaa(id, -1)
16241624
if (storedValue == -1) {
16251625
isOpen = g.setNextTreeNodeOpenVal
16261626
storage[id] = isOpen
@@ -1629,7 +1629,7 @@ interface imgui_internal {
16291629
}
16301630
g.setNextTreeNodeOpenCond = 0
16311631
} else
1632-
isOpen = storage.intaa(id, if (flags has TreeNodeFlags.DefaultOpen) 1 else 0) != 0 // TODO rename back
1632+
isOpen = storage.intaaa(id, if (flags has TreeNodeFlags.DefaultOpen) 1 else 0) != 0 // TODO rename back
16331633

16341634
/* When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like
16351635
sensible behavior).

src/main/kotlin/imgui/imgui/widgetsInputKeyboard.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import imgui.ImGui.inputTextEx
77
import imgui.InputTextFlags
88
import imgui.hasnt
99
import imgui.internal.DataType
10+
import imgui.or
1011
import imgui.Context as g
1112

1213
/** Widgets: Input with Keyboard */
@@ -19,7 +20,10 @@ interface imgui_widgetsInputKeyboard {
1920
assert(flags hasnt InputTextFlags.Multiline) // call InputTextMultiline()
2021
return inputTextEx(label, buf, Vec2(), flags/*, callback, user_data*/)
2122
}
22-
// IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
23+
24+
fun inputTextMultiline(label: String, buf: CharArray, size: Vec2 = Vec2(), flags: Int = 0
25+
/*,ImGuiTextEditCallback callback = NULL, void* user_data = NULL*/) =
26+
inputTextEx(label, buf, size, flags or InputTextFlags.Multiline/*, callback, user_data*/)
2327

2428
fun inputFloat(label: String, v: FloatArray, step: Float = 0f, stepFast: Float = 0f, decimalPrecision: Int = -1, extraFlags: Int = 0) =
2529
inputFloat(label, v, 0, step, stepFast, decimalPrecision, extraFlags)

src/main/kotlin/imgui/impl/JoglGL3.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ object JoglGL3 {
104104
IO.deltaTime = if (time > 0) (currentTime - time).f else 1f / 60f
105105
time = currentTime
106106

107-
// Setup inputs
108-
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
109-
// Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
107+
/* Setup inputs
108+
(we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
109+
Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) */
110110
if (window.hasFocus())
111111
IO.mousePos put cursorPos
112112
else

src/main/kotlin/imgui/impl/JoglVrGL3.kt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import uno.glsl.Program
2323
object JoglVrGL3 {
2424

2525
lateinit var window: GLWindow
26+
val texSize = Vec2i()
2627
var time = 0.0
2728
val mousePressed = BooleanArray(3)
2829
var mouseWheel = 0f
@@ -40,9 +41,10 @@ object JoglVrGL3 {
4041

4142
val mat = Mat4()
4243

43-
fun init(window: GLWindow, installCallbacks: Boolean): Boolean {
44+
fun init(window: GLWindow, texSize: Vec2i, installCallbacks: Boolean): Boolean {
4445

4546
this.window = window
47+
this.texSize put texSize
4648

4749
with(IO) {
4850
// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
@@ -72,8 +74,8 @@ object JoglVrGL3 {
7274
}
7375

7476
if (installCallbacks) {
75-
window.addMouseListener(mouseCallback)
76-
window.addKeyListener(keyCallback)
77+
// window.addMouseListener(mouseCallback)
78+
// window.addKeyListener(keyCallback)
7779
}
7880

7981
return true
@@ -95,8 +97,7 @@ object JoglVrGL3 {
9597
createDeviceObjects(gl)
9698

9799
// Setup display size (every frame to accommodate for window resizing)
98-
IO.displaySize.x = window.width
99-
IO.displaySize.y = window.height
100+
IO.displaySize put texSize
100101
IO.displayFramebufferScale.x = 1f //if (window.width > 0) window.framebufferSize.x / window.size.x.f else 0f
101102
IO.displayFramebufferScale.y = 1f //if (window.height > 0) window.framebufferSize.y / window.size.y.f else 0f
102103

@@ -105,13 +106,13 @@ object JoglVrGL3 {
105106
IO.deltaTime = if (time > 0) (currentTime - time).f else 1f / 60f
106107
time = currentTime
107108

108-
// Setup inputs
109-
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
110-
// Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
111-
if (window.hasFocus())
112-
IO.mousePos put cursorPos
113-
else
114-
IO.mousePos put -1
109+
/* Setup inputs
110+
(we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
111+
Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) */
112+
// if (window.hasFocus())
113+
// IO.mousePos put cursorPos
114+
// else
115+
// IO.mousePos put -1
115116

116117
repeat(3) {
117118
/* If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release
@@ -123,7 +124,7 @@ object JoglVrGL3 {
123124
mouseWheel = 0f
124125

125126
// Hide OS mouse cursor if ImGui is drawing it
126-
window.isPointerVisible = !IO.mouseDrawCursor
127+
// window.isPointerVisible = !IO.mouseDrawCursor
127128

128129
// Start the frame
129130
ImGui.newFrame()

src/main/kotlin/imgui/impl/LwjglGL3.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ object LwjglGL3 {
103103
IO.deltaTime = if (time > 0) (currentTime - time).f else 1f / 60f
104104
time = currentTime
105105

106-
// Setup inputs
107-
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
108-
// Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
106+
/* Setup inputs
107+
(we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
108+
Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) */
109109
if (window.focused)
110110
IO.mousePos put window.cursorPos
111111
else

0 commit comments

Comments
 (0)