diff --git a/data/objects/library_new_deck.cfg b/data/objects/library_new_deck.cfg index a9924f4c..0b3d73dc 100644 --- a/data/objects/library_new_deck.cfg +++ b/data/objects/library_new_deck.cfg @@ -9,15 +9,32 @@ area: "{width: py(260), height: py(72)}", - highlighted: { type: "bool", default: false, set: "if(_data != value, [set(_data, value); render()])" }, + highlighted: { + type: "bool", + default: false, + set: " + if ( + _data != value, + [ + set(_data, value) + ; + render(false) + ], + // else + debug(['library_new_deck#highlighted#set: this code should never run']) + ) + " + }, _show_plus: { default: true }, _text: { default: "Create Deck" }, _font: { type: "string", init: "lib.font.regular_font" }, - render: "def() ->commands + render: "def (bool creating) -> commands [ + map(range(transition_steps), + schedule(step + delay, set(animation, { id: 'fbo', image: 'fbo', @@ -29,8 +46,19 @@ c.fill(), if(highlighted, - c.set_source_rgba(1.0, 1.0, 1.0, 1.0), - c.set_source_rgba(0.29, 0.33, 0.36, 1.0)), + c.set_source_rgba( + if (creating, 1.0, clamp(mix(.29, 1.0, (step + 1) / transition_steps_dec), .29, 1.0)), + if (creating, 1.0, clamp(mix(.33, 1.0, (step + 1) / transition_steps_dec), .33, 1.0)), + if (creating, 1.0, clamp(mix(.36, 1.0, (step + 1) / transition_steps_dec), .36, 1.0)), + 1.0 + ), + c.set_source_rgba( + if (creating, .29, clamp(mix(1.0, .29, (step + 1) / transition_steps_dec), .29, 1.0)), + if (creating, .33, clamp(mix(1.0, .33, (step + 1) / transition_steps_dec), .33, 1.0)), + if (creating, .36, clamp(mix(1.0, .36, (step + 1) / transition_steps_dec), .36, 1.0)), + 1.0 + ) + ), c.rectangle(0, area.height*0.1, area.width, area.height*0.8), c.set_line_width(py(20)/10.0), c.stroke(), @@ -58,7 +86,16 @@ ]), } where c = canvas() - ), + ) // set(animation, ...) + ) // schedule(int, set(animation, ...)) + // A little bit of syntactic sugar. + where step = value + ) // map(range(...), schedule(int, set(animation, ...))) + // Casted to `decimal` for convenience. + where transition_steps_dec = transition_steps * 1.0 + where transition_steps = 1 + where delay = 0 + , set(x2, x2), set(y, y) ]", @@ -75,6 +112,6 @@ on_mouse_enter: "set(highlighted, true)", on_mouse_leave: "set(highlighted, false)", - on_create: "render()", - on_type_updated: "render()", + on_create: "render(true)", + on_type_updated: "render(true)", }