UI cleanup:

New layer in texture painting will now allow entering image parameters,
similar to new image.
This commit is contained in:
Antonis Ryakiotakis 2014-07-24 11:39:04 +02:00
parent 6e41b008e3
commit cc40925c36
7 changed files with 47 additions and 64 deletions

View File

@ -1082,11 +1082,6 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
if not mat.use_nodes:
col.operator_menu_enum("paint.add_texture_paint_slot", "type")
row = col.row(align=True)
row.prop(settings, "slot_xresolution_default")
row.prop(settings, "slot_yresolution_default")
col.prop(settings, "slot_color_default")
slot = mat.texture_paint_slots[mat.paint_active_slot]
col.separator()
col.label("UV Layer")

View File

@ -343,14 +343,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
if (!MAIN_VERSION_ATLEAST(main, 271, 3)) {
Scene *sce;
Brush *br;
for (sce = main->scene.first; sce; sce = sce->id.next) {
sce->toolsettings->imapaint.slot_xresolution_default = 1024;
sce->toolsettings->imapaint.slot_yresolution_default = 1024;
}
for (br = main->brush.first; br; br = br->id.next) {
br->fill_threshold = 0.2f;
}

View File

@ -1372,7 +1372,7 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
if (ma) {
has_material = true;
if (!ma->texpaintslot) {
proj_paint_add_slot(C, MAP_COL, ma);
proj_paint_add_slot(C, MAP_COL, ma, NULL);
}
}
}
@ -1385,7 +1385,7 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
Material *ma = BKE_material_add(CTX_data_main(C), "Material");
/* no material found, just assign to first slot */
assign_material(ob, ma, 1, BKE_MAT_ASSIGN_USERPREF);
proj_paint_add_slot(C, MAP_COL, ma);
proj_paint_add_slot(C, MAP_COL, ma, NULL);
}
me = BKE_mesh_from_object(ob);
@ -1407,14 +1407,8 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
Main *bmain = CTX_data_main(C);
float color[4] = {0.0, 0.0, 0.0, 1.0};
/* should not be allowed, but just in case */
if (imapaint->slot_xresolution_default == 0)
imapaint->slot_xresolution_default = 1024;
if (imapaint->slot_yresolution_default == 0)
imapaint->slot_yresolution_default = 1024;
width = imapaint->slot_xresolution_default;
height = imapaint->slot_yresolution_default;
width = 1024;
height = 1024;
imapaint->stencil = BKE_image_add_generated(bmain, width, height, "Stencil", 32, false, IMA_GENTYPE_BLANK, color);
}
}

View File

@ -4816,28 +4816,16 @@ static EnumPropertyItem layer_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
bool proj_paint_add_slot(bContext *C, int type, Material *ma)
bool proj_paint_add_slot(bContext *C, int type, Material *ma, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
int i;
ImagePaintSettings *imapaint = &CTX_data_tool_settings(C)->imapaint;
bool use_nodes = BKE_scene_use_new_shading_nodes(scene);
int width;
int height;
if (!ob)
return false;
/* should not be allowed, but just in case */
if (imapaint->slot_xresolution_default == 0)
imapaint->slot_xresolution_default = 1024;
if (imapaint->slot_yresolution_default == 0)
imapaint->slot_yresolution_default = 1024;
width = imapaint->slot_xresolution_default;
height = imapaint->slot_yresolution_default;
if (!ma)
ma = give_current_material(ob, ob->actcol);
@ -4866,13 +4854,22 @@ bool proj_paint_add_slot(bContext *C, int type, Material *ma)
if (mtex->tex) {
char imagename[FILE_MAX];
float color[4];
bool use_float = type == MAP_NORM;
int width = 1024;
int height = 1024;
bool use_float = false;
short gen_type = IMA_GENTYPE_BLANK;
bool alpha = false;
copy_v4_v4(color, imapaint->slot_color_default);
if (use_float) {
mul_v3_fl(color, color[3]);
if (op) {
width = RNA_int_get(op->ptr, "width");
height = RNA_int_get(op->ptr, "height");
use_float = RNA_boolean_get(op->ptr, "float");
gen_type = RNA_enum_get(op->ptr, "generated_type");
RNA_float_get_array(op->ptr, "color", color);
alpha = RNA_boolean_get(op->ptr, "alpha");
}
else {
if (!use_float) {
/* crappy workaround because we only upload straight color to OpenGL and that makes
* painting result on viewport too opaque */
color[3] = 1.0;
@ -4881,8 +4878,8 @@ bool proj_paint_add_slot(bContext *C, int type, Material *ma)
/* take the second letter to avoid the ID identifier */
BLI_snprintf(imagename, FILE_MAX, "%s_%s", &ma->id.name[2], name);
ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, 32, use_float,
IMA_GENTYPE_BLANK, color);
ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float,
gen_type, color);
BKE_texpaint_slot_refresh_cache(ma, false);
BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE);
@ -4904,17 +4901,28 @@ static int texture_paint_add_texture_paint_slot_exec(bContext *C, wmOperator *op
{
int type = RNA_enum_get(op->ptr, "type");
return proj_paint_add_slot(C, type, NULL) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
return proj_paint_add_slot(C, type, NULL, op);
}
static int texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, 5 * UI_UNIT_Y);
}
void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
{
PropertyRNA *prop;
static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
/* identifiers */
ot->name = "Add Texture Paint Slot";
ot->description = "Add a texture paint slot";
ot->idname = "PAINT_OT_add_texture_paint_slot";
/* api callbacks */
ot->invoke = texture_paint_add_texture_paint_slot_invoke;
ot->exec = texture_paint_add_texture_paint_slot_exec;
ot->poll = ED_operator_region_view3d_active;
@ -4922,5 +4930,17 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", layer_type_items, 0, "Type", "Merge method to use");
prop = RNA_def_enum(ot->srna, "type", layer_type_items, 0, "Type", "Merge method to use");
RNA_def_property_flag(prop, PROP_HIDDEN);
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);
RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel");
RNA_def_enum(ot->srna, "generated_type", image_generated_type_items, IMA_GENTYPE_BLANK,
"Generated Type", "Fill the image with a grid for UV map testing");
RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth");
}

