| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \file blender/editors/interface/interface_query.c
 | 
					
						
							|  |  |  |  *  \ingroup edinterface | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Utilities to inspect the interface, extract information. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_screen_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "UI_interface.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "interface_intern.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 10:58:56 +02:00
										 |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Button (uiBut)
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool ui_but_is_editable(const uiBut *but) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 	return !ELEM( | 
					
						
							|  |  |  | 	        but->type, | 
					
						
							|  |  |  | 	        UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, | 
					
						
							|  |  |  | 	        UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX, UI_BTYPE_PROGRESS_BAR); | 
					
						
							| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool ui_but_is_editable_as_text(const uiBut *but) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-01 19:57:31 +02:00
										 |  |  | 	return ELEM( | 
					
						
							|  |  |  | 	        but->type, | 
					
						
							|  |  |  | 	        UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, | 
					
						
							|  |  |  | 	        UI_BTYPE_SEARCH_MENU); | 
					
						
							| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool ui_but_is_toggle(const uiBut *but) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ELEM( | 
					
						
							|  |  |  | 	        but->type, | 
					
						
							|  |  |  | 	        UI_BTYPE_BUT_TOGGLE, | 
					
						
							|  |  |  | 	        UI_BTYPE_TOGGLE, | 
					
						
							|  |  |  | 	        UI_BTYPE_ICON_TOGGLE, | 
					
						
							|  |  |  | 	        UI_BTYPE_ICON_TOGGLE_N, | 
					
						
							|  |  |  | 	        UI_BTYPE_TOGGLE_N, | 
					
						
							|  |  |  | 	        UI_BTYPE_CHECKBOX, | 
					
						
							|  |  |  | 	        UI_BTYPE_CHECKBOX_N, | 
					
						
							|  |  |  | 	        UI_BTYPE_ROW | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 10:58:56 +02:00
										 |  |  | #ifdef USE_UI_POPOVER_ONCE
 | 
					
						
							|  |  |  | bool ui_but_is_popover_once_compat(const uiBut *but) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ( | 
					
						
							|  |  |  | 	        (but->type == UI_BTYPE_BUT) || | 
					
						
							|  |  |  | 	        ui_but_is_toggle(but) | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool UI_but_is_tool(const uiBut *but) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	/* very evil! */ | 
					
						
							|  |  |  | 	if (but->optype != NULL) { | 
					
						
							|  |  |  | 		static wmOperatorType *ot = NULL; | 
					
						
							|  |  |  | 		if (ot == NULL) { | 
					
						
							|  |  |  | 			ot = WM_operatortype_find("WM_OT_tool_set_by_name", false); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (but->optype == ot) { | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 13:52:19 +10:00
										 |  |  | bool UI_but_has_tooltip_label(const uiBut *but) | 
					
						
							| 
									
										
										
										
											2018-09-04 17:57:59 +10:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-06 11:19:14 +10:00
										 |  |  | 	if ((but->drawstr[0] == '\0') && !ui_block_is_popover(but->block)) { | 
					
						
							| 
									
										
										
										
											2018-09-04 17:57:59 +10:00
										 |  |  | 		return UI_but_is_tool(but); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Block (uiBlock)
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool ui_block_is_menu(const uiBlock *block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return (((block->flag & UI_BLOCK_LOOP) != 0) && | 
					
						
							|  |  |  | 	        /* non-menu popups use keep-open, so check this is off */ | 
					
						
							|  |  |  | 	        ((block->flag & UI_BLOCK_KEEP_OPEN) == 0)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 10:45:35 +10:00
										 |  |  | bool ui_block_is_popover(const uiBlock *block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return (block->flag & UI_BLOCK_POPOVER) != 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | bool ui_block_is_pie_menu(const uiBlock *block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ((block->flag & UI_BLOCK_RADIAL) != 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-31 10:37:46 +10:00
										 |  |  | bool ui_block_is_popup_any(const uiBlock *block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ( | 
					
						
							|  |  |  | 	        ui_block_is_menu(block) || | 
					
						
							| 
									
										
										
										
											2018-07-31 10:45:35 +10:00
										 |  |  | 	        ui_block_is_popover(block) || | 
					
						
							| 
									
										
										
										
											2018-07-31 10:37:46 +10:00
										 |  |  | 	        ui_block_is_pie_menu(block) | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 10:36:40 +02:00
										 |  |  | bool UI_block_is_empty(const uiBlock *block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	for (const uiBut *but = block->buttons.first; but; but = but->next) { | 
					
						
							|  |  |  | 		if (!ELEM(but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) { | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ |