gimp/libgimpwidgets/gimpscaleentry.h

80 lines
2.9 KiB
C
Raw Normal View History

/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpscaleentry.h
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>,
* 2008 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* 2020 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_WIDGETS_H_INSIDE__) && !defined (GIMP_WIDGETS_COMPILATION)
#error "Only <libgimpwidgets/gimpwidgets.h> can be included directly."
#endif
#include <libgimpwidgets/gimplabelspin.h>
#ifndef __GIMP_SCALE_ENTRY_H__
#define __GIMP_SCALE_ENTRY_H__
G_BEGIN_DECLS
#define GIMP_TYPE_SCALE_ENTRY (gimp_scale_entry_get_type ())
G_DECLARE_DERIVABLE_TYPE (GimpScaleEntry, gimp_scale_entry, GIMP, SCALE_ENTRY, GimpLabelSpin)
libgimpwidgets: make GimpScaleEntry into its own widget. Instead of the gimp_scale_entry_new() which creates several bound yet independant widgets, and in the same time pack them into an existing grid and return a GtkAdjustment (while heavily relying on GObject data to link widgets), let's have a proper custom widget with its own clean API. This also simplifies the gimp_prop_scale_entry_new() property widget variant. First advantage is that we don't force the usage of a grid to use this widget (there are a few pieces of code which create a GtkGrid with only this inside just to be able to use this feature). Second thing is that I am creating a much simpler API. gimp_scale_entry_new() had 17 parameters! How crazy is that? So I removed all the grid packing related parameters. Also I moved the spin button/scale unconstraining parameters into their separate function, because the constrained behavior is the most common use case, so it's stupid to add 3 permanent dummy parameters for most calls. Instead the few times where we'll want different ranges for the spin button and the scale, we'll call the separate API gimp_scale_entry_set_range(). Thirdly the tooltip can be set directly with gimp_help_set_help_data() since this is now its own widget. No need to have dedicated logics anymore, better stay generic. Similarly no need of a custom function to switch sensitivitivy (instead of generic gtk_widget_set_sensitive()). Fourth thing is that we should not use macros for the public API, but proper functions, because macros are not properly introspected for binding. For future improvements, maybe we could even make this widget implement GtkOrientable interface, in order to be able to use it vertically. Note: right now, I created a separate gimp_scale_entry_new2() and only modified the property widget API to use this new code. Eventually I will remove fully the old gimp_scale_entry_new() function (and the new code will replace it).
2020-10-30 07:30:03 +08:00
struct _GimpScaleEntryClass
{
GimpLabelSpinClass parent_class;
/* Signals */
void (* value_changed) (GimpScaleEntry *entry);
/* Class methods */
GtkWidget * (* new_range_widget) (GtkAdjustment *adjustment);
libgimpwidgets: make GimpScaleEntry into its own widget. Instead of the gimp_scale_entry_new() which creates several bound yet independant widgets, and in the same time pack them into an existing grid and return a GtkAdjustment (while heavily relying on GObject data to link widgets), let's have a proper custom widget with its own clean API. This also simplifies the gimp_prop_scale_entry_new() property widget variant. First advantage is that we don't force the usage of a grid to use this widget (there are a few pieces of code which create a GtkGrid with only this inside just to be able to use this feature). Second thing is that I am creating a much simpler API. gimp_scale_entry_new() had 17 parameters! How crazy is that? So I removed all the grid packing related parameters. Also I moved the spin button/scale unconstraining parameters into their separate function, because the constrained behavior is the most common use case, so it's stupid to add 3 permanent dummy parameters for most calls. Instead the few times where we'll want different ranges for the spin button and the scale, we'll call the separate API gimp_scale_entry_set_range(). Thirdly the tooltip can be set directly with gimp_help_set_help_data() since this is now its own widget. No need to have dedicated logics anymore, better stay generic. Similarly no need of a custom function to switch sensitivitivy (instead of generic gtk_widget_set_sensitive()). Fourth thing is that we should not use macros for the public API, but proper functions, because macros are not properly introspected for binding. For future improvements, maybe we could even make this widget implement GtkOrientable interface, in order to be able to use it vertically. Note: right now, I created a separate gimp_scale_entry_new2() and only modified the property widget API to use this new code. Eventually I will remove fully the old gimp_scale_entry_new() function (and the new code will replace it).
2020-10-30 07:30:03 +08:00
/* Padding for future expansion */
void (* _gimp_reserved1) (void);
void (* _gimp_reserved2) (void);
void (* _gimp_reserved3) (void);
void (* _gimp_reserved4) (void);
void (* _gimp_reserved5) (void);
void (* _gimp_reserved6) (void);
void (* _gimp_reserved7) (void);
void (* _gimp_reserved8) (void);
};
GtkWidget * gimp_scale_entry_new (const gchar *text,
libgimpwidgets: make GimpScaleEntry into its own widget. Instead of the gimp_scale_entry_new() which creates several bound yet independant widgets, and in the same time pack them into an existing grid and return a GtkAdjustment (while heavily relying on GObject data to link widgets), let's have a proper custom widget with its own clean API. This also simplifies the gimp_prop_scale_entry_new() property widget variant. First advantage is that we don't force the usage of a grid to use this widget (there are a few pieces of code which create a GtkGrid with only this inside just to be able to use this feature). Second thing is that I am creating a much simpler API. gimp_scale_entry_new() had 17 parameters! How crazy is that? So I removed all the grid packing related parameters. Also I moved the spin button/scale unconstraining parameters into their separate function, because the constrained behavior is the most common use case, so it's stupid to add 3 permanent dummy parameters for most calls. Instead the few times where we'll want different ranges for the spin button and the scale, we'll call the separate API gimp_scale_entry_set_range(). Thirdly the tooltip can be set directly with gimp_help_set_help_data() since this is now its own widget. No need to have dedicated logics anymore, better stay generic. Similarly no need of a custom function to switch sensitivitivy (instead of generic gtk_widget_set_sensitive()). Fourth thing is that we should not use macros for the public API, but proper functions, because macros are not properly introspected for binding. For future improvements, maybe we could even make this widget implement GtkOrientable interface, in order to be able to use it vertically. Note: right now, I created a separate gimp_scale_entry_new2() and only modified the property widget API to use this new code. Eventually I will remove fully the old gimp_scale_entry_new() function (and the new code will replace it).
2020-10-30 07:30:03 +08:00
gdouble value,
gdouble lower,
gdouble upper,
guint digits);
GtkWidget * gimp_scale_entry_get_range (GimpScaleEntry *entry);
libgimpwidgets: make GimpScaleEntry into its own widget. Instead of the gimp_scale_entry_new() which creates several bound yet independant widgets, and in the same time pack them into an existing grid and return a GtkAdjustment (while heavily relying on GObject data to link widgets), let's have a proper custom widget with its own clean API. This also simplifies the gimp_prop_scale_entry_new() property widget variant. First advantage is that we don't force the usage of a grid to use this widget (there are a few pieces of code which create a GtkGrid with only this inside just to be able to use this feature). Second thing is that I am creating a much simpler API. gimp_scale_entry_new() had 17 parameters! How crazy is that? So I removed all the grid packing related parameters. Also I moved the spin button/scale unconstraining parameters into their separate function, because the constrained behavior is the most common use case, so it's stupid to add 3 permanent dummy parameters for most calls. Instead the few times where we'll want different ranges for the spin button and the scale, we'll call the separate API gimp_scale_entry_set_range(). Thirdly the tooltip can be set directly with gimp_help_set_help_data() since this is now its own widget. No need to have dedicated logics anymore, better stay generic. Similarly no need of a custom function to switch sensitivitivy (instead of generic gtk_widget_set_sensitive()). Fourth thing is that we should not use macros for the public API, but proper functions, because macros are not properly introspected for binding. For future improvements, maybe we could even make this widget implement GtkOrientable interface, in order to be able to use it vertically. Note: right now, I created a separate gimp_scale_entry_new2() and only modified the property widget API to use this new code. Eventually I will remove fully the old gimp_scale_entry_new() function (and the new code will replace it).
2020-10-30 07:30:03 +08:00
void gimp_scale_entry_set_bounds (GimpScaleEntry *entry,
libgimpwidgets: make GimpScaleEntry into its own widget. Instead of the gimp_scale_entry_new() which creates several bound yet independant widgets, and in the same time pack them into an existing grid and return a GtkAdjustment (while heavily relying on GObject data to link widgets), let's have a proper custom widget with its own clean API. This also simplifies the gimp_prop_scale_entry_new() property widget variant. First advantage is that we don't force the usage of a grid to use this widget (there are a few pieces of code which create a GtkGrid with only this inside just to be able to use this feature). Second thing is that I am creating a much simpler API. gimp_scale_entry_new() had 17 parameters! How crazy is that? So I removed all the grid packing related parameters. Also I moved the spin button/scale unconstraining parameters into their separate function, because the constrained behavior is the most common use case, so it's stupid to add 3 permanent dummy parameters for most calls. Instead the few times where we'll want different ranges for the spin button and the scale, we'll call the separate API gimp_scale_entry_set_range(). Thirdly the tooltip can be set directly with gimp_help_set_help_data() since this is now its own widget. No need to have dedicated logics anymore, better stay generic. Similarly no need of a custom function to switch sensitivitivy (instead of generic gtk_widget_set_sensitive()). Fourth thing is that we should not use macros for the public API, but proper functions, because macros are not properly introspected for binding. For future improvements, maybe we could even make this widget implement GtkOrientable interface, in order to be able to use it vertically. Note: right now, I created a separate gimp_scale_entry_new2() and only modified the property widget API to use this new code. Eventually I will remove fully the old gimp_scale_entry_new() function (and the new code will replace it).
2020-10-30 07:30:03 +08:00
gdouble lower,
gdouble upper,
gboolean limit_scale);
void gimp_scale_entry_set_logarithmic (GimpScaleEntry *entry,
gboolean logarithmic);
gboolean gimp_scale_entry_get_logarithmic (GimpScaleEntry *entry);
G_END_DECLS
#endif /* __GIMP_SCALE_ENTRY_H__ */