Add TypesSelector, simplify default styles
This commit is contained in:
@@ -183,23 +183,15 @@ class GUI : Extension {
|
|||||||
this.height = 175.px
|
this.height = 175.px
|
||||||
}
|
}
|
||||||
|
|
||||||
descendant(has type "sequence-editor") {
|
descendant(has type listOf(
|
||||||
|
"sequence-editor",
|
||||||
|
"sliders-vector2",
|
||||||
|
"sliders-vector3",
|
||||||
|
"sliders-vector4"
|
||||||
|
)) {
|
||||||
this.width = 175.px
|
this.width = 175.px
|
||||||
this.height = 100.px
|
this.height = 100.px
|
||||||
}
|
}
|
||||||
descendant(has type "sliders-vector2") {
|
|
||||||
this.width = 175.px
|
|
||||||
this.height = 100.px
|
|
||||||
}
|
|
||||||
descendant(has type "sliders-vector3") {
|
|
||||||
this.width = 175.px
|
|
||||||
this.height = 100.px
|
|
||||||
}
|
|
||||||
descendant(has type "sliders-vector4") {
|
|
||||||
this.width = 175.px
|
|
||||||
this.height = 100.px
|
|
||||||
}
|
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import org.openrndr.math.Vector2
|
|||||||
import org.openrndr.math.Vector3
|
import org.openrndr.math.Vector3
|
||||||
import org.openrndr.math.Vector4
|
import org.openrndr.math.Vector4
|
||||||
|
|
||||||
|
|
||||||
class SlidersVector2 : SequenceEditorBase("sliders-vector2") {
|
class SlidersVector2 : SequenceEditorBase("sliders-vector2") {
|
||||||
var value : Vector2
|
var value : Vector2
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -98,43 +98,12 @@ fun defaultStyles(
|
|||||||
marginRight = 5.px
|
marginRight = 5.px
|
||||||
},
|
},
|
||||||
|
|
||||||
styleSheet(has type "sequence-editor") {
|
styleSheet(has type listOf(
|
||||||
height = 60.px
|
"sequence-editor",
|
||||||
width = 100.percent
|
"sliders-vector2",
|
||||||
marginTop = 5.px
|
"sliders-vector3",
|
||||||
marginBottom = 15.px
|
"sliders-vector4"
|
||||||
marginLeft = 5.px
|
)) {
|
||||||
marginRight = 5.px
|
|
||||||
color = controlTextColor
|
|
||||||
and(has state "active") {
|
|
||||||
color = controlActiveColor
|
|
||||||
}
|
|
||||||
},
|
|
||||||
styleSheet(has type "sliders-vector2") {
|
|
||||||
height = 60.px
|
|
||||||
width = 100.percent
|
|
||||||
marginTop = 5.px
|
|
||||||
marginBottom = 15.px
|
|
||||||
marginLeft = 5.px
|
|
||||||
marginRight = 5.px
|
|
||||||
color = controlTextColor
|
|
||||||
and(has state "active") {
|
|
||||||
color = controlActiveColor
|
|
||||||
}
|
|
||||||
},
|
|
||||||
styleSheet(has type "sliders-vector3") {
|
|
||||||
height = 60.px
|
|
||||||
width = 100.percent
|
|
||||||
marginTop = 5.px
|
|
||||||
marginBottom = 15.px
|
|
||||||
marginLeft = 5.px
|
|
||||||
marginRight = 5.px
|
|
||||||
color = controlTextColor
|
|
||||||
and(has state "active") {
|
|
||||||
color = controlActiveColor
|
|
||||||
}
|
|
||||||
},
|
|
||||||
styleSheet(has type "sliders-vector4") {
|
|
||||||
height = 60.px
|
height = 60.px
|
||||||
width = 100.percent
|
width = 100.percent
|
||||||
marginTop = 5.px
|
marginTop = 5.px
|
||||||
@@ -156,8 +125,6 @@ fun defaultStyles(
|
|||||||
marginRight = 5.px
|
marginRight = 5.px
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
styleSheet(has type "xy-pad") {
|
styleSheet(has type "xy-pad") {
|
||||||
display = Display.BLOCK
|
display = Display.BLOCK
|
||||||
background = Color.RGBa(ColorRGBa.GRAY)
|
background = Color.RGBa(ColorRGBa.GRAY)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class CompoundSelector {
|
|||||||
companion object {
|
companion object {
|
||||||
val DUMMY = CompoundSelector()
|
val DUMMY = CompoundSelector()
|
||||||
}
|
}
|
||||||
|
|
||||||
var previous: Pair<Combinator, CompoundSelector>?
|
var previous: Pair<Combinator, CompoundSelector>?
|
||||||
var selectors: MutableList<Selector>
|
var selectors: MutableList<Selector>
|
||||||
|
|
||||||
@@ -84,6 +85,14 @@ class TypeSelector(val type: ElementType) : Selector() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TypesSelector(vararg types: ElementType) : Selector() {
|
||||||
|
private val typeSet = types.toSet()
|
||||||
|
override fun accept(element: Element): Boolean = element.type in typeSet
|
||||||
|
override fun toString(): String {
|
||||||
|
return "TypesSelector(types=$typeSet)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PseudoClassSelector(val c: ElementPseudoClass) : Selector() {
|
class PseudoClassSelector(val c: ElementPseudoClass) : Selector() {
|
||||||
override fun accept(element: Element): Boolean = c in element.pseudoClasses
|
override fun accept(element: Element): Boolean = c in element.pseudoClasses
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
@@ -93,7 +102,7 @@ class PseudoClassSelector(val c: ElementPseudoClass) : Selector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object has {
|
object has {
|
||||||
operator fun invoke (vararg selectors:CompoundSelector) : CompoundSelector {
|
operator fun invoke(vararg selectors: CompoundSelector): CompoundSelector {
|
||||||
val active = CompoundSelector()
|
val active = CompoundSelector()
|
||||||
selectors.forEach {
|
selectors.forEach {
|
||||||
active.selectors.addAll(it.selectors)
|
active.selectors.addAll(it.selectors)
|
||||||
@@ -101,26 +110,33 @@ object has {
|
|||||||
return active
|
return active
|
||||||
}
|
}
|
||||||
|
|
||||||
infix fun state(q:String):CompoundSelector {
|
infix fun state(q: String): CompoundSelector {
|
||||||
val active = CompoundSelector()
|
val active = CompoundSelector()
|
||||||
active.selectors.add(PseudoClassSelector(ElementPseudoClass((q))))
|
active.selectors.add(PseudoClassSelector(ElementPseudoClass((q))))
|
||||||
return active
|
return active
|
||||||
}
|
}
|
||||||
|
|
||||||
infix fun class_(q:String): CompoundSelector {
|
infix fun class_(q: String): CompoundSelector {
|
||||||
val active = CompoundSelector()
|
val active = CompoundSelector()
|
||||||
active.selectors.add(ClassSelector(ElementClass(q)))
|
active.selectors.add(ClassSelector(ElementClass(q)))
|
||||||
return active
|
return active
|
||||||
}
|
}
|
||||||
|
|
||||||
infix fun type(q:String):CompoundSelector {
|
infix fun type(q: String): CompoundSelector {
|
||||||
val active = CompoundSelector()
|
val active = CompoundSelector()
|
||||||
active.selectors.add(TypeSelector(ElementType(q)))
|
active.selectors.add(TypeSelector(ElementType(q)))
|
||||||
return active
|
return active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
infix fun type(qs: Iterable<String>): CompoundSelector {
|
||||||
|
val active = CompoundSelector()
|
||||||
|
val aqs = qs.map { ElementType(it) }.toList().toTypedArray()
|
||||||
|
active.selectors.add(TypesSelector(*aqs))
|
||||||
|
return active
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
infix fun CompoundSelector.and(other:CompoundSelector):CompoundSelector {
|
infix fun CompoundSelector.and(other: CompoundSelector): CompoundSelector {
|
||||||
val c = CompoundSelector()
|
val c = CompoundSelector()
|
||||||
c.previous = previous
|
c.previous = previous
|
||||||
c.selectors.addAll(selectors)
|
c.selectors.addAll(selectors)
|
||||||
|
|||||||
Reference in New Issue
Block a user