RNA: Add pixels property type

This commit is contained in:
Scott Petrovic 2013-12-13 04:39:15 +11:00 committed by Campbell Barton
parent 6c96535fd8
commit c701082a92
Notes: blender-bot 2023-02-14 11:29:52 +01:00
Referenced by issue #37793, Sculpting brush radius hotkey no longer works
14 changed files with 33 additions and 22 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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,

View File

@ -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";

View File

@ -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");

View File

@ -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)");

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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", ""},

View File

@ -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);

View File

@ -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");

View File

@ -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");

View File

@ -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", ""},