-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from marad/window_inspector
Window inspector
- Loading branch information
Showing
6 changed files
with
87 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package gh.marad.tiler.help | ||
|
||
import gh.marad.tiler.common.Window | ||
import gh.marad.tiler.os.OsFacade | ||
import gh.marad.tiler.os.WindowEventHandler | ||
import java.awt.BorderLayout | ||
import java.awt.Dimension | ||
import java.awt.Font | ||
import javax.swing.* | ||
|
||
class WindowInspector(private val osFacade: OsFacade) : JFrame("Tiler Window Inspector"), WindowEventHandler { | ||
private val btn = JButton("Inspect next window") | ||
private val pane = JEditorPane() | ||
private var capturing = false | ||
init { | ||
val uiFont = Font.getFont("Segoe UI") | ||
font = uiFont | ||
btn.font = uiFont | ||
pane.font = uiFont | ||
pane.isEditable = false | ||
isAlwaysOnTop = true | ||
defaultCloseOperation = WindowConstants.HIDE_ON_CLOSE | ||
preferredSize = Dimension(600, 400) | ||
contentPane.add(btn, BorderLayout.NORTH) | ||
contentPane.add(pane, BorderLayout.CENTER) | ||
pack() | ||
|
||
btn.addActionListener { | ||
pane.text = "Activate a window to inspect..." | ||
capturing = true | ||
} | ||
pane.text = osFacade.windowDebugInfo(osFacade.activeWindow()) | ||
} | ||
|
||
override suspend fun windowActivated(window: Window) { | ||
if (capturing) { | ||
pane.text = osFacade.windowDebugInfo(window) | ||
capturing = false | ||
} | ||
} | ||
|
||
override suspend fun windowAppeared(window: Window) { } | ||
override suspend fun windowDisappeared(window: Window) { } | ||
override suspend fun windowMinimized(window: Window) { } | ||
override suspend fun windowRestored(window: Window) { } | ||
override suspend fun windowMovedOrResized(window: Window) { } | ||
} | ||
|
||
fun main() { | ||
val osFacade = OsFacade.createWindowsFacade() | ||
val win = WindowInspector(osFacade) | ||
win.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE | ||
win.isVisible = true | ||
|
||
OsFacade.createWindowsFacade().startEventHandling(win) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters