Making the Hue Correct Curves Wrap #117114

Merged
Omar Emara merged 31 commits from JonasDichelle/blender:hue-correct-bezier-wrap into main 2024-03-21 15:35:13 +01:00
20 changed files with 65 additions and 33 deletions
Showing only changes of commit 30ee82881a - Show all commits

View File

@ -2647,7 +2647,7 @@ class SEQUENCER_PT_modifiers(SequencerButtonsPanel, Panel):
elif mod.type == 'CURVES':
box.template_curve_mapping(mod, "curve_mapping", type='COLOR', show_tone=True)
elif mod.type == 'HUE_CORRECT':
box.template_curve_mapping(mod, "curve_mapping", type='HUE', use_wrapping=True)
box.template_curve_mapping(mod, "curve_mapping", type='HUE')
elif mod.type == 'BRIGHT_CONTRAST':
col = box.column()
col.prop(mod, "bright")

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 2
#define BLENDER_FILE_SUBVERSION 3
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -61,6 +61,7 @@
#include "BKE_node_runtime.hh"
#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "BKE_colortools.hh"
#include "SEQ_iterator.hh"
#include "SEQ_retiming.hh"
@ -1947,6 +1948,32 @@ static bool seq_filter_bilinear_to_auto(Sequence *seq, void * /*user_data*/)
return true;
}
static bool seq_hue_correct_set_wrapping(Sequence *seq, void * /*user_data*/)
{
LISTBASE_FOREACH (SequenceModifierData *, smd, &seq->modifiers) {
if (smd->type == seqModifierType_HueCorrect) {
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
CurveMapping *cumap = (CurveMapping *)&hcmd->curve_mapping;
cumap->use_wrapping = true;
}
}
return true;
}
static void versioning_node_hue_correct_set_wrappng(bNodeTree *ntree)
{
if (ntree->type == NTREE_COMPOSIT) {
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_HUECORRECT) {
CurveMapping *cumap = (CurveMapping *)node->storage;
cumap->use_wrapping = true;
}
}
}
}
void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
{
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 1)) {
@ -2926,6 +2953,19 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 3)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
versioning_node_hue_correct_set_wrappng(ntree);
}
FOREACH_NODETREE_END;
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
if (scene->ed != nullptr) {
SEQ_for_each_callback(&scene->ed->seqbase, seq_hue_correct_set_wrapping, nullptr);
}
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@ -1478,7 +1478,7 @@ static void gpencil_interpolate_seq_ui(bContext *C, wmOperator *op)
PointerRNA gpsettings_ptr = RNA_pointer_create(
&scene->id, &RNA_GPencilInterpolateSettings, &ts->gp_interpolate);
uiTemplateCurveMapping(
layout, &gpsettings_ptr, "interpolation_curve", 0, false, true, true, false, false);
layout, &gpsettings_ptr, "interpolation_curve", 0, false, true, true, false);
}
else if (type != GP_IPO_LINEAR) {
row = uiLayoutRow(layout, false);

View File

@ -2484,8 +2484,7 @@ void uiTemplateCurveMapping(uiLayout *layout,
bool levels,
bool brush,
bool neg_slope,
bool tone,
bool use_wrapping);
bool tone);
/**
* Template for a path creation widget intended for custom bevel profiles.
* This section is quite similar to #uiTemplateCurveMapping, but with reduced complexity.

View File

@ -4563,7 +4563,6 @@ static void curvemap_buttons_layout(uiLayout *layout,
bool brush,
bool neg_slope,
bool tone,
bool use_wrapping,
RNAUpdateCb *cb)
{
CurveMapping *cumap = static_cast<CurveMapping *>(ptr->data);
@ -4576,10 +4575,6 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_block_emboss_set(block, UI_EMBOSS);
if (use_wrapping) {
BKE_curvemap_set_wrapping(cumap, true);
}
if (tone) {
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
@ -4939,8 +4934,7 @@ void uiTemplateCurveMapping(uiLayout *layout,
bool levels,
bool brush,
bool neg_slope,
bool tone,
bool use_wrapping)
bool tone)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
uiBlock *block = uiLayoutGetBlock(layout);
@ -4967,7 +4961,7 @@ void uiTemplateCurveMapping(uiLayout *layout,
ID *id = cptr.owner_id;
UI_block_lock_set(block, (id && ID_IS_LINKED(id)), ERROR_LIBDATA_MESSAGE);
curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, tone, use_wrapping, cb);
curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, tone, cb);
UI_block_lock_clear(block);
@ -6808,7 +6802,7 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout,
uiItemR(col, &view_transform_ptr, "use_curve_mapping", UI_ITEM_NONE, nullptr, ICON_NONE);
if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
uiTemplateCurveMapping(
col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false, false);
col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false);
}
}

View File

@ -1194,7 +1194,6 @@ static void cavity_bake_ui(bContext *C, wmOperator *op)
false,
false,
false,
false,
false);
}
break;

View File

@ -18,7 +18,6 @@
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "BKE_colortools.hh"
#include "BKE_context.hh"
#include "BKE_curve.hh"
#include "BKE_image.h"
@ -128,7 +127,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext * /*C*/, PointerRNA *pt
static void node_buts_time(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiTemplateCurveMapping(layout, ptr, "curve", 's', false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "curve", 's', false, false, false, false);
uiLayout *col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "frame_start", DEFAULT_FLAGS, IFACE_("Start"), ICON_NONE);
@ -142,12 +141,12 @@ static void node_buts_colorramp(uiLayout *layout, bContext * /*C*/, PointerRNA *
static void node_buts_curvevec(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false, false);
}
static void node_buts_curvefloat(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiTemplateCurveMapping(layout, ptr, "mapping", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "mapping", 0, false, false, false, false);
}
} // namespace blender::ed::space_node
@ -183,7 +182,7 @@ static void node_buts_curvecol(uiLayout *layout, bContext * /*C*/, PointerRNA *p
/* "Tone" (Standard/Film-like) only used in the Compositor. */
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
uiTemplateCurveMapping(
layout, ptr, "mapping", 'c', false, false, false, (ntree->type == NTREE_COMPOSIT), false);
layout, ptr, "mapping", 'c', false, false, false, (ntree->type == NTREE_COMPOSIT));
}
static void node_buts_normal(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
@ -595,7 +594,7 @@ static void node_composit_buts_huecorrect(uiLayout *layout, bContext * /*C*/, Po
cumap->flag &= ~CUMA_DRAW_SAMPLE;
}
uiTemplateCurveMapping(layout, ptr, "mapping", 'h', false, false, false, false, true);
uiTemplateCurveMapping(layout, ptr, "mapping", 'h', false, false, false, false);
}
static void node_composit_buts_ycc(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)

