sun_position: cleanup UI and properties
UI for the normal mode is now split into subpanels.
This commit is contained in:
parent
0e2bd7b405
commit
dbc441d58a
|
@ -65,6 +65,8 @@ def register():
|
|||
bpy.utils.register_class(ui_sun.SUNPOS_OT_DefaultPresets)
|
||||
bpy.utils.register_class(ui_sun.SUNPOS_MT_Presets)
|
||||
bpy.utils.register_class(ui_sun.SUNPOS_PT_Panel)
|
||||
bpy.utils.register_class(ui_sun.SUNPOS_PT_Position)
|
||||
bpy.utils.register_class(ui_sun.SUNPOS_PT_Time)
|
||||
bpy.utils.register_class(hdr.SUNPOS_OT_ShowHdr)
|
||||
|
||||
bpy.app.handlers.frame_change_post.append(sun_calc.sun_handler)
|
||||
|
@ -73,6 +75,8 @@ def register():
|
|||
def unregister():
|
||||
bpy.utils.unregister_class(hdr.SUNPOS_OT_ShowHdr)
|
||||
bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Panel)
|
||||
bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Position)
|
||||
bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Time)
|
||||
bpy.utils.unregister_class(ui_sun.SUNPOS_MT_Presets)
|
||||
bpy.utils.unregister_class(ui_sun.SUNPOS_OT_DefaultPresets)
|
||||
bpy.utils.unregister_class(ui_sun.SUNPOS_OT_AddPreset)
|
||||
|
|
|
@ -45,16 +45,19 @@ class SunPosProperties(PropertyGroup):
|
|||
update=sun_update)
|
||||
|
||||
use_daylight_savings: BoolProperty(
|
||||
name="Daylight savings",
|
||||
description="Daylight savings time adds 1 hour to standard time",
|
||||
default=False,
|
||||
update=sun_update)
|
||||
|
||||
use_refraction: BoolProperty(
|
||||
name="Use refraction",
|
||||
description="Show apparent sun position due to refraction",
|
||||
default=True,
|
||||
update=sun_update)
|
||||
|
||||
show_north: BoolProperty(
|
||||
name="Show North",
|
||||
description="Draw line pointing north",
|
||||
default=False,
|
||||
update=north_update)
|
||||
|
@ -99,7 +102,7 @@ class SunPosProperties(PropertyGroup):
|
|||
|
||||
year: IntProperty(
|
||||
name="Year",
|
||||
min=1800, max=4000, default=TODAY.year,
|
||||
min=1, max=4000, default=TODAY.year,
|
||||
update=sun_update)
|
||||
|
||||
use_day_of_year: BoolProperty(
|
||||
|
@ -135,6 +138,7 @@ class SunPosProperties(PropertyGroup):
|
|||
update=sun_update)
|
||||
|
||||
use_sun_object: BoolProperty(
|
||||
name="Use object",
|
||||
description="Enable sun positioning of light object",
|
||||
default=False,
|
||||
update=sun_update)
|
||||
|
@ -146,6 +150,7 @@ class SunPosProperties(PropertyGroup):
|
|||
update=sun_update)
|
||||
|
||||
use_object_collection: BoolProperty(
|
||||
name="Use collection",
|
||||
description="Allow a collection of objects to be positioned",
|
||||
default=False,
|
||||
update=sun_update)
|
||||
|
@ -166,6 +171,7 @@ class SunPosProperties(PropertyGroup):
|
|||
update=sun_update)
|
||||
|
||||
use_sky_texture: BoolProperty(
|
||||
name="Use sky texture",
|
||||
description="Enable use of Cycles' "
|
||||
"sky texture. World nodes must be enabled, "
|
||||
"then set color to Sky Texture",
|
||||
|
@ -223,39 +229,47 @@ class SunPosAddonPreferences(AddonPreferences):
|
|||
bl_idname = __package__
|
||||
|
||||
show_time_place: BoolProperty(
|
||||
name="Time and place presets",
|
||||
description="Show time/place presets",
|
||||
default=False)
|
||||
|
||||
show_object_collection: BoolProperty(
|
||||
description="Use object collection",
|
||||
name="Collection",
|
||||
description="Show object collection",
|
||||
default=True,
|
||||
update=sun_update)
|
||||
|
||||
show_dms: BoolProperty(
|
||||
name="D° M' S\"",
|
||||
description="Show lat/long degrees, minutes, seconds labels",
|
||||
default=True)
|
||||
|
||||
show_north: BoolProperty(
|
||||
name="Show North",
|
||||
description="Show north offset choice and slider",
|
||||
default=True,
|
||||
update=sun_update)
|
||||
|
||||
show_refraction: BoolProperty(
|
||||
name="Refraction",
|
||||
description="Show sun refraction choice",
|
||||
default=True,
|
||||
update=sun_update)
|
||||
|
||||
show_az_el: BoolProperty(
|
||||
name="Azimuth and elevation info",
|
||||
description="Show azimuth and solar elevation info",
|
||||
default=True)
|
||||
|
||||
show_daylight_savings: BoolProperty(
|
||||
name="Daylight savings",
|
||||
description="Show daylight savings time choice",
|
||||
default=True,
|
||||
update=sun_update)
|
||||
|
||||
show_rise_set: BoolProperty(
|
||||
description="Show sunrise and sunset",
|
||||
name="Sunrise and sunset info",
|
||||
description="Show sunrise and sunset labels",
|
||||
default=True)
|
||||
|
||||
def draw(self, context):
|
||||
|
@ -266,11 +280,11 @@ class SunPosAddonPreferences(AddonPreferences):
|
|||
|
||||
col.label(text="Show or use:")
|
||||
flow = col.grid_flow(columns=0, even_columns=True, even_rows=False, align=False)
|
||||
flow.prop(self, "show_time_place", text="Time/place presets")
|
||||
flow.prop(self, "show_object_collection", text="Use collection")
|
||||
flow.prop(self, "show_dms", text="D° M' S\"")
|
||||
flow.prop(self, "show_north", text="North offset")
|
||||
flow.prop(self, "show_refraction", text="Refraction")
|
||||
flow.prop(self, "show_az_el", text="Azimuth, elevation")
|
||||
flow.prop(self, "show_daylight_savings", text="Daylight savings time")
|
||||
flow.prop(self, "show_rise_set", text="Sunrise, sunset")
|
||||
flow.prop(self, "show_time_place")
|
||||
flow.prop(self, "show_object_collection")
|
||||
flow.prop(self, "show_dms")
|
||||
flow.prop(self, "show_north")
|
||||
flow.prop(self, "show_refraction")
|
||||
flow.prop(self, "show_az_el")
|
||||
flow.prop(self, "show_daylight_savings")
|
||||
flow.prop(self, "show_rise_set")
|
||||
|
|
|
@ -216,15 +216,7 @@ def move_sun(context):
|
|||
def update_time(context):
|
||||
sun_props = context.scene.sun_pos_properties
|
||||
|
||||
if not sun_props.use_day_of_year:
|
||||
dt = datetime.date(sun_props.year, sun_props.month, sun_props.day)
|
||||
day_of_year = dt.timetuple().tm_yday
|
||||
if sun_props.day_of_year != day_of_year:
|
||||
sun_props.day_of_year = day_of_year
|
||||
sun.day = sun_props.day
|
||||
sun.month = sun_props.month
|
||||
sun.day_of_year = day_of_year
|
||||
else:
|
||||
if sun_props.use_day_of_year:
|
||||
dt = (datetime.date(sun_props.year, 1, 1) +
|
||||
datetime.timedelta(sun_props.day_of_year - 1))
|
||||
sun.day = dt.day
|
||||
|
@ -234,6 +226,14 @@ def update_time(context):
|
|||
sun_props.day = dt.day
|
||||
if sun_props.month != dt.month:
|
||||
sun_props.month = dt.month
|
||||
else:
|
||||
dt = datetime.date(sun_props.year, sun_props.month, sun_props.day)
|
||||
day_of_year = dt.timetuple().tm_yday
|
||||
if sun_props.day_of_year != day_of_year:
|
||||
sun_props.day_of_year = day_of_year
|
||||
sun.day = sun_props.day
|
||||
sun.month = sun_props.month
|
||||
sun.day_of_year = day_of_year
|
||||
sun.year = sun_props.year
|
||||
sun.longitude = sun_props.longitude
|
||||
sun.latitude = sun_props.latitude
|
||||
|
|
|
@ -104,7 +104,6 @@ sun_props.use_daylight_savings = {}
|
|||
# -------------------------------------------------------------------
|
||||
|
||||
class SUNPOS_PT_Panel(bpy.types.Panel):
|
||||
bl_idname = "SUNPOS_PT_world"
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "world"
|
||||
|
@ -118,25 +117,27 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
self.draw_panel(context, sp, p, layout)
|
||||
|
||||
def draw_panel(self, context, sp, p, layout):
|
||||
self.layout.label(text="Usage mode:")
|
||||
self.layout.prop(sp, "usage_mode", expand=True)
|
||||
col = self.layout.column(align=True)
|
||||
col.label(text="Usage mode:")
|
||||
row = col.row()
|
||||
row.prop(sp, "usage_mode", expand=True)
|
||||
col.separator()
|
||||
if sp.usage_mode == "HDR":
|
||||
self.draw_environ_mode_panel(context, sp, p, layout)
|
||||
else:
|
||||
self.draw_normal_mode_panel(context, sp, p, layout)
|
||||
|
||||
def draw_environ_mode_panel(self, context, sp, p, layout):
|
||||
box = self.layout.box()
|
||||
flow = box.grid_flow(row_major=True, columns=0, even_columns=True,
|
||||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True,
|
||||
even_rows=False, align=False)
|
||||
|
||||
col = flow.column()
|
||||
col = flow.column(align=True)
|
||||
col.label(text="Environment texture:")
|
||||
col.prop_search(sp, "hdr_texture",
|
||||
context.scene.world.node_tree, "nodes", text="")
|
||||
col.separator()
|
||||
|
||||
col = flow.column()
|
||||
col = flow.column(align=True)
|
||||
col.label(text="Sun object:")
|
||||
col.prop_search(sp, "sun_object",
|
||||
context.view_layer, "objects", text="")
|
||||
|
@ -150,15 +151,14 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
col.separator()
|
||||
|
||||
col = flow.column(align=True)
|
||||
row1 = col.row()
|
||||
if sp.bind_to_sun:
|
||||
prop_text="Release binding"
|
||||
else:
|
||||
prop_text="Bind Texture to Sun "
|
||||
row1.prop(sp, "bind_to_sun", toggle=True, icon="CONSTRAINT",
|
||||
col.prop(sp, "bind_to_sun", toggle=True, icon="CONSTRAINT",
|
||||
text=prop_text)
|
||||
|
||||
row = col.row()
|
||||
row = col.row(align=True)
|
||||
row.enabled = not sp.bind_to_sun
|
||||
row.operator("world.sunpos_show_hdr", icon='LIGHT_SUN')
|
||||
|
||||
|
@ -170,41 +170,55 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
row.operator(SUNPOS_OT_AddPreset.bl_idname, text="", icon='REMOVE').remove_active = True
|
||||
row.operator(SUNPOS_OT_DefaultPresets.bl_idname, text="", icon='FILE_REFRESH')
|
||||
|
||||
box = self.layout.box()
|
||||
flow = box.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
col = flow.column()
|
||||
col.prop(sp, "use_sky_texture", text="Cycles sky")
|
||||
if sp.use_sky_texture:
|
||||
col.prop_search(sp, "sky_texture", context.scene.world.node_tree,
|
||||
"nodes", text="")
|
||||
col.separator()
|
||||
|
||||
col = flow.column()
|
||||
col.prop(sp, "use_sun_object", text="Use object")
|
||||
col = flow.column(align=True)
|
||||
col.prop(sp, "use_sun_object")
|
||||
if sp.use_sun_object:
|
||||
col.prop(sp, "sun_object", text="")
|
||||
col.separator()
|
||||
col.separator()
|
||||
|
||||
col = flow.column()
|
||||
col = flow.column(align=True)
|
||||
if p.show_object_collection:
|
||||
col.prop(sp, "use_object_collection", text="Use collection")
|
||||
col.prop(sp, "use_object_collection")
|
||||
if sp.use_object_collection:
|
||||
col.prop(sp, "object_collection", text="")
|
||||
if sp.object_collection:
|
||||
col.prop(sp, "object_collection_type")
|
||||
if sp.object_collection_type == 'ECLIPTIC':
|
||||
col.prop(sp, "time_spread")
|
||||
col.separator()
|
||||
|
||||
box = self.layout.box()
|
||||
col = flow.column(align=True)
|
||||
col.prop(sp, "use_sky_texture")
|
||||
if sp.use_sky_texture:
|
||||
col.prop_search(sp, "sky_texture", context.scene.world.node_tree,
|
||||
"nodes", text="")
|
||||
|
||||
col = box.column(align=True)
|
||||
class SUNPOS_PT_Position(bpy.types.Panel):
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "world"
|
||||
bl_label = "Position"
|
||||
bl_parent_id = "SUNPOS_PT_Panel"
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
sp = context.scene.sun_pos_properties
|
||||
return sp.usage_mode != "HDR"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
sp = context.scene.sun_pos_properties
|
||||
p = context.preferences.addons[__package__].preferences
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Enter coordinates:")
|
||||
col.prop(sp, "co_parser", text='', icon='URL')
|
||||
|
||||
box.separator()
|
||||
layout.separator()
|
||||
|
||||
flow = box.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
col = flow.column(align=True)
|
||||
col.prop(sp, "latitude")
|
||||
|
@ -223,7 +237,7 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
|
||||
if p.show_north:
|
||||
col = flow.column(align=True)
|
||||
col.prop(sp, "show_north", text="Show North", toggle=True)
|
||||
col.prop(sp, "show_north", toggle=True)
|
||||
col.prop(sp, "north_offset")
|
||||
col.separator()
|
||||
|
||||
|
@ -241,15 +255,31 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
|
||||
if p.show_refraction:
|
||||
col = flow.column()
|
||||
col.prop(sp, "use_refraction", text="Show refraction")
|
||||
col.prop(sp, "use_refraction")
|
||||
col.separator()
|
||||
|
||||
col = flow.column()
|
||||
col.prop(sp, "sun_distance")
|
||||
|
||||
|
||||
box = self.layout.box()
|
||||
flow = box.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
class SUNPOS_PT_Time(bpy.types.Panel):
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "world"
|
||||
bl_label = "Time"
|
||||
bl_parent_id = "SUNPOS_PT_Panel"
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
sp = context.scene.sun_pos_properties
|
||||
return sp.usage_mode != "HDR"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
sp = context.scene.sun_pos_properties
|
||||
p = context.preferences.addons[__package__].preferences
|
||||
|
||||
flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
col = flow.column(align=True)
|
||||
col.prop(sp, "use_day_of_year",
|
||||
|
@ -257,8 +287,8 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
if sp.use_day_of_year:
|
||||
col.prop(sp, "day_of_year")
|
||||
else:
|
||||
col.prop(sp, "month")
|
||||
col.prop(sp, "day")
|
||||
col.prop(sp, "month")
|
||||
col.prop(sp, "year")
|
||||
col.separator()
|
||||
|
||||
|
@ -266,9 +296,10 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
col.prop(sp, "time")
|
||||
col.prop(sp, "UTC_zone")
|
||||
if p.show_daylight_savings:
|
||||
col.prop(sp, "use_daylight_savings", text="Daylight Savings")
|
||||
col.prop(sp, "use_daylight_savings")
|
||||
col.separator()
|
||||
|
||||
col = flow.column(align=True)
|
||||
lt = format_time(sp.time,
|
||||
p.show_daylight_savings and sp.use_daylight_savings,
|
||||
sp.longitude)
|
||||
|
@ -276,7 +307,6 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
|
|||
p.show_daylight_savings and sp.use_daylight_savings,
|
||||
sp.longitude,
|
||||
sp.UTC_zone)
|
||||
col = flow.column(align=True)
|
||||
col.alignment = 'CENTER'
|
||||
col.label(text="Local: " + lt, icon='TIME')
|
||||
col.label(text=" UTC: " + ut, icon='PREVIEW_RANGE')
|
||||
|
|
Loading…
Reference in New Issue