new $.oPieMenu(name, widgets, show, minAngle, maxAngle, radius, position)
openHarmony/openHarmony_dialog.js, line 562
The $.oPieMenu constructor.
Name | Type | Default | Description |
---|---|---|---|
name |
string | The name for this pie Menu. | |
widgets |
Array.<QWidget> | optional The widgets to display in the menu. | |
show |
bool | false | optional Whether to immediately show the dialog. |
minAngle |
float | optional The low limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom) | |
maxAngle |
float | optional The high limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom) | |
radius |
float | optional The radius of the menu. | |
position |
$.oPoint | optional The central position of the menu. |
Properties:
Name | Type | Description |
---|---|---|
name |
string | The name for this pie Menu. |
widgets |
Array.<QWidget> | The widgets to display in the menu. |
minAngle |
float | The low limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom) |
maxAngle |
float | The high limit of the range of angles used by the menu, in multiples of PI (0 : left, 0.5 : top, 1 : right, -0.5 : bottom) |
radius |
float | The radius of the menu. |
position |
$.oPoint | The central position of the menu or button position for imbricated menus. |
menuWidget |
QWidget | The central position of the menu or button position for imbricated menus. |
sliceColor |
QColor | The color of the slices. Can set to any fill type accepted by QBrush |
backgroundColor |
QColor | The background of the menu. Can set to any fill type accepted by QBrush |
linesColor |
QColor | The color of the lines. |
Example
// This example function creates a menu full of generated push buttons with callbacks, but any type of widget can be added.
// Normally it doesn't make sense to create buttons this way, and they will be created one by one to cater to specific needs,
// such as launching Harmony actions, or scripts, etc. Assign this function to a shortcut by creating a Harmony Package for it.
function openMenu(){
MessageLog.clearLog()
// we create a list of tool widgets for our submenu
var toolSubMenuWidgets = [
new $.oToolButton("select"),
new $.oToolButton("brush"),
new $.oToolButton("pencil"),
new $.oToolButton("eraser"),
];
// we initialise our submenu
var toolSubMenu = new $.oPieSubMenu("tools", toolSubMenuWidgets);
// we create a list of tool widgets for our submenu
// (check out the scripts from http://raindropmoment.com and http://www.cartoonflow.com, they are great!)
var ScriptSubMenuWidgets = [
new $.oScriptButton(specialFolders.userScripts + "/CF_CopyPastePivots_1.0.1.js", "CF_CopyPastePivots" ),
new $.oScriptButton(specialFolders.userScripts + "/ANM_Paste_In_Place.js", "ANM_Paste_In_Place"),
new $.oScriptButton(specialFolders.userScripts + "/ANM_Set_Layer_Pivots_At_Center_Of_Drawings.js", "ANM_Set_Layer_Pivots_At_Center_Of_Drawings"),
new $.oScriptButton(specialFolders.userScripts + "/DEF_Copy_Deformation_Values_To_Resting.js", "DEF_Copy_Deformation_Values_To_Resting"),
];
var scriptsSubMenu = new $.oPieSubMenu("scripts", ScriptSubMenuWidgets);
// we create a list of color widgets for our submenu
var colorSubMenuWidgets = []
var currentPalette = $.scn.selectedPalette
var colors = currentPalette.colors
for (var i in colors){
colorSubMenuWidgets.push(new $.oColorButton(currentPalette.name, colors[i].name));
}
var colorSubMenu = new $.oPieSubMenu("colors", colorSubMenuWidgets);
onionSkinSlider = new QSlider(Qt.Horizontal)
onionSkinSlider.minimum = 0;
onionSkinSlider.maximum = 256;
onionSkinSlider.valueChanged.connect(function(value){
preferences.setDouble("DRAWING_ONIONSKIN_MAX_OPACITY",
value/256.0);
view.refreshViews();
})
// widgets that will appear in the main menu
var mainWidgets = [
onionSkinSlider,
toolSubMenu,
colorSubMenu,
scriptsSubMenu
]
// we initialise our main menu. The numerical values are for the minimum and maximum angle of the
// circle in multiples of Pi. Going clockwise, 0 is right, 1 is left, -0.5 is the bottom from the right,
// and 1.5 is the bottom from the left side. 0.5 is the top of the circle.
var menu = new $.oPieMenu("menu", mainWidgets, false, -0.2, 1.2);
// configurating the look of it
// var backgroundGradient = new QRadialGradient (menu.center, menu.maxRadius);
// var menuBg = menu.backgroundColor
// backgroundGradient.setColorAt(1, new QColor(menuBg.red(), menuBg.green(), menuBg.blue(), 255));
// backgroundGradient.setColorAt(0, menuBg);
// var sliceGradient = new QRadialGradient (menu.center, menu.maxRadius);
// var menuColor = menu.sliceColor
// sliceGradient.setColorAt(1, new QColor(menuColor.red(), menuColor.green(), menuColor.blue(), 20));
// sliceGradient.setColorAt(0, menuColor);
// menu.backgroundColor = backgroundGradient
// menu.sliceColor = sliceGradient
// we show it!
menu.show();
}
Members
-
anchor$.oPoint
-
The top left point of the entire widget
-
center$.oPoint
-
The center of the entire widget
-
maxRadiusint
-
The max radius of the pie background
-
minRadiusint
-
The min radius of the pie background
-
widgetSizeint
-
The widget size of the pie background (it's a square so it's both the width and the height.)
Methods
-
buildButton(){$.oPieButton}
openHarmony/openHarmony_dialog.js, line 805 -
Builds the menu's main button.
Returns:
Type Description $.oPieButton -
deactivate()
openHarmony/openHarmony_dialog.js, line 726 -
function run when the menu button is clicked