[vlc-commits] [Git][videolan/vlc][master] gradient: replace --gradient-type with --gradient-color

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Mon Feb 28 21:15:39 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
2b3ad74b by Lyndon Brown at 2022-02-28T20:19:12+00:00
gradient: replace --gradient-type with --gradient-color

the old option was an int type used like a bool. the new options is an
actual bool, simplifying things, including the UX in the GUI and CLI.

- - - - -


4 changed files:

- modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
- modules/gui/qt/dialogs/extended/extended_panels.cpp
- modules/gui/qt/dialogs/extended/video_effects.ui
- modules/video_filter/gradient.c


Changes:

=====================================
modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
=====================================
@@ -168,7 +168,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
     [VLCVideoFilterHelper setVideoFilterProperty: "sepia-intensity" forFilter: "sepia" withValue: getWidgetIntValue([items objectAtIndex:17])];
     [VLCVideoFilterHelper setVideoFilterProperty: "gradient-mode" forFilter: "gradient" withValue: (vlc_value_t){ .psz_string = (char *)[B64DecNSStr([items objectAtIndex:18]) UTF8String] }];
     [VLCVideoFilterHelper setVideoFilterProperty: "gradient-cartoon" forFilter: "gradient" withValue: (vlc_value_t){ .b_bool = [[items objectAtIndex:19] intValue] }];
-    [VLCVideoFilterHelper setVideoFilterProperty: "gradient-type" forFilter: "gradient" withValue: getWidgetIntValue([items objectAtIndex:20])];
+    [VLCVideoFilterHelper setVideoFilterProperty: "gradient-color" forFilter: "gradient" withValue: (vlc_value_t){ .b_bool = [[items objectAtIndex:20] intValue] }];
     [VLCVideoFilterHelper setVideoFilterProperty: "extract-component" forFilter: "extract" withValue: getWidgetIntValue([items objectAtIndex:21])];
     [VLCVideoFilterHelper setVideoFilterProperty: "posterize-level" forFilter: "posterize" withValue: getWidgetIntValue([items objectAtIndex:22])];
     [VLCVideoFilterHelper setVideoFilterProperty: "blur-factor" forFilter: "motionblur" withValue: getWidgetIntValue([items objectAtIndex:23])];
@@ -634,7 +634,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
     b_state = [_gradientCheckbox state];
     [self setWidgetValue: _gradientModePopup forOption: "gradient-mode" enabled: b_state];
     [self setWidgetValue: _gradientCartoonCheckbox forOption: "gradient-cartoon" enabled: b_state];
-    [self setWidgetValue: _gradientColorCheckbox forOption: "gradient-type" enabled: b_state];
+    [self setWidgetValue: _gradientColorCheckbox forOption: "gradient-color" enabled: b_state];
     [_gradientModeLabel setEnabled: b_state];
 
     [self setWidgetValue: _extractTextField forOption: "extract-component" enabled: [_extractCheckbox state]];
@@ -690,7 +690,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
                      var_InheritInteger(vout, "sepia-intensity"),
                      B64EncAndFree(var_InheritString(vout, "gradient-mode")),
                      (int64_t)var_InheritBool(vout, "gradient-cartoon"),
-                     var_InheritInteger(vout, "gradient-type"),
+                     (int64_t)var_InheritBool(vout, "gradient-color"),
                      var_InheritInteger(vout, "extract-component"),
                      var_InheritInteger(vout, "posterize-level"),
                      var_InheritInteger(vout, "blur-factor"),
@@ -1187,7 +1187,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
         vlc_value_t value = { .psz_string = (char *)[[[sender selectedItem] representedObject] UTF8String] };
         [VLCVideoFilterHelper setVideoFilterProperty: "gradient-mode" forFilter: "gradient" withValue: value];
     } else if (sender == _gradientColorCheckbox)
-        [VLCVideoFilterHelper setVideoFilterProperty: "gradient-type" forFilter: "gradient" withValue: getWidgetBoolValue(sender)];
+        [VLCVideoFilterHelper setVideoFilterProperty: "gradient-color" forFilter: "gradient" withValue: getWidgetBoolValue(sender)];
     else
         [VLCVideoFilterHelper setVideoFilterProperty: "gradient-cartoon" forFilter: "gradient" withValue: getWidgetBoolValue(sender)];
 }


=====================================
modules/gui/qt/dialogs/extended/extended_panels.cpp
=====================================
@@ -181,7 +181,7 @@ ExtVideo::ExtVideo( qt_intf_t *_p_intf, QTabWidget *_parent ) :
 
     SETUP_VFILTER_gb( gradient )
     SETUP_VFILTER_OPTION( gradientModeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged) )
-    SETUP_VFILTER_OPTION( gradientTypeCheck, &QCheckBox::stateChanged )
+    SETUP_VFILTER_OPTION( gradientColorCheck, &QCheckBox::stateChanged )
     SETUP_VFILTER_OPTION( gradientCartoonCheck, &QCheckBox::stateChanged )
 
     SETUP_VFILTER_gb( motionblur )


