mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: visual window stick
This commit is contained in:
@@ -14,6 +14,7 @@ import kotlin.math.min
|
|||||||
open class VisualWindowPanel(protected val id: String, protected val visualWindowManager: VisualWindowManager) :
|
open class VisualWindowPanel(protected val id: String, protected val visualWindowManager: VisualWindowManager) :
|
||||||
JPanel(BorderLayout()), VisualWindow {
|
JPanel(BorderLayout()), VisualWindow {
|
||||||
|
|
||||||
|
private val stickPx = 2
|
||||||
protected val properties get() = Database.getDatabase().properties
|
protected val properties get() = Database.getDatabase().properties
|
||||||
private val titleLabel = JLabel()
|
private val titleLabel = JLabel()
|
||||||
private val toolbar = FlatToolBar()
|
private val toolbar = FlatToolBar()
|
||||||
@@ -141,8 +142,11 @@ open class VisualWindowPanel(protected val id: String, protected val visualWindo
|
|||||||
addPropertyChangeListener("ancestor", object : PropertyChangeListener {
|
addPropertyChangeListener("ancestor", object : PropertyChangeListener {
|
||||||
override fun propertyChange(evt: PropertyChangeEvent) {
|
override fun propertyChange(evt: PropertyChangeEvent) {
|
||||||
removePropertyChangeListener("ancestor", this)
|
removePropertyChangeListener("ancestor", this)
|
||||||
// 是否吸附
|
// 获取缓存是否是粘附
|
||||||
isStick = properties.getString("VisualWindow.${id}.stick", "false").toBoolean()
|
val isStick = properties.getString("VisualWindow.${id}.stick", "false").toBoolean()
|
||||||
|
if (isStick && bounds.y <= stickPx) {
|
||||||
|
visualWindow.isStick = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -245,7 +249,6 @@ open class VisualWindowPanel(protected val id: String, protected val visualWindo
|
|||||||
|
|
||||||
private inner class DragListener : MouseAdapter() {
|
private inner class DragListener : MouseAdapter() {
|
||||||
private var startPoint: Point? = null
|
private var startPoint: Point? = null
|
||||||
private val stickPx = 2
|
|
||||||
|
|
||||||
override fun mousePressed(e: MouseEvent) {
|
override fun mousePressed(e: MouseEvent) {
|
||||||
if (isWindow) {
|
if (isWindow) {
|
||||||
|
|||||||
Reference in New Issue
Block a user