From a861a2dd1159425b6f6bcc279a10e5ef76d4ed09 Mon Sep 17 00:00:00 2001 From: jill Date: Sun, 19 Sep 2021 22:11:33 +0300 Subject: [PATCH] add a swap button for eases --- assets/textures/clipboard.png | Bin 0 -> 158 bytes assets/textures/screenshot.png | Bin 0 -> 145 bytes assets/textures/swap.png | Bin 0 -> 139 bytes src/button.lua | 28 ++++++++++++++++++++++++++++ src/dropdown.lua | 7 +++++++ 5 files changed, 35 insertions(+) create mode 100644 assets/textures/clipboard.png create mode 100644 assets/textures/screenshot.png create mode 100644 assets/textures/swap.png diff --git a/assets/textures/clipboard.png b/assets/textures/clipboard.png new file mode 100644 index 0000000000000000000000000000000000000000..24f2f1040791a0bf689940062ad7504412f3014c GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|B0OCjLo9le z6C^SYbe#G5|NsB`MJ9$uMoCi@jxm&&>MW6HIh(eI?Lmo>m;q0W!xXog2F~e@Cm3!P zl+02QUm)FenRSOr@?+ttQxY57b^N`27E1J)^PFI0@JvX)e#>HW6VMI@Pgg&ebxsLQ E0EsO$ga7~l literal 0 HcmV?d00001 diff --git a/assets/textures/screenshot.png b/assets/textures/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..bb56f425db0a15fc8bb01d6980ee863ccb406995 GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|yggkULo9ml z20HRFC~!==_J4oO^jmArELkigxnPAy-j+uFX0s~Ajt(E?hSmh8E!*y}gt3-$T>iV0 rv3Zv;gMqqCdl!pKZyLkzQz|d)1H7-@H8&9f8q476>gTe~DWM4f&~`60 literal 0 HcmV?d00001 diff --git a/assets/textures/swap.png b/assets/textures/swap.png new file mode 100644 index 0000000000000000000000000000000000000000..3df04b9209f8905e37a9815a5f917baff9134f0c GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|Ts>VJLo9mF zPTVNOpupjD@c;kxs9Q?b#UIylykhKeo}~5pq9HRw{TY=^*4$O$GKy;(ZtnPgh&Rk> lMyKR;t@zu~x@Xr^Fy3d-zuzPFg&AldgQu&X%Q~loCIHoNE=~Xd literal 0 HcmV?d00001 diff --git a/src/button.lua b/src/button.lua index 4b13ece..b78f999 100644 --- a/src/button.lua +++ b/src/button.lua @@ -1,5 +1,11 @@ local self = {} +local icon = { + clipboard = love.graphics.newImage('assets/textures/clipboard.png'), + screenshot = love.graphics.newImage('assets/textures/screenshot.png'), + swap = love.graphics.newImage('assets/textures/swap.png'), +} + local buttons = {} function self.get(index) @@ -40,6 +46,7 @@ function self.createButtons() name = 'clipboard', displayname = 'Copy to Clipboard', tooltip = 'Copy to Clipboard', + icon = 'clipboard', func = function() local s = '' @@ -122,6 +129,7 @@ function self.createButtons() name = 'screenshot', displayname = 'Screenshot', tooltip = 'Take a screenshot', + icon = 'screenshot', func = function() screenshot = true screenshotCanvas = love.graphics.newCanvas() @@ -129,6 +137,21 @@ function self.createButtons() }) end + if mode == modes.mix or mode == modes.multiply then + insertButton(s, { + x = outerpadding + dropdownWidth * 2 + padding, + y = outerpadding + fontHeight/2 - padding/2, + size = padding, + name = 'swap', + displayname = 'Swap', + icon = 'swap', + func = function() + dropdown.swap('ease1', 'ease2') + createUI() + end + }) + end + buttons = s end @@ -171,6 +194,11 @@ function self.render() love.graphics.rectangle('fill', x, y, w, h) love.graphics.setColor(1, 1, 1, 1) love.graphics.rectangle('line', x, y, w, h) + + if v.icon and icon[v.icon] then + local icon = icon[v.icon] + love.graphics.draw(icon, x, y, 0, w / icon:getWidth(), h / icon:getHeight()) + end end end diff --git a/src/dropdown.lua b/src/dropdown.lua index 1bb96b9..6474c12 100644 --- a/src/dropdown.lua +++ b/src/dropdown.lua @@ -71,6 +71,13 @@ function self.kselected(key) end end +function self.swap(key, key2) + local a, b = self.kget(key), self.kget(key2) + local s = a.selected + a.selected = b.selected + b.selected = s +end + local dropdownId local function insertDropdown(tab, f) dropdownId = dropdownId + 1