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.
82 lines
3.0 KiB
82 lines
3.0 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"}); |
|
app.registerUi({["menu"] = "Solid", ["callback"] = "solid", ["accelerator"] = "<Alt>F15"}); |
|
app.registerUi({["menu"] = "dash", ["callback"] = "dash", ["accelerator"] = "<Alt>F16"}); |
|
-- 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}, |
|
{"yellow", 0xb58900}, |
|
{"blue", 0x268bd2}, |
|
{"red", 0xdc322f} |
|
} |
|
|
|
-- 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 solid() |
|
app.uiAction({["action"]="ACTION_TOOL_LINE_STYLE_PLAIN"}) |
|
end |
|
|
|
function dash() |
|
app.uiAction({["action"]="ACTION_TOOL_LINE_STYLE_DOT"}) |
|
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 highlighter color or the color from another tool with color capabilities. |
|
end
|
|
|