1 /* 2 * Copyright (C) 2018-2019 Alexandros Theodotou <alex at zrythm dot org> 3 * 4 * This file is part of Zrythm 5 * 6 * Zrythm is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Zrythm is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with Zrythm. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __GUI_WIDGETS_COLOR_AREA_H__ 21 #define __GUI_WIDGETS_COLOR_AREA_H__ 22 23 /** 24 * \file 25 * 26 * Color picker for a channel strip. 27 */ 28 29 #include <gtk/gtk.h> 30 31 #define COLOR_AREA_WIDGET_TYPE \ 32 (color_area_widget_get_type ()) 33 G_DECLARE_FINAL_TYPE ( 34 ColorAreaWidget, 35 color_area_widget, 36 Z, COLOR_AREA_WIDGET, 37 GtkDrawingArea) 38 39 /** 40 * Type of ColorAreaWidget this is. */ 41 typedef enum ColorAreaType 42 { 43 /** Generic, only fill with color. */ 44 COLOR_AREA_TYPE_GENERIC, 45 46 /** 47 * Track, for use in TrackWidget implementations. 48 * 49 * It will show an icon and an index inside the 50 * color box. 51 */ 52 COLOR_AREA_TYPE_TRACK, 53 } ColorAreaType; 54 55 typedef struct Track Track; 56 57 typedef struct _ColorAreaWidget 58 { 59 GtkDrawingArea parent_instance; 60 61 /** Color pointer to set/read value. */ 62 GdkRGBA color; 63 64 /** The type. */ 65 ColorAreaType type; 66 67 /** Track, if track. */ 68 Track * track; 69 70 /** Set to 1 to redraw. */ 71 int redraw; 72 73 bool hovered; 74 75 cairo_t * cached_cr; 76 77 cairo_surface_t * cached_surface; 78 } ColorAreaWidget; 79 80 /** 81 * Creates a generic color widget using the given 82 * color pointer. 83 * 84 * FIXME currently not used, should be used instead 85 * of manually changing the color. 86 */ 87 void 88 color_area_widget_setup_generic ( 89 ColorAreaWidget * self, 90 GdkRGBA * color); 91 92 /** 93 * Creates a ColorAreaWidget for use inside 94 * TrackWidget implementations. 95 */ 96 void 97 color_area_widget_setup_track ( 98 ColorAreaWidget * self, 99 Track * track); 100 101 /** 102 * Changes the color. 103 * 104 * Track types don't need to do this since the 105 * color is read directly from the Track. 106 */ 107 void 108 color_area_widget_set_color ( 109 ColorAreaWidget * widget, 110 GdkRGBA * color); 111 112 #endif 113