Cleanup: minor wording clarification for OBJ import
[blender-addons.git] / archipack / archipack_progressbar.py
blob35ed166dd3206f4c67c3b5baaf7a5728beb2a067
1 # -*- coding:utf-8 -*-
3 # ##### BEGIN GPL LICENSE BLOCK #####
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
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 General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110- 1301, USA.
19 # ##### END GPL LICENSE BLOCK #####
21 # <pep8 compliant>
23 # ----------------------------------------------------------
24 # Author: Stephen Leger (s-leger)
25 # Inspired reportpanel.py by Michel Anders
26 # ----------------------------------------------------------
27 import bpy
28 from bpy.props import FloatProperty, StringProperty
29 from bpy.types import Scene
30 from time import time
33 last_update = 0
34 info_header_draw = None
37 def update(self, context):
38 global last_update
39 if (context.window is not None and
40 context.window.screen is not None and
41 context.window.screen.areas is not None):
42 areas = context.window.screen.areas
43 for area in areas:
44 if area.type == 'INFO':
45 area.tag_redraw()
46 if time() - last_update > 0.1:
47 bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1)
48 last_update = time()
51 def register():
52 Scene.archipack_progress = FloatProperty(
53 options={'SKIP_SAVE'},
54 default=-1,
55 subtype='PERCENTAGE',
56 precision=1,
57 min=-1,
58 soft_min=0,
59 soft_max=100,
60 max=101,
61 update=update)
63 Scene.archipack_progress_text = StringProperty(
64 options={'SKIP_SAVE'},
65 default="Progress",
66 update=update)
68 global info_header_draw
69 info_header_draw = bpy.types.INFO_HT_header.draw
71 def info_draw(self, context):
72 global info_header_draw
73 info_header_draw(self, context)
74 if (context.scene.archipack_progress > -1 and
75 context.scene.archipack_progress < 101):
76 self.layout.separator()
77 text = context.scene.archipack_progress_text
78 self.layout.prop(context.scene,
79 "archipack_progress",
80 text=text,
81 slider=True)
83 bpy.types.INFO_HT_header.draw = info_draw
86 def unregister():
87 del Scene.archipack_progress
88 del Scene.archipack_progress_text
89 global info_header_draw
90 bpy.types.INFO_HT_header.draw = info_header_draw