diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-30 11:56:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-30 11:56:12 +0300 |
commit | b89307acfd71955000662232b5964edcdfef5ccf (patch) | |
tree | 504c24627c2ebeb680439092b3205e859aac2cdf | |
parent | ea6fef938500f9405e7d6ff39297164b95d2811a (diff) | |
parent | a42fd3de5d82deff4b7d9b1f14a58fd95d9d20ff (diff) |
Merge branch 'master' into blender2.8
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 22 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 30 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 19 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_query.c | 97 |
6 files changed, 114 insertions, 62 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b00717665a9..7540e6ed602 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -402,6 +402,11 @@ typedef void (*uiMenuHandleFunc)(struct bContext *C, void *arg, int event); */ typedef bool (*uiMenuStepFunc)(struct bContext *C, int direction, void *arg1); + +/* interface_query.c */ +bool UI_block_is_empty(const uiBlock *block); + + /* interface_region_menu_popup.c */ /* Popup Menus * @@ -535,8 +540,6 @@ void UI_block_flag_enable(uiBlock *block, int flag); void UI_block_flag_disable(uiBlock *block, int flag); void UI_block_translate(uiBlock *block, int x, int y); -bool UI_block_is_empty(const uiBlock *block); - int UI_but_return_value_get(uiBut *but); void UI_but_drag_set_id(uiBut *but, struct ID *id); diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index 882db88879d..ee18f956cac 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -57,6 +57,7 @@ set(SRC interface_layout.c interface_ops.c interface_panel.c + interface_query.c interface_region_color_picker.c interface_region_hud.c interface_region_menu_pie.c diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f4c4b8afc94..834abc84c0d 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -105,18 +105,6 @@ static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, str static void ui_but_free(const bContext *C, uiBut *but); -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); -} - static bool ui_but_is_unit_radians_ex(UnitSettings *unit, const int unit_type) { return (unit->system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION); @@ -4032,16 +4020,6 @@ int UI_blocklist_min_y_get(ListBase *lb) return min; } -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; -} - void UI_block_direction_set(uiBlock *block, char direction) { block->direction = direction; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5edc66300ce..893700376b0 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -467,36 +467,6 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) } } -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 - ); -} - #ifdef USE_UI_POPOVER_ONCE bool ui_but_is_popover_once_compat(const uiBut *but) { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 2f2c77abc9c..04e9e2b18b4 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -444,8 +444,6 @@ typedef struct uiSafetyRct { void ui_fontscale(short *points, float aspect); -extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; -extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y); extern void ui_block_to_window_rctf(const struct ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src); @@ -696,10 +694,6 @@ extern void ui_but_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut extern uiBut *ui_but_find_select_in_enum(uiBut *but, int direction); extern uiBut *ui_but_find_active_in_region(struct ARegion *ar); extern uiBut *ui_but_find_mouse_over(struct ARegion *ar, const struct wmEvent *event); -bool ui_but_is_editable(const uiBut *but); -bool ui_but_is_editable_as_text(const uiBut *but); -bool ui_but_is_toggle(const uiBut *but); -bool ui_but_is_popover_once_compat(const uiBut *but); void ui_but_pie_dir_visual(RadialDirection dir, float vec[2]); void ui_but_pie_dir(RadialDirection dir, float vec[2]); float ui_block_calc_pie_segment(struct uiBlock *block, const float event_xy[2]); @@ -755,14 +749,14 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_popover_back(ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_pie_center(uiBlock *block); -uiWidgetColors *ui_tooltip_get_theme(void); +struct uiWidgetColors *ui_tooltip_get_theme(void); void ui_draw_widget_back_color( uiWidgetTypeEnum type, bool use_shadow, const rcti *rect, const float color[4]); void ui_draw_widget_back( uiWidgetTypeEnum type, bool use_shadow, const rcti *rect); -void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); +void ui_draw_tooltip_background(struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); @@ -814,6 +808,15 @@ void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, fl void ui_but_anim_decorate_cb(struct bContext *C, void *arg_but, void *arg_dummy); void ui_but_anim_decorate_update_from_flag(uiBut *but); +/* interface_query.c */ +bool ui_but_is_editable(const uiBut *but); +bool ui_but_is_editable_as_text(const uiBut *but); +bool ui_but_is_toggle(const uiBut *but); +bool ui_but_is_popover_once_compat(const uiBut *but); + +extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; +extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; + /* interface_context_menu.c */ bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but); void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa); 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; +} + +/** \} */ |