-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
2277 lines (1489 loc) · 69.8 KB
/
__init__.py
File metadata and controls
2277 lines (1489 loc) · 69.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import bpy
import json
import os
import pathlib
import nodeitems_utils
from copy import copy
import bpy.utils.previews
import random
from bpy.app.handlers import persistent
from bpy.types import (
Panel,
PropertyGroup,
Operator,
UIList,
Header,
)
from bpy.props import (
FloatProperty,
BoolProperty,
PointerProperty,
EnumProperty,
StringProperty,
IntProperty,
CollectionProperty,
)
from .Notes_list import *
from .Nodes import *
bl_info = {
"name" : "Noter",
"author" : "Rovh",
"description" : "Noter is an add-on created to increase productivity in Blender by organizing the workflow.",
"blender" : (2, 90, 0),
"version" : (1, 1, 0),
"location" : "Text Editor > Sidebar > Noter Tab",
"warning" : "",
"category" : "System",
"wiki_url": "https://github.com/rovh/Noter#noter",
"tracker_url": "https://github.com/rovh/Noter/issues",
}
custom_scene_name = ".Noter_Data"
class Noter_Actions(bpy.types.Operator):
"""Tooltip"""
bl_idname = "window_manager.export_note_text"
bl_label = ""
bl_description = 'You can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut'
# bl_options = {'REGISTER', 'UNDO'}
bl_options = {'UNDO'}
action: StringProperty(options = {"SKIP_SAVE"})
header_note: BoolProperty(options = {"SKIP_SAVE"}, default = True)
@classmethod
def description(cls, context, properties):
if properties.action == 'object':
return "Assign text to the active object"
elif properties.action == 'object_get':
return "Get text from the active object"
elif properties.action == 'object_delete':
return "Delete text in the active object"
elif properties.action == 'object*':
return "Import text to the active object list"
elif properties.action == 'object_get*':
return "Export text from the active object list"
elif properties.action == 'scene':
return "Assign text to the active scene"
elif properties.action == 'scene_get':
return "Get text from the active scene"
elif properties.action == 'scene_delete':
return "Delete text in the active scene"
elif properties.action == 'scene*':
return "Import text to the scene list"
elif properties.action == 'scene_get*':
return "Export text from the scene list"
elif properties.action == 'blender_file':
return "Assign text to the .blend file"
elif properties.action == 'blender_file_get':
return "Get text from the .blend file"
elif properties.action == 'blender_file_delete':
return "Delete text in the .blend file"
elif properties.action == 'blender_file*':
return "Import text to the File(.blend) list"
elif properties.action == 'blender_file_get*':
return "Export text from the File(.blend) list"
elif properties.action == 'blender':
return "Assign text to Blender (Noter)"
elif properties.action == 'blender_get':
return "Get text from Blender (Noter)"
elif properties.action == 'blender_delete':
return "Delete text in Blender (Noter)"
elif properties.action == 'splash_screen':
return "Assign text to the Noter Splash Screen"
elif properties.action == 'splash_screen_get':
return "Get text from the Noter Splash Screen"
elif properties.action == 'splash_screen_delete':
return "Delete text in the Noter Splash Screen"
def execute(self, context):
# t1 = time.perf_counter()
# t1 = time.perf_counter()
action = self.action
header_note = self.header_note
if action.count("*") != 0:
action = self.action.replace("*", "")
header_note = False
else:
header_note = True
action_type = action.split("_")
action_type = action_type[0]
if header_note == True:
pass
else:
if len(bpy.context.active_object.notes_list_object) == 0 and action_type == 'object':
bpy.context.active_object.notes_list_object.add()
elif len(bpy.context.scene.notes_list_scene) == 0 and action_type == 'scene':
bpy.context.scene.notes_list_scene.add()
if (action == 'object' or\
action == 'object_get' or\
action == 'object_delete') and\
bpy.context.active_object is None:
text = "No Active Object was found"
war = "ERROR"
self.report({war}, text)
return {'FINISHED'}
if len(bpy.data.texts.values()) == 0 and header_note == True:
bpy.ops.text.new()
try:
bpy.data.texts[bpy.context.space_data.text.name].name = bpy.context.scene.file_name
except AttributeError:
pass
text = f'A new text file " {bpy.context.scene.file_name} " was created'
war = "INFO"
self.report({war}, text)
# return {'FINISHED'}
#object
try:
note_text_object = bpy.context.active_object.note_text_object
except AttributeError:
pass
#scene
note_text_scene = bpy.context.scene.note_text_scene
#blender_file
# note_text_blender_file = ""
# for i in bpy.data.scenes:
# if bool(i.note_text_blender_file) == True:
# note_text_blender_file = i.note_text_blender_file
# break
#splash_screen
# note_text_splash_screen = ""
# for i in bpy.data.scenes:
# if i.splash_screen == True:
# note_text_splash_screen = i.note_text_splash_screen
# break
#
use_file_path = bpy.context.preferences.addons[__name__].preferences.use_file_path
if use_file_path == 'OPENED':
try:
# for i in bpy.context.workspace:
# file_name = i.text.name
file_name = bpy.data.screens['Scripting'].areas.data.text.name
except AttributeError:
pass
else:
file_name = bpy.context.scene.file_name
try:
if bpy.context.space_data.text.name != file_name:
if action.count('get'):
if bpy.data.texts.find(file_name) != -1:
bpy.context.space_data.text = bpy.data.texts[file_name]
text = f'File was changed to " {file_name} " '
war = "INFO"
self.report({war}, text)
else:
bpy.ops.text.new()
bpy.data.texts[bpy.context.space_data.text.name].name = file_name
text = f'A new text file " {file_name} " was created'
war = "INFO"
self.report({war}, text)
elif action.count('get') == 0 and action.count('delete') == 0:
text = 'The name of the open file does not match the name of the files used by "Noter"'
war = "WARNING"
self.report({war}, text)
# file_name = bpy.context.space_data.text.name
except AttributeError:
pass
try:
main_text = bpy.data.texts[file_name].as_string()
except KeyError:
if action.count('delete'):
pass
else:
text = "File was not found"
war = "ERROR"
self.report({war}, text)
return {'FINISHED'}
if action == 'object':
if header_note == True:
bpy.context.active_object.note_text_object = main_text
else:
item = self.item_object(context)
item.text = main_text
elif action == "object_get":
bpy.data.texts[file_name].clear()
if header_note == True:
bpy.data.texts[file_name].write(note_text_object)
else:
item = self.item_object(context)
bpy.data.texts[file_name].write(item.text)
elif action == "object_delete":
if header_note == True:
bpy.context.active_object.note_text_object = ""
else:
item = self.item_object(context)
item.text = ""
elif action == 'scene':
if header_note == True:
bpy.context.scene.note_text_scene = main_text
else:
item = self.item_scene(context)
item.text = main_text
elif action == 'scene_get':
bpy.data.texts[file_name].clear()
if header_note == True:
bpy.data.texts[file_name].write(note_text_scene)
else:
item = self.item_scene(context)
bpy.data.texts[file_name].write(item.text)
elif action == 'scene_delete':
if header_note == True:
bpy.context.scene.note_text_scene = ""
else:
item = self.item_scene(context)
item.text = ""
elif action == 'blender_file':
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
if header_note == True:
bpy.data.scenes[custom_scene_name].note_text_blender_file = main_text
# for i in bpy.data.scenes:
# i.note_text_blender_file = main_text
else:
item = self.item_blender_file(context)
item.text = main_text
elif action == "blender_file_get":
bpy.data.texts[file_name].clear()
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
if header_note == True:
note_text_blender_file = bpy.data.scenes[custom_scene_name].note_text_blender_file
bpy.data.texts[file_name].write(note_text_blender_file)
else:
item = self.item_blender_file(context)
bpy.data.texts[file_name].write(item.text)
elif action == "blender_file_delete":
if header_note == True:
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
bpy.data.scenes[custom_scene_name].note_text_blender_file = ""
# for i in bpy.data.scenes:
# i.note_text_blender_file = ""
else:
item = self.item_object(context)
item.text = ""
elif action == 'blender':
if header_note == True:
file_folder_path = pathlib.Path(__file__).parent.absolute()
file_folder_path = os.path.join(file_folder_path, 'note_text_blender.json')
with open(file_folder_path, "w", encoding='utf-8') as data_file:
json.dump(main_text, data_file)
# bpy.context.preferences.addons[__name__].preferences.note_text_blender = main_text
# bpy.context.preferences.use_preferences_save
else:
item = self.item_scene(context)
item.text = main_text
elif action == 'blender_get':
bpy.data.texts[file_name].clear()
if header_note == True:
file_folder_path = pathlib.Path(__file__).parent.absolute()
file_folder_path = os.path.join(file_folder_path, 'note_text_blender.json')
with open(file_folder_path, encoding='utf-8') as f:
note_text_blender_json = json.load(f)
bpy.data.texts[file_name].write(note_text_blender_json)
else:
item = self.item_scene(context)
bpy.data.texts[file_name].write(item.text)
elif action == 'blender_delete':
if header_note == True:
file_folder_path = pathlib.Path(__file__).parent.absolute()
file_folder_path = os.path.join(file_folder_path, 'note_text_blender.json')
with open(file_folder_path, 'w', encoding ='utf-8') as f:
json.dump('', f)
# bpy.context.preferences.addons[__name__].preferences.note_text_blender = ""
else:
item = self.item_scene(context)
item.text = ""
elif action == 'splash_screen':
if header_note == True:
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
bpy.data.scenes[custom_scene_name].note_text_splash_screen = main_text
# for i in bpy.data.scenes:
# i.note_text_splash_screen = main_text
else:
item = self.item_object(context)
item.text = main_text
elif action == "splash_screen_get":
bpy.data.texts[file_name].clear()
if header_note == True:
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
note_text_splash_screen = bpy.data.scenes[custom_scene_name].note_text_splash_screen
bpy.data.texts[file_name].write(note_text_splash_screen)
else:
item = self.item_object(context)
bpy.data.texts[file_name].write(item.text)
elif action == "splash_screen_delete":
if header_note == True:
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
bpy.data.scenes[custom_scene_name].note_text_splash_screen = ''
else:
item = self.item_object(context)
item.text = ""
# t2 = time.perf_counter()
# t2 = time.perf_counter()
# print(f"\nProgramm Time:{t2 - t1}\n")
bpy.ops.wm.redraw_timer(type = "DRAW_WIN_SWAP", iterations = 1)
print("Warning because of Noter")
return {'FINISHED'}
def item_object(self, context):
act_obj = context.active_object
idx = act_obj.notes_list_object_index
try:
item = act_obj.notes_list_object[idx]
except IndexError:
pass
return item
def item_scene(self, context):
scene = context.scene
idx = scene.notes_list_scene_index
try:
item = scene.notes_list_scene[idx]
except IndexError:
pass
return item
def item_blender_file(self, context):
scene = bpy.data.scenes[custom_scene_name]
idx = scene.notes_list_blender_file_index
try:
item = scene.notes_list_blender_file[idx]
except IndexError:
pass
return item
def window(self, context):
# Call user prefs window
# bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
# # Change area type
# area = bpy.context.window_manager.windows[-1].screen.areas[0]
# area.type = 'TEXT_EDITOR'
# Copy context member
context = bpy.context.copy()
# context = bpy.context.window.workspace.copy()
# context = bpy.data.screens['Default'].copy()
# context = bpy.context.window.workspace
# context = bpy.data.workspaces['Scripting'].copy()
# print(bpy.context.window.screen.areas.data)
stop_space = False
# # Iterate through the areas
for area in bpy.context.screen.areas:
if area.type == ('TEXT_EDITOR'):
stop_space = True
break
# for area in bpy.context.window.screen.areas:
# if area.type == ('TEXT_EDITOR'):
# stop_space = True
# break
if stop_space == False:
for area in bpy.context.screen.areas:
# if area.type in ('IMAGE_EDITOR', 'VIEW_3D', 'NODE_EDITOR'):
if area.type in ('PROPERTIES', 'EMPTY' 'VIEW_3D', 'NODE_EDITOR'):
old_area = area.type # Store current area type
area.type = 'TEXT_EDITOR' # Set the area to the Image editor
# context['area'] = area # Override the area member
context['area'] = area
bpy.ops.screen.area_dupli(context, 'INVOKE_DEFAULT')
# bpy.ops.wm.window_duplicate(context, 'INVOKE_DEFAULT')
area.type = old_area # Restore the old area
break
# bpy.context.area.spaces.active.type = 'IMAGE_EDITOR'
class Noter_Splash_Screen_Bool_Switch(Operator):
"""Tooltip"""
bl_idname = "window_manager.global_bool"
bl_label = ""
bl_description = 'Display Noter Splash Screen on startup \n\n You can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut'
# bl_options = {'REGISTER', 'UNDO'}
bl_options = {'UNDO'}
def execute(self, context):
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
if bpy.data.scenes[custom_scene_name].splash_screen == True:
bpy.data.scenes[custom_scene_name].splash_screen = False
else:
bpy.data.scenes[custom_scene_name].splash_screen = True
# if bpy.context.scene.splash_screen == True:
# for i in bpy.data.scenes:
# i.splash_screen = False
# else:
# for i in bpy.data.scenes:
# i.splash_screen = True
return {'FINISHED'}
class Noter_Text_Wrap_Words(Operator):
"""Tooltip"""
bl_idname = "window_manager.wrap_words__create_lines_for_text"
bl_label = "Wrap Words (Create Text Lines)"
bl_description = 'Create lines for the text \n\n You can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut'
# bl_options = {'REGISTER', 'UNDO'}
# bl_options = {'UNDO'}
def execute(self, context):
file_name = bpy.context.scene.file_name
line_width_characters = bpy.context.scene.line_width_characters
try:
main_text = bpy.data.texts[file_name].as_string()
except KeyError:
text = "File was not found"
war = "ERROR"
self.report({war}, text)
return {'FINISHED'}
line_width_characters = line_width_characters
new_main_text = ""
new_main_text_split = ""
main_text = main_text.replace("\n", " ")
main_text_split_list = main_text.split(" ")
for index, split in enumerate(main_text_split_list):
if len(new_main_text_split) == 0:
new_main_text_split = new_main_text_split + split
else:
new_main_text_split = new_main_text_split + " " + split
try:
split_future = main_text_split_list[index + 1]
if len(new_main_text_split) == 0:
new_main_text_split_future = new_main_text_split + split_future
else:
new_main_text_split_future = new_main_text_split + " " + split_future
except IndexError:
pass
if len(new_main_text_split) <= line_width_characters and \
len(new_main_text_split_future) >= line_width_characters:
new_main_text += new_main_text_split + "\n"
new_main_text_split = ""
new_main_text_split_future = ""
new_main_text += new_main_text_split
bpy.data.texts[file_name].from_string(new_main_text)
# text = '123123123123'
# line_start = 2
# char_start = 0
# line_end = 30
# char_end = 100
# t = bpy.data.texts['Text'].cursor_set(line, character=10, select=False)
# t = bpy.data.texts['Text'].select_set(line_start, char_start, line_end, char_end)
# t = bpy.data.texts['Text'].write(text)
# t = bpy.data.texts['Text'].as_string()
# t = bpy.data.texts['Text'].from_string(text)
return {'FINISHED'}
class Noter_Splash_Screen_Notes_List(Operator):
"""Tooltip"""
bl_idname = "window_manager.splash_screen_notes_list"
bl_label = "Display List"
bl_description = '\nDisplay File(.blend) List in Noter Splash Screen \n\n You can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut'
# bl_options = {'REGISTER', 'UNDO'}
# bl_options = {'UNDO'}
def execute(self, context):
if bpy.data.scenes.find(custom_scene_name) == -1:
bpy.data.scenes.new(custom_scene_name)
if bpy.data.scenes[custom_scene_name].splash_screen_notes_list == True:
bpy.data.scenes[custom_scene_name].splash_screen_notes_list = False
else:
bpy.data.scenes[custom_scene_name].splash_screen_notes_list = True
return {'FINISHED'}
class Clear_Text_Data_Block(Operator):
"""Tooltip"""
bl_idname = "text.clear_text_data_block"
bl_label = "Clear Text"
bl_description = 'Clear Text Data Block \n\n You can also assign shortcut \n How to do it: > right-click on this button > Assign Shortcut'
def execute(self, context):
try:
name = bpy.context.space_data.text.name
bpy.data.texts[name].clear()
except AttributeError:
pass
return {'FINISHED'}
def draw_text( self, text,\
centering = False, \
enable_list_mode = False, item = None, item_index = None):
text_parts_list = text.split('\n')
if enable_list_mode == True:
multiple_strokes = True if text.count("\n") > 0 else False
layout = self.layout
box = layout.box()
row = box.row(align = 0)
text_centering = bpy.context.preferences.addons[__name__].preferences.text_centering
if centering == True and text_centering == True: row.alignment = 'CENTER'
col = row.column(align = 0)
for i in text_parts_list:
row = col.row(align = 1)
row.scale_y = 0.85
ic = "NONE"
count = 0
add_space = False
symbols = [ "*", "-", "+", "@", ">", "/", "#", "!", "%", "?"]
for character in i:
if character == " ":
count += 1
else:
first_character = character
if first_character in symbols:
i = i.replace( first_character, "", 1)
if first_character in symbols[0:3]:
symbol_for_the_syntax_1 = bpy.context.preferences.addons[__name__].preferences.symbol_for_the_syntax_1
symbol_for_the_syntax_2 = bpy.context.preferences.addons[__name__].preferences.symbol_for_the_syntax_2
if count >= 4:
ic = symbol_for_the_syntax_2
add_space = True
i = i.replace( " ", "", count)
else:
ic = symbol_for_the_syntax_1
elif first_character == "@":
ic = "RADIOBUT_ON"
elif first_character == ">":
ic = "DISCLOSURE_TRI_RIGHT"
elif first_character == "/":
ic = "OUTLINER_DATA_GP_LAYER"
elif first_character == "#":
ic = "EDITMODE_HLT"
elif first_character == "!":
ic = "ERROR"
elif first_character == "%":
ic = "INFO"
elif first_character == "?":
ic = "QUESTION"
break
def add_text_syntax(self, row, icon):
if ic != "NONE":
label = row.row(align = 1)
if add_space == True:
label.separator(factor = 1.5)
label.label(icon = "BLANK1")
label.label(icon = ic)
else:
label.label(icon = ic )
label.scale_x = 0.7
if enable_list_mode == True:
index = item_index
my_bool = item.bool
text = i
# row = row.row()
# row.alignment = 'LEFT'
try:
if previous_index == index:
add_buttons = False
else:
add_buttons = True
except UnboundLocalError:
add_buttons = True
previous_index = index
if my_bool == False and add_buttons == True:
add_ic = "BOOKMARKS"
# row_info = row.row(align = 0)
row_info = row
row_info.operator("notes_list_blender_file.list_action_bool", text = "", icon = add_ic, emboss = 0).my_index = index
# row_info.alignment = 'LEFT'
elif (add_buttons == False) or \
(my_bool == True and add_buttons == True):
# row_info = row.row(align = True)
row_info = row
row_info.label(icon = "BLANK1")
# row_info.alignment = 'LEFT'
# row_info.scale_x = .35
row_text = row
add_text_syntax(self, row_text, ic)
# if ic != "NONE":
# label = row_text.row(align = 1)
# if add_space == True:
# label.label(icon = ic, text = "000" )
# else:
# label.label(icon = ic )
# label.scale_x = 0.7
if multiple_strokes == True:
row_text.label(text = text)
else:
row_text.prop(item, "text", emboss = 1, text = "", expand = True )
if my_bool == True and add_buttons == True:
add_ic = "CHECKBOX_DEHLT"
# row_info = row.row(align = 0)
row_info = row
row_info.operator("notes_list_blender_file.list_action_bool", text = "", icon = add_ic, emboss = 0).my_index = index
# row_info.alignment = 'RIGHT'
if add_buttons == True:
# row = row.row()
operator = row.operator("notes_list_blender_file.list_action", icon='REMOVE', text="")
operator.by_index = index
operator.action = 'REMOVE'
# row.scale_x = .35
# row_info.scale_x = .35
try:
max_length
except UnboundLocalError:
max_length = 0
if max_length > len(text): max_length = len(text)
else:
add_text_syntax(self, row, ic)
row.alignment = 'LEFT'
row.label(text = i)
# row.label(text = i, icon = ic )
def calculate_width_menu(self, text, scale_factor = 12):
# from matplotlib.afm import AFM
# afm = AFM(open(afm_filename, "rb"))
# AFM.string_width_height('What the?')
text_parts_list = text.split('\n')
length = 25
for row in text_parts_list:
row = len(row)
if row > length:
length = row
# 450 pixels = 50 symbols > 1 symbol = 9 pixels
# 550 pixels = 50 symbols > 1 symbol = 11 pixels
width_menu = length * scale_factor
return width_menu
class Splash_Screen_Pop_Up_Operator (Operator):
bl_idname = "window_manager.note_popup_operator"
bl_label = "Noter Splash Screen"
location_cursor: BoolProperty(default = True, options = {"SKIP_SAVE"})
@classmethod
def poll(cls, context):
find = False
try:
find = bpy.data.scenes[custom_scene_name].splash_screen
except KeyError:
pass
# find = False
# find = False
# for i in bpy.data.scenes:
# if i.splash_screen == True:
# find = True
# break
return find
def execute(self, context):
return {'FINISHED'}
def draw(self, context):
layout = self.layout
row = layout.row()
row.operator("window_manager.note_popup_operator_2",text='' , icon="MOUSE_LMB_DRAG").action = 'drag'
row.alignment = 'RIGHT'
# ABCDEFGHIJKLMNOPQRSTUVWXYZ
ic_list = [
'AUTO',
'ANTIALIASED',
'BRUSH_TEXFILL',
'BRUSH_TEXDRAW',
'BRUSH_SOFTEN',
# 'COLORSET_02_VEC',
# 'COLLAPSEMENU',
'CONSTRAINT',
'FILE_BLEND',
'FUND',
'FREEZE',
'FILE_3D',
'FILE_VOLUME',
'LIGHTPROBE_PLANAR',
'MATCUBE',
'MATSPHERE',
'MONKEY',
'MESH_CYLINDER',
'META_PLANE',
'MESH_CAPSULE',
# 'OUTLINER_DATA_LIGHTPROBE',
'OUTLINER_OB_POINTCLOUD',
'PLAY',
'RADIOBUT_ON',
'SOLO_ON',
'SEQ_CHROMA_SCOPE',
'SHADING_SOLID',
'SNAP_VOLUME',
]
ic = random.choice(ic_list)
# ic = 'SNAP_VOLUME'
def draw_word(self, context):
def label_draw(length):
for _ in range(0, length):
column_text.label(icon = ic)
layout = self.layout
row_text = layout.row(align = 1)
# row_text.scale_y = 0.2
row_text.scale_x = 0.6
row_text.alignment = "CENTER"
row_text.separator(factor = 2)
column_text = row_text.column(align = 1)
column_text.separator(factor = 1.7)
column_text.scale_y = .6
label_draw(4)
column_text = row_text.column(align = 1)
column_text.scale_x = .9
column_text.separator(factor = 1.8)
label_draw(1)