Skip to content

Commit

Permalink
fixed rendering of labels such as '##value' on the right side of slid…
Browse files Browse the repository at this point in the history
…erFloat
  • Loading branch information
elect86 committed May 4, 2019
1 parent 41f57d8 commit fa01531
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
5 changes: 5 additions & 0 deletions imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ Pos=208.0,83.0
Size=350,560
Collapsed=0

[Window][Example: Property editor]
Pos=60.0,60.0
Size=464,450
Collapsed=0

6 changes: 2 additions & 4 deletions src/main/kotlin/imgui/imgui/internal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1162,13 +1162,11 @@ interface imgui_internal {
}
}

fun renderTextWrapped(pos: Vec2, text: String, textEnd_: Int, wrapWidth: Float) {
fun renderTextWrapped(pos: Vec2, text: String, textEnd_: Int?, wrapWidth: Float) {

val window = g.currentWindow!!

var textEnd = textEnd_
if (textEnd == 0)
textEnd = text.length // FIXME-OPT
val textEnd = textEnd_ ?: text.length // FIXME-OPT

if (textEnd > 0) {
window.drawList.addText(g.font, g.fontSize, pos, Col.Text.u32, text.toCharArray(), textEnd, wrapWidth)
Expand Down
12 changes: 5 additions & 7 deletions src/main/kotlin/imgui/imgui/utilities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface imgui_utilities {

/** was the last item just made active (item was previously inactive). */
val isItemActivated: Boolean
get() = when(g.activeId) {
get() = when (g.activeId) {
0 -> false
else -> g.currentWindow!!.run { g.activeId == dc.lastItemId && g.activeIdPreviousFrame != dc.lastItemId }
}
Expand Down Expand Up @@ -185,12 +185,10 @@ interface imgui_utilities {

fun calcTextSize(text: String, textEnd: Int = text.length, hideTextAfterDoubleHash: Boolean = false, wrapWidth: Float = -1f): Vec2 {

val textDisplayEnd =
when {
hideTextAfterDoubleHash -> findRenderedTextEnd(text, textEnd) // Hide anything after a '##' string
textEnd == 0 -> text.length
else -> textEnd
}
val textDisplayEnd = when {
hideTextAfterDoubleHash -> findRenderedTextEnd(text, textEnd) // Hide anything after a '##' string
else -> textEnd
}

val font = g.font
val fontSize = g.fontSize
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/imgui/imgui/widgets/drags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ interface drags {
dragScalar(label, DataType.Float, v, vSpeed, vMin, vMax, format, power)

fun dragFloat(label: String, v: FloatArray, ptr: Int, vSpeed: Float = 1f, vMin: Float = 0f, vMax: Float = 0f,
format: String = "%.3f", power: Float = 1f): Boolean = withFloat(v, ptr) {
dragScalar(label, DataType.Float, it, vSpeed, vMin, vMax, format, power)
}
format: String = "%.3f", power: Float = 1f): Boolean =
withFloat(v, ptr) { dragScalar(label, DataType.Float, it, vSpeed, vMin, vMax, format, power) }

fun dragFloat2(label: String, v: FloatArray, vSpeed: Float = 1f, vMin: Float = 0f, vMax: Float = 0f, format: String = "%.3f", power: Float = 1f) =
dragFloatN(label, v, 2, vSpeed, vMin, vMax, format, power)
Expand Down

0 comments on commit fa01531

Please sign in to comment.