Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-01-25 08:28:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-01-25 08:32:43 +0300
commit38dafd5f44a07b4937ca53cf67cce4093d5797f7 (patch)
tree02612f48da66659340d3fd5b7ebd514502fd8e29 /source/blender/windowmanager/intern
parent032129ef3527424de241f381376a3b94a2247965 (diff)
parent693b41eb17557ba12e7c64c5ba589c499ff45c4d (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c37
-rw-r--r--source/blender/windowmanager/intern/wm_tooltip.c106
2 files changed, 124 insertions, 19 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 6e559ef7157..133ac6564f8 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2275,30 +2275,13 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
wm_manipulatormap_handler_context(C, handler);
wm_region_mouse_co(C, event);
- if (event->type == MOUSEMOVE) {
- WM_manipulatormap_tooltip_clear(C, mmap);
- }
-
/* handle manipulator highlighting */
if (event->type == MOUSEMOVE && !wm_manipulatormap_modal_get(mmap)) {
int part;
mpr = wm_manipulatormap_highlight_find(mmap, C, event, &part);
wm_manipulatormap_highlight_set(mmap, C, mpr, part);
if (mpr != NULL) {
- WM_manipulatormap_tooltip_timer_init(C, mmap);
- }
- }
- /* handle user configurable manipulator-map keymap */
- else if ((event->type == TIMER) &&
- (event->customdata == WM_manipulatormap_tooltip_timer_get(mmap)))
- {
- if (mpr) {
- if (mpr->state & WM_MANIPULATOR_STATE_MODAL) {
- WM_manipulatormap_tooltip_clear(C, mmap);
- }
- else {
- WM_manipulatormap_tooltip_create(C, mmap);
- }
+ WM_tooltip_timer_init(C, CTX_wm_window(C), region, WM_manipulatormap_tooltip_init);
}
}
else {
@@ -2735,6 +2718,13 @@ void wm_event_do_handlers(bContext *C)
CTX_wm_window_set(C, win);
+ /* Clear tool-tip on mouse move. */
+ if (screen->tool_tip && screen->tool_tip->exit_on_event) {
+ if (ISMOUSE(event->type)) {
+ WM_tooltip_clear(C, win);
+ }
+ }
+
/* we let modal handlers get active area/region, also wm_paintcursor_test needs it */
CTX_wm_area_set(C, area_event_inside(C, &event->x));
CTX_wm_region_set(C, region_event_inside(C, &event->x));
@@ -2751,7 +2741,16 @@ void wm_event_do_handlers(bContext *C)
/* fileread case */
if (CTX_wm_window(C) == NULL)
return;
-
+
+ /* check for a tooltip */
+ if (screen == WM_window_get_active_screen(win)) {
+ if (screen->tool_tip && screen->tool_tip->timer) {
+ if ((event->type == TIMER) && (event->customdata == screen->tool_tip->timer)) {
+ WM_tooltip_init(C, win);
+ }
+ }
+ }
+
/* check dragging, creates new event or frees, adds draw tag */
wm_event_drag_test(wm, win, event);
diff --git a/source/blender/windowmanager/intern/wm_tooltip.c b/source/blender/windowmanager/intern/wm_tooltip.c
new file mode 100644
index 00000000000..83d620d1522
--- /dev/null
+++ b/source/blender/windowmanager/intern/wm_tooltip.c
@@ -0,0 +1,106 @@
+/*
+ * ***** 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/windowmanager/intern/wm_tooltip.c
+ * \ingroup wm
+ *
+ * Manages a per-window tool-tip.
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+
+#include "ED_screen.h"
+
+#include "UI_interface.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+void WM_tooltip_timer_init(
+ bContext *C, wmWindow *win, ARegion *ar,
+ wmTooltipInitFn init)
+{
+ bScreen *screen = WM_window_get_active_screen(win);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ if (screen->tool_tip == NULL) {
+ screen->tool_tip = MEM_callocN(sizeof(*screen->tool_tip), __func__);
+ }
+ screen->tool_tip->region_from = ar;
+ screen->tool_tip->timer = WM_event_add_timer(wm, win, TIMER, UI_TOOLTIP_DELAY);
+ screen->tool_tip->init = init;
+}
+
+void WM_tooltip_timer_clear(bContext *C, wmWindow *win)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ bScreen *screen = WM_window_get_active_screen(win);
+ if (screen->tool_tip != NULL) {
+ if (screen->tool_tip->timer != NULL) {
+ WM_event_remove_timer(wm, win, screen->tool_tip->timer);
+ screen->tool_tip->timer = NULL;
+ }
+ }
+}
+
+void WM_tooltip_clear(bContext *C, wmWindow *win)
+{
+ WM_tooltip_timer_clear(C, win);
+ bScreen *screen = WM_window_get_active_screen(win);
+ if (screen->tool_tip != NULL) {
+ if (screen->tool_tip->region) {
+ UI_tooltip_free(C, screen, screen->tool_tip->region);
+ screen->tool_tip->region = NULL;
+ }
+ MEM_freeN(screen->tool_tip);
+ screen->tool_tip = NULL;
+ }
+}
+
+void WM_tooltip_init(bContext *C, wmWindow *win)
+{
+ WM_tooltip_timer_clear(C, win);
+ bScreen *screen = WM_window_get_active_screen(win);
+ if (screen->tool_tip->region) {
+ UI_tooltip_free(C, screen, screen->tool_tip->region);
+ screen->tool_tip->region = NULL;
+ }
+ screen->tool_tip->region = screen->tool_tip->init(
+ C, screen->tool_tip->region_from, &screen->tool_tip->exit_on_event);
+ if (screen->tool_tip->region == NULL) {
+ WM_tooltip_clear(C, win);
+ }
+}
+
+void WM_tooltip_refresh(bContext *C, wmWindow *win)
+{
+ WM_tooltip_timer_clear(C, win);
+ bScreen *screen = WM_window_get_active_screen(win);
+ if (screen->tool_tip != NULL) {
+ if (screen->tool_tip->region) {
+ UI_tooltip_free(C, screen, screen->tool_tip->region);
+ screen->tool_tip->region = NULL;
+ }
+ WM_tooltip_init(C, win);
+ }
+}