View File

@ -169,7 +169,7 @@ void paint_proj_stroke(const struct bContext *C, void *ps, const float prevmval_
void paint_proj_redraw(const struct bContext *C, void *pps, bool final);
void paint_proj_stroke_done(void *ps);
void paint_proj_mesh_data_ensure(bContext *C, struct Object *ob, struct wmOperator *op);
bool proj_paint_add_slot(bContext *C, int type, struct Material *ma);
bool proj_paint_add_slot(bContext *C, int type, struct Material *ma, struct wmOperator *op);
void paint_brush_color_get(struct Scene *scene, struct Brush *br, bool color_correction, bool invert, float distance, float pressure, float color[3], struct ColorManagedDisplay *display);
bool paint_use_opacity_masking(struct Brush *brush);

View File

@ -841,15 +841,10 @@ typedef struct ImagePaintSettings {
short seam_bleed, normal_angle;
short screen_grab_size[2]; /* capture size for re-projection */
/* new layer default resolution */
int slot_xresolution_default;
int slot_yresolution_default;
int pad1;
void *paintcursor; /* wm handle */
struct Image *stencil; /* workaround until we support true layer masks */
float slot_color_default[4];
float stencil_col[3];
float pad2;
} ImagePaintSettings;

View File

@ -614,11 +614,6 @@ static void rna_def_image_paint(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "stencil_col");
RNA_def_property_ui_text(prop, "Stencil Color", "Stencil color in the viewport");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_stencil_update");
prop = RNA_def_property(srna, "slot_color_default", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "New Layer Color", "Color/Alpha used for new");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE);
@ -639,16 +634,6 @@ static void rna_def_image_paint(BlenderRNA *brna)
prop = RNA_def_int_array(srna, "screen_grab_size", 2, NULL, 0, 0, "screen_grab_size",
"Size to capture the image for re-projecting", 0, 0);
RNA_def_property_range(prop, 512, 16384);
prop = RNA_def_property(srna, "slot_xresolution_default", PROP_INT, PROP_UNSIGNED);
RNA_def_property_range(prop, 1, SHRT_MAX);
RNA_def_property_ui_range(prop, 64, 4096, 0, -1);
RNA_def_property_ui_text(prop, "X resolution", "X Resolution of new image");
prop = RNA_def_property(srna, "slot_yresolution_default", PROP_INT, PROP_UNSIGNED);
RNA_def_property_range(prop, 1, SHRT_MAX);
RNA_def_property_ui_range(prop, 64, 4096, 0, -1);
RNA_def_property_ui_text(prop, "Y resolution", "Y Resolution of new image");
}
static void rna_def_particle_edit(BlenderRNA *brna)