changes to the sequencer in trunk between 20855:20928, (excluding UI changes)
[blender-staging.git] / release / ui / space_image.py
1
2 import bpy
3
4 class IMAGE_MT_view(bpy.types.Menu):
5         __space_type__ = "IMAGE_EDITOR"
6         __label__ = "View"
7
8         def draw(self, context):
9                 layout = self.layout
10                 sima = context.space_data
11                 uv = sima.uv_editor
12
13                 show_uvedit = sima.show_uvedit
14
15                 layout.itemO("IMAGE_OT_properties") # icon
16
17                 layout.itemS()
18
19                 layout.itemR(sima, "update_automatically")
20                 # XXX if show_uvedit:
21                 # XXX   layout.itemR(uv, "local_view") # "UV Local View", Numpad /
22
23                 layout.itemS()
24
25                 layout.itemO("IMAGE_OT_view_zoom_in")
26                 layout.itemO("IMAGE_OT_view_zoom_out")
27
28                 layout.itemS()
29
30                 ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]];
31
32                 for a, b in ratios:
33                         text = "Zoom %d:%d" % (a, b)
34                         layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text)
35
36                 layout.itemS()
37
38                 if show_uvedit:
39                         layout.itemO("IMAGE_OT_view_selected")
40
41                 layout.itemO("IMAGE_OT_view_all")
42                 layout.itemO("SCREEN_OT_screen_full_area")
43
44 class IMAGE_MT_select(bpy.types.Menu):
45         __space_type__ = "IMAGE_EDITOR"
46         __label__ = "Select"
47
48         def draw(self, context):
49                 layout = self.layout
50
51                 layout.itemO("UV_OT_select_border")
52                 layout.item_booleanO("UV_OT_select_border", "pinned", True)
53
54                 layout.itemS()
55                 
56                 layout.itemO("UV_OT_select_all_toggle")
57                 layout.itemO("UV_OT_select_invert")
58                 layout.itemO("UV_OT_unlink_selection")
59                 
60                 layout.itemS()
61
62                 layout.itemO("UV_OT_select_pinned")
63                 layout.itemO("UV_OT_select_linked")
64
65 class IMAGE_MT_image(bpy.types.Menu):
66         __space_type__ = "IMAGE_EDITOR"
67         __label__ = "Image"
68
69         def draw(self, context):
70                 layout = self.layout
71                 sima = context.space_data
72                 ima = sima.image
73
74                 layout.itemO("IMAGE_OT_new")
75                 layout.itemO("IMAGE_OT_open")
76
77                 show_render = sima.show_render
78
79                 if ima:
80                         if show_render:
81                                 layout.itemO("IMAGE_OT_replace")
82                                 layout.itemO("IMAGE_OT_reload")
83
84                         layout.itemO("IMAGE_OT_save")
85                         layout.itemO("IMAGE_OT_save_as")
86
87                         if ima.source == "SEQUENCE":
88                                 layout.itemO("IMAGE_OT_save_sequence")
89
90                         if not show_render:
91                                 layout.itemS()
92
93                                 if ima.packed_file:
94                                         layout.itemO("IMAGE_OT_unpack")
95                                 else:
96                                         layout.itemO("IMAGE_OT_pack")
97
98                                 # only for dirty && specific image types : XXX poll?
99                                 #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
100                                 if False:
101                                         if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER":
102                                                 layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG")
103
104                         layout.itemS()
105
106                         layout.itemR(sima, "image_painting")
107
108 class IMAGE_MT_uvs_showhide(bpy.types.Menu):
109         __space_type__ = "IMAGE_EDITOR"
110         __label__ = "Show/Hide Faces"
111
112         def draw(self, context):
113                 layout = self.layout
114
115                 layout.itemO("UV_OT_reveal")
116                 layout.itemO("UV_OT_hide")
117                 layout.item_booleanO("UV_OT_hide", "unselected", True)
118
119 class IMAGE_MT_uvs_transform(bpy.types.Menu):
120         __space_type__ = "IMAGE_EDITOR"
121         __label__ = "Transform"
122
123         def draw(self, context):
124                 layout = self.layout
125
126                 layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION")
127                 layout.item_enumO("TFM_OT_transform", "mode", "ROTATION")
128                 layout.item_enumO("TFM_OT_transform", "mode", "RESIZE")
129
130 class IMAGE_MT_uvs_mirror(bpy.types.Menu):
131         __space_type__ = "IMAGE_EDITOR"
132         __label__ = "Mirror"
133
134         def draw(self, context):
135                 layout = self.layout
136
137                 layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M, 
138                 layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M, 
139
140 class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
141         __space_type__ = "IMAGE_EDITOR"
142         __label__ = "Weld/Align"
143
144         def draw(self, context):
145                 layout = self.layout
146
147                 layout.itemO("UV_OT_weld") # W, 1
148                 layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4
149
150
151 class IMAGE_MT_uvs(bpy.types.Menu):
152         __space_type__ = "IMAGE_EDITOR"
153         __label__ = "UVs"
154
155         def draw(self, context):
156                 layout = self.layout
157                 sima = context.space_data
158                 uv = sima.uv_editor
159                 scene = context.scene
160
161                 layout.itemR(uv, "snap_to_pixels")
162                 layout.itemR(uv, "constrain_to_image_bounds")
163
164                 layout.itemS()
165
166                 layout.itemR(uv, "live_unwrap")
167                 layout.itemO("UV_OT_unwrap")
168                 layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin")
169                 layout.itemO("UV_OT_pin")
170
171                 layout.itemS()
172
173                 layout.itemO("UV_OT_pack_islands")
174                 layout.itemO("UV_OT_average_islands_scale")
175                 layout.itemO("UV_OT_minimize_stretch")
176                 layout.itemO("UV_OT_stitch")
177
178                 layout.itemS()
179
180                 layout.itemM(context, "IMAGE_MT_uvs_transform")
181                 layout.itemM(context, "IMAGE_MT_uvs_mirror")
182                 layout.itemM(context, "IMAGE_MT_uvs_weldalign")
183
184                 layout.itemS()
185
186                 # XXX layout.itemR(scene, "proportional_editing")
187                 layout.item_menu_enumR(scene, "proportional_editing_falloff")
188
189                 layout.itemS()
190
191                 layout.itemM(context, "IMAGE_MT_uvs_showhide")
192
193 class IMAGE_HT_header(bpy.types.Header):
194         __space_type__ = "IMAGE_EDITOR"
195
196         def draw(self, context):
197                 sima = context.space_data
198                 ima = sima.image
199                 layout = self.layout
200
201                 show_render = sima.show_render
202                 show_paint = sima.show_paint
203                 show_uvedit = sima.show_uvedit
204
205                 layout.template_header(context)
206
207                 # menus
208                 if context.area.show_menus:
209                         row = layout.row()
210                         row.itemM(context, "IMAGE_MT_view")
211
212                         if show_uvedit:
213                                 row.itemM(context, "IMAGE_MT_select")
214
215                         # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
216                         row.itemM(context, "IMAGE_MT_image")
217
218                         if show_uvedit:
219                                 row.itemM(context, "IMAGE_MT_uvs")
220
221                 layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
222
223                 """
224                 /* image select */
225
226                 pinflag= (show_render)? 0: UI_ID_PIN;
227                 xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco,
228                         sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
229                 xco += 8;
230                 """
231
232                 """
233                 if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
234                         /* XXX this should not be a static var */
235                         static int headerbuttons_packdummy;
236                         
237                         headerbuttons_packdummy = 0;
238
239                         if (ima->packedfile) {
240                                 headerbuttons_packdummy = 1;
241                         }
242                         if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
243                                 uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE,    xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
244                         else
245                                 uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE,        xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
246                                 
247                         xco+= XIC+8;
248                 }
249                 """
250
251                 # uv editing
252                 if show_uvedit:
253                         pass
254                 
255                 """
256                 /* uv editing */
257                 if(show_uvedit) {
258                         /* pivot */
259                         uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE,
260                                         "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1",
261                                         xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0,
262                                         "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)");
263                         xco+= XIC + 18;
264                         
265                         /* selection modes */
266                         uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection");
267                         xco+= XIC+8;
268
269                         if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
270                                 uiBlockBeginAlign(block);
271                                 
272                                 uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL,
273                                         xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
274                                 uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL,
275                                         xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
276                                 uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL,
277                                         xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
278
279                                 uiBlockEndAlign(block);
280                         }
281                         else {
282                                 uiBlockBeginAlign(block);
283
284                                 uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL,
285                                         xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode");
286                                 uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL,
287                                         xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode");
288                                 uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL,
289                                         xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode");
290                                 uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL,
291                                         xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode");
292
293                                 uiBlockEndAlign(block);
294
295                                 /* would use these if const's could go in strings 
296                                  * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */
297                                 but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC,
298                                                 "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2",
299                                                 xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0,
300                                                 "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)");
301                         }
302
303                         xco+= XIC + 16;
304                         
305                         /* snap options, identical to options in 3d view header */
306                         uiBlockBeginAlign(block);
307
308                         if (scene->snap_flag & SCE_SNAP) {
309                                 uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab).");
310                                 xco+= XIC;
311                                 uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode.");
312                                 xco+= 70;
313                         }
314                         else {
315                                 uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)."); 
316                                 xco+= XIC;
317                         }
318
319                         uiBlockEndAlign(block);
320                         xco+= 8;
321
322                         /* uv layers */
323                         {
324                                 Object *obedit= CTX_data_edit_object(C);
325                                 char menustr[34*MAX_MTFACE];
326                                 static int act;
327                                 
328                                 image_menu_uvlayers(obedit, menustr, &act);
329
330                                 but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
331                                 // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
332                                 
333                                 xco+= 85;
334                         }
335
336                         xco+= 8;
337                 }
338                 """
339
340                 if ima:
341                         """
342                         RenderResult *rr;
343                 
344                         /* render layers and passes */
345                         rr= BKE_image_get_renderresult(scene, ima);
346                         if(rr) {
347                                 uiBlockBeginAlign(block);
348 #if 0
349                                 uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160);
350 #endif
351                                 uiBlockEndAlign(block);
352                                 xco+= 166;
353                         }
354                         """
355
356                         # painting
357                         layout.itemR(sima, "image_painting", text="")
358
359                         # draw options
360                         row = layout.row(align=True)
361                         row.itemR(sima, "draw_channels", text="", expand=True)
362
363                         row = layout.row(align=True)
364                         if ima.type == "COMPOSITE":
365                                 row.itemO("IMAGE_OT_record_composite", icon="ICON_REC")
366                         if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"):
367                                 row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY")
368                 
369                 layout.itemR(sima, "update_automatically", text="")
370
371 class IMAGE_PT_game_properties(bpy.types.Panel):
372         __space_type__ = "IMAGE_EDITOR"
373         __region_type__ = "UI"
374         __label__ = "Game Properties"
375
376         def draw(self, context):
377                 sima = context.space_data
378                 layout = self.layout
379
380                 ima = sima.image
381
382                 if ima:
383                         split = layout.split()
384
385                         col = split.column(align=True)
386                         col.itemR(ima, "animated")
387
388                         subcol = col.column()
389                         subcol.itemR(ima, "animation_start", text="Start")
390                         subcol.itemR(ima, "animation_end", text="End")
391                         subcol.itemR(ima, "animation_speed", text="Speed")
392                         subcol.active = ima.animated
393
394                         col = split.column()
395                         col.itemR(ima, "tiles")
396
397                         subrow = col.row(align=True)
398                         subrow.itemR(ima, "tiles_x", text="X")
399                         subrow.itemR(ima, "tiles_y", text="Y")
400                         subrow.active = ima.tiles
401
402                         col.itemS()
403                         col.itemR(ima, "clamp_x")
404                         col.itemR(ima, "clamp_y")
405
406                         col.itemR(ima, "mapping", expand=True)
407
408 bpy.types.register(IMAGE_MT_view)
409 bpy.types.register(IMAGE_MT_select)
410 bpy.types.register(IMAGE_MT_image)
411 bpy.types.register(IMAGE_MT_uvs_showhide)
412 bpy.types.register(IMAGE_MT_uvs_transform)
413 bpy.types.register(IMAGE_MT_uvs_mirror)
414 bpy.types.register(IMAGE_MT_uvs_weldalign)
415 bpy.types.register(IMAGE_MT_uvs)
416 bpy.types.register(IMAGE_HT_header)
417 bpy.types.register(IMAGE_PT_game_properties)
418
419
420 import bpy
421
422 class IMAGE_MT_view(bpy.types.Menu):
423         __space_type__ = "IMAGE_EDITOR"
424         __label__ = "View"
425
426         def draw(self, context):
427                 layout = self.layout
428                 sima = context.space_data
429                 uv = sima.uv_editor
430
431                 show_uvedit = sima.show_uvedit
432
433                 layout.itemO("IMAGE_OT_properties") # icon
434
435                 layout.itemS()
436
437                 layout.itemR(sima, "update_automatically")
438                 # XXX if show_uvedit:
439                 # XXX   layout.itemR(uv, "local_view") # "UV Local View", Numpad /
440
441                 layout.itemS()
442
443                 layout.itemO("IMAGE_OT_view_zoom_in")
444                 layout.itemO("IMAGE_OT_view_zoom_out")
445
446                 layout.itemS()
447
448                 ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]];
449
450                 for a, b in ratios:
451                         text = "Zoom %d:%d" % (a, b)
452                         layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text)
453
454                 layout.itemS()
455
456                 if show_uvedit:
457                         layout.itemO("IMAGE_OT_view_selected")
458
459                 layout.itemO("IMAGE_OT_view_all")
460                 layout.itemO("SCREEN_OT_screen_full_area")
461
462 class IMAGE_MT_select(bpy.types.Menu):
463         __space_type__ = "IMAGE_EDITOR"
464         __label__ = "Select"
465
466         def draw(self, context):
467                 layout = self.layout
468
469                 layout.itemO("UV_OT_select_border")
470                 layout.item_booleanO("UV_OT_select_border", "pinned", True)
471
472                 layout.itemS()
473                 
474                 layout.itemO("UV_OT_select_all_toggle")
475                 layout.itemO("UV_OT_select_invert")
476                 layout.itemO("UV_OT_unlink_selection")
477                 
478                 layout.itemS()
479
480                 layout.itemO("UV_OT_select_pinned")
481                 layout.itemO("UV_OT_select_linked")
482
483 class IMAGE_MT_image(bpy.types.Menu):
484         __space_type__ = "IMAGE_EDITOR"
485         __label__ = "Image"
486
487         def draw(self, context):
488                 layout = self.layout
489                 sima = context.space_data
490                 ima = sima.image
491
492                 layout.itemO("IMAGE_OT_new")
493                 layout.itemO("IMAGE_OT_open")
494
495                 show_render = sima.show_render
496
497                 if ima:
498                         if show_render:
499                                 layout.itemO("IMAGE_OT_replace")
500                                 layout.itemO("IMAGE_OT_reload")
501
502                         layout.itemO("IMAGE_OT_save")
503                         layout.itemO("IMAGE_OT_save_as")
504
505                         if ima.source == "SEQUENCE":
506                                 layout.itemO("IMAGE_OT_save_sequence")
507
508                         if not show_render:
509                                 layout.itemS()
510
511                                 if ima.packed_file:
512                                         layout.itemO("IMAGE_OT_unpack")
513                                 else:
514                                         layout.itemO("IMAGE_OT_pack")
515
516                                 # only for dirty && specific image types : XXX poll?
517                                 #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
518                                 if False:
519                                         if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER":
520                                                 layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG")
521
522                         layout.itemS()
523
524                         layout.itemR(sima, "image_painting")
525
526 class IMAGE_MT_uvs_showhide(bpy.types.Menu):
527         __space_type__ = "IMAGE_EDITOR"
528         __label__ = "Show/Hide Faces"
529
530         def draw(self, context):
531                 layout = self.layout
532
533                 layout.itemO("UV_OT_reveal")
534                 layout.itemO("UV_OT_hide")
535                 layout.item_booleanO("UV_OT_hide", "unselected", True)
536
537 class IMAGE_MT_uvs_transform(bpy.types.Menu):
538         __space_type__ = "IMAGE_EDITOR"
539         __label__ = "Transform"
540
541         def draw(self, context):
542                 layout = self.layout
543
544                 layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION")
545                 layout.item_enumO("TFM_OT_transform", "mode", "ROTATION")
546                 layout.item_enumO("TFM_OT_transform", "mode", "RESIZE")
547
548 class IMAGE_MT_uvs_mirror(bpy.types.Menu):
549         __space_type__ = "IMAGE_EDITOR"
550         __label__ = "Mirror"
551
552         def draw(self, context):
553                 layout = self.layout
554
555                 layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M, 
556                 layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M, 
557
558 class IMAGE_MT_uvs_weldalign(bpy.types.Menu):
559         __space_type__ = "IMAGE_EDITOR"
560         __label__ = "Weld/Align"
561
562         def draw(self, context):
563                 layout = self.layout
564
565                 layout.itemO("UV_OT_weld") # W, 1
566                 layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4
567
568
569 class IMAGE_MT_uvs(bpy.types.Menu):
570         __space_type__ = "IMAGE_EDITOR"
571         __label__ = "UVs"
572
573         def draw(self, context):
574                 layout = self.layout
575                 sima = context.space_data
576                 uv = sima.uv_editor
577                 scene = context.scene
578
579                 layout.itemR(uv, "snap_to_pixels")
580                 layout.itemR(uv, "constrain_to_image_bounds")
581
582                 layout.itemS()
583
584                 layout.itemR(uv, "live_unwrap")
585                 layout.itemO("UV_OT_unwrap")
586                 layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin")
587                 layout.itemO("UV_OT_pin")
588
589                 layout.itemS()
590
591                 layout.itemO("UV_OT_pack_islands")
592                 layout.itemO("UV_OT_average_islands_scale")
593                 layout.itemO("UV_OT_minimize_stretch")
594                 layout.itemO("UV_OT_stitch")
595
596                 layout.itemS()
597
598                 layout.itemM(context, "IMAGE_MT_uvs_transform")
599                 layout.itemM(context, "IMAGE_MT_uvs_mirror")
600                 layout.itemM(context, "IMAGE_MT_uvs_weldalign")
601
602                 layout.itemS()
603
604                 # XXX layout.itemR(scene, "proportional_editing")
605                 layout.item_menu_enumR(scene, "proportional_editing_falloff")
606
607                 layout.itemS()
608
609                 layout.itemM(context, "IMAGE_MT_uvs_showhide")
610
611 class IMAGE_HT_header(bpy.types.Header):
612         __space_type__ = "IMAGE_EDITOR"
613
614         def draw(self, context):
615                 sima = context.space_data
616                 ima = sima.image
617                 layout = self.layout
618
619                 show_render = sima.show_render
620                 show_paint = sima.show_paint
621                 show_uvedit = sima.show_uvedit
622
623                 layout.template_header(context)
624
625                 # menus
626                 if context.area.show_menus:
627                         row = layout.row()
628                         row.itemM(context, "IMAGE_MT_view")
629
630                         if show_uvedit:
631                                 row.itemM(context, "IMAGE_MT_select")
632
633                         # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image";
634                         row.itemM(context, "IMAGE_MT_image")
635
636                         if show_uvedit:
637                                 row.itemM(context, "IMAGE_MT_uvs")
638
639                 layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open")
640
641                 """
642                 /* image select */
643
644                 pinflag= (show_render)? 0: UI_ID_PIN;
645                 xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco,
646                         sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag);
647                 xco += 8;
648                 """
649
650                 """
651                 if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) {
652                         /* XXX this should not be a static var */
653                         static int headerbuttons_packdummy;
654                         
655                         headerbuttons_packdummy = 0;
656
657                         if (ima->packedfile) {
658                                 headerbuttons_packdummy = 1;
659                         }
660                         if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY))
661                                 uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE,    xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG");
662                         else
663                                 uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE,        xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image");
664                                 
665                         xco+= XIC+8;
666                 }
667                 """
668
669                 # uv editing
670                 if show_uvedit:
671                         pass
672                 
673                 """
674                 /* uv editing */
675                 if(show_uvedit) {
676                         /* pivot */
677                         uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE,
678                                         "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1",
679                                         xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0,
680                                         "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)");
681                         xco+= XIC + 18;
682                         
683                         /* selection modes */
684                         uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection");
685                         xco+= XIC+8;
686
687                         if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
688                                 uiBlockBeginAlign(block);
689                                 
690                                 uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL,
691                                         xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
692                                 uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL,
693                                         xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
694                                 uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL,
695                                         xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
696
697                                 uiBlockEndAlign(block);
698                         }
699                         else {
700                                 uiBlockBeginAlign(block);
701
702                                 uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL,
703                                         xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode");
704                                 uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL,
705                                         xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode");
706                                 uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL,
707                                         xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode");
708                                 uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL,
709                                         xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode");
710
711                                 uiBlockEndAlign(block);
712
713                                 /* would use these if const's could go in strings 
714                                  * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */
715                                 but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC,
716                                                 "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2",
717                                                 xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0,
718                                                 "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)");
719                         }
720
721                         xco+= XIC + 16;
722                         
723                         /* snap options, identical to options in 3d view header */
724                         uiBlockBeginAlign(block);
725
726                         if (scene->snap_flag & SCE_SNAP) {
727                                 uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab).");
728                                 xco+= XIC;
729                                 uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode.");
730                                 xco+= 70;
731                         }
732                         else {
733                                 uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)."); 
734                                 xco+= XIC;
735                         }
736
737                         uiBlockEndAlign(block);
738                         xco+= 8;
739
740                         /* uv layers */
741                         {
742                                 Object *obedit= CTX_data_edit_object(C);
743                                 char menustr[34*MAX_MTFACE];
744                                 static int act;
745                                 
746                                 image_menu_uvlayers(obedit, menustr, &act);
747
748                                 but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing.");
749                                 // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL);
750                                 
751                                 xco+= 85;
752                         }
753
754                         xco+= 8;
755                 }
756                 """
757
758                 if ima:
759                         """
760                         RenderResult *rr;
761                 
762                         /* render layers and passes */
763                         rr= BKE_image_get_renderresult(scene, ima);
764                         if(rr) {
765                                 uiBlockBeginAlign(block);
766 #if 0
767                                 uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160);
768 #endif
769                                 uiBlockEndAlign(block);
770                                 xco+= 166;
771                         }
772                         """
773
774                         # painting
775                         layout.itemR(sima, "image_painting", text="")
776
777                         # draw options
778                         row = layout.row(align=True)
779                         row.itemR(sima, "draw_channels", text="", expand=True)
780
781                         row = layout.row(align=True)
782                         if ima.type == "COMPOSITE":
783                                 row.itemO("IMAGE_OT_record_composite", icon="ICON_REC")
784                         if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"):
785                                 row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY")
786                 
787                 layout.itemR(sima, "update_automatically", text="")
788
789 class IMAGE_PT_game_properties(bpy.types.Panel):
790         __space_type__ = "IMAGE_EDITOR"
791         __region_type__ = "UI"
792         __label__ = "Game Properties"
793
794         def draw(self, context):
795                 sima = context.space_data
796                 layout = self.layout
797
798                 ima = sima.image
799
800                 if ima:
801                         split = layout.split()
802
803                         col = split.column(align=True)
804                         col.itemR(ima, "animated")
805
806                         subcol = col.column()
807                         subcol.itemR(ima, "animation_start", text="Start")
808                         subcol.itemR(ima, "animation_end", text="End")
809                         subcol.itemR(ima, "animation_speed", text="Speed")
810                         subcol.active = ima.animated
811
812                         col = split.column()
813                         col.itemR(ima, "tiles")
814
815                         subrow = col.row(align=True)
816                         subrow.itemR(ima, "tiles_x", text="X")
817                         subrow.itemR(ima, "tiles_y", text="Y")
818                         subrow.active = ima.tiles
819
820                         col.itemS()
821                         col.itemR(ima, "clamp_x")
822                         col.itemR(ima, "clamp_y")
823
824                         col.itemR(ima, "mapping", expand=True)
825
826 bpy.types.register(IMAGE_MT_view)
827 bpy.types.register(IMAGE_MT_select)
828 bpy.types.register(IMAGE_MT_image)
829 bpy.types.register(IMAGE_MT_uvs_showhide)
830 bpy.types.register(IMAGE_MT_uvs_transform)
831 bpy.types.register(IMAGE_MT_uvs_mirror)
832 bpy.types.register(IMAGE_MT_uvs_weldalign)
833 bpy.types.register(IMAGE_MT_uvs)
834 bpy.types.register(IMAGE_HT_header)
835 bpy.types.register(IMAGE_PT_game_properties)
836