From 3092e1031d2194e9d6fcc8f157a6e0fcb5d1e45a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 9 Jun 2015 14:57:29 +0200 Subject: Fix T45003: some UI/i18n issues. * Do not translate renderlayers' names, those are data, not UI (defined by user). * Translate passes' names, even in button itself (menu items were already translated). * Translate 'ID type' in ID eyedropper helper message. Also, added i18n context to IDType private struct, and `BKE_idcode_to_translation_context()` helper, much more generic and easy to maintain than the private util in interface_template.c. --- source/blender/blenkernel/BKE_idcode.h | 1 + source/blender/blenkernel/intern/idcode.c | 87 ++++++++++++++++++------------- 2 files changed, 53 insertions(+), 35 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_idcode.h b/source/blender/blenkernel/BKE_idcode.h index 10a34838662..420df77ff1e 100644 --- a/source/blender/blenkernel/BKE_idcode.h +++ b/source/blender/blenkernel/BKE_idcode.h @@ -34,6 +34,7 @@ const char *BKE_idcode_to_name(int code); const char *BKE_idcode_to_name_plural(int code); +const char *BKE_idcode_to_translation_context(int code); int BKE_idcode_from_name(const char *name); bool BKE_idcode_is_linkable(int code); bool BKE_idcode_is_valid(int code); diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 1b7a03ec80e..091d8a6ea17 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -37,11 +37,15 @@ #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_idcode.h" typedef struct { unsigned short code; const char *name, *plural; + + const char *i18n_context; int flags; #define IDTYPE_FLAGS_ISLINKABLE (1 << 0) @@ -50,41 +54,41 @@ typedef struct { /* plural need to match rna_main.c's MainCollectionDef */ /* WARNING! Keep it in sync with i18n contexts in BLF_translation.h */ static IDType idtypes[] = { - { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE }, - { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE }, - { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE }, - { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE }, - { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */ - { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE }, - { ID_ID, "ID", "ids", 0 }, /* plural is fake */ - { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE }, - { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */ - { ID_KE, "Key", "shape_keys", 0 }, - { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE }, - { ID_LI, "Library", "libraries", 0 }, - { ID_LS, "FreestyleLineStyle", "linestyles", IDTYPE_FLAGS_ISLINKABLE }, - { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE }, - { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_MSK, "Mask", "masks", IDTYPE_FLAGS_ISLINKABLE }, - { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE }, - { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE }, - { ID_PA, "ParticleSettings", "particles", 0 }, - { ID_PAL, "Palettes", "palettes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_PC, "PaintCurve", "paint_curves", IDTYPE_FLAGS_ISLINKABLE }, - { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE }, - { ID_SCR, "Screen", "screens", 0 }, - { ID_SEQ, "Sequence", "sequences", 0 }, /* not actually ID data */ - { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE }, - { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE }, - { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE }, - { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE }, - { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE }, - { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE }, - { ID_WM, "WindowManager", "window_managers", 0 }, + { ID_AC, "Action", "actions", BLF_I18NCONTEXT_ID_ACTION, IDTYPE_FLAGS_ISLINKABLE }, + { ID_AR, "Armature", "armatures", BLF_I18NCONTEXT_ID_ARMATURE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_BR, "Brush", "brushes", BLF_I18NCONTEXT_ID_BRUSH, IDTYPE_FLAGS_ISLINKABLE }, + { ID_CA, "Camera", "cameras", BLF_I18NCONTEXT_ID_CAMERA, IDTYPE_FLAGS_ISLINKABLE }, + { ID_CU, "Curve", "curves", BLF_I18NCONTEXT_ID_CURVE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_GD, "GPencil", "grease_pencil", BLF_I18NCONTEXT_ID_GPENCIL, IDTYPE_FLAGS_ISLINKABLE }, /* rename gpencil */ + { ID_GR, "Group", "groups", BLF_I18NCONTEXT_ID_GROUP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_ID, "ID", "ids", BLF_I18NCONTEXT_ID_ID, 0 }, /* plural is fake */ + { ID_IM, "Image", "images", BLF_I18NCONTEXT_ID_IMAGE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_IP, "Ipo", "ipos", "", IDTYPE_FLAGS_ISLINKABLE }, /* deprecated */ + { ID_KE, "Key", "shape_keys", BLF_I18NCONTEXT_ID_SHAPEKEY, 0 }, + { ID_LA, "Lamp", "lamps", BLF_I18NCONTEXT_ID_LAMP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_LI, "Library", "libraries", BLF_I18NCONTEXT_ID_LIBRARY, 0 }, + { ID_LS, "FreestyleLineStyle", "linestyles", BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_LT, "Lattice", "lattices", BLF_I18NCONTEXT_ID_LATTICE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MA, "Material", "materials", BLF_I18NCONTEXT_ID_MATERIAL, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MB, "Metaball", "metaballs", BLF_I18NCONTEXT_ID_METABALL, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MC, "MovieClip", "movieclips", BLF_I18NCONTEXT_ID_MOVIECLIP, IDTYPE_FLAGS_ISLINKABLE }, + { ID_ME, "Mesh", "meshes", BLF_I18NCONTEXT_ID_MESH, IDTYPE_FLAGS_ISLINKABLE }, + { ID_MSK, "Mask", "masks", BLF_I18NCONTEXT_ID_MASK, IDTYPE_FLAGS_ISLINKABLE }, + { ID_NT, "NodeTree", "node_groups", BLF_I18NCONTEXT_ID_NODETREE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_OB, "Object", "objects", BLF_I18NCONTEXT_ID_OBJECT, IDTYPE_FLAGS_ISLINKABLE }, + { ID_PA, "ParticleSettings", "particles", BLF_I18NCONTEXT_ID_PARTICLESETTINGS, 0 }, + { ID_PAL, "Palettes", "palettes", BLF_I18NCONTEXT_ID_PALETTE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_PC, "PaintCurve", "paint_curves", BLF_I18NCONTEXT_ID_PAINTCURVE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_SCE, "Scene", "scenes", BLF_I18NCONTEXT_ID_SCENE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_SCR, "Screen", "screens", BLF_I18NCONTEXT_ID_SCREEN, 0 }, + { ID_SEQ, "Sequence", "sequences", BLF_I18NCONTEXT_ID_SEQUENCE, 0 }, /* not actually ID data */ + { ID_SPK, "Speaker", "speakers", BLF_I18NCONTEXT_ID_SPEAKER, IDTYPE_FLAGS_ISLINKABLE }, + { ID_SO, "Sound", "sounds", BLF_I18NCONTEXT_ID_SOUND, IDTYPE_FLAGS_ISLINKABLE }, + { ID_TE, "Texture", "textures", BLF_I18NCONTEXT_ID_TEXTURE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_TXT, "Text", "texts", BLF_I18NCONTEXT_ID_TEXT, IDTYPE_FLAGS_ISLINKABLE }, + { ID_VF, "VFont", "fonts", BLF_I18NCONTEXT_ID_VFONT, IDTYPE_FLAGS_ISLINKABLE }, + { ID_WO, "World", "worlds", BLF_I18NCONTEXT_ID_WORLD, IDTYPE_FLAGS_ISLINKABLE }, + { ID_WM, "WindowManager", "window_managers", BLF_I18NCONTEXT_ID_WINDOWMANAGER, 0 }, }; static IDType *idtype_from_name(const char *str) @@ -175,6 +179,19 @@ const char *BKE_idcode_to_name_plural(int code) return idt ? idt->plural : NULL; } +/** + * Convert an idcode into its translations' context. + * + * \param code The code to convert. + * \return A static string representing the i18n context of the code. + */ +const char *BKE_idcode_to_translation_context(int code) +{ + IDType *idt = idtype_from_code(code); + BLI_assert(idt); + return idt ? idt->i18n_context : BLF_I18NCONTEXT_DEFAULT; +} + /** * Return an ID code and steps the index forward 1. * -- cgit v1.2.3 From 9f911f62dcefd3ce4312bb8aa1d522cae6bbf6e9 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 10 Jun 2015 13:32:11 +0200 Subject: Fix T45013 negative curve falloff not working. Was doing clamping as fix for T42984. Seems we can ommit clamping for sculpting if we make sure overlap is not zero with negative values. Control for clamping is moved to the "Use Clipping" function of curves (which is on by default), so both bugs remain squashed and advanced users can now properly utilize curves in sculpting, though not all brushes work well with negative curves. --- source/blender/blenkernel/BKE_brush.h | 1 + source/blender/blenkernel/intern/brush.c | 13 +++++++++++-- source/blender/blenkernel/intern/colortools.c | 12 +++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 023303fe602..042fba7294c 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -63,6 +63,7 @@ void BKE_brush_randomize_texture_coords(struct UnifiedPaintSettings *ups, bool m /* brush curve */ void BKE_brush_curve_preset(struct Brush *b, int preset); +float BKE_brush_curve_strength_clamped(struct Brush *br, float p, const float len); float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* sampling */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 307f97f1344..2464b3b2668 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -971,7 +971,7 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask) } } -/* Uses the brush curve control to find a strength value between 0 and 1 */ +/* Uses the brush curve control to find a strength value */ float BKE_brush_curve_strength(Brush *br, float p, const float len) { float strength; @@ -981,6 +981,15 @@ float BKE_brush_curve_strength(Brush *br, float p, const float len) strength = curvemapping_evaluateF(br->curve, 0, p); + return strength; +} + + +/* Uses the brush curve control to find a strength value between 0 and 1 */ +float BKE_brush_curve_strength_clamped(Brush *br, float p, const float len) +{ + float strength = BKE_brush_curve_strength(br, p, len); + CLAMP(strength, 0.0f, 1.0f); return strength; @@ -1042,7 +1051,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary) for (i = 0; i < side; ++i) { for (j = 0; j < side; ++j) { float magn = sqrtf(pow2f(i - half) + pow2f(j - half)); - im->rect_float[i * side + j] = BKE_brush_curve_strength(br, magn, half); + im->rect_float[i * side + j] = BKE_brush_curve_strength_clamped(br, magn, half); } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index c5f7e12c9d0..1120034e217 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -790,7 +790,17 @@ float curvemap_evaluateF(const CurveMap *cuma, float value) float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) { const CurveMap *cuma = cumap->cm + cur; - return curvemap_evaluateF(cuma, value); + float val = curvemap_evaluateF(cuma, value); + + /* account for clipping */ + if (cumap->flag & CUMA_DO_CLIP) { + if (val < cumap->curr.ymin) + val = cumap->curr.ymin; + else if (val > cumap->curr.ymax) + val = cumap->curr.ymax; + } + + return val; } /* vector case */ -- cgit v1.2.3