| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  |  * 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 2 | 
					
						
							|  |  |  |  * 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, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup edinterface | 
					
						
							| 
									
										
										
										
											2011-02-27 20:29:51 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-15 23:24:20 +11:00
										 |  |  | /* a full doc with API notes can be found in
 | 
					
						
							|  |  |  |  * bf-blender/trunk/blender/doc/guides/interface_API.txt */ | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | #include <math.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #include <ctype.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "PIL_time.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_blenlib.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-10 20:43:45 +00:00
										 |  |  | #include "BLI_math.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-16 17:32:01 +10:00
										 |  |  | #include "BLT_translation.h"
 | 
					
						
							| 
									
										
										
										
											2011-11-09 14:13:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | #include "DNA_userdef_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BKE_context.h"
 | 
					
						
							|  |  |  | #include "BKE_screen.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | #include "BLF_api.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ED_screen.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-22 13:07:02 +11:00
										 |  |  | #include "UI_view2d.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | #include "UI_interface.h"
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | #include "UI_interface_icons.h"
 | 
					
						
							| 
									
										
										
										
											2011-11-19 20:57:53 +00:00
										 |  |  | #include "UI_resources.h"
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-10 01:33:56 -04:00
										 |  |  | #include "GPU_immediate.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | #include "GPU_state.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-10 01:33:56 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | #include "interface_intern.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /*********************** defines and structs ************************/ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | #define ANIMATION_TIME      0.30
 | 
					
						
							|  |  |  | #define ANIMATION_INTERVAL  0.02
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | #define PNL_LAST_ADDED      1
 | 
					
						
							|  |  |  | #define PNL_ACTIVE          2
 | 
					
						
							|  |  |  | #define PNL_WAS_ACTIVE      4
 | 
					
						
							|  |  |  | #define PNL_ANIM_ALIGN      8
 | 
					
						
							|  |  |  | #define PNL_NEW_ADDED       16
 | 
					
						
							|  |  |  | #define PNL_FIRST           32
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | /* only show pin header button for pinned panels */ | 
					
						
							|  |  |  | #define USE_PIN_HIDDEN
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | /* the state of the mouse position relative to the panel */ | 
					
						
							|  |  |  | typedef enum uiPanelMouseState { | 
					
						
							|  |  |  | 	PANEL_MOUSE_OUTSIDE,        /* mouse is not in the panel */ | 
					
						
							|  |  |  | 	PANEL_MOUSE_INSIDE_CONTENT, /* mouse is in the actual panel content */ | 
					
						
							|  |  |  | 	PANEL_MOUSE_INSIDE_HEADER,  /* mouse is in the panel header */ | 
					
						
							|  |  |  | 	PANEL_MOUSE_INSIDE_SCALE,   /* mouse is inside panel scale widget */ | 
					
						
							|  |  |  | } uiPanelMouseState; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | typedef enum uiHandlePanelState { | 
					
						
							|  |  |  | 	PANEL_STATE_DRAG, | 
					
						
							|  |  |  | 	PANEL_STATE_DRAG_SCALE, | 
					
						
							|  |  |  | 	PANEL_STATE_WAIT_UNTAB, | 
					
						
							|  |  |  | 	PANEL_STATE_ANIMATION, | 
					
						
							|  |  |  | 	PANEL_STATE_EXIT | 
					
						
							|  |  |  | } uiHandlePanelState; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct uiHandlePanelData { | 
					
						
							|  |  |  | 	uiHandlePanelState state; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* animation */ | 
					
						
							|  |  |  | 	wmTimer *animtimer; | 
					
						
							|  |  |  | 	double starttime; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* dragging */ | 
					
						
							|  |  |  | 	int startx, starty; | 
					
						
							|  |  |  | 	int startofsx, startofsy; | 
					
						
							|  |  |  | 	int startsizex, startsizey; | 
					
						
							|  |  |  | } uiHandlePanelData; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-12 10:11:32 +02:00
										 |  |  | static int get_panel_real_size_y(const Panel *pa); | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | static void panel_title_color_get(bool show_background, uchar color[4]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (show_background) { | 
					
						
							|  |  |  | 		UI_GetThemeColor4ubv(TH_TITLE, color); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* Use menu colors for floating panels. */ | 
					
						
							|  |  |  | 		bTheme *btheme = UI_GetTheme(); | 
					
						
							|  |  |  | 		const uiWidgetColors *wcol = &btheme->tui.wcol_menu_back; | 
					
						
							|  |  |  | 		copy_v4_v4_uchar(color, (const uchar *)wcol->text); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /*********************** space specific code ************************/ | 
					
						
							|  |  |  | /* temporary code to remove all sbuts stuff from panel code         */ | 
					
						
							| 
									
										
										
										
											2009-02-10 15:38:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-16 10:44:15 +11:00
										 |  |  | /* SpaceProperties.align */ | 
					
						
							| 
									
										
										
										
											2018-07-06 13:46:26 +02:00
										 |  |  | typedef enum eSpaceButtons_Align { | 
					
						
							|  |  |  | 	BUT_HORIZONTAL = 0, | 
					
						
							|  |  |  | 	BUT_VERTICAL = 1, | 
					
						
							|  |  |  | 	BUT_AUTO = 2, | 
					
						
							|  |  |  | } eSpaceButtons_Align; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-10 15:38:00 +00:00
										 |  |  | static int panel_aligned(ScrArea *sa, ARegion *ar) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) { | 
					
						
							| 
									
										
										
										
											2018-07-06 13:46:26 +02:00
										 |  |  | 		return BUT_VERTICAL; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) { | 
					
						
							| 
									
										
										
										
											2009-07-15 19:19:43 +00:00
										 |  |  | 		return BUT_VERTICAL; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) { | 
					
						
							| 
									
										
										
										
											2009-06-29 20:23:40 +00:00
										 |  |  | 		return BUT_VERTICAL; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) { | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | 		return BUT_VERTICAL; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HUD, RGN_TYPE_NAV_BAR, RGN_TYPE_EXECUTE)) { | 
					
						
							| 
									
										
										
										
											2009-02-10 15:38:00 +00:00
										 |  |  | 		return BUT_VERTICAL; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-10 15:38:00 +00:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, bool *no_animation) | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (Panel *pa = lb->first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 		/* Detect panel active flag changes. */ | 
					
						
							|  |  |  | 		if (!(pa->type && pa->type->parent)) { | 
					
						
							|  |  |  | 			if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) { | 
					
						
							|  |  |  | 				return true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE)) { | 
					
						
							|  |  |  | 				return true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if ((pa->runtime_flag & PNL_ACTIVE) && !(pa->flag & PNL_CLOSED)) { | 
					
						
							|  |  |  | 			if (panel_active_animation_changed(&pa->children, pa_animation, no_animation)) { | 
					
						
							|  |  |  | 				return true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Detect animation. */ | 
					
						
							|  |  |  | 		if (pa->activedata) { | 
					
						
							|  |  |  | 			uiHandlePanelData *data = pa->activedata; | 
					
						
							|  |  |  | 			if (data->state == PANEL_STATE_ANIMATION) { | 
					
						
							|  |  |  | 				*pa_animation = pa; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				/* Don't animate while handling other interaction. */ | 
					
						
							|  |  |  | 				*no_animation = true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if ((pa->runtime_flag & PNL_ANIM_ALIGN) && !(*pa_animation)) { | 
					
						
							|  |  |  | 			*pa_animation = pa; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | static bool panels_need_realign(ScrArea *sa, ARegion *ar, Panel **r_pa_animate) | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | 	*r_pa_animate = NULL; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-16 10:44:15 +11:00
										 |  |  | 	if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) { | 
					
						
							|  |  |  | 		SpaceProperties *sbuts = sa->spacedata.first; | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 13:46:26 +02:00
										 |  |  | 		if (sbuts->mainbo != sbuts->mainb) { | 
					
						
							|  |  |  | 			return true; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	/* Detect if a panel was added or removed. */ | 
					
						
							|  |  |  | 	Panel *pa_animation = NULL; | 
					
						
							|  |  |  | 	bool no_animation = false; | 
					
						
							|  |  |  | 	if (panel_active_animation_changed(&ar->panels, &pa_animation, &no_animation)) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	/* Detect panel marked for animation, if we're not already animating. */ | 
					
						
							|  |  |  | 	if (pa_animation) { | 
					
						
							|  |  |  | 		if (!no_animation) { | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | 			*r_pa_animate = pa_animation; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /****************************** panels ******************************/ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-02 12:15:09 +11:00
										 |  |  | static void panels_collapse_all(ScrArea *sa, ARegion *ar, const Panel *from_pa) | 
					
						
							| 
									
										
										
										
											2012-05-28 00:02:24 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-03-02 12:15:09 +11:00
										 |  |  | 	const bool has_category_tabs = UI_panel_category_is_visible(ar); | 
					
						
							|  |  |  | 	const char *category = has_category_tabs ? UI_panel_category_active_get(ar, false) : NULL; | 
					
						
							|  |  |  | 	const int flag = ((panel_aligned(sa, ar) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY); | 
					
						
							|  |  |  | 	const PanelType *from_pt = from_pa->type; | 
					
						
							| 
									
										
										
										
											2012-06-04 20:11:09 +00:00
										 |  |  | 	Panel *pa; | 
					
						
							| 
									
										
										
										
											2012-05-28 00:02:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-05 21:54:21 +00:00
										 |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							| 
									
										
										
										
											2014-03-02 12:15:09 +11:00
										 |  |  | 		PanelType *pt = pa->type; | 
					
						
							| 
									
										
										
										
											2012-12-18 14:46:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* close panels with headers in the same context */ | 
					
						
							| 
									
										
										
										
											2014-02-05 13:39:39 +01:00
										 |  |  | 		if (pt && from_pt && !(pt->flag & PNL_NO_HEADER)) { | 
					
						
							| 
									
										
										
										
											2014-03-02 12:15:09 +11:00
										 |  |  | 			if (!pt->context[0] || !from_pt->context[0] || STREQ(pt->context, from_pt->context)) { | 
					
						
							|  |  |  | 				if ((pa->flag & PNL_PIN) || !category || !pt->category[0] || STREQ(pt->category, category)) { | 
					
						
							| 
									
										
										
										
											2014-02-24 19:52:34 +01:00
										 |  |  | 					pa->flag &= ~PNL_CLOSED; | 
					
						
							|  |  |  | 					pa->flag |= flag; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-02-05 13:39:39 +01:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-06-04 20:11:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-05-28 00:02:24 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | static void ui_panel_copy_offset(Panel *pa, Panel *papar) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	/* with respect to sizes... papar is parent */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	pa->ofsx = papar->ofsx; | 
					
						
							|  |  |  | 	pa->ofsy = papar->ofsy + papar->sizey - pa->sizey; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 14:20:03 +10:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * XXX Disabled paneltab handling for now. Old 2.4x feature, *DO NOT* confuse it with new tool tabs in 2.70. ;) | 
					
						
							|  |  |  |  * See also T41704. | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | /* #define UI_USE_PANELTAB */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | Panel *UI_panel_find_by_type(ListBase *lb, PanelType *pt) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	Panel *pa; | 
					
						
							|  |  |  | 	const char *idname = pt->idname; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | #ifdef UI_USE_PANELTAB
 | 
					
						
							|  |  |  | 	const char *tabname = pt->idname; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (pa = lb->first; pa; pa = pa->next) { | 
					
						
							| 
									
										
										
										
											2014-05-03 04:16:04 +10:00
										 |  |  | 		if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) { | 
					
						
							| 
									
										
										
										
											2014-08-27 11:57:05 +10:00
										 |  |  | 			if (STREQLEN(pa->tabname, tabname, sizeof(pa->tabname))) { | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 				return pa; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (pa = lb->first; pa; pa = pa->next) { | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | 		if (STREQLEN(pa->panelname, idname, sizeof(pa->panelname))) { | 
					
						
							|  |  |  | 			return pa; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  |  * \note \a pa should be return value from #UI_panel_find_by_type and can be NULL. | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, PanelType *pt, Panel *pa, bool *r_open) | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | 	Panel *palast, *panext; | 
					
						
							| 
									
										
										
										
											2013-03-15 14:32:29 +00:00
										 |  |  | 	const char *drawname = CTX_IFACE_(pt->translation_context, pt->label); | 
					
						
							| 
									
										
										
										
											2014-04-27 00:22:49 +10:00
										 |  |  | 	const char *idname = pt->idname; | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | #ifdef UI_USE_PANELTAB
 | 
					
						
							|  |  |  | 	const char *tabname = pt->idname; | 
					
						
							| 
									
										
										
										
											2014-04-27 00:22:49 +10:00
										 |  |  | 	const char *hookname = NULL; | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	const bool newpanel = (pa == NULL); | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	int align = panel_aligned(sa, ar); | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!newpanel) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		pa->type = pt; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* new panel */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		pa = MEM_callocN(sizeof(Panel), "new panel"); | 
					
						
							|  |  |  | 		pa->type = pt; | 
					
						
							| 
									
										
										
										
											2014-05-03 04:16:04 +10:00
										 |  |  | 		BLI_strncpy(pa->panelname, idname, sizeof(pa->panelname)); | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (pt->flag & PNL_DEFAULT_CLOSED) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			if (align == BUT_VERTICAL) { | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 				pa->flag |= PNL_CLOSEDY; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 				pa->flag |= PNL_CLOSEDX; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		pa->ofsx = 0; | 
					
						
							|  |  |  | 		pa->ofsy = 0; | 
					
						
							|  |  |  | 		pa->sizex = 0; | 
					
						
							|  |  |  | 		pa->sizey = 0; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		pa->blocksizex = 0; | 
					
						
							|  |  |  | 		pa->blocksizey = 0; | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 		pa->runtime_flag |= PNL_NEW_ADDED; | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		BLI_addtail(lb, pa); | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef UI_USE_PANELTAB
 | 
					
						
							|  |  |  | 		BLI_strncpy(pa->tabname, tabname, sizeof(pa->tabname)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 		/* make new Panel tabbed? */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (hookname) { | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | 			Panel *patab; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 			for (patab = lb->first; patab; patab = patab->next) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab == NULL) { | 
					
						
							| 
									
										
										
										
											2014-05-03 04:16:04 +10:00
										 |  |  | 					if (STREQLEN(hookname, patab->panelname, sizeof(patab->panelname))) { | 
					
						
							|  |  |  | 						if (STREQLEN(tabname, patab->tabname, sizeof(patab->tabname))) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 							pa->paneltab = patab; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 							ui_panel_copy_offset(pa, patab); | 
					
						
							|  |  |  | 							break; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-09-04 14:38:29 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 		BLI_strncpy(pa->tabname, idname, sizeof(pa->tabname)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-28 08:58:20 +00:00
										 |  |  | 	/* Do not allow closed panels without headers! Else user could get "disappeared" UI! */ | 
					
						
							|  |  |  | 	if ((pt->flag & PNL_NO_HEADER) && (pa->flag & PNL_CLOSED)) { | 
					
						
							|  |  |  | 		pa->flag &= ~PNL_CLOSED; | 
					
						
							|  |  |  | 		/* Force update of panels' positions! */ | 
					
						
							|  |  |  | 		pa->sizex = 0; | 
					
						
							|  |  |  | 		pa->sizey = 0; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		pa->blocksizex = 0; | 
					
						
							|  |  |  | 		pa->blocksizey = 0; | 
					
						
							| 
									
										
										
										
											2013-01-28 08:58:20 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-15 05:11:14 +00:00
										 |  |  | 	BLI_strncpy(pa->drawname, drawname, sizeof(pa->drawname)); | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 	/* if a new panel is added, we insert it right after the panel
 | 
					
						
							|  |  |  | 	 * that was last added. this way new panels are inserted in the | 
					
						
							|  |  |  | 	 * right place between versions */ | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (palast = lb->first; palast; palast = palast->next) { | 
					
						
							|  |  |  | 		if (palast->runtime_flag & PNL_LAST_ADDED) { | 
					
						
							|  |  |  | 			BLI_remlink(lb, pa); | 
					
						
							|  |  |  | 			BLI_insertlinkafter(lb, palast, pa); | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (newpanel) { | 
					
						
							| 
									
										
										
										
											2013-12-18 15:10:40 +01:00
										 |  |  | 		pa->sortorder = (palast) ? palast->sortorder + 1 : 0; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		for (panext = lb->first; panext; panext = panext->next) { | 
					
						
							|  |  |  | 			if (panext != pa && panext->sortorder >= pa->sortorder) { | 
					
						
							| 
									
										
										
										
											2009-04-17 13:37:03 +00:00
										 |  |  | 				panext->sortorder++; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (palast) { | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 		palast->runtime_flag &= ~PNL_LAST_ADDED; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	/* assign to block */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	block->panel = pa; | 
					
						
							|  |  |  | 	pa->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED; | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | 	if (ar->alignment == RGN_ALIGN_FLOAT) { | 
					
						
							|  |  |  | 		UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	*r_open = false; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (pa->paneltab) { | 
					
						
							|  |  |  | 		return pa; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (pa->flag & PNL_CLOSED) { | 
					
						
							|  |  |  | 		return pa; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-05-19 17:13:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	*r_open = true; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	return pa; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | void UI_panel_end(uiBlock *block, int width, int height) | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	Panel *pa = block->panel; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	/* Set panel size excluding children. */ | 
					
						
							|  |  |  | 	pa->blocksizex = width; | 
					
						
							|  |  |  | 	pa->blocksizey = height; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Compute total panel size including children. */ | 
					
						
							|  |  |  | 	for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) { | 
					
						
							|  |  |  | 		if (pachild->runtime_flag & PNL_ACTIVE) { | 
					
						
							|  |  |  | 			width = max_ii(width, pachild->sizex); | 
					
						
							|  |  |  | 			height += get_panel_real_size_y(pachild); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Update total panel size. */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (pa->runtime_flag & PNL_NEW_ADDED) { | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 		pa->runtime_flag &= ~PNL_NEW_ADDED; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		pa->sizex = width; | 
					
						
							|  |  |  | 		pa->sizey = height; | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-07-15 22:58:34 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		/* check if we need to do an animation */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) { | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 			pa->runtime_flag |= PNL_ANIM_ALIGN; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			if (height != 0) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				pa->ofsy += pa->sizey - height; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-15 22:58:34 +00:00
										 |  |  | 		/* update width/height if non-zero */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (width != 0) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			pa->sizex = width; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if (height != 0) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			pa->sizey = height; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-06-16 01:08:39 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-19 17:13:33 +00:00
										 |  |  | static void ui_offset_panel_block(uiBlock *block) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 	uiStyle *style = UI_style_get_dpi(); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-20 14:46:49 +00:00
										 |  |  | 	/* compute bounds and offset */ | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 	ui_block_bounds_calc(block); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	int ofsy = block->panel->sizey - style->panelspace; | 
					
						
							| 
									
										
										
										
											2009-05-20 14:46:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (uiBut *but = block->buttons.first; but; but = but->next) { | 
					
						
							| 
									
										
										
										
											2012-08-18 16:53:46 +00:00
										 |  |  | 		but->rect.ymin += ofsy; | 
					
						
							|  |  |  | 		but->rect.ymax += ofsy; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-18 16:53:46 +00:00
										 |  |  | 	block->rect.xmax = block->panel->sizex; | 
					
						
							|  |  |  | 	block->rect.ymax = block->panel->sizey; | 
					
						
							|  |  |  | 	block->rect.xmin = block->rect.ymin = 0.0; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /**************************** drawing *******************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | /* triangle 'icon' for panel header */ | 
					
						
							| 
									
										
										
										
											2017-02-14 13:00:22 +01:00
										 |  |  | void UI_draw_icon_tri(float x, float y, char dir, const float color[4]) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-25 12:53:15 +02:00
										 |  |  | 	float f3 = 0.05 * U.widget_unit; | 
					
						
							|  |  |  | 	float f5 = 0.15 * U.widget_unit; | 
					
						
							|  |  |  | 	float f7 = 0.25 * U.widget_unit; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	if (dir == 'h') { | 
					
						
							| 
									
										
										
										
											2018-04-22 19:02:17 +02:00
										 |  |  | 		UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	else if (dir == 't') { | 
					
						
							| 
									
										
										
										
											2018-04-22 19:02:17 +02:00
										 |  |  | 		UI_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3, color); | 
					
						
							| 
									
										
										
											
												Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
  - name "Undo History"
  - hotkey alt+ctrl+z (alt+apple+z for mac)
  - works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
  - for small windows or screens, popup menus now allow to display
    all items, using internal scrolling
  - works with a timer, scrolling 10 items per second when mouse 
    is over the top or bottom arrow
  - if menu is too big to display, it now draws to top or bottom, 
    based on largest available space.
  - also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
  - widgets & headers now become bigger and smaller, to match 
    'dpi' font sizes. Works well to match UI to monitor size.
  - note that icons can get fuzzy, we need better mipmaps for it
											
										 
											2011-06-04 17:03:46 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { /* 'v' = vertical, down */ | 
					
						
							| 
									
										
										
										
											2018-04-22 19:02:17 +02:00
										 |  |  | 		UI_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7, color); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | static void ui_draw_anti_x(uint pos, float x1, float y1, float x2, float y2) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* set antialias line */ | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_line_smooth(true); | 
					
						
							|  |  |  | 	GPU_blend(true); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_line_width(2.0); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	immBegin(GPU_PRIM_LINES, 4); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	immVertex2f(pos, x1, y1); | 
					
						
							|  |  |  | 	immVertex2f(pos, x2, y2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immVertex2f(pos, x1, y2); | 
					
						
							|  |  |  | 	immVertex2f(pos, x2, y1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immEnd(); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_line_smooth(false); | 
					
						
							|  |  |  | 	GPU_blend(false); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* x 'icon' for panel header */ | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | static void ui_draw_x_icon(uint pos, float x, float y) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	ui_draw_anti_x(pos, x, y, x + 9.375f, y + 9.375f); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | #define PNL_ICON    UI_UNIT_X  /* could be UI_UNIT_Y too */
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | static void ui_draw_panel_scalewidget(uint pos, const rcti *rect) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float xmin, xmax, dx; | 
					
						
							|  |  |  | 	float ymin, ymax, dy; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	xmin = rect->xmax - PNL_HEADER + 2; | 
					
						
							|  |  |  | 	xmax = rect->xmax - 3; | 
					
						
							|  |  |  | 	ymin = rect->ymin + 3; | 
					
						
							|  |  |  | 	ymax = rect->ymin + PNL_HEADER - 2; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	dx = 0.5f * (xmax - xmin); | 
					
						
							|  |  |  | 	dy = 0.5f * (ymax - ymin); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_blend(true); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	immUniformColor4ub(255, 255, 255, 50); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	immBegin(GPU_PRIM_LINES, 4); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	immVertex2f(pos, xmin, ymin); | 
					
						
							|  |  |  | 	immVertex2f(pos, xmax, ymax); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immVertex2f(pos, xmin + dx, ymin); | 
					
						
							|  |  |  | 	immVertex2f(pos, xmax, ymax - dy); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immEnd(); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:50:35 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	immUniformColor4ub(0, 0, 0, 50); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	immBegin(GPU_PRIM_LINES, 4); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	immVertex2f(pos, xmin, ymin + 1); | 
					
						
							|  |  |  | 	immVertex2f(pos, xmax, ymax + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immVertex2f(pos, xmin + dx, ymin + 1); | 
					
						
							|  |  |  | 	immVertex2f(pos, xmax, ymax - dy + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immEnd(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_blend(false); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-01 20:15:21 +02:00
										 |  |  | static void immRectf_tris_color_ex( | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  |         uint pos, float x1, float y1, float x2, float y2, | 
					
						
							|  |  |  |         uint col, const float color[3]) | 
					
						
							| 
									
										
										
										
											2009-04-08 16:51:35 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 	immAttr4fv(col, color); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immVertex2f(pos, x1, y1); | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 	immAttr4fv(col, color); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immVertex2f(pos, x2, y1); | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 	immAttr4fv(col, color); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immVertex2f(pos, x2, y2); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 	immAttr4fv(col, color); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immVertex2f(pos, x1, y1); | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 	immAttr4fv(col, color); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immVertex2f(pos, x2, y2); | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 	immAttr4fv(col, color); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immVertex2f(pos, x1, y2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | static void ui_draw_panel_dragwidget(uint pos, uint col, const rctf *rect) | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	float col_high[4], col_dark[4]; | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 	const int col_tint = 84; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const int px = (int)U.pixelsize; | 
					
						
							| 
									
										
										
										
											2017-09-27 11:13:03 +10:00
										 |  |  | 	const int px_zoom = max_ii(round_fl_to_int(BLI_rctf_size_y(rect) / 22.0f), 1); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-27 11:13:03 +10:00
										 |  |  | 	const int box_margin = max_ii(round_fl_to_int((float)(px_zoom * 2.0f)), px); | 
					
						
							|  |  |  | 	const int box_size = max_ii(round_fl_to_int((BLI_rctf_size_y(rect) / 8.0f) - px), px); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	const int x_min = rect->xmin; | 
					
						
							|  |  |  | 	const int y_min = rect->ymin; | 
					
						
							| 
									
										
										
										
											2018-11-03 04:10:48 +01:00
										 |  |  | 	const int y_ofs = max_ii(round_fl_to_int(BLI_rctf_size_y(rect) / 2.5f), px); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 	const int x_ofs = y_ofs; | 
					
						
							|  |  |  | 	int i_x, i_y; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 	UI_GetThemeColorShade4fv(TH_PANEL_HEADER,  col_tint, col_high); | 
					
						
							|  |  |  | 	UI_GetThemeColorShade4fv(TH_PANEL_BACK, -col_tint, col_dark); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* draw multiple boxes */ | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	immBegin(GPU_PRIM_TRIS, 4 * 2 * (6 * 2)); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 	for (i_x = 0; i_x < 4; i_x++) { | 
					
						
							|  |  |  | 		for (i_y = 0; i_y < 2; i_y++) { | 
					
						
							|  |  |  | 			const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin)); | 
					
						
							|  |  |  | 			const int y_co = (y_min + y_ofs) + (i_y * (box_size + box_margin)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-01 20:15:21 +02:00
										 |  |  | 			immRectf_tris_color_ex( | 
					
						
							|  |  |  | 			        pos, x_co - box_size, y_co - px_zoom, x_co, (y_co + box_size) - px_zoom, | 
					
						
							|  |  |  | 			        col, col_dark); | 
					
						
							|  |  |  | 			immRectf_tris_color_ex( | 
					
						
							|  |  |  | 			        pos, x_co - box_size, y_co, x_co, y_co + box_size, | 
					
						
							|  |  |  | 			        col, col_high); | 
					
						
							| 
									
										
										
										
											2014-07-28 14:57:39 +10:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 	immEnd(); | 
					
						
							| 
									
										
										
										
											2009-04-08 16:51:35 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | /* For button layout next to label. */ | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | void UI_panel_label_offset(uiBlock *block, int *r_x, int *r_y) | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	Panel *panel = block->panel; | 
					
						
							|  |  |  | 	const bool is_subpanel = (panel->type && panel->type->parent); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | 	*r_x = UI_UNIT_X * 1.0f; | 
					
						
							|  |  |  | 	*r_y = UI_UNIT_Y * 1.5f; | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (is_subpanel) { | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | 		*r_x += (0.7f * UI_UNIT_X); | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-08 16:51:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | static void ui_draw_aligned_panel_header( | 
					
						
							|  |  |  |         uiStyle *style, uiBlock *block, const rcti *rect, char dir, | 
					
						
							|  |  |  |         const bool show_background) | 
					
						
							| 
									
										
										
										
											2009-04-08 16:51:35 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	Panel *panel = block->panel; | 
					
						
							| 
									
										
										
										
											2009-04-09 18:11:18 +00:00
										 |  |  | 	rcti hrect; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	int pnl_icons; | 
					
						
							| 
									
										
										
										
											2013-03-15 14:32:29 +00:00
										 |  |  | 	const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname; | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 	const bool is_subpanel = (panel->type && panel->type->parent); | 
					
						
							|  |  |  | 	uiFontStyle *fontstyle = (is_subpanel) ? &style->widgetlabel : &style->paneltitle; | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 	uchar col_title[4]; | 
					
						
							| 
									
										
										
										
											2011-09-15 13:20:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-19 17:13:33 +00:00
										 |  |  | 	/* + 0.001f to avoid flirting with float inaccuracy */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (panel->control & UI_PNL_CLOSE) { | 
					
						
							| 
									
										
										
										
											2019-01-14 15:02:21 +01:00
										 |  |  | 		pnl_icons = (panel->labelofs + (2.0f * PNL_ICON)) / block->aspect + 0.001f; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2019-01-14 15:02:21 +01:00
										 |  |  | 		pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-02-10 00:00:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-19 03:54:30 +00:00
										 |  |  | 	/* draw text label */ | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 	panel_title_color_get(show_background, col_title); | 
					
						
							| 
									
										
										
										
											2017-04-05 10:59:46 +02:00
										 |  |  | 	col_title[3] = 255; | 
					
						
							| 
									
										
										
										
											2017-02-10 00:00:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	hrect = *rect; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (dir == 'h') { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		hrect.xmin = rect->xmin + pnl_icons; | 
					
						
							| 
									
										
										
										
											2019-01-14 15:02:21 +01:00
										 |  |  | 		hrect.ymin -= 2.0f / block->aspect; | 
					
						
							| 
									
										
										
										
											2019-01-04 09:58:03 +11:00
										 |  |  | 		UI_fontstyle_draw( | 
					
						
							|  |  |  | 		        fontstyle, &hrect, activename, col_title, | 
					
						
							|  |  |  | 		        &(struct uiFontStyleDraw_Params) { .align = UI_STYLE_TEXT_LEFT, }); | 
					
						
							| 
									
										
										
										
											2009-04-08 16:51:35 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-19 03:54:30 +00:00
										 |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 		/* ignore 'pnl_icons', otherwise the text gets offset horizontally
 | 
					
						
							| 
									
										
										
										
											2009-10-19 03:54:30 +00:00
										 |  |  | 		 * + 0.001f to avoid flirting with float inaccuracy | 
					
						
							|  |  |  | 		 */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f; | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 		UI_fontstyle_draw_rotated(fontstyle, &hrect, activename, col_title); | 
					
						
							| 
									
										
										
										
											2009-04-08 16:51:35 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
  can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
  reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
  shows the last operator, if appropriate.
  Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
  (See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types. 
  Currently colors are defined for Window, Header, List/Channels and
  for Button/Tool views. 
  The screen manager handles this btw, so a TH_BACK will always pick the
  right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
  the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
  Only Panel font, widget font and widget-label work now. The 'group label'
  will be for templates mostly.
  Style settings will be expanded with spacing defaults, label conventions, 
  etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
  Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
											
										 
											2009-04-27 13:44:11 +00:00
										 |  |  | /* panel integrated in buttonswindow, tool/property lists etc */ | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | void ui_draw_aligned_panel( | 
					
						
							|  |  |  |         uiStyle *style, uiBlock *block, const rcti *rect, | 
					
						
							|  |  |  |         const bool show_pin, const bool show_background) | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	Panel *panel = block->panel; | 
					
						
							| 
									
										
										
										
											2009-04-12 13:40:29 +00:00
										 |  |  | 	rcti headrect; | 
					
						
							|  |  |  | 	rctf itemrect; | 
					
						
							| 
									
										
										
										
											2017-02-06 15:19:45 +01:00
										 |  |  | 	float color[4]; | 
					
						
							| 
									
										
										
										
											2015-05-31 14:30:25 +02:00
										 |  |  | 	const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false; | 
					
						
							|  |  |  | 	const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	const bool is_subpanel = (panel->type && panel->type->parent); | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | 	const bool show_drag = ( | 
					
						
							|  |  |  | 	        !is_subpanel && | 
					
						
							|  |  |  | 	        /* FIXME(campbell): currently no background means floating panel which can't be dragged.
 | 
					
						
							|  |  |  | 	         * This may be changed in future. */ | 
					
						
							|  |  |  | 	        show_background); | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (panel->paneltab) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (panel->type && (panel->type->flag & PNL_NO_HEADER)) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 13:40:29 +00:00
										 |  |  | 	/* calculate header rect */ | 
					
						
							| 
									
										
										
										
											2009-05-19 17:13:33 +00:00
										 |  |  | 	/* + 0.001f to prevent flicker due to float inaccuracy */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	headrect = *rect; | 
					
						
							| 
									
										
										
										
											2012-03-24 02:51:46 +00:00
										 |  |  | 	headrect.ymin = headrect.ymax; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f); | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 	rcti titlerect = headrect; | 
					
						
							|  |  |  | 	if (is_subpanel) { | 
					
						
							| 
									
										
										
										
											2019-01-14 19:32:58 +01:00
										 |  |  | 		titlerect.xmin += (0.7f * UI_UNIT_X); | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | 	if (show_background && !is_subpanel) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		float minx = rect->xmin; | 
					
						
							| 
									
										
										
										
											2015-05-31 14:30:25 +02:00
										 |  |  | 		float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		float y = headrect.ymax; | 
					
						
							| 
									
										
										
										
											2011-11-19 20:57:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(true); | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 		/* draw with background color */ | 
					
						
							|  |  |  | 		immUniformThemeColor(TH_PANEL_HEADER); | 
					
						
							|  |  |  | 		immRectf(pos, minx, headrect.ymin, maxx, y); | 
					
						
							| 
									
										
										
										
											2011-11-19 20:57:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 		immBegin(GPU_PRIM_LINES, 4); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 		immVertex2f(pos, minx, y); | 
					
						
							|  |  |  | 		immVertex2f(pos, maxx, y); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 		immVertex2f(pos, minx, y); | 
					
						
							|  |  |  | 		immVertex2f(pos, maxx, y); | 
					
						
							| 
									
										
										
										
											2017-02-23 02:52:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 		immEnd(); | 
					
						
							| 
									
										
										
										
											2011-11-19 20:57:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(false); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	immUnbindProgram(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	/* draw optional pin icon */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_PIN_HIDDEN
 | 
					
						
							|  |  |  | 	if (show_pin && (block->panel->flag & PNL_PIN)) | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 	if (show_pin) | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 		uchar col_title[4]; | 
					
						
							|  |  |  | 		panel_title_color_get(show_background, col_title); | 
					
						
							| 
									
										
										
										
											2018-09-27 18:25:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(true); | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 		UI_icon_draw_aspect( | 
					
						
							|  |  |  | 		        headrect.xmax - ((PNL_ICON * 2.2f) / block->aspect), headrect.ymin + (5.0f / block->aspect), | 
					
						
							|  |  |  | 		        (panel->flag & PNL_PIN) ? ICON_PINNED : ICON_UNPINNED, | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 		        (block->aspect / UI_DPI_FAC), 1.0f, (const char *)col_title); | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(false); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-19 03:54:30 +00:00
										 |  |  | 	/* horizontal title */ | 
					
						
							| 
									
										
										
										
											2015-05-31 14:30:25 +02:00
										 |  |  | 	if (is_closed_x == false) { | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 		ui_draw_aligned_panel_header(style, block, &titlerect, 'h', show_background); | 
					
						
							| 
									
										
										
										
											2018-03-28 00:00:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		if (show_drag) { | 
					
						
							| 
									
										
										
										
											2018-07-08 12:48:04 +02:00
										 |  |  | 			uint col; | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 			GPUVertFormat *format = immVertexFormat(); | 
					
						
							|  |  |  | 			pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | 
					
						
							|  |  |  | 			col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* itemrect smaller */ | 
					
						
							| 
									
										
										
										
											2019-01-14 15:02:21 +01:00
										 |  |  | 			itemrect.xmax = headrect.xmax - (0.2f * UI_UNIT_X); | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 			itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect); | 
					
						
							|  |  |  | 			itemrect.ymin = headrect.ymin; | 
					
						
							|  |  |  | 			itemrect.ymax = headrect.ymax; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			BLI_rctf_scale(&itemrect, 0.7f); | 
					
						
							|  |  |  | 			immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); | 
					
						
							|  |  |  | 			ui_draw_panel_dragwidget(pos, col, &itemrect); | 
					
						
							|  |  |  | 			immUnbindProgram(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* Restore format for the following draws. */ | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 			pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	/* if the panel is minimized vertically:
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	 * (------) | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2015-05-31 14:30:25 +02:00
										 |  |  | 	if (is_closed_y) { | 
					
						
							|  |  |  | 		/* skip */ | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-05-31 14:30:25 +02:00
										 |  |  | 	else if (is_closed_x) { | 
					
						
							| 
									
										
										
										
											2009-10-19 03:54:30 +00:00
										 |  |  | 		/* draw vertical title */ | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 		ui_draw_aligned_panel_header(style, block, &headrect, 'v', show_background); | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 		pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	/* an open panel */ | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* in some occasions, draw a border */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (panel->flag & PNL_SELECT) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			if (panel->control & UI_PNL_SOLID) { | 
					
						
							|  |  |  | 				UI_draw_roundbox_corner_set(UI_CNR_ALL); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				UI_draw_roundbox_corner_set(UI_CNR_NONE); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-06 15:19:45 +01:00
										 |  |  | 			UI_GetThemeColorShade4fv(TH_BACK, -120, color); | 
					
						
							| 
									
										
										
										
											2017-04-06 19:15:26 -04:00
										 |  |  | 			UI_draw_roundbox_aa(false, 0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8, color); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 		GPU_blend(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | 		if (show_background) { | 
					
						
							|  |  |  | 			/* panel backdrop */ | 
					
						
							|  |  |  | 			int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK; | 
					
						
							| 
									
										
										
										
											2018-07-10 00:47:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | 			immUniformThemeColor(panel_col); | 
					
						
							|  |  |  | 			immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (panel->control & UI_PNL_SCALE) { | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			ui_draw_panel_scalewidget(pos, rect); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		immUnbindProgram(); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	uchar col_title[4]; | 
					
						
							|  |  |  | 	panel_title_color_get(show_background, col_title); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	/* draw optional close icon */ | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (panel->control & UI_PNL_CLOSE) { | 
					
						
							| 
									
										
										
										
											2017-04-04 15:39:38 -04:00
										 |  |  | 		const int ofsx = 6; | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 		immUniformColor3ubv(col_title); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		ui_draw_x_icon(pos, rect->xmin + 2 + ofsx, rect->ymax + 2); | 
					
						
							|  |  |  | 		immUnbindProgram(); | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | 	/* draw collapse icon */ | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 	/* itemrect smaller */ | 
					
						
							| 
									
										
										
										
											2019-01-14 15:02:21 +01:00
										 |  |  | 	itemrect.xmin = titlerect.xmin; | 
					
						
							| 
									
										
										
										
											2018-06-06 13:28:40 +02:00
										 |  |  | 	itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&titlerect); | 
					
						
							|  |  |  | 	itemrect.ymin = titlerect.ymin; | 
					
						
							|  |  |  | 	itemrect.ymax = titlerect.ymax; | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-24 11:23:00 +02:00
										 |  |  | 	BLI_rctf_scale(&itemrect, 0.25f); | 
					
						
							| 
									
										
										
										
											2013-06-24 12:18:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-05 23:30:53 +02:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		float tria_color[4]; | 
					
						
							| 
									
										
										
										
											2018-12-19 13:09:05 +11:00
										 |  |  | 		rgb_uchar_to_float(tria_color, col_title); | 
					
						
							| 
									
										
										
										
											2018-07-05 23:30:53 +02:00
										 |  |  | 		tria_color[3] = 1.0f; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (is_closed_y) { | 
					
						
							| 
									
										
										
										
											2018-07-05 23:30:53 +02:00
										 |  |  | 			ui_draw_anti_tria_rect(&itemrect, 'h', tria_color); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (is_closed_x) { | 
					
						
							| 
									
										
										
										
											2018-07-05 23:30:53 +02:00
										 |  |  | 			ui_draw_anti_tria_rect(&itemrect, 'h', tria_color); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2018-07-05 23:30:53 +02:00
										 |  |  | 			ui_draw_anti_tria_rect(&itemrect, 'v', tria_color); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-05 23:30:53 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-02 15:01:11 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /************************** panel alignment *************************/ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-12 10:11:32 +02:00
										 |  |  | static int get_panel_header(const Panel *pa) | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return PNL_HEADER; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-12 10:11:32 +02:00
										 |  |  | static int get_panel_size_y(const Panel *pa) | 
					
						
							| 
									
										
										
										
											2009-07-09 19:45:27 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { | 
					
						
							| 
									
										
										
										
											2009-07-09 19:45:27 +00:00
										 |  |  | 		return pa->sizey; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-07-09 19:45:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-19 20:57:53 +00:00
										 |  |  | 	return PNL_HEADER + pa->sizey; | 
					
						
							| 
									
										
										
										
											2009-07-09 19:45:27 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-12 10:11:32 +02:00
										 |  |  | static int get_panel_real_size_y(const Panel *pa) | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	int sizey = (pa->flag & PNL_CLOSED) ? 0 : pa->sizey; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (pa->type && (pa->type->flag & PNL_NO_HEADER)) { | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		return sizey; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return PNL_HEADER + sizey; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-12 10:11:32 +02:00
										 |  |  | int UI_panel_size_y(const Panel *pa) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return get_panel_real_size_y(pa); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-18 07:38:51 +00:00
										 |  |  | /* this function is needed because uiBlock and Panel itself don't
 | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  |  * change sizey or location when closed */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | static int get_panel_real_ofsy(Panel *pa) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (pa->flag & PNL_CLOSEDY) { | 
					
						
							|  |  |  | 		return pa->ofsy + pa->sizey; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) { | 
					
						
							|  |  |  | 		return pa->ofsy + pa->sizey; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (pa->paneltab) { | 
					
						
							|  |  |  | 		return pa->paneltab->ofsy; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return pa->ofsy; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int get_panel_real_ofsx(Panel *pa) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (pa->flag & PNL_CLOSEDX) { | 
					
						
							|  |  |  | 		return pa->ofsx + get_panel_header(pa); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) { | 
					
						
							|  |  |  | 		return pa->ofsx + get_panel_header(pa); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return pa->ofsx + pa->sizex; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct PanelSort { | 
					
						
							|  |  |  | 	Panel *pa, *orig; | 
					
						
							|  |  |  | } PanelSort; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 14:20:03 +10:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * \note about sorting; | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  |  * the sortorder has a lower value for new panels being added. | 
					
						
							|  |  |  |  * however, that only works to insert a single panel, when more new panels get | 
					
						
							| 
									
										
										
										
											2012-03-04 04:35:12 +00:00
										 |  |  |  * added the coordinates of existing panels and the previously stored to-be-inserted | 
					
						
							| 
									
										
										
										
											2015-05-31 14:20:03 +10:00
										 |  |  |  * panels do not match for sorting | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static int find_leftmost_panel(const void *a1, const void *a2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	const PanelSort *ps1 = a1, *ps2 = a2; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (ps1->pa->ofsx > ps2->pa->ofsx) { | 
					
						
							|  |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->ofsx < ps2->pa->ofsx) { | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->sortorder > ps2->pa->sortorder) { | 
					
						
							|  |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->sortorder < ps2->pa->sortorder) { | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int find_highest_panel(const void *a1, const void *a2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	const PanelSort *ps1 = a1, *ps2 = a2; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-09 07:55:49 +00:00
										 |  |  | 	/* stick uppermost header-less panels to the top of the region -
 | 
					
						
							| 
									
										
										
										
											2015-01-13 03:29:25 +01:00
										 |  |  | 	 * prevent them from being sorted (multiple header-less panels have to be sorted though) */ | 
					
						
							|  |  |  | 	if (ps1->pa->type->flag & PNL_NO_HEADER && ps2->pa->type->flag & PNL_NO_HEADER) { | 
					
						
							|  |  |  | 		/* skip and check for ofs and sortorder below */ | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	else if (ps1->pa->type->flag & PNL_NO_HEADER) { | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps2->pa->type->flag & PNL_NO_HEADER) { | 
					
						
							|  |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-01-13 03:29:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) { | 
					
						
							|  |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) { | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->sortorder > ps2->pa->sortorder) { | 
					
						
							|  |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->sortorder < ps2->pa->sortorder) { | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int compare_panel(const void *a1, const void *a2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	const PanelSort *ps1 = a1, *ps2 = a2; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (ps1->pa->sortorder > ps2->pa->sortorder) { | 
					
						
							|  |  |  | 		return 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (ps1->pa->sortorder < ps2->pa->sortorder) { | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | static void align_sub_panels(Panel *pa) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* Position sub panels. */ | 
					
						
							|  |  |  | 	int ofsy = get_panel_real_ofsy(pa) + pa->sizey - pa->blocksizey; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) { | 
					
						
							|  |  |  | 		if (pachild->runtime_flag & PNL_ACTIVE) { | 
					
						
							|  |  |  | 			pachild->ofsx = pa->ofsx; | 
					
						
							|  |  |  | 			pachild->ofsy = ofsy - get_panel_size_y(pachild); | 
					
						
							|  |  |  | 			ofsy -= get_panel_real_size_y(pachild); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (pachild->children.first) { | 
					
						
							|  |  |  | 				align_sub_panels(pachild); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 15:49:59 +02:00
										 |  |  | /* this doesn't draw */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | /* returns 1 when it did something */ | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bool drag) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Panel *pa; | 
					
						
							|  |  |  | 	PanelSort *ps, *panelsort, *psnext; | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | 	int a, tot = 0; | 
					
						
							|  |  |  | 	bool done; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	int align = panel_aligned(sa, ar); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	bool has_category_tabs = UI_panel_category_is_visible(ar); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	/* count active, not tabbed panels */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 		if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) { | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 			tot++; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (tot == 0) { | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* extra; change close direction? */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 		if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 				pa->flag ^= PNL_CLOSED; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 				pa->flag ^= PNL_CLOSED; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	/* sort panels */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort"); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	ps = panelsort; | 
					
						
							|  |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 		if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) { | 
					
						
							|  |  |  | 			ps->pa = MEM_dupallocN(pa); | 
					
						
							|  |  |  | 			ps->orig = pa; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			ps++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (drag) { | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 		/* while we are dragging, we sort on location and update sortorder */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (align == BUT_VERTICAL) { | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 			qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 			qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		for (ps = panelsort, a = 0; a < tot; a++, ps++) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			ps->orig->sortorder = a; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2009-04-17 11:59:25 +00:00
										 |  |  | 		/* otherwise use sortorder */ | 
					
						
							|  |  |  | 		qsort(panelsort, tot, sizeof(PanelSort), compare_panel); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	/* no smart other default start loc! this keeps switching f5/f6/etc compatible */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	ps = panelsort; | 
					
						
							|  |  |  | 	ps->pa->ofsx = 0; | 
					
						
							|  |  |  | 	ps->pa->ofsy = -get_panel_size_y(ps->pa); | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	if (has_category_tabs) { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 		if (align == BUT_VERTICAL && (ar->alignment != RGN_ALIGN_RIGHT)) { | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			ps->pa->ofsx += UI_PANEL_CATEGORY_MARGIN_WIDTH; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	for (a = 0; a < tot - 1; a++, ps++) { | 
					
						
							|  |  |  | 		psnext = ps + 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (align == BUT_VERTICAL) { | 
					
						
							|  |  |  | 			psnext->pa->ofsx = ps->pa->ofsx; | 
					
						
							|  |  |  | 			psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			psnext->pa->ofsx = get_panel_real_ofsx(ps->pa); | 
					
						
							|  |  |  | 			psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	/* we interpolate */ | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | 	done = false; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	ps = panelsort; | 
					
						
							|  |  |  | 	for (a = 0; a < tot; a++, ps++) { | 
					
						
							|  |  |  | 		if ((ps->pa->flag & PNL_SELECT) == 0) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { | 
					
						
							| 
									
										
										
										
											2017-09-27 11:13:03 +10:00
										 |  |  | 				ps->orig->ofsx = round_fl_to_int(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx); | 
					
						
							|  |  |  | 				ps->orig->ofsy = round_fl_to_int(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy); | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | 				done = true; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	/* set locations for tabbed and sub panels */ | 
					
						
							|  |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 		if (pa->runtime_flag & PNL_ACTIVE) { | 
					
						
							|  |  |  | 			if (pa->paneltab) { | 
					
						
							|  |  |  | 				ui_panel_copy_offset(pa, pa->paneltab); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (pa->children.first) { | 
					
						
							|  |  |  | 				align_sub_panels(pa); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* free panelsort array */ | 
					
						
							| 
									
										
										
										
											2012-01-21 22:00:40 +00:00
										 |  |  | 	for (ps = panelsort, a = 0; a < tot; a++, ps++) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		MEM_freeN(ps->pa); | 
					
						
							| 
									
										
										
										
											2012-01-21 22:00:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	MEM_freeN(panelsort); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	return done; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | static void ui_panels_size(ScrArea *sa, ARegion *ar, int *r_x, int *r_y) | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	Panel *pa; | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	int align = panel_aligned(sa, ar); | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | 	int sizex = 0; | 
					
						
							|  |  |  | 	int sizey = 0; | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* compute size taken up by panels, for setting in view2d */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (pa->runtime_flag & PNL_ACTIVE) { | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | 			int pa_sizex, pa_sizey; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			if (align == BUT_VERTICAL) { | 
					
						
							|  |  |  | 				pa_sizex = pa->ofsx + pa->sizex; | 
					
						
							|  |  |  | 				pa_sizey = get_panel_real_ofsy(pa); | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				pa_sizex = get_panel_real_ofsx(pa) + pa->sizex; | 
					
						
							|  |  |  | 				pa_sizey = pa->ofsy + get_panel_size_y(pa); | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-24 05:06:40 +00:00
										 |  |  | 			sizex = max_ii(sizex, pa_sizex); | 
					
						
							|  |  |  | 			sizey = min_ii(sizey, pa_sizey); | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (sizex == 0) { | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | 		sizex = UI_PANEL_WIDTH; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (sizey == 0) { | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | 		sizey = -UI_PANEL_WIDTH; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | 	*r_x = sizex; | 
					
						
							|  |  |  | 	*r_y = sizey; | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | static void ui_do_animate(const bContext *C, Panel *panel) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	uiHandlePanelData *data = panel->activedata; | 
					
						
							|  |  |  | 	ScrArea *sa = CTX_wm_area(C); | 
					
						
							|  |  |  | 	ARegion *ar = CTX_wm_region(C); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	float fac; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME; | 
					
						
							| 
									
										
										
										
											2014-03-28 14:53:37 +11:00
										 |  |  | 	fac = min_ff(sqrtf(fac), 1.0f); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* for max 1 second, interpolate positions */ | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | 	if (uiAlignPanelStep(sa, ar, fac, false)) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		ED_region_tag_redraw(ar); | 
					
						
							| 
									
										
										
										
											2012-07-29 16:59:51 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		fac = 1.0f; | 
					
						
							| 
									
										
										
										
											2012-07-29 16:59:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (fac >= 1.0f) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		panel_activate_state(C, panel, PANEL_STATE_EXIT); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | static void panel_list_clear_active(ListBase *lb) | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 	/* set all panels as inactive, so that at the end we know
 | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 	 * which ones were used */ | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (Panel *pa = lb->first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 		if (pa->runtime_flag & PNL_ACTIVE) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			pa->runtime_flag = PNL_WAS_ACTIVE; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			pa->runtime_flag = 0; | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		panel_list_clear_active(&pa->children); | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | void UI_panels_begin(const bContext *UNUSED(C), ARegion *ar) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	panel_list_clear_active(&ar->panels); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | /* only draws blocks with panels */ | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | void UI_panels_end(const bContext *C, ARegion *ar, int *r_x, int *r_y) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	ScrArea *sa = CTX_wm_area(C); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	uiBlock *block; | 
					
						
							| 
									
										
										
										
											2009-06-19 23:11:41 +00:00
										 |  |  | 	Panel *panot, *panew, *patest, *pa, *firstpa; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-20 14:46:49 +00:00
										 |  |  | 	/* offset contents */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	for (block = ar->uiblocks.first; block; block = block->next) { | 
					
						
							|  |  |  | 		if (block->active && block->panel) { | 
					
						
							| 
									
										
										
										
											2009-05-19 17:13:33 +00:00
										 |  |  | 			ui_offset_panel_block(block); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-06 04:35:57 +00:00
										 |  |  | 	/* consistency; are panels not made, whilst they have tabs */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	for (panot = ar->panels.first; panot; panot = panot->next) { | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | 		if ((panot->runtime_flag & PNL_ACTIVE) == 0) {  /* not made */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			for (panew = ar->panels.first; panew; panew = panew->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if ((panew->runtime_flag & PNL_ACTIVE)) { | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | 					if (panew->paneltab == panot) {  /* panew is tab in notmade pa */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			/* now panew can become the new parent, check all other tabs */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (panew) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				for (patest = ar->panels.first; patest; patest = patest->next) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (patest->paneltab == panot) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 						patest->paneltab = panew; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				panot->paneltab = panew; | 
					
						
							|  |  |  | 				panew->paneltab = NULL; | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | 				ED_region_tag_redraw(ar); /* the buttons panew were not made */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	/* re-align, possibly with animation */ | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	if (panels_need_realign(sa, ar, &pa)) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (pa) { | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 			panel_activate_state(C, pa, PANEL_STATE_ANIMATION); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | 			uiAlignPanelStep(sa, ar, 1.0, false); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-19 23:11:41 +00:00
										 |  |  | 	/* tag first panel */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	firstpa = NULL; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	for (block = ar->uiblocks.first; block; block = block->next) { | 
					
						
							|  |  |  | 		if (block->active && block->panel) { | 
					
						
							|  |  |  | 			if (!firstpa || block->panel->sortorder < firstpa->sortorder) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				firstpa = block->panel; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (firstpa) { | 
					
						
							| 
									
										
										
										
											2009-06-19 23:11:41 +00:00
										 |  |  | 		firstpa->runtime_flag |= PNL_FIRST; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | 	/* compute size taken up by panel */ | 
					
						
							| 
									
										
										
										
											2019-03-25 12:19:55 +11:00
										 |  |  | 	ui_panels_size(sa, ar, r_x, r_y); | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | void UI_panels_draw(const bContext *C, ARegion *ar) | 
					
						
							| 
									
										
										
										
											2011-11-20 14:31:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	uiBlock *block; | 
					
						
							| 
									
										
										
										
											2009-06-19 23:11:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 11:22:08 +10:00
										 |  |  | 	if (ar->alignment != RGN_ALIGN_FLOAT) { | 
					
						
							|  |  |  | 		UI_ThemeClearColor(TH_BACK); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	/* Draw panels, selected on top. Also in reverse order, because
 | 
					
						
							|  |  |  | 	 * UI blocks are added in reverse order and we need child panels | 
					
						
							|  |  |  | 	 * to draw on top. */ | 
					
						
							|  |  |  | 	for (block = ar->uiblocks.last; block; block = block->prev) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) { | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 			UI_block_draw(C, block); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	for (block = ar->uiblocks.last; block; block = block->prev) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) { | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 			UI_block_draw(C, block); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | void UI_panels_scale(ARegion *ar, float new_width) | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	uiBlock *block; | 
					
						
							|  |  |  | 	uiBut *but; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | 	for (block = ar->uiblocks.first; block; block = block->next) { | 
					
						
							|  |  |  | 		if (block->panel) { | 
					
						
							|  |  |  | 			float fac = new_width / (float)block->panel->sizex; | 
					
						
							|  |  |  | 			block->panel->sizex = new_width; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-26 13:05:39 +00:00
										 |  |  | 			for (but = block->buttons.first; but; but = but->next) { | 
					
						
							|  |  |  | 				but->rect.xmin *= fac; | 
					
						
							|  |  |  | 				but->rect.xmax *= fac; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | /* ------------ panel merging ---------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void check_panel_overlap(ARegion *ar, Panel *panel) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Panel *pa; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-27 19:40:36 +00:00
										 |  |  | 	/* also called with (panel == NULL) for clear */ | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		pa->flag &= ~PNL_OVERLAP; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (panel && (pa != panel)) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) { | 
					
						
							|  |  |  | 				float safex = 0.2, safey = 0.2; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				if (pa->flag & PNL_CLOSEDX) { | 
					
						
							|  |  |  | 					safex = 0.05; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else if (pa->flag & PNL_CLOSEDY) { | 
					
						
							|  |  |  | 					safey = 0.05; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else if (panel->flag & PNL_CLOSEDX) { | 
					
						
							|  |  |  | 					safex = 0.05; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else if (panel->flag & PNL_CLOSEDY) { | 
					
						
							|  |  |  | 					safey = 0.05; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				if (pa->ofsx > panel->ofsx - safex * panel->sizex) { | 
					
						
							|  |  |  | 					if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex) { | 
					
						
							|  |  |  | 						if (pa->ofsy > panel->ofsy - safey * panel->sizey) { | 
					
						
							|  |  |  | 							if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 								pa->flag |= PNL_OVERLAP; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /************************ panel dragging ****************************/ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-01 01:01:20 +00:00
										 |  |  | static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	uiHandlePanelData *data = panel->activedata; | 
					
						
							|  |  |  | 	ScrArea *sa = CTX_wm_area(C); | 
					
						
							|  |  |  | 	ARegion *ar = CTX_wm_region(C); | 
					
						
							|  |  |  | 	short align = panel_aligned(sa, ar), dx = 0, dy = 0; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	/* first clip for window, no dragging outside */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	dx = (event->x - data->startx) & ~(PNL_GRID - 1); | 
					
						
							|  |  |  | 	dy = (event->y - data->starty) & ~(PNL_GRID - 1); | 
					
						
							| 
									
										
										
										
											2009-07-23 20:50:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-15 11:48:20 +00:00
										 |  |  | 	dx *= (float)BLI_rctf_size_x(&ar->v2d.cur) / (float)BLI_rcti_size_x(&ar->winrct); | 
					
						
							|  |  |  | 	dy *= (float)BLI_rctf_size_y(&ar->v2d.cur) / (float)BLI_rcti_size_y(&ar->winrct); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (data->state == PANEL_STATE_DRAG_SCALE) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (data->startsizey - dy < UI_PANEL_MINY) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			dy = -UI_PANEL_MINY + data->startsizey; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		panel->sizey = data->startsizey - dy; | 
					
						
							|  |  |  | 		panel->ofsy = data->startofsy + dy; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* reset the panel snapping, to allow dragging away from snapped edges */ | 
					
						
							|  |  |  | 		panel->snap = PNL_SNAP_NONE; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		panel->ofsx = data->startofsx + dx; | 
					
						
							|  |  |  | 		panel->ofsy = data->startofsy + dy; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		check_panel_overlap(ar, panel); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (align) { | 
					
						
							|  |  |  | 			uiAlignPanelStep(sa, ar, 0.2, true); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ED_region_tag_redraw(ar); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /******************* region level panel interaction *****************/ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | static uiPanelMouseState ui_panel_mouse_state_get(const uiBlock *block, const Panel *pa, const int mx, const int my) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* open panel */ | 
					
						
							|  |  |  | 	if (pa->flag & PNL_CLOSEDX) { | 
					
						
							|  |  |  | 		if ((block->rect.xmin <= mx) && (block->rect.xmin + PNL_HEADER >= mx)) { | 
					
						
							|  |  |  | 			return PANEL_MOUSE_INSIDE_HEADER; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* outside left/right side */ | 
					
						
							|  |  |  | 	else if ((block->rect.xmin > mx) || (block->rect.xmax < mx)) { | 
					
						
							|  |  |  | 		/* pass */ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { | 
					
						
							|  |  |  | 		return PANEL_MOUSE_INSIDE_HEADER; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* open panel */ | 
					
						
							|  |  |  | 	else if (!(pa->flag & PNL_CLOSEDY)) { | 
					
						
							|  |  |  | 		if (pa->control & UI_PNL_SCALE) { | 
					
						
							|  |  |  | 			if (block->rect.xmax - PNL_HEADER <= mx) { | 
					
						
							|  |  |  | 				if (block->rect.ymin + PNL_HEADER >= my) { | 
					
						
							|  |  |  | 					return PANEL_MOUSE_INSIDE_SCALE; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if ((block->rect.xmin <= mx) && (block->rect.xmax >= mx)) { | 
					
						
							|  |  |  | 			if ((block->rect.ymin <= my) && (block->rect.ymax + PNL_HEADER >= my)) { | 
					
						
							|  |  |  | 				return PANEL_MOUSE_INSIDE_CONTENT; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return PANEL_MOUSE_OUTSIDE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct uiPanelDragCollapseHandle { | 
					
						
							|  |  |  | 	bool was_first_open; | 
					
						
							|  |  |  | 	int xy_init[2]; | 
					
						
							|  |  |  | } uiPanelDragCollapseHandle; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void ui_panel_drag_collapse_handler_remove(bContext *UNUSED(C), void *userdata) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	uiPanelDragCollapseHandle *dragcol_data = userdata; | 
					
						
							|  |  |  | 	MEM_freeN(dragcol_data); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void ui_panel_drag_collapse(bContext *C, uiPanelDragCollapseHandle *dragcol_data, const int xy_dst[2]) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ScrArea *sa = CTX_wm_area(C); | 
					
						
							|  |  |  | 	ARegion *ar = CTX_wm_region(C); | 
					
						
							|  |  |  | 	uiBlock *block; | 
					
						
							|  |  |  | 	Panel *pa; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (block = ar->uiblocks.first; block; block = block->next) { | 
					
						
							|  |  |  | 		float xy_a_block[2] = {UNPACK2(dragcol_data->xy_init)}; | 
					
						
							|  |  |  | 		float xy_b_block[2] = {UNPACK2(xy_dst)}; | 
					
						
							|  |  |  | 		rctf rect = block->rect; | 
					
						
							|  |  |  | 		int oldflag; | 
					
						
							|  |  |  | 		const bool is_horizontal = (panel_aligned(sa, ar) == BUT_HORIZONTAL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if ((pa = block->panel) == 0 || (pa->type && (pa->type->flag & PNL_NO_HEADER))) { | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		oldflag = pa->flag; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* lock one axis */ | 
					
						
							|  |  |  | 		if (is_horizontal) { | 
					
						
							|  |  |  | 			xy_b_block[1] = dragcol_data->xy_init[1]; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			xy_b_block[0] = dragcol_data->xy_init[0]; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* use cursor coords in block space */ | 
					
						
							|  |  |  | 		ui_window_to_block_fl(ar, block, &xy_a_block[0], &xy_a_block[1]); | 
					
						
							|  |  |  | 		ui_window_to_block_fl(ar, block, &xy_b_block[0], &xy_b_block[1]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* set up rect to match header size */ | 
					
						
							|  |  |  | 		rect.ymin = rect.ymax; | 
					
						
							|  |  |  | 		rect.ymax = rect.ymin + PNL_HEADER; | 
					
						
							|  |  |  | 		if (pa->flag & PNL_CLOSEDX) { | 
					
						
							|  |  |  | 			rect.xmax = rect.xmin + PNL_HEADER; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* touch all panels between last mouse coord and the current one */ | 
					
						
							|  |  |  | 		if (BLI_rctf_isect_segment(&rect, xy_a_block, xy_b_block)) { | 
					
						
							|  |  |  | 			/* force panel to close */ | 
					
						
							|  |  |  | 			if (dragcol_data->was_first_open == true) { | 
					
						
							|  |  |  | 				pa->flag |= (is_horizontal ? PNL_CLOSEDX : PNL_CLOSEDY); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			/* force panel to open */ | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				pa->flag &= ~PNL_CLOSED; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* if pa->flag has changed this means a panel was opened/closed here */ | 
					
						
							|  |  |  | 			if (pa->flag != oldflag) { | 
					
						
							|  |  |  | 				panel_activate_state(C, pa, PANEL_STATE_ANIMATION); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Panel drag-collapse (modal handler) | 
					
						
							|  |  |  |  * Clicking and dragging over panels toggles their collapse state based on the panel that was first | 
					
						
							| 
									
										
										
										
											2018-09-27 15:35:22 +02:00
										 |  |  |  * dragged over. If it was open all affected panels incl the initial one are closed and vice versa. | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  |  */ | 
					
						
							|  |  |  | static int ui_panel_drag_collapse_handler(bContext *C, const wmEvent *event, void *userdata) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							|  |  |  | 	uiPanelDragCollapseHandle *dragcol_data = userdata; | 
					
						
							|  |  |  | 	short retval = WM_UI_HANDLER_CONTINUE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch (event->type) { | 
					
						
							|  |  |  | 		case MOUSEMOVE: | 
					
						
							|  |  |  | 			ui_panel_drag_collapse(C, dragcol_data, &event->x); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			retval = WM_UI_HANDLER_BREAK; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case LEFTMOUSE: | 
					
						
							|  |  |  | 			if (event->val == KM_RELEASE) { | 
					
						
							|  |  |  | 				/* done! */ | 
					
						
							|  |  |  | 				WM_event_remove_ui_handler( | 
					
						
							|  |  |  | 				        &win->modalhandlers, | 
					
						
							|  |  |  | 				        ui_panel_drag_collapse_handler, | 
					
						
							|  |  |  | 				        ui_panel_drag_collapse_handler_remove, | 
					
						
							|  |  |  | 				        dragcol_data, true); | 
					
						
							|  |  |  | 				ui_panel_drag_collapse_handler_remove(C, dragcol_data); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			/* don't let any left-mouse event fall through! */ | 
					
						
							|  |  |  | 			retval = WM_UI_HANDLER_BREAK; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return retval; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was_open) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							| 
									
										
										
										
											2017-10-14 17:29:54 +11:00
										 |  |  | 	const wmEvent *event = win->eventstate; | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 	uiPanelDragCollapseHandle *dragcol_data = MEM_mallocN(sizeof(*dragcol_data), __func__); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dragcol_data->was_first_open = was_open; | 
					
						
							|  |  |  | 	copy_v2_v2_int(dragcol_data->xy_init, &event->x); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WM_event_add_ui_handler( | 
					
						
							|  |  |  | 	        C, &win->modalhandlers, | 
					
						
							|  |  |  | 	        ui_panel_drag_collapse_handler, | 
					
						
							|  |  |  | 	        ui_panel_drag_collapse_handler_remove, | 
					
						
							| 
									
										
										
										
											2015-06-01 16:40:43 +10:00
										 |  |  | 	        dragcol_data, 0); | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* this function is supposed to call general window drawing too */ | 
					
						
							| 
									
										
										
										
											2012-03-18 07:38:51 +00:00
										 |  |  | /* also it supposes a block has panel, and isn't a menu */ | 
					
						
							| 
									
										
										
										
											2014-01-06 03:00:54 +11:00
										 |  |  | static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	ScrArea *sa = CTX_wm_area(C); | 
					
						
							|  |  |  | 	ARegion *ar = CTX_wm_region(C); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	Panel *pa; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | #ifdef USE_PIN_HIDDEN
 | 
					
						
							|  |  |  | 	const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->flag & PNL_PIN); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 	const bool show_pin = UI_panel_category_is_visible(ar); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	const bool is_subpanel = (block->panel->type && block->panel->type->parent); | 
					
						
							|  |  |  | 	const bool show_drag = !is_subpanel; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	int align = panel_aligned(sa, ar), button = 0; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	rctf rect_drag, rect_pin; | 
					
						
							|  |  |  | 	float rect_leftmost; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* drag and pin rect's */ | 
					
						
							|  |  |  | 	rect_drag = block->rect; | 
					
						
							|  |  |  | 	rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f); | 
					
						
							|  |  |  | 	rect_pin = rect_drag; | 
					
						
							|  |  |  | 	if (show_pin) { | 
					
						
							|  |  |  | 		BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	rect_leftmost = rect_pin.xmin; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	/* mouse coordinates in panel space! */ | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 13:40:29 +00:00
										 |  |  | 	/* XXX weak code, currently it assumes layout style for location of widgets */ | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	/* check open/collapsed button */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (event == RETKEY) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		button = 1; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else if (event == AKEY) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		button = 1; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-07-20 01:30:29 +10:00
										 |  |  | 	else if (ELEM(event, 0, RETKEY, LEFTMOUSE) && shift) { | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		block->panel->flag ^= PNL_PIN; | 
					
						
							|  |  |  | 		button = 2; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (block->panel->flag & PNL_CLOSEDX) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (my >= block->rect.ymax) { | 
					
						
							|  |  |  | 			button = 1; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (block->panel->control & UI_PNL_CLOSE) { | 
					
						
							| 
									
										
										
										
											2011-01-12 02:15:38 +00:00
										 |  |  | 		/* whole of header can be used to collapse panel (except top-right corner) */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (mx <= block->rect.xmax - 8 - PNL_ICON) { | 
					
						
							|  |  |  | 			button = 2; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		//else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {
 | 
					
						
							|  |  |  | 		//	button = 1;
 | 
					
						
							|  |  |  | 		//}
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	else if (mx < rect_leftmost) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		button = 1; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (button) { | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | 		if (button == 2) {  /* close */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			ED_region_tag_redraw(ar); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | 		else {  /* collapse */ | 
					
						
							| 
									
										
										
										
											2015-04-12 08:03:46 +02:00
										 |  |  | 			if (ctrl) { | 
					
						
							| 
									
										
										
										
											2012-12-18 14:46:00 +00:00
										 |  |  | 				panels_collapse_all(sa, ar, block->panel); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-12 08:03:46 +02:00
										 |  |  | 				/* reset the view - we don't want to display a view without content */ | 
					
						
							|  |  |  | 				UI_view2d_offset(&ar->v2d, 0.0f, 1.0f); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (block->panel->flag & PNL_CLOSED) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 				block->panel->flag &= ~PNL_CLOSED; | 
					
						
							|  |  |  | 				/* snap back up so full panel aligns with screen edge */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				if (block->panel->snap & PNL_SNAP_BOTTOM) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 					block->panel->ofsy = 0; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				if (event == LEFTMOUSE) { | 
					
						
							|  |  |  | 					ui_panel_drag_collapse_handler_add(C, false); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			else if (align == BUT_HORIZONTAL) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 				block->panel->flag |= PNL_CLOSEDX; | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				if (event == LEFTMOUSE) { | 
					
						
							|  |  |  | 					ui_panel_drag_collapse_handler_add(C, true); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 				/* snap down to bottom screen edge */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 				block->panel->flag |= PNL_CLOSEDY; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				if (block->panel->snap & PNL_SNAP_BOTTOM) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 					block->panel->ofsy = -block->panel->sizey; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				if (event == LEFTMOUSE) { | 
					
						
							|  |  |  | 					ui_panel_drag_collapse_handler_add(C, true); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			for (pa = ar->panels.first; pa; pa = pa->next) { | 
					
						
							|  |  |  | 				if (pa->paneltab == block->panel) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 					if (block->panel->flag & PNL_CLOSED) { | 
					
						
							|  |  |  | 						pa->flag |= PNL_CLOSED; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					else { | 
					
						
							|  |  |  | 						pa->flag &= ~PNL_CLOSED; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-30 18:58:18 +10:00
										 |  |  | 		if (align) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION); | 
					
						
							| 
									
										
										
										
											2018-08-30 18:58:18 +10:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* FIXME: this doesn't update the panel drawing, assert to avoid debugging why this is.
 | 
					
						
							|  |  |  | 			 * We could fix this in the future if it's ever needed. */ | 
					
						
							|  |  |  | 			BLI_assert(0); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			ED_region_tag_redraw(ar); | 
					
						
							| 
									
										
										
										
											2018-08-30 18:58:18 +10:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-03 13:32:36 +02:00
										 |  |  | 	else if (show_drag && BLI_rctf_isect_x(&rect_drag, mx)) { | 
					
						
							| 
									
										
										
										
											2018-06-12 10:11:32 +02:00
										 |  |  | 		/* XXX, for now don't allow dragging in floating windows yet. */ | 
					
						
							|  |  |  | 		if (ar->alignment == RGN_ALIGN_FLOAT) { | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		panel_activate_state(C, block->panel, PANEL_STATE_DRAG); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx)) { | 
					
						
							|  |  |  | 		block->panel->flag ^= PNL_PIN; | 
					
						
							|  |  |  | 		ED_region_tag_redraw(ar); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool UI_panel_category_is_visible(ARegion *ar) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-21 14:14:50 +01:00
										 |  |  | 	/* more than one */ | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	return ar->panels_category.first && ar->panels_category.first != ar->panels_category.last; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PanelCategoryDyn *UI_panel_category_find(ARegion *ar, const char *idname) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return BLI_findstring(&ar->panels_category, idname, offsetof(PanelCategoryDyn, idname)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PanelCategoryStack *UI_panel_category_active_find(ARegion *ar, const char *idname) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return BLI_findstring(&ar->panels_category_active, idname, offsetof(PanelCategoryStack, idname)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const char *UI_panel_category_active_get(ARegion *ar, bool set_fallback) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PanelCategoryStack *pc_act; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (pc_act = ar->panels_category_active.first; pc_act; pc_act = pc_act->next) { | 
					
						
							|  |  |  | 		if (UI_panel_category_find(ar, pc_act->idname)) { | 
					
						
							|  |  |  | 			return pc_act->idname; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (set_fallback) { | 
					
						
							|  |  |  | 		PanelCategoryDyn *pc_dyn = ar->panels_category.first; | 
					
						
							|  |  |  | 		if (pc_dyn) { | 
					
						
							|  |  |  | 			UI_panel_category_active_set(ar, pc_dyn->idname); | 
					
						
							|  |  |  | 			return pc_dyn->idname; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void UI_panel_category_active_set(ARegion *ar, const char *idname) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ListBase *lb = &ar->panels_category_active; | 
					
						
							|  |  |  | 	PanelCategoryStack *pc_act = UI_panel_category_active_find(ar, idname); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (pc_act) { | 
					
						
							|  |  |  | 		BLI_remlink(lb, pc_act); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		pc_act = MEM_callocN(sizeof(PanelCategoryStack), __func__); | 
					
						
							|  |  |  | 		BLI_strncpy(pc_act->idname, idname, sizeof(pc_act->idname)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BLI_addhead(lb, pc_act); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* validate all active panels, we could do this on load,
 | 
					
						
							|  |  |  | 	 * they are harmless - but we should remove somewhere. | 
					
						
							|  |  |  | 	 * (addons could define own and gather cruft over time) */ | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PanelCategoryStack *pc_act_next; | 
					
						
							|  |  |  | 		/* intentionally skip first */ | 
					
						
							|  |  |  | 		pc_act_next = pc_act->next; | 
					
						
							|  |  |  | 		while ((pc_act = pc_act_next)) { | 
					
						
							|  |  |  | 			pc_act_next = pc_act->next; | 
					
						
							|  |  |  | 			if (!BLI_findstring(&ar->type->paneltypes, pc_act->idname, offsetof(PanelType, category))) { | 
					
						
							|  |  |  | 				BLI_remlink(lb, pc_act); | 
					
						
							| 
									
										
										
										
											2016-02-24 05:48:33 +11:00
										 |  |  | 				MEM_freeN(pc_act); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PanelCategoryDyn *UI_panel_category_find_mouse_over_ex(ARegion *ar, const int x, const int y) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PanelCategoryDyn *ptd; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (ptd = ar->panels_category.first; ptd; ptd = ptd->next) { | 
					
						
							|  |  |  | 		if (BLI_rcti_isect_pt(&ptd->rect, x, y)) { | 
					
						
							|  |  |  | 			return ptd; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PanelCategoryDyn *UI_panel_category_find_mouse_over(ARegion *ar, const wmEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return UI_panel_category_find_mouse_over_ex(ar, event->mval[0], event->mval[1]); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void UI_panel_category_add(ARegion *ar, const char *name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PanelCategoryDyn *pc_dyn = MEM_callocN(sizeof(*pc_dyn), __func__); | 
					
						
							|  |  |  | 	BLI_addtail(&ar->panels_category, pc_dyn); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BLI_strncpy(pc_dyn->idname, name, sizeof(pc_dyn->idname)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* 'pc_dyn->rect' must be set on draw */ | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void UI_panel_category_clear_all(ARegion *ar) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BLI_freelistN(&ar->panels_category); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | static void imm_buf_append( | 
					
						
							|  |  |  |         float vbuf[][2], | 
					
						
							|  |  |  |         uchar cbuf[][3], | 
					
						
							|  |  |  |         float x, float y, const uchar col[3], int *index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ARRAY_SET_ITEMS(vbuf[*index], x, y); | 
					
						
							|  |  |  | 	ARRAY_SET_ITEMS(cbuf[*index], UNPACK3(col)); | 
					
						
							|  |  |  | 	(*index)++; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 19:15:26 -04:00
										 |  |  | /* based on UI_draw_roundbox, check on making a version which allows us to skip some sides */ | 
					
						
							| 
									
										
										
										
											2015-05-05 03:13:47 +10:00
										 |  |  | static void ui_panel_category_draw_tab( | 
					
						
							| 
									
										
										
										
											2017-04-06 19:37:50 -04:00
										 |  |  |         bool filled, float minx, float miny, float maxx, float maxy, float rad, | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  |         const int roundboxtype, | 
					
						
							|  |  |  |         const bool use_highlight, const bool use_shadow, const bool use_flip_x, | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  |         const uchar highlight_fade[3], | 
					
						
							|  |  |  |         const uchar col[3]) | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | { | 
					
						
							|  |  |  | 	float vec[4][2] = { | 
					
						
							|  |  |  | 	    {0.195, 0.02}, | 
					
						
							|  |  |  | 	    {0.55, 0.169}, | 
					
						
							|  |  |  | 	    {0.831, 0.45}, | 
					
						
							|  |  |  | 	    {0.98, 0.805}}; | 
					
						
							|  |  |  | 	int a; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* mult */ | 
					
						
							|  |  |  | 	for (a = 0; a < 4; a++) { | 
					
						
							|  |  |  | 		mul_v2_fl(vec[a], rad); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-08 13:19:10 +02:00
										 |  |  | 	uint vert_len = 0; | 
					
						
							| 
									
										
										
										
											2017-04-06 19:37:50 -04:00
										 |  |  | 	if (use_highlight) { | 
					
						
							| 
									
										
										
										
											2018-07-08 13:19:10 +02:00
										 |  |  | 		vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1; | 
					
						
							|  |  |  | 		vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1; | 
					
						
							| 
									
										
										
										
											2017-04-06 19:37:50 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (use_highlight && !use_shadow) { | 
					
						
							| 
									
										
										
										
											2018-07-08 13:19:10 +02:00
										 |  |  | 		vert_len++; | 
					
						
							| 
									
										
										
										
											2017-04-06 19:37:50 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2018-07-08 13:19:10 +02:00
										 |  |  | 		vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1; | 
					
						
							|  |  |  | 		vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1; | 
					
						
							| 
									
										
										
										
											2017-04-06 19:37:50 -04:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	/* Maximum size. */ | 
					
						
							|  |  |  | 	float vbuf[24][2]; | 
					
						
							|  |  |  | 	uchar cbuf[24][3]; | 
					
						
							|  |  |  | 	int buf_index = 0; | 
					
						
							| 
									
										
										
										
											2016-10-10 01:33:56 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	/* start with corner right-top */ | 
					
						
							|  |  |  | 	if (use_highlight) { | 
					
						
							|  |  |  | 		if (roundboxtype & UI_CNR_TOP_RIGHT) { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, maxx, maxy - rad, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			for (a = 0; a < 4; a++) { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 				imm_buf_append(vbuf, cbuf, maxx - vec[a][1], maxy - rad + vec[a][0], col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, maxx - rad, maxy, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, maxx, maxy, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* corner left-top */ | 
					
						
							|  |  |  | 		if (roundboxtype & UI_CNR_TOP_LEFT) { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, minx + rad, maxy, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			for (a = 0; a < 4; a++) { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 				imm_buf_append(vbuf, cbuf, minx + rad - vec[a][0], maxy - vec[a][1], col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, minx, maxy - rad, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, minx, maxy, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (use_highlight && !use_shadow) { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 		imm_buf_append(vbuf, cbuf, minx, miny + rad, highlight_fade ? col : highlight_fade, &buf_index); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* corner left-bottom */ | 
					
						
							|  |  |  | 		if (roundboxtype & UI_CNR_BOTTOM_LEFT) { | 
					
						
							|  |  |  | 			imm_buf_append(vbuf, cbuf,  minx, miny + rad, col, &buf_index); | 
					
						
							|  |  |  | 			for (a = 0; a < 4; a++) { | 
					
						
							|  |  |  | 				imm_buf_append(vbuf, cbuf,  minx + vec[a][1], miny + rad - vec[a][0], col, &buf_index); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			imm_buf_append(vbuf, cbuf, minx + rad, miny, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-30 22:51:28 +02:00
										 |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			imm_buf_append(vbuf, cbuf, minx, miny, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2018-03-30 22:51:28 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 		/* corner right-bottom */ | 
					
						
							|  |  |  | 		if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { | 
					
						
							|  |  |  | 			imm_buf_append(vbuf, cbuf, maxx - rad, miny, col, &buf_index); | 
					
						
							|  |  |  | 			for (a = 0; a < 4; a++) { | 
					
						
							|  |  |  | 				imm_buf_append(vbuf, cbuf, maxx - rad + vec[a][0], miny + vec[a][1], col, &buf_index); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			imm_buf_append(vbuf, cbuf, maxx, miny + rad, col, &buf_index); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			imm_buf_append(vbuf, cbuf, maxx, miny, col, &buf_index); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	if (use_flip_x) { | 
					
						
							|  |  |  | 		float midx = (minx + maxx) / 2.0f; | 
					
						
							|  |  |  | 		for (int i = 0; i < buf_index; i++) { | 
					
						
							|  |  |  | 			vbuf[i][0] = midx - (vbuf[i][0] - midx); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	GPUVertFormat *format = immVertexFormat(); | 
					
						
							|  |  |  | 	uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | 
					
						
							|  |  |  | 	uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); | 
					
						
							|  |  |  | 	immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len); | 
					
						
							|  |  |  | 	for (int i = 0; i < buf_index; i++) { | 
					
						
							| 
									
										
										
										
											2018-10-09 11:01:50 +11:00
										 |  |  | 		immAttr3ubv(color, cbuf[i]); | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 		immVertex2fv(pos, vbuf[i]); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-10-10 01:33:56 -04:00
										 |  |  | 	immEnd(); | 
					
						
							|  |  |  | 	immUnbindProgram(); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Draw vertical tabs on the left side of the region, | 
					
						
							|  |  |  |  * one tab per category. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* no tab outlines for */ | 
					
						
							| 
									
										
										
										
											2014-01-04 13:54:39 -06:00
										 |  |  | // #define USE_FLAT_INACTIVE
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	const bool is_left = (ar->alignment != RGN_ALIGN_RIGHT); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	View2D *v2d = &ar->v2d; | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 	uiStyle *style = UI_style_get(); | 
					
						
							| 
									
										
										
										
											2014-01-04 13:55:40 +11:00
										 |  |  | 	const uiFontStyle *fstyle = &style->widget; | 
					
						
							|  |  |  | 	const int fontid = fstyle->uifont_id; | 
					
						
							|  |  |  | 	short fstyle_points = fstyle->points; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	PanelCategoryDyn *pc_dyn; | 
					
						
							| 
									
										
										
										
											2014-01-04 13:55:40 +11:00
										 |  |  | 	const float aspect = ((uiBlock *)ar->uiblocks.first)->aspect; | 
					
						
							|  |  |  | 	const float zoom = 1.0f / aspect; | 
					
						
							| 
									
										
										
										
											2017-09-27 11:13:03 +10:00
										 |  |  | 	const int px = max_ii(1, round_fl_to_int(U.pixelsize)); | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	const int px_x_sign = is_left ? px : -px; | 
					
						
							| 
									
										
										
										
											2017-09-27 11:13:03 +10:00
										 |  |  | 	const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	const float dpi_fac = UI_DPI_FAC; | 
					
						
							| 
									
										
										
										
											2019-01-15 23:24:20 +11:00
										 |  |  | 	/* padding of tabs around text */ | 
					
						
							|  |  |  | 	const int tab_v_pad_text = round_fl_to_int((2 + ((px * 3) * dpi_fac)) * zoom); | 
					
						
							|  |  |  | 	/* padding between tabs */ | 
					
						
							|  |  |  | 	const int tab_v_pad = round_fl_to_int((4 + (2 * px * dpi_fac)) * zoom); | 
					
						
							| 
									
										
										
										
											2014-01-04 13:55:40 +11:00
										 |  |  | 	const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom; | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	/* We flip the tab drawing, so always use these flags. */ | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT; | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	bool is_alpha; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	bool do_scaletabs = false; | 
					
						
							|  |  |  | #ifdef USE_FLAT_INACTIVE
 | 
					
						
							|  |  |  | 	bool is_active_prev = false; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	float scaletabs = 1.0f; | 
					
						
							|  |  |  | 	/* same for all tabs */ | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	/* intentionally dont scale by 'px' */ | 
					
						
							|  |  |  | 	const int rct_xmin = is_left ? v2d->mask.xmin + 3 : (v2d->mask.xmax - category_tabs_width); | 
					
						
							|  |  |  | 	const int rct_xmax = is_left ? v2d->mask.xmin + category_tabs_width : (v2d->mask.xmax - 3); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	const int text_v_ofs = (rct_xmax - rct_xmin) * 0.3f; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int y_ofs = tab_v_pad; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Primary theme colors */ | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | 	uchar theme_col_back[4]; | 
					
						
							|  |  |  | 	uchar theme_col_text[3]; | 
					
						
							|  |  |  | 	uchar theme_col_text_hi[3]; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-23 11:44:35 +11:00
										 |  |  | 	/* Tab colors */ | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | 	uchar theme_col_tab_bg[4]; | 
					
						
							|  |  |  | 	uchar theme_col_tab_active[3]; | 
					
						
							|  |  |  | 	uchar theme_col_tab_inactive[3]; | 
					
						
							| 
									
										
										
										
											2014-01-23 11:44:35 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Secondary theme colors */ | 
					
						
							| 
									
										
										
										
											2019-01-04 11:05:53 +11:00
										 |  |  | 	uchar theme_col_tab_outline[3]; | 
					
						
							|  |  |  | 	uchar theme_col_tab_divider[3];  /* line that divides tabs from the main region */ | 
					
						
							|  |  |  | 	uchar theme_col_tab_highlight[3]; | 
					
						
							|  |  |  | 	uchar theme_col_tab_highlight_inactive[3]; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 13:38:41 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	UI_GetThemeColor4ubv(TH_BACK, theme_col_back); | 
					
						
							| 
									
										
										
										
											2014-02-10 17:02:53 +11:00
										 |  |  | 	UI_GetThemeColor3ubv(TH_TEXT, theme_col_text); | 
					
						
							|  |  |  | 	UI_GetThemeColor3ubv(TH_TEXT_HI, theme_col_text_hi); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-23 11:44:35 +11:00
										 |  |  | 	UI_GetThemeColor4ubv(TH_TAB_BACK, theme_col_tab_bg); | 
					
						
							| 
									
										
										
										
											2014-02-10 17:02:53 +11:00
										 |  |  | 	UI_GetThemeColor3ubv(TH_TAB_ACTIVE, theme_col_tab_active); | 
					
						
							|  |  |  | 	UI_GetThemeColor3ubv(TH_TAB_INACTIVE, theme_col_tab_inactive); | 
					
						
							|  |  |  | 	UI_GetThemeColor3ubv(TH_TAB_OUTLINE, theme_col_tab_outline); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-10 17:02:53 +11:00
										 |  |  | 	interp_v3_v3v3_uchar(theme_col_tab_divider, theme_col_back, theme_col_tab_outline, 0.3f); | 
					
						
							|  |  |  | 	interp_v3_v3v3_uchar(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f); | 
					
						
							|  |  |  | 	interp_v3_v3v3_uchar(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	is_alpha = (ar->overlap && (theme_col_back[3] != 255)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-04 13:55:40 +11:00
										 |  |  | 	if (fstyle->kerning == 1) { | 
					
						
							|  |  |  | 		BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	BLF_enable(fontid, BLF_ROTATION); | 
					
						
							| 
									
										
										
										
											2015-01-31 17:23:30 +11:00
										 |  |  | 	BLF_rotation(fontid, M_PI_2); | 
					
						
							| 
									
										
										
										
											2014-11-09 21:20:40 +01:00
										 |  |  | 	//UI_fontstyle_set(&style->widget);
 | 
					
						
							| 
									
										
										
										
											2014-01-15 13:38:41 +11:00
										 |  |  | 	ui_fontscale(&fstyle_points, aspect / (U.pixelsize * 1.1f)); | 
					
						
							|  |  |  | 	BLF_size(fontid, fstyle_points, U.dpi); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	BLI_assert(UI_panel_category_is_visible(ar)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* calculate tab rect's and check if we need to scale down */ | 
					
						
							|  |  |  | 	for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) { | 
					
						
							|  |  |  | 		rcti *rct = &pc_dyn->rect; | 
					
						
							|  |  |  | 		const char *category_id = pc_dyn->idname; | 
					
						
							|  |  |  | 		const char *category_id_draw = IFACE_(category_id); | 
					
						
							|  |  |  | 		const int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		rct->xmin = rct_xmin; | 
					
						
							|  |  |  | 		rct->xmax = rct_xmax; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		rct->ymin = v2d->mask.ymax - (y_ofs + category_width + (tab_v_pad_text * 2)); | 
					
						
							|  |  |  | 		rct->ymax = v2d->mask.ymax - (y_ofs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		y_ofs += category_width + tab_v_pad + (tab_v_pad_text * 2); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (y_ofs > BLI_rcti_size_y(&v2d->mask)) { | 
					
						
							|  |  |  | 		scaletabs = (float)BLI_rcti_size_y(&v2d->mask) / (float)y_ofs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) { | 
					
						
							|  |  |  | 			rcti *rct = &pc_dyn->rect; | 
					
						
							|  |  |  | 			rct->ymin = ((rct->ymin - v2d->mask.ymax) * scaletabs) + v2d->mask.ymax; | 
					
						
							|  |  |  | 			rct->ymax = ((rct->ymax - v2d->mask.ymax) * scaletabs) + v2d->mask.ymax; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		do_scaletabs = true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* begin drawing */ | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_line_smooth(true); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 	uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	/* draw the background */ | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	if (is_alpha) { | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(true); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		immUniformColor4ubv(theme_col_tab_bg); | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		immUniformColor3ubv(theme_col_tab_bg); | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	if (is_left) { | 
					
						
							|  |  |  | 		immRecti(pos, v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		immRecti(pos, v2d->mask.xmax - category_tabs_width, v2d->mask.ymin, v2d->mask.xmax, v2d->mask.ymax); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	if (is_alpha) { | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(false); | 
					
						
							| 
									
										
										
										
											2014-02-09 01:38:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 	immUnbindProgram(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	const int divider_xmin = | 
					
						
							|  |  |  | 		is_left ? (v2d->mask.xmin + (category_tabs_width - px)) : (v2d->mask.xmax - category_tabs_width) + px; | 
					
						
							|  |  |  | 	const int divider_xmax = | 
					
						
							|  |  |  | 		is_left ? (v2d->mask.xmin + category_tabs_width) : (v2d->mask.xmax - (category_tabs_width + px)) + px; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) { | 
					
						
							|  |  |  | 		const rcti *rct = &pc_dyn->rect; | 
					
						
							|  |  |  | 		const char *category_id = pc_dyn->idname; | 
					
						
							|  |  |  | 		const char *category_id_draw = IFACE_(category_id); | 
					
						
							|  |  |  | 		int category_width = BLI_rcti_size_y(rct) - (tab_v_pad_text * 2); | 
					
						
							|  |  |  | 		size_t category_draw_len = BLF_DRAW_STR_DUMMY_MAX; | 
					
						
							|  |  |  | 		// int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		const bool is_active = STREQ(category_id, category_id_active); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(true); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_FLAT_INACTIVE
 | 
					
						
							|  |  |  | 		if (is_active) | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			const bool use_flip_x = !is_left; | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 			ui_panel_category_draw_tab( | 
					
						
							| 
									
										
										
										
											2018-07-01 20:15:21 +02:00
										 |  |  | 			        true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			        tab_curve_radius - px, roundboxtype, true, true, use_flip_x, | 
					
						
							|  |  |  | 			        NULL, | 
					
						
							| 
									
										
										
										
											2018-07-01 20:15:21 +02:00
										 |  |  | 			        is_active ? theme_col_tab_active : theme_col_tab_inactive); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* tab outline */ | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 			ui_panel_category_draw_tab( | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			        false, rct->xmin - px_x_sign, rct->ymin - px, rct->xmax - px_x_sign, rct->ymax + px, | 
					
						
							|  |  |  | 			        tab_curve_radius, roundboxtype, true, true, use_flip_x, | 
					
						
							|  |  |  | 			        NULL, | 
					
						
							|  |  |  | 			        theme_col_tab_outline); | 
					
						
							| 
									
										
										
										
											2016-10-10 01:33:56 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 			/* tab highlight (3d look) */ | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 			ui_panel_category_draw_tab( | 
					
						
							| 
									
										
										
										
											2018-07-01 20:15:21 +02:00
										 |  |  | 			        false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			        tab_curve_radius, roundboxtype, true, false, use_flip_x, | 
					
						
							| 
									
										
										
										
											2018-07-01 20:15:21 +02:00
										 |  |  | 			        is_active ? theme_col_back : theme_col_tab_inactive, | 
					
						
							|  |  |  | 			        is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* tab blackline */ | 
					
						
							|  |  |  | 		if (!is_active) { | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 			pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			immUniformColor3ubv(theme_col_tab_divider); | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			immRecti(pos, | 
					
						
							|  |  |  | 			         divider_xmin, | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			         rct->ymin - tab_v_pad, | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			         divider_xmax, | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			         rct->ymax + tab_v_pad); | 
					
						
							|  |  |  | 			immUnbindProgram(); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (do_scaletabs) { | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 			category_draw_len = BLF_width_to_strlen( | 
					
						
							|  |  |  | 			        fontid, category_id_draw, category_draw_len, | 
					
						
							|  |  |  | 			        category_width, NULL); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		BLF_position(fontid, rct->xmax - text_v_ofs, rct->ymin + tab_v_pad_text, 0.0f); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-04 13:54:39 -06:00
										 |  |  | 		/* tab titles */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-14 13:39:55 +11:00
										 |  |  | 		/* draw white shadow to give text more depth */ | 
					
						
							| 
									
										
										
										
											2017-02-05 00:54:21 -05:00
										 |  |  | 		BLF_color3ubv(fontid, theme_col_text); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-14 13:39:55 +11:00
										 |  |  | 		/* main tab title */ | 
					
						
							|  |  |  | 		BLF_draw(fontid, category_id_draw, category_draw_len); | 
					
						
							| 
									
										
										
										
											2014-01-04 13:54:39 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 		GPU_blend(false); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* tab blackline remaining (last tab) */ | 
					
						
							| 
									
										
										
										
											2018-07-18 00:12:21 +02:00
										 |  |  | 		pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		if (pc_dyn->prev == NULL) { | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			immUniformColor3ubv(theme_col_tab_divider); | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			immRecti(pos, | 
					
						
							|  |  |  | 			         divider_xmin, | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			         rct->ymax + px, | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			         divider_xmax, | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			         v2d->mask.ymax); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if (pc_dyn->next == NULL) { | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			immUniformColor3ubv(theme_col_tab_divider); | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			immRecti(pos, | 
					
						
							|  |  |  | 			         divider_xmin, | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			         0, | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 			         divider_xmax, | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			         rct->ymin); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_FLAT_INACTIVE
 | 
					
						
							|  |  |  | 		/* draw line between inactive tabs */ | 
					
						
							|  |  |  | 		if (is_active == false && is_active_prev == false && pc_dyn->prev) { | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 			immUniformColor3ubv(theme_col_tab_divider); | 
					
						
							|  |  |  | 			immRecti(pos, v2d->mask.xmin + (category_tabs_width / 5), | 
					
						
							|  |  |  | 			         rct->ymax + px, | 
					
						
							|  |  |  | 			         (v2d->mask.xmin + category_tabs_width) - (category_tabs_width / 5), | 
					
						
							|  |  |  | 			         rct->ymax + (px * 3)); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		is_active_prev = is_active; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-02-20 15:17:23 +01:00
										 |  |  | 		immUnbindProgram(); | 
					
						
							| 
									
										
										
										
											2014-01-14 04:15:54 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* not essential, but allows events to be handled right up until the region edge [#38171] */ | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 		if (is_left) { | 
					
						
							|  |  |  | 			pc_dyn->rect.xmin = v2d->mask.xmin; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			pc_dyn->rect.xmax = v2d->mask.xmax; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-27 19:07:23 -06:00
										 |  |  | 	GPU_line_smooth(false); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	BLF_disable(fontid, BLF_ROTATION); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-04 13:55:40 +11:00
										 |  |  | 	if (fstyle->kerning == 1) { | 
					
						
							|  |  |  | 		BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | #undef USE_FLAT_INACTIVE
 | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | static int ui_handle_panel_category_cycling(const wmEvent *event, ARegion *ar, const uiBut *active_but) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	const bool is_mousewheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE); | 
					
						
							| 
									
										
										
										
											2018-09-27 16:21:57 +10:00
										 |  |  | 	const bool inside_tabregion = ( | 
					
						
							|  |  |  | 	        (ar->alignment != RGN_ALIGN_RIGHT) ? | 
					
						
							|  |  |  | 	        (event->mval[0] < ((PanelCategoryDyn *)ar->panels_category.first)->rect.xmax) : | 
					
						
							|  |  |  | 	        (event->mval[0] > ((PanelCategoryDyn *)ar->panels_category.first)->rect.xmin)); | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* if mouse is inside non-tab region, ctrl key is required */ | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (is_mousewheel && !event->ctrl && !inside_tabregion) { | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | 		return WM_UI_HANDLER_CONTINUE; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (active_but && ui_but_supports_cycling(active_but)) { | 
					
						
							|  |  |  | 		/* skip - exception to make cycling buttons
 | 
					
						
							|  |  |  | 		 * using ctrl+mousewheel work in tabbed regions */ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		const char *category = UI_panel_category_active_get(ar, false); | 
					
						
							|  |  |  | 		if (LIKELY(category)) { | 
					
						
							|  |  |  | 			PanelCategoryDyn *pc_dyn = UI_panel_category_find(ar, category); | 
					
						
							|  |  |  | 			if (LIKELY(pc_dyn)) { | 
					
						
							|  |  |  | 				if (is_mousewheel) { | 
					
						
							|  |  |  | 					/* we can probably get rid of this and only allow ctrl+tabbing */ | 
					
						
							|  |  |  | 					pc_dyn = (event->type == WHEELDOWNMOUSE) ? pc_dyn->next : pc_dyn->prev; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else { | 
					
						
							|  |  |  | 					const bool backwards = event->shift; | 
					
						
							|  |  |  | 					pc_dyn = backwards ? pc_dyn->prev : pc_dyn->next; | 
					
						
							|  |  |  | 					if (!pc_dyn) { | 
					
						
							| 
									
										
										
										
											2019-01-15 23:24:20 +11:00
										 |  |  | 						/* proper cyclic behavior,
 | 
					
						
							|  |  |  | 						 * back to first/last category (only used for ctrl+tab) */ | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | 						pc_dyn = backwards ? ar->panels_category.last : ar->panels_category.first; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if (pc_dyn) { | 
					
						
							|  |  |  | 					/* intentionally don't reset scroll in this case,
 | 
					
						
							|  |  |  | 					 * this allows for quick browsing between tabs */ | 
					
						
							|  |  |  | 					UI_panel_category_active_set(ar, pc_dyn->idname); | 
					
						
							|  |  |  | 					ED_region_tag_redraw(ar); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return WM_UI_HANDLER_BREAK; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return WM_UI_HANDLER_CONTINUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-11 11:52:39 +00:00
										 |  |  | /* XXX should become modal keymap */ | 
					
						
							| 
									
										
										
										
											2010-04-12 17:45:51 +00:00
										 |  |  | /* AKey is opening/closing panels, independent of button state now */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-05 19:28:24 +02:00
										 |  |  | int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, const uiBut *active_but) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	uiBlock *block; | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 	Panel *pa; | 
					
						
							| 
									
										
										
										
											2012-12-13 10:24:46 +00:00
										 |  |  | 	int retval, mx, my; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	bool has_category_tabs = UI_panel_category_is_visible(ar); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	retval = WM_UI_HANDLER_CONTINUE; | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-27 00:49:00 +02:00
										 |  |  | 	/* Scrollbars can overlap panels now, they have handling priority. */ | 
					
						
							|  |  |  | 	if (UI_view2d_mouse_in_scrollers(ar, &ar->v2d, event->x, event->y)) { | 
					
						
							|  |  |  | 		return retval; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | 	/* handle category tabs */ | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 	if (has_category_tabs) { | 
					
						
							|  |  |  | 		if (event->val == KM_PRESS) { | 
					
						
							|  |  |  | 			if (event->type == LEFTMOUSE) { | 
					
						
							|  |  |  | 				PanelCategoryDyn *pc_dyn = UI_panel_category_find_mouse_over(ar, event); | 
					
						
							|  |  |  | 				if (pc_dyn) { | 
					
						
							|  |  |  | 					UI_panel_category_active_set(ar, pc_dyn->idname); | 
					
						
							|  |  |  | 					ED_region_tag_redraw(ar); | 
					
						
							| 
									
										
										
										
											2014-02-22 13:07:02 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					/* reset scroll to the top [#38348] */ | 
					
						
							|  |  |  | 					UI_view2d_offset(&ar->v2d, -1.0f, 1.0f); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 					retval = WM_UI_HANDLER_BREAK; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-09-05 16:58:40 +02:00
										 |  |  | 			else if ((event->type == TABKEY && event->ctrl) || ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { | 
					
						
							|  |  |  | 				/* cycle tabs */ | 
					
						
							|  |  |  | 				retval = ui_handle_panel_category_cycling(event, ar, active_but); | 
					
						
							| 
									
										
										
										
											2014-02-17 13:46:07 +11:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (retval == WM_UI_HANDLER_BREAK) { | 
					
						
							|  |  |  | 		return retval; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	for (block = ar->uiblocks.last; block; block = block->prev) { | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 		uiPanelMouseState mouse_state; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		mx = event->x; | 
					
						
							|  |  |  | 		my = event->y; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		ui_window_to_block(ar, block, &mx, &my); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-13 10:24:46 +00:00
										 |  |  | 		/* checks for mouse position inside */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		pa = block->panel; | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-15 23:24:20 +11:00
										 |  |  | 		if (!pa || pa->paneltab != NULL) { | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2019-01-15 23:24:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		/* XXX - accessed freed panels when scripts reload, need to fix. */ | 
					
						
							|  |  |  | 		if (pa->type && pa->type->flag & PNL_NO_HEADER) { | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2019-01-15 23:24:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		mouse_state = ui_panel_mouse_state_get(block, pa, mx, my); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-13 10:24:46 +00:00
										 |  |  | 		/* XXX hardcoded key warning */ | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 		if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) { | 
					
						
							| 
									
										
										
										
											2015-01-26 02:38:39 +01:00
										 |  |  | 			if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) { | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (pa->flag & PNL_CLOSEDY) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 					if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { | 
					
						
							| 
									
										
										
										
											2014-01-06 03:00:54 +11:00
										 |  |  | 						ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2010-04-12 17:45:51 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				else { | 
					
						
							| 
									
										
										
										
											2014-01-06 03:00:54 +11:00
										 |  |  | 					ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-20 19:18:46 +00:00
										 |  |  | 				retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2010-04-12 17:45:51 +00:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-12 17:45:51 +00:00
										 |  |  | 		/* on active button, do not handle panels */ | 
					
						
							| 
									
										
										
										
											2019-03-23 00:18:16 +11:00
										 |  |  | 		if (ui_region_find_active_but(ar) != NULL) { | 
					
						
							| 
									
										
										
										
											2010-04-12 17:45:51 +00:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2019-03-23 00:18:16 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 		if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			if (event->val == KM_PRESS) { | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-11 11:52:39 +00:00
										 |  |  | 				/* open close on header */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (ELEM(event->type, RETKEY, PADENTER)) { | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 					if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { | 
					
						
							| 
									
										
										
										
											2014-01-06 03:00:54 +11:00
										 |  |  | 						ui_handle_panel_header(C, block, mx, my, RETKEY, event->ctrl, event->shift); | 
					
						
							| 
									
										
										
										
											2012-12-13 10:58:00 +00:00
										 |  |  | 						retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2010-04-11 11:52:39 +00:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				else if (event->type == LEFTMOUSE) { | 
					
						
							| 
									
										
										
										
											2012-12-13 10:58:00 +00:00
										 |  |  | 					/* all inside clicks should return in break - overlapping/float panels */ | 
					
						
							|  |  |  | 					retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 					if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { | 
					
						
							|  |  |  | 						ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); | 
					
						
							| 
									
										
										
										
											2012-12-13 10:58:00 +00:00
										 |  |  | 						retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2009-04-17 13:37:03 +00:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 					else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) { | 
					
						
							| 
									
										
										
										
											2009-07-08 15:34:41 +00:00
										 |  |  | 						panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE); | 
					
						
							| 
									
										
										
										
											2012-12-13 10:58:00 +00:00
										 |  |  | 						retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2009-04-17 13:37:03 +00:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-12-13 10:58:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 				else if (event->type == RIGHTMOUSE) { | 
					
						
							| 
									
										
										
										
											2015-04-25 12:56:24 +10:00
										 |  |  | 					if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { | 
					
						
							| 
									
										
										
										
											2018-06-24 10:01:13 +02:00
										 |  |  | 						ui_popup_context_menu_for_panel(C, ar, block->panel); | 
					
						
							| 
									
										
										
										
											2013-12-17 03:21:55 +11:00
										 |  |  | 						retval = WM_UI_HANDLER_BREAK; | 
					
						
							|  |  |  | 						break; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				else if (event->type == ESCKEY) { | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 					/*XXX 2.50*/ | 
					
						
							|  |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (block->handler) { | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 						rem_blockhandler(sa, block->handler); | 
					
						
							|  |  |  | 						ED_region_tag_redraw(ar); | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 						retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2012-03-03 16:31:46 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 				else if (event->type == PADPLUSKEY || event->type == PADMINUS) { | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | #if 0 /* XXX make float panel exception? */
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 					int zoom = 0; | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 					/* if panel is closed, only zoom if mouse is over the header */ | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 					if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 						if (inside_header) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 							zoom = 1; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 					else { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 						zoom = 1; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 					if (zoom) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 						ScrArea *sa = CTX_wm_area(C); | 
					
						
							|  |  |  | 						SpaceLink *sl = sa->spacedata.first; | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-16 10:44:15 +11:00
										 |  |  | 						if (sa->spacetype != SPACE_PROPERTIES) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 							if (!(pa->control & UI_PNL_SCALE)) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 								if (event->type == PADPLUSKEY) { | 
					
						
							|  |  |  | 									sl->blockscale += 0.1; | 
					
						
							|  |  |  | 								} | 
					
						
							|  |  |  | 								else { | 
					
						
							|  |  |  | 									sl->blockscale -= 0.1; | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 								CLAMP(sl->blockscale, 0.6, 1.0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								ED_region_tag_redraw(ar); | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 								retval = WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2012-10-21 05:46:41 +00:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return retval; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | /**************** window level modal panel interaction **************/ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-27 12:41:28 +00:00
										 |  |  | /* note, this is modal handler and should not swallow events for animation */ | 
					
						
							| 
									
										
										
										
											2013-02-01 01:01:20 +00:00
										 |  |  | static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	Panel *panel = userdata; | 
					
						
							|  |  |  | 	uiHandlePanelData *data = panel->activedata; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* verify if we can stop */ | 
					
						
							| 
									
										
										
										
											2018-06-08 18:58:41 +02:00
										 |  |  | 	if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		ScrArea *sa = CTX_wm_area(C); | 
					
						
							|  |  |  | 		ARegion *ar = CTX_wm_region(C); | 
					
						
							|  |  |  | 		int align = panel_aligned(sa, ar); | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (align) { | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 			panel_activate_state(C, panel, PANEL_STATE_ANIMATION); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 			panel_activate_state(C, panel, PANEL_STATE_EXIT); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (event->type == MOUSEMOVE) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (data->state == PANEL_STATE_DRAG) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			ui_do_drag(C, event, panel); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	else if (event->type == TIMER && event->customdata == data->animtimer) { | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (data->state == PANEL_STATE_ANIMATION) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			ui_do_animate(C, panel); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (data->state == PANEL_STATE_DRAG) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 			ui_do_drag(C, event, panel); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	data = panel->activedata; | 
					
						
							| 
									
										
										
										
											2009-04-02 01:39:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (data && data->state == PANEL_STATE_ANIMATION) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		return WM_UI_HANDLER_CONTINUE; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		return WM_UI_HANDLER_BREAK; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void ui_handler_remove_panel(bContext *C, void *userdata) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	Panel *pa = userdata; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	panel_activate_state(C, pa, PANEL_STATE_EXIT); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-16 21:39:45 +00:00
										 |  |  | static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state) | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 	uiHandlePanelData *data = pa->activedata; | 
					
						
							|  |  |  | 	wmWindow *win = CTX_wm_window(C); | 
					
						
							|  |  |  | 	ARegion *ar = CTX_wm_region(C); | 
					
						
							| 
									
										
										
										
											2018-05-23 10:47:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	if (data && data->state == state) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) { | 
					
						
							|  |  |  | 		if (data && data->state != PANEL_STATE_ANIMATION) { | 
					
						
							| 
									
										
										
										
											2009-09-23 11:49:12 +00:00
										 |  |  | 			/* XXX:
 | 
					
						
							| 
									
										
										
										
											2018-11-14 12:53:15 +11:00
										 |  |  | 			 * - the panel tabbing function call below (test_add_new_tabs()) has been commented out | 
					
						
							|  |  |  | 			 *   "It is too easy to do by accident when reordering panels, | 
					
						
							|  |  |  | 			 *   is very hard to control and use, and has no real benefit." - BillRey | 
					
						
							| 
									
										
										
										
											2009-09-23 11:49:12 +00:00
										 |  |  | 			 * Aligorith, 2009Sep | 
					
						
							|  |  |  | 			 */ | 
					
						
							|  |  |  | 			//test_add_new_tabs(ar);   // also copies locations of tabs in dragged panel
 | 
					
						
							| 
									
										
										
										
											2012-08-19 10:41:27 +00:00
										 |  |  | 			check_panel_overlap(ar, NULL);  /* clears */ | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		pa->flag &= ~PNL_SELECT; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		pa->flag |= PNL_SELECT; | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (data && data->animtimer) { | 
					
						
							| 
									
										
										
										
											2009-10-20 13:58:53 +00:00
										 |  |  | 		WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer); | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		data->animtimer = NULL; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (state == PANEL_STATE_EXIT) { | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		MEM_freeN(data); | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 		pa->activedata = NULL; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-04 17:16:19 +11:00
										 |  |  | 		WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, false); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!data) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData"); | 
					
						
							|  |  |  | 			pa->activedata = data; | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-01 16:40:43 +10:00
										 |  |  | 			WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) { | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 			data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL); | 
					
						
							| 
									
										
										
										
											2019-03-25 10:15:20 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-30 01:51:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		data->state = state; | 
					
						
							|  |  |  | 		data->startx = win->eventstate->x; | 
					
						
							|  |  |  | 		data->starty = win->eventstate->y; | 
					
						
							|  |  |  | 		data->startofsx = pa->ofsx; | 
					
						
							|  |  |  | 		data->startofsy = pa->ofsy; | 
					
						
							|  |  |  | 		data->startsizex = pa->sizex; | 
					
						
							|  |  |  | 		data->startsizey = pa->sizey; | 
					
						
							|  |  |  | 		data->starttime = PIL_check_seconds_timer(); | 
					
						
							| 
									
										
										
										
											2008-12-26 13:11:04 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ED_region_tag_redraw(ar); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-23 19:46:40 +02:00
										 |  |  | PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SpaceType *st = BKE_spacetype_from_id(space_id); | 
					
						
							|  |  |  | 	if (st) { | 
					
						
							|  |  |  | 		ARegionType *art = BKE_regiontype_from_id(st, region_id); | 
					
						
							|  |  |  | 		if (art) { | 
					
						
							|  |  |  | 			return BLI_findstring(&art->paneltypes, idname, offsetof(PanelType, idname)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return NULL; | 
					
						
							|  |  |  | } |