=====================================
modules/gui/qt/dialogs/extended/video_effects.ui
=====================================
@@ -558,7 +558,7 @@
         </widget>
        </item>
        <item row="1" column="0" colspan="2">
-        <widget class="QCheckBox" name="gradientTypeCheck">
+        <widget class="QCheckBox" name="gradientColorCheck">
          <property name="text">
           <string>Color</string>
          </property>


=====================================
modules/video_filter/gradient.c
=====================================
@@ -60,9 +60,8 @@ static void FilterHough   ( filter_t *, picture_t *, picture_t * );
 #define MODE_TEXT N_("Distort mode")
 #define MODE_LONGTEXT N_("Distort mode, one of \"gradient\", \"edge\" and \"hough\".")
 
-#define GRADIENT_TEXT N_("Gradient image type")
-#define GRADIENT_LONGTEXT N_("Gradient image type (0 or 1). 0 will " \
-        "turn the image to white while 1 will keep colors." )
+#define COLOR_TEXT N_("Keep color")
+#define COLOR_LONGTEXT N_("This will keep the colors, otherwise the image will be turned white." )
 
 #define CARTOON_TEXT N_("Apply cartoon effect")
 #define CARTOON_LONGTEXT N_("Apply cartoon effect. It is only used by " \
@@ -85,8 +84,9 @@ vlc_module_begin ()
                 MODE_TEXT, MODE_LONGTEXT )
         change_string_list( mode_list, mode_list_text )
 
-    add_integer_with_range( FILTER_PREFIX "type", 0, 0, 1,
-                GRADIENT_TEXT, GRADIENT_LONGTEXT )
+    add_obsolete_integer( "gradient-type" ) /* since 4.0.0 */
+    add_bool( FILTER_PREFIX "color", false,
+                COLOR_TEXT, COLOR_LONGTEXT )
     add_bool( FILTER_PREFIX "cartoon", true,
                 CARTOON_TEXT, CARTOON_LONGTEXT )
 
@@ -95,7 +95,7 @@ vlc_module_begin ()
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
-    "mode", "type", "cartoon", NULL
+    "mode", "color", "cartoon", NULL
 };
 
 /*****************************************************************************
@@ -110,7 +110,7 @@ typedef struct
     int i_mode;
 
     /* For the gradient mode */
-    int i_gradient_type;
+    int color;
     bool b_cartoon;
 
     uint32_t *p_buf32;
@@ -183,15 +183,15 @@ static int Create( filter_t *p_filter )
     }
     free( psz_method );
 
-    p_sys->i_gradient_type =
-        var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "type" );
+    p_sys->color =
+        var_CreateGetBoolCommand( p_filter, FILTER_PREFIX "color" );
     p_sys->b_cartoon =
         var_CreateGetBoolCommand( p_filter, FILTER_PREFIX "cartoon" );
 
     vlc_mutex_init( &p_sys->lock );
     var_AddCallback( p_filter, FILTER_PREFIX "mode",
                      GradientCallback, p_sys );
-    var_AddCallback( p_filter, FILTER_PREFIX "type",
+    var_AddCallback( p_filter, FILTER_PREFIX "color",
                      GradientCallback, p_sys );
     var_AddCallback( p_filter, FILTER_PREFIX "cartoon",
                      GradientCallback, p_sys );
@@ -214,7 +214,7 @@ static void Destroy( filter_t *p_filter )
 
     var_DelCallback( p_filter, FILTER_PREFIX "mode",
                      GradientCallback, p_sys );
-    var_DelCallback( p_filter, FILTER_PREFIX "type",
+    var_DelCallback( p_filter, FILTER_PREFIX "color",
                      GradientCallback, p_sys );
     var_DelCallback( p_filter, FILTER_PREFIX "cartoon",
                      GradientCallback, p_sys );
@@ -381,7 +381,7 @@ static void FilterGradient( filter_t *p_filter, picture_t *p_inpic,
                     + ((int)p_smooth[(y + 1) * i_src_visible + x - 1] \
                      - (int)p_smooth[(y + 1) * i_src_visible + x + 1]));
 
-    if( p_sys->i_gradient_type )
+    if( p_sys->color )
     {
         if( p_sys->b_cartoon )
         {
@@ -751,9 +751,9 @@ static int GradientCallback( vlc_object_t *p_this, char const *psz_var,
             p_sys->i_mode = GRADIENT;
         }
     }
-    else if( !strcmp( psz_var, FILTER_PREFIX "type" ) )
+    else if( !strcmp( psz_var, FILTER_PREFIX "color" ) )
     {
-        p_sys->i_gradient_type = newval.i_int;
+        p_sys->color = newval.b_bool;
     }
     else if( !strcmp( psz_var, FILTER_PREFIX "cartoon" ) )
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2b3ad74b12eb4140e4bb01dc18ee96848d0d883f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/2b3ad74b12eb4140e4bb01dc18ee96848d0d883f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list