1 /* 2 * Copyright (C) 2019-2020 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 /** 21 * \file 22 * 23 * ArrangerObject related functions for the GUI. 24 */ 25 26 #ifndef __GUI_WIDGETS_ARRANGER_OBJECT_H__ 27 #define __GUI_WIDGETS_ARRANGER_OBJECT_H__ 28 29 #include "gui/backend/arranger_object.h" 30 #include "utils/ui.h" 31 32 #include <gtk/gtk.h> 33 34 /** 35 * @addtogroup widgets 36 * 37 * @{ 38 */ 39 40 #define ARRANGER_OBJECT_FADE_POINT_WIDTH 12 41 #define ARRANGER_OBJECT_FADE_POINT_HALFWIDTH 6 42 43 /** 44 * Returns if the current position is for moving the 45 * fade in/out mark (timeline only). 46 * 47 * @param in True for fade in, false for fade out. 48 * @param x X in local coordinates. 49 * @param only_handle Whether to only check if this 50 * is inside the fade handle. If this is false, 51 * \ref only_outer will be considered. 52 * @param only_outer Whether to only check if this 53 * is inside the fade's outter (unplayed) region. 54 * If this is false, the whole fade area will 55 * be considered. 56 * @param check_lane Whether to check the lane 57 * region instead of the main one (if region). 58 */ 59 bool 60 arranger_object_is_fade ( 61 ArrangerObject * self, 62 bool in, 63 const int x, 64 int y, 65 bool only_handle, 66 bool only_outer, 67 bool check_lane); 68 69 #define arranger_object_is_fade_in( \ 70 self,x,y,only_handle,only_outer) \ 71 arranger_object_is_fade ( \ 72 self, true, x, y, only_handle, only_outer, \ 73 true) || \ 74 arranger_object_is_fade ( \ 75 self, true, x, y, only_handle, only_outer, \ 76 false) 77 78 #define arranger_object_is_fade_out( \ 79 self,x,y,only_handle,only_outer) \ 80 arranger_object_is_fade ( \ 81 self, false, x, y, only_handle, only_outer, \ 82 true) || \ 83 arranger_object_is_fade ( \ 84 self, false, x, y, only_handle, only_outer, \ 85 false) 86 87 /** 88 * Returns if the current position is for resizing 89 * L. 90 * 91 * @param x X in local coordinates. 92 */ 93 bool 94 arranger_object_is_resize_l ( 95 ArrangerObject * self, 96 const int x); 97 98 /** 99 * Returns if the current position is for resizing 100 * R. 101 * 102 * @param x X in local coordinates. 103 */ 104 bool 105 arranger_object_is_resize_r ( 106 ArrangerObject * self, 107 const int x); 108 109 /** 110 * Returns if the current position is for resizing 111 * up (eg, Velocity). 112 * 113 * @param x X in local coordinates. 114 * @param y Y in local coordinates. 115 */ 116 bool 117 arranger_object_is_resize_up ( 118 ArrangerObject * self, 119 const int x, 120 const int y); 121 122 /** 123 * Returns if the current position is for resizing 124 * loop. 125 * 126 * @param y Y in local coordinates. 127 */ 128 bool 129 arranger_object_is_resize_loop ( 130 ArrangerObject * self, 131 const int y); 132 133 /** 134 * Returns if the current position is for renaming 135 * the object. 136 * 137 * @param x X in local coordinates. 138 * @param y Y in local coordinates. 139 */ 140 bool 141 arranger_object_is_rename ( 142 ArrangerObject * self, 143 const int x, 144 const int y); 145 146 /** 147 * Returns if arranger_object widgets should show 148 * cut lines. 149 * 150 * To be used to set the arranger_object's 151 * "show_cut". 152 * 153 * @param alt_pressed Whether alt is currently 154 * pressed. 155 */ 156 bool 157 arranger_object_should_show_cut_lines ( 158 ArrangerObject * self, 159 bool alt_pressed); 160 161 /** 162 * Gets the full rectangle for a linked object. 163 */ 164 int 165 arranger_object_get_full_rect_x_for_region_child ( 166 ArrangerObject * self, 167 ZRegion * region, 168 GdkRectangle * full_rect); 169 170 void 171 arranger_object_set_full_rectangle ( 172 ArrangerObject * self, 173 ArrangerWidget * arranger); 174 175 /** 176 * Gets the draw rectangle based on the given 177 * full rectangle of the arranger object. 178 * 179 * @param parent_rect The current arranger 180 * rectangle. 181 * @param full_rect The object's full rectangle. 182 * This will usually be ArrangerObject->full_rect, 183 * unless drawing in a lane (for Region's). 184 * @param draw_rect The rectangle will be set 185 * here. 186 * 187 * @return Whether the draw rect is visible. 188 */ 189 int 190 arranger_object_get_draw_rectangle ( 191 ArrangerObject * self, 192 GdkRectangle * parent_rect, 193 GdkRectangle * full_rect, 194 GdkRectangle * draw_rect); 195 196 /** 197 * Draws the given object. 198 * 199 * To be called from the arranger's draw callback. 200 * 201 * @param cr Cairo context of the arranger. 202 * @param rect Rectangle in the arranger. 203 */ 204 void 205 arranger_object_draw ( 206 ArrangerObject * self, 207 ArrangerWidget * arranger, 208 cairo_t * cr, 209 GdkRectangle * rect); 210 211 /** 212 * Queues a redraw in the area covered by this 213 * object. 214 */ 215 void 216 arranger_object_queue_redraw ( 217 ArrangerObject * self); 218 219 /** 220 * @} 221 */ 222 223 #endif 224