Skip to content

Commit 0e73adf

Browse files
committed
🚧 up 20 Mar
Kotlin 1.2.40 Gradle 4.7 KotlinTest 3.0.4 Shadow Plugin 2.0.3
1 parent a038c05 commit 0e73adf

File tree

12 files changed

+138
-69
lines changed

12 files changed

+138
-69
lines changed

build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ group = 'com.github.kotlin-graphics'
1313

1414
buildscript {
1515

16-
ext.kotlinVersion = '1.2.40-eap-51'
16+
ext.kotlinVersion = '1.2.40'
1717

1818
repositories {
1919
jcenter() // shadow
@@ -24,17 +24,18 @@ buildscript {
2424

2525
dependencies {
2626
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
27-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
27+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
28+
classpath "org.junit.platform:junit-platform-gradle-plugin:1.1.0"
2829
}
2930
}
3031

3132
dependencies {
3233

3334
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
3435

35-
compile 'com.github.kotlin-graphics:uno-sdk:c3462559f303b6dd3a9e7f94f548406ac98df4e3'
36+
compile 'com.github.kotlin-graphics:uno-sdk:0452df6599691f04dc496989cf056682df1d3427'
3637

37-
testCompile 'io.kotlintest:kotlintest:2.0.7'
38+
testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.4'
3839

3940
def joglVersion = '2.3.2'
4041
testCompile "org.jogamp.gluegen:gluegen-rt-main:$joglVersion"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip

src/main/kotlin/imgui/Context.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ class IO(sharedFontAtlas: FontAtlas?) {
383383
// Settings (fill once)
384384
//------------------------------------------------------------------
385385

386+
/** See ConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc. */
387+
var configFlags: ConfigFlags = 0
388+
/** Set ImGuiBackendFlags_ enum. Set by imgui_impl_xxx files or custom back-end. */
389+
var backendFlags: BackendFlags = 0
386390
/** Display size, in pixels. For clamping windows positions. */
387391
var displaySize = Vec2i(-1)
388392
/** Time elapsed since last frame, in seconds. */
@@ -393,8 +397,6 @@ class IO(sharedFontAtlas: FontAtlas?) {
393397
var iniFilename: String? = "imgui.ini"
394398
/** Path to .log file (default parameter to ImGui::LogToFile when no file is specified). */
395399
var logFilename = "imgui_log.txt"
396-
/** See ConfigFlag enum. Gamepad/keyboard navigation options, etc. */
397-
var configFlags: ConfigFlags = 0
398400
/** Time for a double-click, in seconds. */
399401
var mouseDoubleClickTime = 0.3f
400402
/** Distance threshold to stay in to validate a double-click, in pixels. */
@@ -522,8 +524,8 @@ class IO(sharedFontAtlas: FontAtlas?) {
522524
* it wants textual keyboard input to happen (e.g. when a InputText widget is active). */
523525
var wantTextInput = false
524526
/** MousePos has been altered, back-end should reposition mouse on next frame.
525-
* Set only when ConfigFlag.NavMoveMouse flag is enabled in IO.configFlags. */
526-
var wantMoveMouse = false
527+
* Set only when ConfigFlag.NavEnableSetMousePos flag is enabled in IO.configFlags. */
528+
var wantSetMousePos = false
527529
/** Directional navigation is currently allowed (will handle KeyNavXXX events) = a window is focused and it doesn't
528530
* use the WindowFlag.NoNavInputs flag. */
529531
var navActive = false

src/main/kotlin/imgui/enums.kt

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -413,25 +413,31 @@ enum class NavInput {
413413
fun isPressed(mode: InputReadMode) = getNavInputAmount(this, mode) > 0f
414414
}
415415

416+
typealias ConfidFlags = Int
417+
416418
/** Configuration flags stored in io.configFlags */
417419
enum class ConfigFlag(val i: Int) {
418-
/** Master keyboard navigation enable flag. ::newFrame() will automatically fill io.navInputs[] based on io.keyDown[]. */
420+
/** Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeyDown[]. */
419421
NavEnableKeyboard(1 shl 0),
420-
/** Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.navInputs[]. */
422+
/** Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[].
423+
* Back-end also needs to set ImGuiBackendFlags_HasGamepad. */
421424
NavEnableGamepad(1 shl 1),
422425
/** Request navigation to allow moving the mouse cursor. May be useful on TV/console systems where moving a virtual
423-
* mouse is awkward. Will update io.mousePos and set io.WantMoveMouse = true. If enabled you MUST honor io.wantMoveMouse
424-
* requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth. */
425-
NavMoveMouse(1 shl 2),
426-
/** Do not set the io.WantCaptureKeyboard flag with io.NavActive is set. */
426+
* mouse is awkward. Will update io.mousePos and set io.wantSetMousePos=true.
427+
* If enabled you MUST honor io.wantSetMousePos requests in your binding, otherwise ImGui will react as
428+
* if the mouse is jumping around back and forth. */
429+
NavEnableSetMousePos(1 shl 2),
430+
/** Do not set the io.WantCaptureKeyboard flag with io.NavActive is set. */
427431
NavNoCaptureKeyboard(1 shl 3),
432+
/** Request back-end to not alter mouse cursor configuration. */
433+
NoSetMouseCursor(1 shl 4),
428434

429435
/* User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects.
430436
Those flags are not used by core ImGui) */
431437

432-
/** Back-end is SRGB-aware. */
438+
/** Application is SRGB-aware. */
433439
IsSRGB(1 shl 20),
434-
/** Back-end is using a touch screen instead of a mouse. */
440+
/** Application is using a touch screen instead of a mouse. */
435441
IsTouchScreen(1 shl 21);
436442
}
437443

@@ -440,15 +446,27 @@ infix fun Int.hasnt(b: ConfigFlag) = and(b.i) == 0
440446
infix fun Int.or(b: ConfigFlag): ConfigFlags = or(b.i)
441447
infix fun ConfigFlag.or(b: ConfigFlag): ConfigFlags = i or b.i
442448

443-
/** Enumeration for PushStyleColor() / PopStyleColor() */
444-
445-
open class Enum(val i: Int) {
449+
typealias BackendFlags = Int
446450

447-
infix fun Int.has(b: Enum) = and(b.i) != 0
448-
infix fun Int.hasnt(b: Enum) = and(b.i) == 0
449-
infix fun Int.or(b: Enum) = or(b.i)
450-
infix fun Enum.or(b: Enum) = i or b.i
451+
/** Back-end capabilities flags stored in io.BackendFlag. Set by imgui_impl_xxx or custom back-end. */
452+
enum class BackendFlag(val i: Int) {
453+
/** Back-end has a connected gamepad. */
454+
HasGamepad (1 shl 0),
455+
/** Back-end can honor GetMouseCursor() values and change the OS cursor shape. */
456+
HasMouseCursors (1 shl 1),
457+
/** Back-end can honor io.wantSetMousePos and reposition the mouse (only used if ConfigFlags.NavEnableSetMousePos is set). */
458+
HasSetMousePos (1 shl 2)
451459
}
460+
461+
462+
infix fun Int.has(b: BackendFlag) = and(b.i) != 0
463+
infix fun Int.hasnt(b: BackendFlag) = and(b.i) == 0
464+
infix fun Int.or(b: BackendFlag): BackendFlags = or(b.i)
465+
infix fun Int.wo(b: BackendFlag): BackendFlags = and(b.i.inv())
466+
infix fun BackendFlag.or(b: BackendFlag): BackendFlags = i or b.i
467+
468+
/** Enumeration for PushStyleColor() / PopStyleColor() */
469+
452470
//
453471
//sealed class Co(i: Int) : Enum(i) {
454472
// object Text : Co(_i++)

src/main/kotlin/imgui/imgui.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ typealias DrawCornerFlags = Int
107107
typealias DrawListFlags = Int
108108
/** flags: for FontAtlas // enum FontAtlasFlags */
109109
typealias FontAtlasFlags = Int
110-
//typedef int ImGuiBackendFlags; // flags: for io.BackendFlags // enum ImGuiBackendFlags_
110+
//typedef int ImGuiBackendFlags; // flags: for io.BackendFlag // enum ImGuiBackendFlags_
111111
/** flags: for ColorEdit*(), ColorPicker*() // enum ColorEditFlag */
112112
typealias ColorEditFlags = Int
113113
/** flags: for *Columns*() // enum ColumnsFlag */

src/main/kotlin/imgui/imgui/demo/inputNavigationAndFocus.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,18 @@ object inputNavigationAndFocus {
6464
text("WantCaptureMouse: ${io.wantCaptureMouse}")
6565
text("WantCaptureKeyboard: ${io.wantCaptureKeyboard}")
6666
text("WantTextInput: ${io.wantTextInput}")
67-
text("WantMoveMouse: ${io.wantMoveMouse}")
67+
text("WantMoveMouse: ${io.wantSetMousePos}")
6868
text("NavActive: ${io.navActive}, NavVisible: ${io.navVisible}")
6969

7070
checkbox("io.MouseDrawCursor", io::mouseDrawCursor)
7171
sameLine(); showHelpMarker("Request ImGui to render a mouse cursor for you in software. Note that " +
7272
"a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware " +
7373
"cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both " +
7474
"kinds of cursors (e.g. enable software cursor only when resizing/dragging something).")
75-
checkboxFlags("io.ConfigFlag: EnableGamepad", io::configFlags, ConfigFlag.NavEnableGamepad.i)
76-
checkboxFlags("io.ConfigFlag: EnableKeyboard", io::configFlags, ConfigFlag.NavEnableKeyboard.i)
77-
checkboxFlags("io.ConfigFlag: MoveMouse", io::configFlags, ConfigFlag.NavMoveMouse.i)
75+
checkboxFlags("io.ConfigFlags: NavEnableGamepad", io::configFlags, ConfigFlag.NavEnableGamepad.i)
76+
checkboxFlags("io.ConfigFlags: NavEnableKeyboard", io::configFlags, ConfigFlag.NavEnableKeyboard.i)
77+
checkboxFlags("io.ConfigFlags: NavEnableSetMousePos", io::configFlags, ConfigFlag.NavEnableSetMousePos.i)
78+
checkboxFlags("io.ConfigFlags: NoSetMouseCursor", io::configFlags, ConfigFlag.NoSetMouseCursor.i)
7879
sameLine(); showHelpMarker("Request ImGui to move your move cursor when using gamepad/keyboard " +
7980
"navigation. NewFrame() will change io.MousePos and set the io.WantMoveMouse flag, your backend will " +
8081
"need to apply the new mouse position.")

src/main/kotlin/imgui/imgui/menus.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ interface imgui_menus {
131131
We could remove it by scoring in advance for multiple window (probably not worth the hassle/cost) */
132132
assert(window.dc.navLayerActiveMaskNext has 0x02) // Sanity check
133133
window.focus()
134-
setNavIdAndMoveMouse(window.navLastIds[1], 1, window.navRectRel[1])
134+
setNavIDWithRectRel(window.navLastIds[1], 1, window.navRectRel[1])
135135
g.navLayer = 1
136136
g.navDisableHighlight = true // Hide highlight for the current frame so we don't see the intermediary selection.
137137
g.navMoveRequestForward = NavForward.ForwardQueued

src/main/kotlin/imgui/imgui/static.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fun navRestoreLayer(layer: Int) {
173173
if (layer == 0)
174174
g.navWindow = navRestoreLastChildNavWindow(g.navWindow!!)
175175
if (layer == 0 && g.navWindow!!.navLastIds[0] != 0)
176-
setNavIdAndMoveMouse(g.navWindow!!.navLastIds[0], layer, g.navWindow!!.navRectRel[0])
176+
setNavIDWithRectRel(g.navWindow!!.navLastIds[0], layer, g.navWindow!!.navRectRel[0])
177177
else
178178
navInitWindow(g.navWindow!!, true)
179179
}
@@ -198,7 +198,7 @@ fun setNavId(id: ID, navLayer: Int) {
198198
g.navWindow!!.navLastIds[navLayer] = id
199199
}
200200

201-
fun setNavIdAndMoveMouse(id: ID, navLayer: Int, rectRel: Rect) {
201+
fun setNavIDWithRectRel(id: ID, navLayer: Int, rectRel: Rect) {
202202
setNavId(id, navLayer)
203203
g.navWindow!!.navRectRel[navLayer] put rectRel
204204
g.navMousePosDirty = true

src/main/kotlin/imgui/imgui/window.kt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import imgui.ImGui.itemSize
2525
import imgui.ImGui.navInitWindow
2626
import imgui.ImGui.popClipRect
2727
import imgui.ImGui.pushClipRect
28+
import imgui.ImGui.renderArrow
2829
import imgui.ImGui.renderFrame
2930
import imgui.ImGui.renderNavHighlight
3031
import imgui.ImGui.renderTextClipped
31-
import imgui.ImGui.renderArrow
3232
import imgui.ImGui.scrollbar
3333
import imgui.ImGui.setActiveId
3434
import imgui.ImGui.setNextWindowSize
@@ -39,14 +39,14 @@ import imgui.internal.*
3939
import kotlin.math.floor
4040
import kotlin.math.max
4141
import kotlin.reflect.KMutableProperty0
42+
import imgui.FocusedFlag as Ff
43+
import imgui.HoveredFlag as Hf
4244
import imgui.ItemFlag as If
4345
import imgui.WindowFlag as Wf
4446
import imgui.internal.ButtonFlag as Bf
4547
import imgui.internal.DrawCornerFlag as Dcf
4648
import imgui.internal.DrawListFlag as Dlf
4749
import imgui.internal.LayoutType as Lt
48-
import imgui.FocusedFlag as Ff
49-
import imgui.HoveredFlag as Hf
5050

5151

5252
/** (Begin = push window to the stack and start appending to it. End = pop window from the stack.
@@ -373,7 +373,7 @@ interface imgui_window {
373373
val sc = style.mouseCursorScale
374374
val refPos = if (!g.navDisableHighlight && g.navDisableMouseHover) navCalcPreferredMousePos() else Vec2(io.mousePos)
375375
val rectToAvoid =
376-
if (!g.navDisableHighlight && g.navDisableMouseHover && io.configFlags hasnt ConfigFlag.NavMoveMouse)
376+
if (!g.navDisableHighlight && g.navDisableMouseHover && io.configFlags hasnt ConfigFlag.NavEnableSetMousePos)
377377
Rect(refPos.x - 16, refPos.y - 8, refPos.x + 16, refPos.y + 8)
378378
else
379379
Rect(refPos.x - 16, refPos.y - 8, refPos.x + 24 * sc, refPos.y + 24 * sc) // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
@@ -397,11 +397,10 @@ interface imgui_window {
397397
window.pos put glm.floor(window.posF)
398398

399399
// Default item width. Make it proportional to window size if window manually resizes
400-
window.itemWidthDefault =
401-
if (window.size.x > 0f && flags hasnt Wf.Tooltip && flags hasnt Wf.AlwaysAutoResize)
402-
(window.size.x * 0.65f).i.f
403-
else (g.fontSize * 16f).i.f
404-
400+
window.itemWidthDefault = when {
401+
window.size.x > 0f && flags hasnt Wf.Tooltip && flags hasnt Wf.AlwaysAutoResize -> window.size.x * 0.65f
402+
else -> g.fontSize * 16f
403+
}.i.f
405404
// Prepare for focus requests
406405
window.focusIdxAllRequestCurrent =
407406
if (window.focusIdxAllRequestNext == Int.MAX_VALUE || window.focusIdxAllCounter == -1)
@@ -674,9 +673,9 @@ interface imgui_window {
674673

675674
// Inner clipping rectangle
676675
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
677-
window.innerClipRect.min.x = floor(0.5f + window.innerRect.min.x + max(0f, floor(window.windowPadding.x*0.5f - window.windowBorderSize)))
676+
window.innerClipRect.min.x = floor(0.5f + window.innerRect.min.x + max(0f, floor(window.windowPadding.x * 0.5f - window.windowBorderSize)))
678677
window.innerClipRect.min.y = floor(0.5f + window.innerRect.min.y)
679-
window.innerClipRect.max.x = floor(0.5f + window.innerRect.max.x - max(0f, floor(window.windowPadding.x*0.5f - window.windowBorderSize)))
678+
window.innerClipRect.max.x = floor(0.5f + window.innerRect.max.x - max(0f, floor(window.windowPadding.x * 0.5f - window.windowBorderSize)))
680679
window.innerClipRect.max.y = floor(0.5f + window.innerRect.max.y)
681680

682681
/* After begin() we fill the last item / hovered data using the title bar data. Make that a standard behavior

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package imgui.impl
22

3-
import com.jogamp.newt.Display
43
import com.jogamp.newt.event.KeyEvent
54
import com.jogamp.newt.event.KeyListener
65
import com.jogamp.newt.event.MouseEvent
@@ -10,7 +9,6 @@ import com.jogamp.opengl.GL
109
import com.jogamp.opengl.GL2ES3.*
1110
import com.jogamp.opengl.GL3
1211
import glm_.*
13-
import glm_.mat4x4.Mat4
1412
import glm_.vec2.Vec2
1513
import glm_.vec2.Vec2i
1614
import glm_.vec4.Vec4i
@@ -26,7 +24,6 @@ import org.lwjgl.opengl.GL33.GL_SAMPLER_BINDING
2624
import uno.buffer.bufferBig
2725
import uno.buffer.destroy
2826
import uno.buffer.intBufferBig
29-
import uno.buffer.intBufferOf
3027
import uno.glsl.Program
3128

3229
object JoglGL3 {
@@ -99,7 +96,7 @@ object JoglGL3 {
9996
(we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
10097
Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.) */
10198
if (window.hasFocus())
102-
if (io.wantMoveMouse)
99+
if (io.wantSetMousePos)
103100
/* Set mouse position if requested by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user
104101
and using directional navigation) */
105102
window.warpPointer(io.mousePos.x.i, io.mousePos.y.i)

0 commit comments

Comments
 (0)