This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/release/ui/buttons_data_lamp.py
Brecht Van Lommel b4d46e5ded UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
  This means the layout engine now works at button level, and makes it
  easier to write templates. Otherwise you had to store all info and
  create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
  These can contain regular buttons, and can be put in a Free layout,
  which means you can specify manual coordinates, but still get nested
  correct inside other layouts.

* API was changed to allow better nesting. Previously items were added
  in the last added layout specifier, i.e. one level up in the layout
  hierarchy. This doesn't work well in always, so now when creating things
  like rows or columns it always returns a layout which you have to add
  the items in. All py scripts were updated to follow this.

* Computing the layout now goes in two passes, first estimating the
  required width/height of all nested layouts, and then in the second
  pass using the results of that to decide on the actual locations.

* Enum and array buttons now follow the direction of the layout, i.e.
  they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
  RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
  opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
  row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
  buttons).

* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00

220 lines
6.2 KiB
Python

import bpy
class DataButtonsPanel(bpy.types.Panel):
__space_type__ = "BUTTONS_WINDOW"
__region_type__ = "WINDOW"
__context__ = "data"
def poll(self, context):
ob = context.active_object
return (ob and ob.type == 'LAMP')
class DATA_PT_lamp(DataButtonsPanel):
__idname__ = "DATA_PT_lamp"
__label__ = "Lamp"
def draw(self, context):
lamp = context.main.lamps[0]
layout = self.layout
if not lamp:
return
row = layout.row()
row.itemR(lamp, "type", expand=True)
split = layout.split()
sub = split.column()
sub.itemR(lamp, "energy")
sub.itemR(lamp, "distance")
sub.itemR(lamp, "negative")
sub.itemR(lamp, "color")
sub = split.column()
sub.itemR(lamp, "layer", text="This Layer Only")
sub.itemR(lamp, "specular")
sub.itemR(lamp, "diffuse")
if lamp.type in ('POINT', 'SPOT'):
sub.itemR(lamp, "falloff_type")
sub.itemR(lamp, "sphere")
if (lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED'):
sub.itemR(lamp, "linear_attenuation")
sub.itemR(lamp, "quadratic_attenuation")
if lamp.type == 'AREA':
sub.column()
sub.itemR(lamp, "gamma")
sub.itemR(lamp, "shape")
if (lamp.shape == 'SQUARE'):
sub.itemR(lamp, "size")
if (lamp.shape == 'RECTANGLE'):
sub.itemR(lamp, "size", text="Size X")
sub.itemR(lamp, "size_y")
class DATA_PT_sunsky(DataButtonsPanel):
__idname__ = "DATA_PT_sunsky"
__label__ = "Sun/Sky"
def poll(self, context):
ob = context.active_object
lamp = context.main.lamps[0]
return (ob.type == 'LAMP' and lamp.type == 'SUN')
def draw(self, context):
lamp = context.main.lamps[0].sky
layout = self.layout
if not lamp:
return
row = layout.row()
row.itemR(lamp, "sky")
row.itemR(lamp, "atmosphere")
if lamp.sky or lamp.atmosphere:
layout.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
split = layout.split()
col = split.column()
if lamp.sky:
sub = col.column()
sub.itemR(lamp, "sky_blend_type", text="Blend Type")
sub.itemR(lamp, "sky_blend")
sub.itemR(lamp, "sky_color_space", text="Color Space")
sub.itemR(lamp, "sky_exposure")
sub = col.column()
sub.itemR(lamp, "horizon_brightness", text="Hor Bright")
sub.itemR(lamp, "spread", text="Hor Spread")
sub.itemR(lamp, "sun_brightness", text="Sun Bright")
sub.itemR(lamp, "sun_size")
sub.itemR(lamp, "backscattered_light", text="Back Light")
sub = split.column()
if lamp.atmosphere:
sub.itemR(lamp, "sun_intensity", text="Sun Intens")
sub.itemR(lamp, "atmosphere_inscattering", text="Inscattering")
sub.itemR(lamp, "atmosphere_extinction", text="Extinction")
sub.itemR(lamp, "atmosphere_distance_factor", text="Distance")
class DATA_PT_shadow(DataButtonsPanel):
__idname__ = "DATA_PT_shadow"
__label__ = "Shadow"
def poll(self, context):
ob = context.active_object
lamp = context.main.lamps[0]
return (ob.type == 'LAMP' and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
def draw(self, context):
lamp = context.main.lamps[0]
layout = self.layout
if not lamp:
return
layout.itemR(lamp, "shadow_method", expand=True)
if lamp.shadow_method in ('BUFFER_SHADOW', 'RAY_SHADOW'):
split = layout.split()
sub = split.column()
sub.itemR(lamp, "only_shadow")
sub.itemR(lamp, "shadow_layer")
sub = split.column()
sub.itemR(lamp, "shadow_color")
if lamp.shadow_method == 'RAY_SHADOW':
col = layout.column()
col.itemL(text="Sampling:")
col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
if lamp.type in ('POINT', 'SUN', 'SPOT') and lamp.shadow_ray_sampling_method in ('CONSTANT_QMC', 'ADAPTIVE_QMC'):
flow = layout.column_flow()
flow.itemR(lamp, "shadow_soft_size", text="Soft Size")
flow.itemR(lamp, "shadow_ray_samples", text="Samples")
if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
if lamp.type == 'AREA':
flow = layout.column_flow()
flow.itemR(lamp, "shadow_ray_samples_x", text="Samples")
if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
flow.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
if lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
flow.itemR(lamp, "umbra")
flow.itemR(lamp, "dither")
flow.itemR(lamp, "jitter")
if lamp.shadow_method == 'BUFFER_SHADOW':
col = layout.column()
col.itemL(text="Buffer Type:")
col.row().itemR(lamp, "shadow_buffer_type", expand=True)
if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY'):
flow = layout.column_flow()
flow.itemL(text="Sample Buffers:")
flow.row().itemR(lamp, "shadow_sample_buffers", expand=True)
flow.itemL(text="Filter Type:")
flow.row().itemR(lamp, "shadow_filter_type", expand=True)
flow = layout.column_flow()
flow.itemR(lamp, "shadow_buffer_size", text="Size")
flow.itemR(lamp, "shadow_buffer_samples", text="Samples")
flow.itemR(lamp, "shadow_buffer_bias", text="Bias")
flow.itemR(lamp, "shadow_buffer_soft", text="Soft")
if (lamp.shadow_buffer_type == 'IRREGULAR'):
row = layout.row()
row.itemR(lamp, "shadow_buffer_bias", text="Bias")
row = layout.row()
row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
if not (lamp.auto_clip_start):
row.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
row = layout.row()
row.itemR(lamp, "auto_clip_end", text="Autoclip End")
if not (lamp.auto_clip_end):
row.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
class DATA_PT_spot(DataButtonsPanel):
__idname__ = "DATA_PT_spot"
__label__ = "Spot"
def poll(self, context):
ob = context.active_object
lamp = context.main.lamps[0]
return (ob.type == 'LAMP' and lamp.type == 'SPOT')
def draw(self, context):
lamp = context.main.lamps[0]
layout = self.layout
if not lamp:
return
split = layout.split()
sub = split.column()
sub.itemR(lamp, "square")
sub.itemR(lamp, "spot_size")
sub.itemR(lamp, "spot_blend")
sub = split.column()
sub.itemR(lamp, "halo")
if lamp.halo:
sub.itemR(lamp, "halo_intensity")
if lamp.shadow_method == 'BUFFER_SHADOW':
sub.itemR(lamp, "halo_step")
bpy.types.register(DATA_PT_lamp)
bpy.types.register(DATA_PT_shadow)
bpy.types.register(DATA_PT_sunsky)
bpy.types.register(DATA_PT_spot)