From c701082a928b4390f1fb910f2eb7520b45b4cdf1 Mon Sep 17 00:00:00 2001 From: Scott Petrovic Date: Fri, 13 Dec 2013 04:39:15 +1100 Subject: RNA: Add pixels property type --- source/blender/editors/interface/interface.c | 3 +++ source/blender/editors/space_image/image_ops.c | 6 ++++-- source/blender/makesrna/RNA_types.h | 1 + source/blender/makesrna/intern/makesrna.c | 1 + source/blender/makesrna/intern/rna_brush.c | 4 ++-- source/blender/makesrna/intern/rna_gpencil.c | 2 +- source/blender/makesrna/intern/rna_image.c | 1 + source/blender/makesrna/intern/rna_particle.c | 4 ++-- source/blender/makesrna/intern/rna_render.c | 8 ++++---- source/blender/makesrna/intern/rna_rna.c | 2 ++ source/blender/makesrna/intern/rna_scene.c | 10 +++++----- source/blender/makesrna/intern/rna_sculpt_paint.c | 6 +++--- source/blender/makesrna/intern/rna_userdef.c | 6 +++--- source/blender/python/intern/bpy_props.c | 1 + 14 files changed, 33 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 45a73e217fe..0b86743b622 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2473,6 +2473,9 @@ void ui_check_but(uiBut *but) if (pstype == PROP_PERCENTAGE) { drawstr_suffix = "%"; } + else if (pstype == PROP_PIXEL) { + drawstr_suffix = " px"; + } } if (drawstr_suffix) { diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 2ea77bba681..bda4be40c5c 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1837,8 +1837,10 @@ void IMAGE_OT_new(wmOperatorType *ot) /* properties */ RNA_def_string(ot->srna, "name", IMA_DEF_NAME, MAX_ID_NAME - 2, "Name", "Image datablock name"); - RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384); - RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384); + prop = RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384); + RNA_def_property_subtype(prop, PROP_PIXEL); + prop = RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384); + RNA_def_property_subtype(prop, PROP_PIXEL); prop = RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f); RNA_def_property_subtype(prop, PROP_COLOR_GAMMA); RNA_def_property_float_array_default(prop, default_color); diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 43bf1973c33..d974933d352 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -116,6 +116,7 @@ typedef enum PropertySubType { PROP_PASSWORD = 6, /* a string which should not be displayed in UI */ /* numbers */ + PROP_PIXEL = 12, PROP_UNSIGNED = 13, PROP_PERCENTAGE = 14, PROP_FACTOR = 15, diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 1cb9eb8e9ae..8070ef1d814 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2443,6 +2443,7 @@ static const char *rna_property_subtypename(PropertySubType type) case PROP_FILEPATH: return "PROP_FILEPATH"; case PROP_FILENAME: return "PROP_FILENAME"; case PROP_DIRPATH: return "PROP_DIRPATH"; + case PROP_PIXEL: return "PROP_PIXEL"; case PROP_BYTESTRING: return "PROP_BYTESTRING"; case PROP_UNSIGNED: return "PROP_UNSIGNED"; case PROP_PERCENTAGE: return "PROP_PERCENTAGE"; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index bd4aa050689..6114686e9b2 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -726,7 +726,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Brush_update"); /* number values */ - prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1); @@ -747,7 +747,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush while painting"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "jitter_absolute", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "jitter_absolute", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "jitter_absolute"); RNA_def_property_range(prop, 0, 1000000); RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush in pixels while painting"); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 6423763c49c..cdedb3576b0 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -489,7 +489,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Line Thickness */ - prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "thickness"); RNA_def_property_range(prop, 1, 10); RNA_def_property_ui_text(prop, "Thickness", "Thickness of strokes (in pixels)"); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 7ddb172e2a2..c901abc834e 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -701,6 +701,7 @@ static void rna_def_image(BlenderRNA *brna) prop = RNA_def_int_vector(srna, "size", 2, NULL, 0, 0, "Size", "Width and height in pixels, zero when image data cant be loaded", 0, 0); + RNA_def_property_subtype(prop, PROP_PIXEL); RNA_def_property_int_funcs(prop, "rna_Image_size_get", NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 01e7b673838..174e3dfdb01 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -2352,7 +2352,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Draw Color", "Draw additional particle data as a color"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "draw_size", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "draw_size", PROP_INT, PROP_PIXEL); RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_range(prop, 0, 100, 1, -1); RNA_def_property_ui_text(prop, "Draw Size", "Size of particles on viewport in pixels (0=default)"); @@ -2517,7 +2517,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", PART_SIMPLIFY_VIEWPORT); RNA_def_property_ui_text(prop, "Viewport", ""); - prop = RNA_def_property(srna, "simplify_refsize", PROP_INT, PROP_UNSIGNED); + prop = RNA_def_property(srna, "simplify_refsize", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "simplify_refsize"); RNA_def_property_range(prop, 1, 32768); RNA_def_property_ui_text(prop, "Reference Size", "Reference size in pixels, after which simplification begins"); diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 1cd27e27f01..9c3c6ce6c04 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -456,11 +456,11 @@ static void rna_def_render_engine(BlenderRNA *brna) prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "tile_y"); - prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "resolution_x"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "resolution_y"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); @@ -525,11 +525,11 @@ static void rna_def_render_result(BlenderRNA *brna) RNA_define_verify_sdna(0); - parm = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); + parm = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(parm, NULL, "rectx"); RNA_def_property_clear_flag(parm, PROP_EDITABLE); - parm = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE); + parm = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(parm, NULL, "recty"); RNA_def_property_clear_flag(parm, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 380bde90ff9..502a6e7a577 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -60,6 +60,7 @@ EnumPropertyItem property_subtype_items[] = { {PROP_PASSWORD, "PASSWORD", 0, "Password", "A string that is displayed hidden ('********')"}, /* numbers */ + {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, @@ -1085,6 +1086,7 @@ static void rna_def_property(BlenderRNA *brna) {PROP_NONE, "NONE", 0, "None", ""}, {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, {PROP_DIRPATH, "DIRECTORY_PATH", 0, "Directory Path", ""}, + {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""}, {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 0daa8c97dec..300414eeb89 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2017,7 +2017,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) /* unified paint settings that override the equivalent settings * from the active brush */ - prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_funcs(prop, NULL, "rna_UnifiedPaintSettings_size_set", NULL); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1); @@ -3138,13 +3138,13 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_struct_nested(brna, srna, "Scene"); RNA_def_struct_ui_text(srna, "Game Data", "Game data for a Scene datablock"); - prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "xplay"); RNA_def_property_range(prop, 4, 10000); RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the screen"); RNA_def_property_update(prop, NC_SCENE, NULL); - prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "yplay"); RNA_def_property_range(prop, 4, 10000); RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the screen"); @@ -4137,14 +4137,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ImageFormatSettings"); RNA_def_property_ui_text(prop, "Image Format", ""); - prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "xsch"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 65536); RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the rendered image"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update"); - prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "ysch"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 65536); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 402b75c9594..6e201a1dc2f 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -406,7 +406,7 @@ static void rna_def_sculpt(BlenderRNA *brna) "Show diffuse color of object and overlay sculpt mask on top of it"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); - prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_PIXEL); RNA_def_property_ui_range(prop, 2, 100, 0, -1); RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)"); @@ -530,7 +530,7 @@ static void rna_def_image_paint(BlenderRNA *brna) /* integers */ - prop = RNA_def_property(srna, "seam_bleed", PROP_INT, PROP_UNSIGNED); + prop = RNA_def_property(srna, "seam_bleed", PROP_INT, PROP_PIXEL); RNA_def_property_ui_range(prop, 0, 8, 0, -1); RNA_def_property_ui_text(prop, "Bleed", "Extend paint beyond the faces UVs to reduce seams (in pixels, slower)"); @@ -678,7 +678,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_struct_path_func(srna, "rna_ParticleBrush_path"); RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush"); - prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 3); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f138964f8e3..40082883336 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -656,13 +656,13 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shadow Size", "Shadow size in pixels (0, 3 and 5 supported)"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "shadow_offset_x", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "shadow_offset_x", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "shadx"); RNA_def_property_range(prop, -10, 10); RNA_def_property_ui_text(prop, "Shadow X Offset", "Shadow offset in pixels"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - prop = RNA_def_property(srna, "shadow_offset_y", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "shadow_offset_y", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "shady"); RNA_def_property_range(prop, -10, 10); RNA_def_property_ui_text(prop, "Shadow Y Offset", "Shadow offset in pixels"); @@ -3189,7 +3189,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_int_default(prop, 14); RNA_def_property_ui_text(prop, "Manipulator Hotspot", "Pixel distance around the handles to accept mouse clicks"); - prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "obcenter_dia"); RNA_def_property_range(prop, 4, 10); RNA_def_property_ui_text(prop, "Object Origin Size", "Diameter in Pixels for Object/Lamp origin display"); diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index bfa4954d4bc..ea18d4ac356 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -88,6 +88,7 @@ static EnumPropertyItem property_subtype_string_items[] = { {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem property_subtype_number_items[] = { + {PROP_PIXEL, "PIXEL", 0, "Pixel", ""}, {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned", ""}, {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, {PROP_FACTOR, "FACTOR", 0, "Factor", ""}, -- cgit v1.2.3