Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2018-06-08 15:30:11 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2018-06-08 15:30:32 +0300
commitaff6cc9cf107e1ca0cde3044075cc35dd1516a02 (patch)
tree3235dcaedec9b954e0010df36eed88aa533f9eee
parent33437719c177ebd9d5d8718a137d1958e595cd8b (diff)
Workbench: Lights user pref
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py53
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c48
2 files changed, 68 insertions, 33 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 7db91449049..29886d3cd0a 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -72,6 +72,10 @@ class USERPREF_HT_header(Header):
layout.operator("wm.addon_install", icon='FILESEL')
layout.operator("wm.addon_refresh", icon='FILE_REFRESH')
layout.menu("USERPREF_MT_addons_online_resources")
+ elif userpref.active_section == 'LIGHTS':
+ layout.operator('wm.studiolight_install', text="Install MatCap").orientation='MATCAP'
+ layout.operator('wm.studiolight_install', text="Install World HDRI").orientation='WORLD'
+ layout.operator('wm.studiolight_install', text="Install Camera HDRI").orientation='CAMERA'
elif userpref.active_section == 'THEMES':
layout.operator("ui.reset_default_theme")
layout.operator("wm.theme_install")
@@ -1571,11 +1575,9 @@ class USERPREF_PT_addons(Panel):
row.label(text=module_name, translate=False)
-class USERPREF_PT_studiolight(Panel):
+class StudioLightPanelMixin():
bl_space_type = 'USER_PREFERENCES'
- bl_label = "Lights"
bl_region_type = 'WINDOW'
- bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
@@ -1586,33 +1588,44 @@ class USERPREF_PT_studiolight(Panel):
box = layout.box()
row = box.row()
- op = row.operator('wm.studiolight_expand', emboss=False, text="", icon='TRIA_DOWN' if studio_light.show_expanded else 'TRIA_RIGHT')
- op.index = studio_light.index
-
- row.label(text=studio_light.name, icon_value=studio_light.radiance_icon_id)
+ row.template_icon_view(studio_light, "icon_id")
op = row.operator('wm.studiolight_uninstall', text="", icon='ZOOMOUT')
op.index = studio_light.index
- if studio_light.show_expanded:
- box.label(studio_light.path)
+class USERPREF_PT_studiolight_matcaps(Panel, StudioLightPanelMixin):
+ bl_label = "MatCaps"
def draw(self, context):
layout = self.layout
+ flow = layout.column_flow(4)
userpref = context.user_preferences
lights = [light for light in userpref.studio_lights if light.is_user_defined]
- layout.label("MatCaps")
for studio_light in filter(lambda x: x.orientation=='MATCAP', lights):
- self.draw_studio_light(layout, studio_light)
- layout.operator('wm.studiolight_install', text="Install Custom MatCap").orientation='MATCAP'
- layout.label("World HDRI")
+ self.draw_studio_light(flow, studio_light)
+
+class USERPREF_PT_studiolight_world(Panel, StudioLightPanelMixin):
+ bl_label = "World HDRI"
+
+ def draw(self, context):
+ layout = self.layout
+ flow = layout.column_flow(4)
+ userpref = context.user_preferences
+ lights = [light for light in userpref.studio_lights if light.is_user_defined]
for studio_light in filter(lambda x: x.orientation=='WORLD', lights):
- self.draw_studio_light(layout, studio_light)
- layout.operator('wm.studiolight_install', text="Install Custom HDRI").orientation='WORLD'
- layout.label("Camera HDRI")
+ self.draw_studio_light(flow, studio_light)
+
+class USERPREF_PT_studiolight_camera(Panel, StudioLightPanelMixin):
+ bl_label = "Camera HDRI"
+
+ def draw(self, context):
+ layout = self.layout
+ flow = layout.column_flow(4)
+ userpref = context.user_preferences
+ lights = [light for light in userpref.studio_lights if light.is_user_defined]
for studio_light in filter(lambda x: x.orientation=='CAMERA', lights):
- self.draw_studio_light(layout, studio_light)
- layout.operator('wm.studiolight_install', text="Install Custom Camera HDRI").orientation='CAMERA'
+ self.draw_studio_light(flow, studio_light)
+
classes = (
@@ -1635,7 +1648,9 @@ classes = (
USERPREF_PT_input,
USERPREF_MT_addons_online_resources,
USERPREF_PT_addons,
- USERPREF_PT_studiolight,
+ USERPREF_PT_studiolight_matcaps,
+ USERPREF_PT_studiolight_world,
+ USERPREF_PT_studiolight_camera,
)
if __name__ == "__main__": # only for live edit.
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 1e97b1c34be..1cd3a8b83d7 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -78,6 +78,12 @@ const EnumPropertyItem rna_enum_navigation_mode_items[] = {
{0, NULL, 0, NULL, NULL}
};
+static const EnumPropertyItem rna_enum_studio_light_icons_id_items[] = {
+ {0, "DEFAULT", 0, "Default", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+
#if defined(WITH_INTERNATIONAL) || !defined(RNA_RUNTIME)
static const EnumPropertyItem rna_enum_language_default_items[] = {
{0, "DEFAULT", 0, "Default (Default)", ""},
@@ -698,18 +704,36 @@ static int rna_UserDef_studiolight_index_get(PointerRNA *ptr)
return sl->index;
}
-/* StudioLight.radiance_icon_id */
-static int rna_UserDef_studiolight_radiance_icon_id_get(PointerRNA *ptr)
+/* StudioLight.icon_id */
+static int rna_UserDef_studiolight_icon_id_get(PointerRNA *ptr)
{
StudioLight *sl = (StudioLight *)ptr->data;
- return sl->radiance_icon_id;
+ if (sl->flag & (STUDIOLIGHT_ORIENTATION_VIEWNORMAL | STUDIOLIGHT_ORIENTATION_CAMERA)) {
+ return 1;
+ }
+ return 0;
}
-/* StudioLight.irradiance_icon_id */
-static int rna_UserDef_studiolight_irradiance_icon_id_get(PointerRNA *ptr)
+static const EnumPropertyItem *rna_UserDef_studiolight_icon_id_itemf(
+ bContext *UNUSED(C), PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), bool *r_free)
{
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
StudioLight *sl = (StudioLight *)ptr->data;
- return sl->irradiance_icon_id;
+
+ if ((sl->flag & (STUDIOLIGHT_ORIENTATION_VIEWNORMAL | STUDIOLIGHT_ORIENTATION_CAMERA)) == 0)
+ {
+ EnumPropertyItem tmp = {0, sl->name, sl->radiance_icon_id, sl->name, ""};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ {
+ EnumPropertyItem tmp = {1, sl->name, sl->irradiance_icon_id, sl->name, ""};
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ RNA_enum_item_end(&item, &totitem);
+ *r_free = true;
+ return item;
}
/* StudioLight.is_user_defined */
@@ -3291,15 +3315,11 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_orientation_get", "rna_UserDef_studiolight_orientation_set", NULL);
RNA_def_property_ui_text(prop, "Orientation", "");
- prop = RNA_def_property(srna, "radiance_icon_id", PROP_INT, PROP_NONE);
- RNA_def_property_int_funcs(prop, "rna_UserDef_studiolight_radiance_icon_id_get", NULL, NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Radiance Icon", "");
-
- prop = RNA_def_property(srna, "irradiance_icon_id", PROP_INT, PROP_NONE);
- RNA_def_property_int_funcs(prop, "rna_UserDef_studiolight_irradiance_icon_id_get", NULL, NULL);
+ prop = RNA_def_property(srna, "icon_id", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_funcs(prop, "rna_UserDef_studiolight_icon_id_get", NULL, "rna_UserDef_studiolight_icon_id_itemf");
+ RNA_def_property_enum_items(prop, rna_enum_studio_light_icons_id_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Irradiance Icon", "");
+ RNA_def_property_ui_text(prop, "Preview", "Preview of the studiolight");
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_UserDef_studiolight_name_get", "rna_UserDef_studiolight_name_length", NULL);