From 12b6886da8a0378be90a13f30d45c7ae28b47432 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 21 Jun 2019 19:02:08 -0400 Subject: [PATCH] Remove UI prefix --- .../asmr/{UITest.kt => TestScreen.kt} | 21 +++++++------------ .../shadowui/{UIScreen.kt => Screen.kt} | 5 ++++- .../shadowui/{UIView.kt => View.kt} | 4 +++- .../shadowui/geometry/{UIRect.kt => Rect.kt} | 0 4 files changed, 15 insertions(+), 15 deletions(-) rename src/main/kotlin/net/shadowfacts/asmr/{UITest.kt => TestScreen.kt} (83%) rename src/main/kotlin/net/shadowfacts/shadowui/{UIScreen.kt => Screen.kt} (90%) rename src/main/kotlin/net/shadowfacts/shadowui/{UIView.kt => View.kt} (97%) rename src/main/kotlin/net/shadowfacts/shadowui/geometry/{UIRect.kt => Rect.kt} (100%) diff --git a/src/main/kotlin/net/shadowfacts/asmr/UITest.kt b/src/main/kotlin/net/shadowfacts/asmr/TestScreen.kt similarity index 83% rename from src/main/kotlin/net/shadowfacts/asmr/UITest.kt rename to src/main/kotlin/net/shadowfacts/asmr/TestScreen.kt index 5c682af..344df36 100644 --- a/src/main/kotlin/net/shadowfacts/asmr/UITest.kt +++ b/src/main/kotlin/net/shadowfacts/asmr/TestScreen.kt @@ -8,23 +8,18 @@ import net.shadowfacts.shadowui.util.Color class UITest: UIScreen() { init { - val red = UIView().apply { + val red = addView(UIView().apply { backgroundColor = Color(0xff0000) - addView(this) - } - val green = UIView().apply { + }) + val green = addView(UIView().apply { backgroundColor = Color(0x00ff00) - addView(this) - } - val blue = UIView().apply { + }) + val blue = addView(UIView().apply { backgroundColor = Color(0x0000ff) - addView(this) - } - - val purple = UIView().apply { + }) + val purple = green.addSubview(UIView().apply { backgroundColor = Color(0x800080) - green.addSubview(this) - } + }) solver.dsl { red.leftAnchor equalTo 0 diff --git a/src/main/kotlin/net/shadowfacts/shadowui/UIScreen.kt b/src/main/kotlin/net/shadowfacts/shadowui/Screen.kt similarity index 90% rename from src/main/kotlin/net/shadowfacts/shadowui/UIScreen.kt rename to src/main/kotlin/net/shadowfacts/shadowui/Screen.kt index d500acc..16deb29 100644 --- a/src/main/kotlin/net/shadowfacts/shadowui/UIScreen.kt +++ b/src/main/kotlin/net/shadowfacts/shadowui/Screen.kt @@ -10,10 +10,13 @@ open class UIScreen: Screen(TextComponent("UIScreen")) { val views = mutableListOf() - fun addView(view: UIView) { + fun addView(view: UIView): UIView { views.add(view) view.solver = solver + view.wasAdded() + + return view } fun layout() { diff --git a/src/main/kotlin/net/shadowfacts/shadowui/UIView.kt b/src/main/kotlin/net/shadowfacts/shadowui/View.kt similarity index 97% rename from src/main/kotlin/net/shadowfacts/shadowui/UIView.kt rename to src/main/kotlin/net/shadowfacts/shadowui/View.kt index 78e0028..8941a54 100644 --- a/src/main/kotlin/net/shadowfacts/shadowui/UIView.kt +++ b/src/main/kotlin/net/shadowfacts/shadowui/View.kt @@ -31,12 +31,14 @@ class UIView { var parent: UIView? = null val subviews = mutableListOf() - fun addSubview(view: UIView) { + fun addSubview(view: UIView): UIView { subviews.add(view) view.parent = this view.solver = solver view.wasAdded() + + return view } fun wasAdded() { diff --git a/src/main/kotlin/net/shadowfacts/shadowui/geometry/UIRect.kt b/src/main/kotlin/net/shadowfacts/shadowui/geometry/Rect.kt similarity index 100% rename from src/main/kotlin/net/shadowfacts/shadowui/geometry/UIRect.kt rename to src/main/kotlin/net/shadowfacts/shadowui/geometry/Rect.kt