FreeCAD

Форк
0
/
OverlayParams.py 
181 строка · 8.6 Кб
1
# -*- coding: utf-8 -*-
2
# ***************************************************************************
3
# *   Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com>*
4
# *                                                                         *
5
# *   This program is free software; you can redistribute it and/or modify  *
6
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
7
# *   as published by the Free Software Foundation; either version 2 of     *
8
# *   the License, or (at your option) any later version.                   *
9
# *   for detail see the LICENCE text file.                                 *
10
# *                                                                         *
11
# *   This program is distributed in the hope that it will be useful,       *
12
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
# *   GNU Library General Public License for more details.                  *
15
# *                                                                         *
16
# *   You should have received a copy of the GNU Library General Public     *
17
# *   License along with this program; if not, write to the Free Software   *
18
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
19
# *   USA                                                                   *
20
# *                                                                         *
21
# ***************************************************************************
22
'''Auto code generator for overlay widgets related parameters in Preferences/View
23
'''
24
import cog
25
import inspect, sys
26
from os import sys, path
27

28
# import Tools/params_utils.py
29
sys.path.append(path.join(path.dirname(path.dirname(path.abspath(__file__))), 'Tools'))
30
import params_utils
31

32
from params_utils import ParamBool, ParamInt, ParamString, ParamUInt, ParamHex, \
33
                         ParamFloat, ParamProxy, ParamLinePattern, ParamFile, \
34
                         ParamComboBox, ParamColor, ParamSpinBox, auto_comment
35

36
NameSpace = 'Gui'
37
ClassName = 'OverlayParams'
38
ParamPath = 'User parameter:BaseApp/Preferences/View'
39
ClassDoc = 'Convenient class to obtain overlay widgets related parameters'
40

41
AnimationCurveTypes = (
42
    "Linear",
43
    "InQuad",
44
    "OutQuad",
45
    "InOutQuad",
46
    "OutInQuad",
47
    "InCubic",
48
    "OutCubic",
49
    "InOutCubic",
50
    "OutInCubic",
51
    "InQuart",
52
    "OutQuart",
53
    "InOutQuart",
54
    "OutInQuart",
55
    "InQuint",
56
    "OutQuint",
57
    "InOutQuint",
58
    "OutInQuint",
59
    "InSine",
60
    "OutSine",
61
    "InOutSine",
62
    "OutInSine",
63
    "InExpo",
64
    "OutExpo",
65
    "InOutExpo",
66
    "OutInExpo",
67
    "InCirc",
68
    "OutCirc",
69
    "InOutCirc",
70
    "OutInCirc",
71
    "InElastic",
72
    "OutElastic",
73
    "InOutElastic",
74
    "OutInElastic",
75
    "InBack",
76
    "OutBack",
77
    "InOutBack",
78
    "OutInBack",
79
    "InBounce",
80
    "OutBounce",
81
    "InOutBounce",
82
    "OutInBounce",
83
)
84

85
class ParamAnimationCurve(ParamProxy):
86
    WidgetType = 'Gui::PrefComboBox'
87

88
    def widget_setter(self, _param):
89
        return None
90

91
    def init_widget(self, param, row, group_name):
92
        super().init_widget(param, row, group_name)
93
        cog.out(f'''
94
    {auto_comment()}
95
    for (const auto &item : OverlayParams::AnimationCurveTypes)
96
        {param.widget_name}->addItem(item);''')
97
        cog.out(f'''
98
    {param.widget_name}->setCurrentIndex({param.namespace}::{param.class_name}::default{param.name}());''')
99

