You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

73 lines
2.7 KiB

-- Register all Toolbar actions and intialize all UI stuff
function initUi()
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 = {
{"chalk", 0x969696},
{"blue", 0x268bd2},
{"red", 0xdc322f},
{"yellow", 0xb58900}
}
-- start with first color
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
currentColor = currentColor + 1
else
currentColor = 1
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
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