[Bf-blender-cvs] [6caad32] master: Code Cleanup - Split out the property-button-finding code so that it can be used for other eyedroppers
Joshua Leung
noreply at git.blender.org
Sun Mar 27 07:11:39 CEST 2016
Commit: 6caad32c1293b2452fe03ee728e5df62eb34c052
Author: Joshua Leung
Date: Sun Mar 27 01:22:19 2016 +1300
Branches: master
https://developer.blender.org/rB6caad32c1293b2452fe03ee728e5df62eb34c052
Code Cleanup - Split out the property-button-finding code so that it can be used for other eyedroppers
===================================================================
M source/blender/editors/interface/interface_eyedropper.c
===================================================================
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 5120a5e..f924160 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -157,6 +157,32 @@ static void eyedropper_draw_cursor_text(const struct bContext *C, ARegion *ar, c
UI_fontstyle_draw_simple_backdrop(fstyle, x, y, name, fg, bg);
}
+
+/**
+ * Utility to retrieve a button representing a RNA property that is currently under the cursor.
+ *
+ * This is to be used by any eyedroppers which fetch properties (e.g. UI_OT_eyedropper_driver).
+ * Especially during modal operations (e.g. as with the eyedroppers), context cannot be relied
+ * upon to provide this information, as it is not updated until the operator finishes.
+ *
+ * \return A button under the mouse which relates to some RNA Property, or NULL
+ */
+static uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *event)
+{
+ wmWindow *win = CTX_wm_window(C);
+ ScrArea *sa = BKE_screen_find_area_xy(win->screen, SPACE_TYPE_ANY, event->x, event->y);
+ ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_ANY, event->x, event->y);
+
+ uiBut *but = ui_but_find_mouse_over(ar, event);
+
+ if (ELEM(NULL, but, but->rnapoin.data, but->rnaprop)) {
+ return NULL;
+ }
+ else {
+ return but;
+ }
+}
+
/** \} */
@@ -1090,18 +1116,13 @@ static void driverdropper_exit(bContext *C, wmOperator *op)
static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *event)
{
DriverDropper *ddr = (DriverDropper *)op->customdata;
-
- wmWindow *win = CTX_wm_window(C);
- ScrArea *sa = BKE_screen_find_area_xy(win->screen, SPACE_TYPE_ANY, event->x, event->y);
- ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_ANY, event->x, event->y);
-
- uiBut *but = ui_but_find_mouse_over(ar, event);
+ uiBut *but = eyedropper_get_property_button_under_mouse(C, event);
short mapping_type = RNA_enum_get(op->ptr, "mapping_type");
short flag = 0;
/* we can only add a driver if we know what RNA property it corresponds to */
- if (ELEM(NULL, but, but->rnapoin.data, but->rnaprop)) {
+ if (but == NULL) {
return;
}
else {
More information about the Bf-blender-cvs
mailing list