better startup
This commit is contained in:
parent
f31790189e
commit
4b9bb66771
1 changed files with 12 additions and 3 deletions
|
|
@ -34,7 +34,6 @@ class ColorPickerData {
|
|||
|
||||
set_rgba(col){set_rgba(col, true)}
|
||||
set_rgba(col, update_spaces){
|
||||
System.print("Set RGB!")
|
||||
if(!ColorPicker.approx(_r, col.r)) _r = col.r
|
||||
if(!ColorPicker.approx(_g, col.g)) _g = col.g
|
||||
if(!ColorPicker.approx(_b, col.b)) _b = col.b
|
||||
|
|
@ -51,7 +50,6 @@ class ColorPickerData {
|
|||
|
||||
set_hsva(col){set_hsva(col, true)}
|
||||
set_hsva(col, update_spaces){
|
||||
System.print("Set HSV!")
|
||||
if(!ColorPicker.approx(_h, col.x)) _h = col.x
|
||||
if(!ColorPicker.approx(_s, col.y)) _s = col.y
|
||||
if(!ColorPicker.approx(_v, col.z)) _v = col.z
|
||||
|
|
@ -165,6 +163,7 @@ class ColorPicker{
|
|||
Control.child_add(hsv_view, rgba_components)
|
||||
|
||||
var hsva_components = hsva_values(ui, color_view)
|
||||
Control.set_visible(hsva_components, false)
|
||||
Control.child_add(hsv_view, hsva_components)
|
||||
|
||||
Control.set_events(rgba_button) {|event|
|
||||
|
|
@ -223,6 +222,8 @@ class ColorPicker{
|
|||
}
|
||||
|
||||
static color_component (ui: Entity, name: String, index: Num, color_view: Control, space: String){
|
||||
var data: ColorPickerData = Control.get_state_data(color_view)
|
||||
|
||||
var base = Control.create(ui)
|
||||
Control.set_size(base, 0, 32)
|
||||
Control.set_behave(base, UIBehave.top | UIBehave.left | UILayoutBehave.hfill)
|
||||
|
|
@ -239,7 +240,6 @@ class ColorPicker{
|
|||
Control.child_add(base, label)
|
||||
|
||||
var number = UINumber.create(ui)
|
||||
UINumber.set_value(number, 0)
|
||||
UINumber.set_validation(number) {|input|
|
||||
return Math.fixed(input)
|
||||
}
|
||||
|
|
@ -256,6 +256,14 @@ class ColorPicker{
|
|||
Control.set_margin(slider, 8, 8, 8, 8)
|
||||
Control.child_add(base, slider)
|
||||
|
||||
if(space == "rgb"){
|
||||
UINumber.set_value(number, data.get_rgba_component(index))
|
||||
UISlider.set_value(slider, data.get_rgba_component(index))
|
||||
} else if(space == "hsv"){
|
||||
UINumber.set_value(number, data.get_hsva_component(index))
|
||||
UISlider.set_value(slider, data.get_hsva_component(index))
|
||||
}
|
||||
|
||||
Control.set_events(number) { |event: UIEvent|
|
||||
if(event.type == UIEvent.change){
|
||||
if(approx(UISlider.get_value(slider), event.change, 0.001)) return
|
||||
|
|
@ -420,6 +428,7 @@ class ColorPicker{
|
|||
Material.set_input(color_tri_mat, "triangle.saturation_gamma", base_sat_gamma)
|
||||
Material.set_input(color_tri_mat, "triangle.hue", data.h)
|
||||
UIImage.set_material(color_triangle, color_tri_mat)
|
||||
UIImage.set_angle(color_triangle, data.h * -360)
|
||||
Control.child_add(color_wheel, color_triangle)
|
||||
//rotates image when color wheel hue updates
|
||||
Control.set_events(data_root) {|event|
|
||||
|
|
|
|||
Loading…
Reference in a new issue