|
|
|
|
@ -1,28 +1,51 @@ |
|
|
|
|
-- Register all Toolbar actions and intialize all UI stuff |
|
|
|
|
function initUi() |
|
|
|
|
app.registerUi({["menu"] = "Cycle through color list", ["callback"] = "cycle", ["accelerator"] = "<Alt>c"}); |
|
|
|
|
app.registerUi({["menu"] = "Cycle forward through color list", ["callback"] = "cycle", ["accelerator"] = "<Alt>c"}); |
|
|
|
|
app.registerUi({["menu"] = "Cycle backward through color list", ["callback"] = "cycleBackward", ["accelerator"] = "<Alt>x"}); |
|
|
|
|
app.registerUi({["menu"] = "Color 1", ["callback"] = "colorOne", ["accelerator"] = "F15"}); |
|
|
|
|
app.registerUi({["menu"] = "Color 2", ["callback"] = "colorTwo", ["accelerator"] = "F16"}); |
|
|
|
|
app.registerUi({["menu"] = "Color 3", ["callback"] = "colorThree", ["accelerator"] = "F17"}); |
|
|
|
|
app.registerUi({["menu"] = "Color 4", ["callback"] = "colorFour", ["accelerator"] = "F18"}); |
|
|
|
|
-- if you want to have multiple color lists you must use the app.registerUi function multiple times |
|
|
|
|
-- with different callback functions and accelerators |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Predefined colors copied from LoadHandlerHelper.cpp |
|
|
|
|
-- modify to your needs |
|
|
|
|
local colorList = { |
|
|
|
|
{"black", 0x000000}, |
|
|
|
|
{"green", 0x008000}, |
|
|
|
|
{"lightblue", 0x00c0ff}, |
|
|
|
|
{"lightgreen", 0x00ff00}, |
|
|
|
|
{"blue", 0x3333cc}, |
|
|
|
|
{"gray", 0x808080}, |
|
|
|
|
{"red", 0xff0000}, |
|
|
|
|
{"magenta", 0xff00ff}, |
|
|
|
|
{"orange", 0xff8000}, |
|
|
|
|
{"yellow", 0xffff00}, |
|
|
|
|
{"white", 0xffffff} |
|
|
|
|
} |
|
|
|
|
-- Predefined colors copied from LoadHandlerHelper.cpp |
|
|
|
|
-- modify to your needs |
|
|
|
|
local colorList = { |
|
|
|
|
{"chalk", 0x969696}, |
|
|
|
|
{"blue", 0x268bd2}, |
|
|
|
|
{"red", 0xdc322f}, |
|
|
|
|
{"yellow", 0xb58900} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
-- start with first color |
|
|
|
|
local currentColor = 0 |
|
|
|
|
local currentColor = 1 |
|
|
|
|
|
|
|
|
|
function colorOne() |
|
|
|
|
currentColor = 1 |
|
|
|
|
|
|
|
|
|
app.changeToolColor({["color"] = colorList[currentColor][2], ["selection"] = true}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function colorTwo() |
|
|
|
|
currentColor = 2 |
|
|
|
|
|
|
|
|
|
app.changeToolColor({["color"] = colorList[currentColor][2], ["selection"] = true}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function colorThree() |
|
|
|
|
currentColor = 3 |
|
|
|
|
|
|
|
|
|
app.changeToolColor({["color"] = colorList[currentColor][2], ["selection"] = true}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function colorFour() |
|
|
|
|
currentColor = 4 |
|
|
|
|
|
|
|
|
|
app.changeToolColor({["color"] = colorList[currentColor][2], ["selection"] = true}) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function cycle() |
|
|
|
|
if (currentColor < #colorList) then |
|
|
|
|
@ -32,7 +55,19 @@ function cycle() |
|
|
|
|
end |
|
|
|
|
-- apply color to currently used tool and allow coloring of elements from selections |
|
|
|
|
app.changeToolColor({["color"] = colorList[currentColor][2], ["selection"] = true}) |
|
|
|
|
-- use app.changeColor({["color"] = colorList[currentColor][2], ["tool"] = "pen""}) |
|
|
|
|
-- use app.changeColor({["color"] = colorList[currentColor][2], ["tool"] = "pen""}) |
|
|
|
|
-- instead if you only want to change pen color |
|
|
|
|
-- similarly if you want to change hilighter color or the color from another tool with color capabilities. |
|
|
|
|
end |
|
|
|
|
function cycleBackward() |
|
|
|
|
if (currentColor >1 ) then |
|
|
|
|
currentColor = currentColor - 1 |
|
|
|
|
else |
|
|
|
|
currentColor = #colorList |
|
|
|
|
end |
|
|
|
|
-- apply color to currently used tool and allow coloring of elements from selections |
|
|
|
|
app.changeToolColor({["color"] = colorList[currentColor][2], ["selection"] = true}) |
|
|
|
|
-- use app.changeColor({["color"] = colorList[currentColor][2], ["tool"] = "pen""}) |
|
|
|
|
-- instead if you only want to change pen color |
|
|
|
|
-- similarly if you want to change hilighter color or the color from another tool with color capabilities. |
|
|
|
|
end |
|
|
|
|
|