Skip to content

Commit

Permalink
Fix context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Nov 4, 2024
1 parent 4aa4350 commit 6e19f14
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
16 changes: 8 additions & 8 deletions EOCVSimPlugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ dependencies {

implementation project(":LwjglPlatform")

// compileOnly('com.github.deltacv.EOCV-Sim:EOCV-Sim:3.8.0') { transitive = false } // jitpack
// compileOnly('com.github.deltacv.EOCV-Sim:Common:3.8.0') { transitive = false } // jitpack
// compileOnly('com.github.deltacv.EOCV-Sim:Vision:3.8.0') // jitpack
compileOnly('com.github.deltacv.EOCV-Sim:EOCV-Sim:3.8.2') { transitive = false } // jitpack
compileOnly('com.github.deltacv.EOCV-Sim:Common:3.8.2') { transitive = false } // jitpack
compileOnly('com.github.deltacv.EOCV-Sim:Vision:3.8.2') // jitpack

compileOnly('com.github.deltacv.EOCV-Sim:EOCV-Sim:15e7f07bea') { changing = true; transitive = false} // jitpack dev
compileOnly('com.github.deltacv.EOCV-Sim:Common:15e7f07bea') { changing = true; transitive = false} // jitpack dev
compileOnly('com.github.deltacv.EOCV-Sim:Vision:15e7f07bea') { changing = true; } // jitpack dev
// compileOnly('com.github.deltacv.EOCV-Sim:EOCV-Sim:15e7f07bea') { changing = true; transitive = false} // jitpack dev
// compileOnly('com.github.deltacv.EOCV-Sim:Common:15e7f07bea') { changing = true; transitive = false} // jitpack dev
// compileOnly('com.github.deltacv.EOCV-Sim:Vision:15e7f07bea') { changing = true; } // jitpack dev

// compileOnly('com.github.deltacv:EOCV-Sim:3.7.1-dev-240925-2310') { transitive = false } // Maven local
// compileOnly('com.github.deltacv:Common:3.7.1-dev-240925-2310') { transitive = false } // Maven local
Expand All @@ -77,11 +77,11 @@ dependencies {

implementation "ch.qos.logback:logback-classic:$logback_classic_version"

implementation('com.github.deltacv.visionloop:visionloop:e5a4c23d1e') {
implementation('com.github.deltacv.visionloop:visionloop:1.2.0') {
exclude group: 'com.github.deltacv.EOCVSim'
}

implementation('com.github.deltacv.visionloop:streaming:e5a4c23d1e') {
implementation('com.github.deltacv.visionloop:streaming:1.2.0') {
exclude group: 'com.github.deltacv.EOCVSim'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,17 @@ class Scope(
}

fun tryName(name: String): String {
if(!usedNames.contains(name)) {
return name
} else {
var count = 1
if (name !in usedNames) return name

while(true) {
val newName = "$name$count"
var count = 1
var newName: String

if(!usedNames.contains(newName)) {
return newName
}
do {
newName = "$name$count"
count++
} while (newName in usedNames)

count++
}
}
return newName
}

fun variableSet(variable: Variable, v: Value) {
Expand All @@ -117,7 +113,6 @@ class Scope(
builder.append("$tabs${language.variableSetDeclaration(variable, v)}")
}


fun arraySet(variable: Variable, index: Value, v: Value) {
newStatement()
importValue(v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ class NodeEditor(val paperVision: PaperVision, private val keyManager: KeyManage
ImGuiWindowFlags.NoTitleBar, ImGuiWindowFlags.NoDecoration
)

val rightClickMenuPopup by lazy {
RightClickMenuPopup(paperVision.nodeList, paperVision::undo, paperVision::redo)
private val popupSelection = mutableListOf<DrawableIdElement>()

private var currentRightClickMenuPopup: RightClickMenuPopup? = null
val rightClickMenuPopup: RightClickMenuPopup get() {
val popup = RightClickMenuPopup(paperVision.nodeList, paperVision::undo, paperVision::redo, popupSelection)
currentRightClickMenuPopup = popup
return popup
}

private val rightClickMenuPopupTimer = ElapsedTime()
Expand All @@ -144,7 +149,6 @@ class NodeEditor(val paperVision: PaperVision, private val keyManager: KeyManage
flagsNode.enable()

inputNode.enable()
rightClickMenuPopup.enable()

outputNode.streamId = outputImageDisplay.id
outputNode.enable()
Expand Down Expand Up @@ -342,11 +346,11 @@ class NodeEditor(val paperVision: PaperVision, private val keyManager: KeyManage
}

private fun updateRightClickMenuSelection() {
if (rightClickMenuPopup.isVisible) {
if (currentRightClickMenuPopup?.isVisible == true) {
return
}

rightClickMenuPopup.selection.clear()
popupSelection.clear()

val nodeSelection = IntArray(ImNodes.numSelectedNodes())
ImNodes.getSelectedNodes(nodeSelection)
Expand All @@ -355,7 +359,7 @@ class NodeEditor(val paperVision: PaperVision, private val keyManager: KeyManage
if (node < 0) continue

nodes[node]?.let {
rightClickMenuPopup.selection.add(it)
popupSelection.add(it)
}
}

Expand All @@ -366,13 +370,13 @@ class NodeEditor(val paperVision: PaperVision, private val keyManager: KeyManage
if (link < 0) continue

links[link]?.let {
rightClickMenuPopup.selection.add(it)
popupSelection.add(it)
}
}

if (ImNodes.getHoveredNode() >= 0) {
nodes[ImNodes.getHoveredNode()]?.let {
rightClickMenuPopup.selection.add(it)
popupSelection.add(it)
}
}
}
Expand Down Expand Up @@ -492,12 +496,17 @@ class NodeEditor(val paperVision: PaperVision, private val keyManager: KeyManage
class RightClickMenuPopup(
val nodeList: NodeList,
val undo: () -> Unit,
val redo: () -> Unit
val redo: () -> Unit,
val selection: List<DrawableIdElement>
) : Popup() {
var selection = mutableListOf<DrawableIdElement>()

override val title = "right click menu"
override val flags = flags(ImGuiWindowFlags.NoTitleBar, ImGuiWindowFlags.NoResize, ImGuiWindowFlags.NoMove)
override val flags = flags(
ImGuiWindowFlags.NoTitleBar,
ImGuiWindowFlags.NoResize,
ImGuiWindowFlags.NoMove,
ImGuiWindowFlags.Popup
)

override fun drawContents() {
ImGui.pushStyleColor(ImGuiCol.Button, 0)
Expand Down

0 comments on commit 6e19f14

Please sign in to comment.