diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-30 11:36:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-30 11:49:04 +0300 |
commit | a42fd3de5d82deff4b7d9b1f14a58fd95d9d20ff (patch) | |
tree | e18f666a3cf402b0a65e968564213d308861cb1d /source/blender/editors/interface/interface_query.c | |
parent | b26e9f00007b048cec3b3c7a93420d92ec0877c9 (diff) |
UI: Add 'interface_query.c'
Interface files are increasingly mixing up too much functionality,
add a file only to handle queries.
More functions can be moved/added here.
Diffstat (limited to 'source/blender/editors/interface/interface_query.c')
-rw-r--r-- | source/blender/editors/interface/interface_query.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c new file mode 100644 index 00000000000..5d6d03ece60 --- /dev/null +++ b/source/blender/editors/interface/interface_query.c @@ -0,0 +1,97 @@ +/* + * ***** 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" + +/* -------------------------------------------------------------------- */ +/** \name Button (uiBut) + * \{ */ + +bool ui_but_is_editable(const uiBut *but) +{ + return !ELEM(but->type, + UI_BTYPE_LABEL, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, + UI_BTYPE_ROUNDBOX, UI_BTYPE_LISTBOX, UI_BTYPE_PROGRESS_BAR); +} + +bool ui_but_is_editable_as_text(const uiBut *but) +{ + return ELEM(but->type, + UI_BTYPE_TEXT, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER, + UI_BTYPE_SEARCH_MENU); + +} + +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 + ); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \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)); +} + +bool ui_block_is_pie_menu(const uiBlock *block) +{ + return ((block->flag & UI_BLOCK_RADIAL) != 0); +} + +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; +} + +/** \} */ |