Skip to content

Commit 3418c82

Browse files
author
ntwigg
committed
Workaround SWT's new kotlin-incompatible geometry class hierarchy
1 parent a52f479 commit 3418c82

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

durian-swt/src/main/java/com/diffplug/common/swt/Shells.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
3838
private var title: String? = null
3939
private var image: Image? = null
4040
private var alpha = SWT.DEFAULT
41-
private val size = Point(SWT.DEFAULT, SWT.DEFAULT)
41+
private val size = SwtKt.Point(SWT.DEFAULT, SWT.DEFAULT)
4242
private var positionIncludesTrim = true
4343
private var location: Map.Entry<Corner, Point>? = null
4444
private var dontOpen = false
@@ -86,7 +86,7 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
8686
* Calls [.setLocation] and [.setSize] in one line.
8787
*/
8888
fun setRectangle(rect: Rectangle): Shells {
89-
return setLocation(Point(rect.x, rect.y)).setSize(Point(rect.width, rect.height))
89+
return setLocation(SwtKt.Point(rect.x, rect.y)).setSize(SwtKt.Point(rect.width, rect.height))
9090
}
9191

9292
/**
@@ -290,12 +290,12 @@ class Shells private constructor(private val style: Int, private val coat: Coat)
290290
}
291291
}
292292
val topLeft =
293-
location!!.key.topLeftRequiredFor(Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
294-
bounds = Rectangle(topLeft.x, topLeft.y, computedSize.x, computedSize.y)
293+
location!!.key.topLeftRequiredFor(SwtKt.Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
294+
bounds = SwtKt.Rectangle(topLeft.x, topLeft.y, computedSize.x, computedSize.y)
295295
} else {
296296
val computedSize = shell.computeSize(size.x, size.y, true)
297297
val topLeft =
298-
location!!.key.topLeftRequiredFor(Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
298+
location!!.key.topLeftRequiredFor(SwtKt.Rectangle(0, 0, computedSize.x, computedSize.y), location!!.value)
299299
bounds = shell.computeTrim(topLeft.x, topLeft.y, computedSize.x, computedSize.y)
300300
}
301301
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (C) 2025 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.diffplug.common.swt;
17+
18+
import org.eclipse.swt.graphics.Point;
19+
import org.eclipse.swt.graphics.Rectangle;
20+
21+
public class SwtKt {
22+
public static Point Point(int x, int y) {
23+
return new Point(x, y);
24+
}
25+
26+
public static Rectangle Rectangle(int x, int y, int width, int height) {
27+
return new Rectangle(x, y, width, height);
28+
}
29+
}

0 commit comments

Comments
 (0)