| 1 |
# *************************************************************************** |
| 2 |
# * Copyright (c) 2022 Zheng Lei (realthunder) <[email protected]>* |
| 3 |
# * * |
| 4 |
# * This program is free software; you can redistribute it and/or modify * |
| 5 |
# * it under the terms of the GNU Lesser General Public License (LGPL) * |
| 6 |
# * as published by the Free Software Foundation; either version 2 of * |
| 7 |
# * the License, or (at your option) any later version. * |
| 8 |
# * for detail see the LICENCE text file. * |
| 9 |
# * * |
| 10 |
# * This program is distributed in the hope that it will be useful, * |
| 11 |
# * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 |
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 |
# * GNU Library General Public License for more details. * |
| 14 |
# * * |
| 15 |
# * You should have received a copy of the GNU Library General Public * |
| 16 |
# * License along with this program; if not, write to the Free Software * |
| 17 |
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
| 18 |
# * USA * |
| 19 |
# * * |
| 20 |
# *************************************************************************** |
| 21 |
"""Auto code generator for overlay widgets related parameters in Preferences/View""" |
| 22 |
import cog |
| 23 |
import inspect, sys |
| 24 |
from os import path |
| 25 |
|
| 26 |
# import Tools/params_utils.py |
| 27 |
sys.path.append(path.join(path.dirname(path.dirname(path.abspath(__file__))), "Tools")) |
| 28 |
import params_utils |
| 29 |
|
| 30 |
from params_utils import ( |
| 31 |
ParamBool, |
| 32 |
ParamInt, |
| 33 |
ParamString, |
| 34 |
ParamUInt, |
| 35 |
ParamHex, |
| 36 |
ParamFloat, |
| 37 |
ParamProxy, |
| 38 |
ParamLinePattern, |
| 39 |
ParamFile, |
| 40 |
ParamComboBox, |
| 41 |
ParamColor, |
| 42 |
ParamSpinBox, |
| 43 |
auto_comment, |
| 44 |
) |
| 45 |
|
| 46 |
NameSpace = "Gui" |
| 47 |
ClassName = "OverlayParams" |
| 48 |
ParamPath = "User parameter:BaseApp/Preferences/View" |
| 49 |
ClassDoc = "Convenient class to obtain overlay widgets related parameters" |
| 50 |
|
| 51 |
AnimationCurveTypes = ( |
| 52 |
"Linear", |
| 53 |
"InQuad", |
| 54 |
"OutQuad", |
| 55 |
"InOutQuad", |
| 56 |
"OutInQuad", |
| 57 |
"InCubic", |
| 58 |
"OutCubic", |
| 59 |
"InOutCubic", |
| 60 |
"OutInCubic", |
| 61 |
"InQuart", |
| 62 |
"OutQuart", |
| 63 |
"InOutQuart", |
| 64 |
"OutInQuart", |
| 65 |
"InQuint", |
| 66 |
"OutQuint", |
| 67 |
"InOutQuint", |
| 68 |
"OutInQuint", |
| 69 |
"InSine", |
| 70 |
"OutSine", |
| 71 |
"InOutSine", |
| 72 |
"OutInSine", |
| 73 |
"InExpo", |
| 74 |
"OutExpo", |
| 75 |
"InOutExpo", |
| 76 |
"OutInExpo", |
| 77 |
"InCirc", |
| 78 |
"OutCirc", |
| 79 |
"InOutCirc", |
| 80 |
"OutInCirc", |
| 81 |
"InElastic", |
| 82 |
"OutElastic", |
| 83 |
"InOutElastic", |
| 84 |
"OutInElastic", |
| 85 |
"InBack", |
| 86 |
"OutBack", |
| 87 |
"InOutBack", |
| 88 |
"OutInBack", |
| 89 |
"InBounce", |
| 90 |
"OutBounce", |
| 91 |
"InOutBounce", |
| 92 |
"OutInBounce", |
| 93 |
) |
| 94 |
|
| 95 |
|
| 96 |
class ParamAnimationCurve(ParamProxy): |
| 97 |
WidgetType = "Gui::PrefComboBox" |
| 98 |
|
| 99 |
def widget_setter(self, _param): |
| 100 |
return None |
| 101 |
|
| 102 |
def init_widget(self, param, row, group_name): |
| 103 |
super().init_widget(param, row, group_name) |
| 104 |
cog.out( |
| 105 |
f""" |
| 106 |
{auto_comment()} |
| 107 |
for (const auto &item : OverlayParams::AnimationCurveTypes) |
| 108 |
{param.widget_name}->addItem(item);""" |
| 109 |
) |
| 110 |
cog.out( |
| 111 |
f""" |
| 112 |
{param.widget_name}->setCurrentIndex({param.namespace}::{param.class_name}::default{param.name}());""" |
| 113 |
) |
| 114 |
|
| 115 |
|
| 116 |
Params = [ |
| 117 |
ParamBool("DockOverlayAutoView", True, on_change=True, title="Auto hide in non 3D view"), |
| 118 |
ParamInt( |
| 119 |
"DockOverlayDelay", |
| 120 |
200, |
| 121 |
"Overlay layout delay", |
| 122 |
title="Layout delay", |
| 123 |
proxy=ParamSpinBox(0, 5000, 100, suffix=" ms"), |
| 124 |
), |
| 125 |
ParamInt("DockOverlayRevealDelay", 2000), |
| 126 |
ParamInt( |
| 127 |
"DockOverlaySplitterHandleTimeout", |
| 128 |
0, |
| 129 |
title="Splitter auto hide delay", |
| 130 |
proxy=ParamSpinBox(0, 99999, 100, suffix=" ms"), |
| 131 |
doc="Overlay splitter handle auto hide delay. Set zero to disable auto hiding.", |
| 132 |
), |
| 133 |
ParamBool( |
| 134 |
"DockOverlayActivateOnHover", |
| 135 |
True, |
| 136 |
title="Activate on hover", |
| 137 |
doc="Show auto hidden dock overlay on mouse over.\n" |
| 138 |
"If disabled, then show on mouse click.", |
| 139 |
), |
| 140 |
ParamBool( |
| 141 |
"DockOverlayAutoMouseThrough", |
| 142 |
True, |
| 143 |
"Auto mouse click through transparent part of dock overlay.", |
| 144 |
title="Auto mouse pass through", |
| 145 |
), |
| 146 |
ParamBool( |
| 147 |
"DockOverlayWheelPassThrough", |
| 148 |
True, |
| 149 |
"Automatically passes mouse wheel events through the transparent areas of an overlay panel", |
| 150 |
title="Auto mouse wheel pass through", |
| 151 |
), |
| 152 |
ParamInt( |
| 153 |
"DockOverlayWheelDelay", |
| 154 |
1000, |
| 155 |
title="Delay mouse wheel pass through", |
| 156 |
proxy=ParamSpinBox(0, 99999, 1, suffix=" ms"), |
| 157 |
doc="Delay capturing mouse wheel event for passing through if it is\n" |
| 158 |
"previously handled by other widget.", |
| 159 |
), |
| 160 |
ParamInt( |
| 161 |
"DockOverlayAlphaRadius", |
| 162 |
2, |
| 163 |
title="Alpha test radius", |
| 164 |
proxy=ParamSpinBox(1, 100, 1, suffix=" px"), |
| 165 |
doc="If auto mouse click through is enabled, then this radius\n" |
| 166 |
"defines a region of alpha test under the mouse cursor.\n" |
| 167 |
"Auto click through is only activated if all pixels within\n" |
| 168 |
"the region are non-opaque.", |
| 169 |
), |
| 170 |
ParamBool( |
| 171 |
"DockOverlayCheckNaviCube", |
| 172 |
True, |
| 173 |
on_change=True, |
| 174 |
title="Check Navigation Cube", |
| 175 |
doc="Leave space for Navigation Cube in dock overlay", |
| 176 |
), |
| 177 |
ParamInt( |
| 178 |
"DockOverlayHintTriggerSize", |
| 179 |
16, |
| 180 |
title="Hint trigger size", |
| 181 |
proxy=ParamSpinBox(1, 100, 1, suffix=" px"), |
| 182 |
doc="Auto hide hint visual display triggering width", |
| 183 |
), |
| 184 |
ParamInt( |
| 185 |
"DockOverlayHintSize", |
| 186 |
8, |
| 187 |
title="Hint width", |
| 188 |
proxy=ParamSpinBox(1, 100, 1, suffix=" px"), |
| 189 |
doc="Auto hide hint visual display width", |
| 190 |
), |
| 191 |
ParamInt( |
| 192 |
"DockOverlayHintLeftLength", |
| 193 |
100, |
| 194 |
title="Left panel hint length", |
| 195 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 196 |
doc="Auto hide hint visual display length for left panel. Set to zero to fill the space.", |
| 197 |
), |
| 198 |
ParamInt( |
| 199 |
"DockOverlayHintRightLength", |
| 200 |
100, |
| 201 |
title="Right panel hint length", |
| 202 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 203 |
doc="Auto hide hint visual display length for right panel. Set to zero to fill the space.", |
| 204 |
), |
| 205 |
ParamInt( |
| 206 |
"DockOverlayHintTopLength", |
| 207 |
100, |
| 208 |
title="Top panel hint length", |
| 209 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 210 |
doc="Auto hide hint visual display length for top panel. Set to zero to fill the space.", |
| 211 |
), |
| 212 |
ParamInt( |
| 213 |
"DockOverlayHintBottomLength", |
| 214 |
100, |
| 215 |
title="Bottom panel hint length", |
| 216 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 217 |
doc="Auto hide hint visual display length for bottom panel. Set to zero to fill the space.", |
| 218 |
), |
| 219 |
ParamInt( |
| 220 |
"DockOverlayHintLeftOffset", |
| 221 |
0, |
| 222 |
title="Left panel hint offset", |
| 223 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 224 |
doc="Auto hide hint visual display offset for left panel", |
| 225 |
), |
| 226 |
ParamInt( |
| 227 |
"DockOverlayHintRightOffset", |
| 228 |
0, |
| 229 |
title="Right panel hint offset", |
| 230 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 231 |
doc="Auto hide hint visual display offset for right panel", |
| 232 |
), |
| 233 |
ParamInt( |
| 234 |
"DockOverlayHintTopOffset", |
| 235 |
0, |
| 236 |
title="Top panel hint offset", |
| 237 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 238 |
doc="Auto hide hint visual display offset for top panel", |
| 239 |
), |
| 240 |
ParamInt( |
| 241 |
"DockOverlayHintBottomOffset", |
| 242 |
0, |
| 243 |
title="Bottom panel hint offset", |
| 244 |
proxy=ParamSpinBox(0, 10000, 10, suffix=" px"), |
| 245 |
doc="Auto hide hint visual display offset for bottom panel", |
| 246 |
), |
| 247 |
ParamBool( |
| 248 |
"DockOverlayHintTabBar", |
| 249 |
False, |
| 250 |
"Show tab bar on mouse over when auto hide", |
| 251 |
title="Hint show tab bar", |
| 252 |
), |
| 253 |
ParamBool( |
| 254 |
"DockOverlayHideTabBar", |
| 255 |
True, |
| 256 |
on_change=True, |
| 257 |
doc="Hide tab bar in dock overlay", |
| 258 |
title="Hide tab bar", |
| 259 |
), |
| 260 |
ParamInt( |
| 261 |
"DockOverlayHintDelay", |
| 262 |
200, |
| 263 |
"Delay before show hint visual", |
| 264 |
title="Hint delay", |
| 265 |
proxy=ParamSpinBox(0, 1000, 100, suffix=" ms"), |
| 266 |
), |
| 267 |
ParamInt( |
| 268 |
"DockOverlayAnimationDuration", |
| 269 |
200, |
| 270 |
"Auto hide animation duration, 0 to disable", |
| 271 |
title="Animation duration", |
| 272 |
proxy=ParamSpinBox(0, 5000, 100, suffix=" ms"), |
| 273 |
), |
| 274 |
ParamInt( |
| 275 |
"DockOverlayAnimationCurve", |
| 276 |
7, |
| 277 |
"Auto hide animation curve type", |
| 278 |
title="Animation curve type", |
| 279 |
proxy=ParamAnimationCurve(), |
| 280 |
), |
| 281 |
ParamBool( |
| 282 |
"DockOverlayHidePropertyViewScrollBar", |
| 283 |
False, |
| 284 |
"Hide property view scroll bar in dock overlay", |
| 285 |
title="Hide property view scroll bar", |
| 286 |
), |
| 287 |
ParamInt( |
| 288 |
"DockOverlayMinimumSize", |
| 289 |
30, |
| 290 |
on_change=True, |
| 291 |
doc="Minimum overlay dock widget width/height", |
| 292 |
title="Minimum dock widget size", |
| 293 |
), |
| 294 |
] |
| 295 |
|
| 296 |
|
| 297 |
def declare(): |
| 298 |
cog.out( |
| 299 |
f""" |
| 300 |
{auto_comment()} |
| 301 |
#include <QString> |
| 302 |
""" |
| 303 |
) |
| 304 |
|
| 305 |
params_utils.declare_begin(sys.modules[__name__]) |
| 306 |
cog.out( |
| 307 |
f""" |
| 308 |
{auto_comment()} |
| 309 |
static const std::vector<QString> AnimationCurveTypes; |
| 310 |
""" |
| 311 |
) |
| 312 |
params_utils.declare_end(sys.modules[__name__]) |
| 313 |
|
| 314 |
|
| 315 |
def define(): |
| 316 |
params_utils.define(sys.modules[__name__]) |
| 317 |
cog.out( |
| 318 |
f""" |
| 319 |
{auto_comment()} |
| 320 |
const std::vector<QString> OverlayParams::AnimationCurveTypes = {{""" |
| 321 |
) |
| 322 |
for item in AnimationCurveTypes: |
| 323 |
cog.out( |
| 324 |
f""" |
| 325 |
QStringLiteral("{item}"),""" |
| 326 |
) |
| 327 |
cog.out( |
| 328 |
f""" |
| 329 |
}}; |
| 330 |
""" |
| 331 |
) |
| 332 |
|
| 333 |
|
| 334 |
params_utils.init_params(Params, NameSpace, ClassName, ParamPath) |