PIKApp/app/widgets/pikagradienteditor.h

127 lines
5.2 KiB
C
Raw Normal View History

2023-09-26 00:35:21 +02:00
/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Gradient editor module copyight (C) 1996-1997 Federico Mena Quintero
* federico@nuclecu.unam.mx
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __PIKA_GRADIENT_EDITOR_H__
#define __PIKA_GRADIENT_EDITOR_H__
#include "pikadataeditor.h"
#define GRAD_NUM_COLORS 10
typedef enum
{
GRAD_DRAG_NONE = 0,
GRAD_DRAG_LEFT,
GRAD_DRAG_MIDDLE,
GRAD_DRAG_ALL
} GradientEditorDragMode;
#define PIKA_TYPE_GRADIENT_EDITOR (pika_gradient_editor_get_type ())
#define PIKA_GRADIENT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_GRADIENT_EDITOR, PikaGradientEditor))
#define PIKA_GRADIENT_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_GRADIENT_EDITOR, PikaGradientEditorClass))
#define PIKA_IS_GRADIENT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_GRADIENT_EDITOR))
#define PIKA_IS_GRADIENT_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_GRADIENT_EDITOR))
#define PIKA_GRADIENT_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_GRADIENT_EDITOR, PikaGradientEditorClass))
typedef struct _PikaGradientEditorClass PikaGradientEditorClass;
struct _PikaGradientEditor
{
PikaDataEditor parent_instance;
GtkWidget *current_color;
GtkWidget *hint_label1;
GtkWidget *hint_label2;
GtkWidget *hint_label3;
GtkWidget *hint_label4;
GtkWidget *scrollbar;
GtkWidget *control;
/* Zoom and scrollbar */
gdouble zoom_factor;
GtkAdjustment *scroll_data;
GtkGesture *zoom_gesture;
gdouble last_zoom_scale;
/* Gradient view */
gint view_last_x; /* -1 if mouse has left focus */
gboolean view_button_down;
/* Gradient control */
PikaGradientSegment *control_drag_segment; /* Segment which is being dragged */
PikaGradientSegment *control_sel_l; /* Left segment of selection */
PikaGradientSegment *control_sel_r; /* Right segment of selection */
GradientEditorDragMode control_drag_mode; /* What is being dragged? */
guint32 control_click_time; /* Time when mouse was pressed */
gboolean control_compress; /* Compressing/expanding handles */
gint control_last_x; /* Last mouse position, -1 if out of focus */
gdouble control_last_gx; /* Last position (wrt gradient) when dragging */
gdouble control_orig_pos; /* Original click position when dragging */
PikaGradientBlendColorSpace blend_color_space;
/* Saved colors */
PikaRGB saved_colors[GRAD_NUM_COLORS];
/* Color dialog */
GtkWidget *color_dialog;
PikaGradientSegment *saved_segments;
gboolean saved_dirty;
};
struct _PikaGradientEditorClass
{
PikaDataEditorClass parent_class;
};
GType pika_gradient_editor_get_type (void) G_GNUC_CONST;
GtkWidget * pika_gradient_editor_new (PikaContext *context,
PikaMenuFactory *menu_factory);
void pika_gradient_editor_get_selection (PikaGradientEditor *editor,
PikaGradient **gradient,
PikaGradientSegment **left,
PikaGradientSegment **right);
void pika_gradient_editor_set_selection (PikaGradientEditor *editor,
PikaGradientSegment *left,
PikaGradientSegment *right);
void pika_gradient_editor_edit_left_color (PikaGradientEditor *editor);
void pika_gradient_editor_edit_right_color (PikaGradientEditor *editor);
void pika_gradient_editor_zoom (PikaGradientEditor *editor,
PikaZoomType zoom_type,
gdouble delta,
gdouble zoom_focus_x);
#endif /* __PIKA_GRADIENT_EDITOR_H__ */