View File

@ -370,7 +370,7 @@ static void falloff_panel_draw(const bContext * /*C*/, Panel *panel)
uiItemR(layout, ptr, "use_falloff_uniform", UI_ITEM_NONE, nullptr, ICON_NONE);
if (RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) {
uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false);
}
}

View File

@ -190,7 +190,7 @@ void gpencil_modifier_curve_panel_draw(const bContext * /*C*/, Panel *panel)
PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, nullptr);
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false);
}
void gpencil_modifier_panel_end(uiLayout *layout, PointerRNA *ptr)

View File

@ -1737,7 +1737,6 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_boolean(func, "brush", false, "", "Show brush options");
RNA_def_boolean(func, "use_negative_slope", false, "", "Use a negative slope by default");
RNA_def_boolean(func, "show_tone", false, "", "Show tone options");
RNA_def_boolean(func, "use_wrapping", false, "", "Use curve wrapping");
func = RNA_def_function(srna, "template_curveprofile", "uiTemplateCurveProfile");
RNA_def_function_ui_description(func, "A profile path editor used for custom profiles");

View File

@ -173,7 +173,7 @@ void draw_custom_curve_settings(const bContext * /*C*/, uiLayout *layout, Pointe
uiLayoutSetPropDecorate(row, false);
uiItemR(row, ptr, "use_custom_curve", UI_ITEM_NONE, "Custom Curve", ICON_NONE);
if (use_custom_curve) {
uiTemplateCurveMapping(layout, ptr, "custom_curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "custom_curve", 0, false, false, false, false);
}
}

View File

@ -506,7 +506,7 @@ static void falloff_panel_draw(const bContext * /*C*/, Panel *panel)
uiItemR(layout, ptr, "use_falloff_uniform", UI_ITEM_NONE, nullptr, ICON_NONE);
if (RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) {
uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false);
}
}

View File

@ -158,7 +158,7 @@ void modifier_grease_pencil_curve_panel_draw(const bContext * /*C*/, Panel *pane
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false);
}
/**

View File

@ -399,7 +399,7 @@ static void falloff_panel_draw(const bContext * /*C*/, Panel *panel)
}
if (use_falloff && RNA_enum_get(ptr, "falloff_type") == eWarp_Falloff_Curve) {
uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "falloff_curve", 0, false, false, false, false);
}
}

View File

@ -342,7 +342,7 @@ static void falloff_panel_draw(const bContext * /*C*/, Panel *panel)
uiLayoutSetPropSep(sub, false);
uiItemR(row, ptr, "invert_falloff", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
if (RNA_enum_get(ptr, "falloff_type") == MOD_WVG_MAPPING_CURVE) {
uiTemplateCurveMapping(layout, ptr, "map_curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "map_curve", 0, false, false, false, false);
}
}

View File

@ -686,7 +686,7 @@ static void falloff_panel_draw(const bContext * /*C*/, Panel *panel)
uiLayoutSetPropSep(sub, false);
uiItemR(row, ptr, "invert_falloff", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT);
if (RNA_enum_get(ptr, "falloff_type") == MOD_WVG_MAPPING_CURVE) {
uiTemplateCurveMapping(layout, ptr, "map_curve", 0, false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "map_curve", 0, false, false, false, false);
}
modifier_panel_end(layout, ptr);
}

View File

@ -129,7 +129,7 @@ static void node_composit_init_curve_vec(bNodeTree * /*ntree*/, bNode *node)
static void node_buts_curvevec(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false, false, false);
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false, false);
}
using namespace blender::realtime_compositor;

View File

@ -42,7 +42,8 @@ static void node_composit_init_huecorrect(bNodeTree * /*ntree*/, bNode *node)
CurveMap *cuma = &cumapping->cm[c];
BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE);
}
/* use wrapping for all hue correct nodes */
BKE_curvemap_set_wrapping(cumapping, true);
/* default to showing Saturation */
cumapping->cur = 1;
}

View File

@ -868,7 +868,8 @@ static void hue_correct_init_data(SequenceModifierData *smd)
BKE_curvemap_reset(
cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CURVEMAP_SLOPE_POSITIVE);
}
/* use wrapping for all hue correct modifiers */
BKE_curvemap_set_wrapping(&hcmd->curve_mapping, true);
/* default to showing Saturation */
hcmd->curve_mapping.cur = 1;
}