100
Params = [
101
    ParamBool('DockOverlayAutoView', True, on_change=True, title="Auto hide in non 3D view"),
102
    ParamInt('DockOverlayDelay', 200, "Overlay dock (re),layout delay.", title="Layout delay (ms)", proxy=ParamSpinBox(0, 5000, 100)),
103
    ParamInt('DockOverlayRevealDelay', 2000),
104
    ParamInt('DockOverlaySplitterHandleTimeout', 0, title="Splitter auto hide delay (ms)", proxy=ParamSpinBox(0, 99999, 100),
105
         doc="Overlay splitter handle auto hide delay. Set zero to disable auto hiding."),
106
    ParamBool('DockOverlayActivateOnHover', True, title="Activate on hover",
107
         doc="Show auto hidden dock overlay on mouse over.\n"
108
             "If disabled, then show on mouse click."),
109
    ParamBool('DockOverlayAutoMouseThrough', True,
110
         "Auto mouse click through transparent part of dock overlay.", title="Auto mouse pass through"),
111
    ParamBool('DockOverlayWheelPassThrough', True,
112
         "Auto pass through mouse wheel event on transparent dock overlay.", title="Auto mouse wheel pass through"),
113
    ParamInt('DockOverlayWheelDelay', 1000, title="Delay mouse wheel pass through (ms)", proxy=ParamSpinBox(0, 99999, 1),
114
         doc="Delay capturing mouse wheel event for passing through if it is\n"
115
              "previously handled by other widget."),
116
    ParamInt('DockOverlayAlphaRadius', 2, title="Alpha test radius", proxy=ParamSpinBox(1, 100, 1), doc=\
117
         "If auto mouse click through is enabled, then this radius\n"
118
         "defines a region of alpha test under the mouse cursor.\n"
119
         "Auto click through is only activated if all pixels within\n"
120
         "the region are non-opaque."),
121
    ParamBool('DockOverlayCheckNaviCube', True, on_change=True, title="Check Navigation Cube",
122
         doc="Leave space for Navigation Cube in dock overlay"),
123
    ParamInt('DockOverlayHintTriggerSize', 16, title="Hint trigger size", proxy=ParamSpinBox(1, 100, 1),
124
         doc="Auto hide hint visual display triggering width"),
125
    ParamInt('DockOverlayHintSize', 8, title="Hint width", proxy=ParamSpinBox(1, 100, 1),
126
         doc="Auto hide hint visual display width"),
127
    ParamInt('DockOverlayHintLeftLength', 100, title='Left panel hint length', proxy=ParamSpinBox(0, 10000, 10),
128
         doc="Auto hide hint visual display length for left panel. Set to zero to fill the space."),
129
    ParamInt('DockOverlayHintRightLength', 100, title='Right panel hint length', proxy=ParamSpinBox(0, 10000, 10),
130
         doc="Auto hide hint visual display length for right panel. Set to zero to fill the space."),
131
    ParamInt('DockOverlayHintTopLength', 100, title='Top panel hint length', proxy=ParamSpinBox(0, 10000, 10),
132
         doc="Auto hide hint visual display length for top panel. Set to zero to fill the space."),
133
    ParamInt('DockOverlayHintBottomLength', 100, title='Bottom panel hint length', proxy=ParamSpinBox(0, 10000, 10),
134
         doc="Auto hide hint visual display length for bottom panel. Set to zero to fill the space."),
135
    ParamInt('DockOverlayHintLeftOffset', 0, title='Left panel hint offset', proxy=ParamSpinBox(0, 10000, 10),
136
         doc="Auto hide hint visual display offset for left panel"),
137
    ParamInt('DockOverlayHintRightOffset', 0, title='Right panel hint offset', proxy=ParamSpinBox(0, 10000, 10),
138
         doc="Auto hide hint visual display offset for right panel"),
139
    ParamInt('DockOverlayHintTopOffset', 0, title='Top panel hint offset', proxy=ParamSpinBox(0, 10000, 10),
140
         doc="Auto hide hint visual display offset for top panel"),
141
    ParamInt('DockOverlayHintBottomOffset', 0, title='Bottom panel hint offset', proxy=ParamSpinBox(0, 10000, 10),
142
         doc="Auto hide hint visual display offset for bottom panel"),
143
    ParamBool('DockOverlayHintTabBar', False, "Show tab bar on mouse over when auto hide", title="Hint show tab bar"),
144
    ParamBool('DockOverlayHideTabBar', True, on_change=True, doc="Hide tab bar in dock overlay", title='Hide tab bar'),
145
    ParamInt('DockOverlayHintDelay', 200, "Delay before show hint visual", title="Hint delay (ms)", proxy=ParamSpinBox(0, 1000, 100)),
146
    ParamInt('DockOverlayAnimationDuration', 200, "Auto hide animation duration, 0 to disable",
147
         title="Animation duration (ms)", proxy=ParamSpinBox(0, 5000, 100)),
148
    ParamInt('DockOverlayAnimationCurve', 7, "Auto hide animation curve type", title="Animation curve type", proxy=ParamAnimationCurve()),
149
    ParamBool('DockOverlayHidePropertyViewScrollBar', False, "Hide property view scroll bar in dock overlay", title="Hide property view scroll bar"),
150
    ParamInt('DockOverlayMinimumSize', 30, on_change=True,
151
            doc="Minimum overlay dock widget width/height",
152
            title="Minimum dock widget size"),
153
]
154

155
def declare():
156
    cog.out(f'''
157
{auto_comment()}
158
#include <QString>
159
''')
160

161
    params_utils.declare_begin(sys.modules[__name__])
162
    cog.out(f'''
163
    {auto_comment()}
164
    static const std::vector<QString> AnimationCurveTypes;
165
''')
166
    params_utils.declare_end(sys.modules[__name__])
167

168
def define():
169
    params_utils.define(sys.modules[__name__])
170
    cog.out(f'''
171
{auto_comment()}
172
const std::vector<QString> OverlayParams::AnimationCurveTypes = {{''')
173
    for item in AnimationCurveTypes:
174
        cog.out(f'''
175
    QStringLiteral("{item}"),''')
176
    cog.out(f'''
177
}};
178
''')
179

180

181
params_utils.init_params(Params, NameSpace, ClassName, ParamPath)
182

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.