[Bf-blender-cvs] [0a3cf083641] blender2.8: Keymaps: take into account DPI for tweak/drag/pie thresholds.

Brecht Van Lommel noreply at git.blender.org
Wed Nov 21 19:31:51 CET 2018


Commit: 0a3cf083641121765fc78277f00d89af6d2cfebc
Author: Brecht Van Lommel
Date:   Wed Nov 21 19:25:13 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB0a3cf083641121765fc78277f00d89af6d2cfebc

Keymaps: take into account DPI for tweak/drag/pie thresholds.

The intention is to fix a too low default threshold on high DPI screen.
Users with high DPI screens that have increased the threshold to fix this
or liked the lower threshold will need to lower it again.

This is still somewhat of a guess, ideally this would be based on the
physical distance travalled, and maybe different per type of input device.
However we do not have access to this information, and hope this gives a
better default.

===================================================================

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_gesture.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index ef20d1a1063..9158f51f0bb 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1721,7 +1721,7 @@ static bool ui_but_drag_init(
 	/* prevent other WM gestures to start while we try to drag */
 	WM_gestures_remove(C);
 
-	if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold) {
+	if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold * U.dpi_fac) {
 
 		button_activate_state(C, but, BUTTON_STATE_EXIT);
 		data->cancel = true;
@@ -8691,7 +8691,7 @@ float ui_block_calc_pie_segment(uiBlock *block, const float event_xy[2])
 
 	len = normalize_v2_v2(block->pie_data.pie_dir, seg2);
 
-	if (len < U.pie_menu_threshold * U.pixelsize)
+	if (len < U.pie_menu_threshold * U.dpi_fac)
 		block->pie_data.flags |= UI_PIE_INVALID_DIR;
 	else
 		block->pie_data.flags &= ~UI_PIE_INVALID_DIR;
@@ -9409,7 +9409,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
 					but = ui_but_find_active_in_region(menu->region);
 
 					if (but && (U.pie_menu_confirm > 0) &&
-					    (dist >= U.pie_menu_threshold + U.pie_menu_confirm))
+					    (dist >= U.dpi_fac * (U.pie_menu_threshold + U.pie_menu_confirm)))
 					{
 						if (but)
 							return ui_but_pie_menu_apply(C, menu, but, true);
@@ -9436,7 +9436,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
 
 						/* here instead, we use the offset location to account for the initial direction timeout */
 						if ((U.pie_menu_confirm > 0) &&
-						    (dist >= U.pie_menu_threshold + U.pie_menu_confirm))
+						    (dist >= U.dpi_fac * (U.pie_menu_threshold + U.pie_menu_confirm)))
 						{
 							block->pie_data.flags |= UI_PIE_GESTURE_END_WAIT;
 							copy_v2_v2(block->pie_data.last_pos, event_xy);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b36f83b1ccf..5e8b420e018 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2957,7 +2957,7 @@ static void ui_litem_layout_root_radial(uiLayout *litem)
 
 		ui_item_size(item, &itemw, &itemh);
 
-		ui_item_position(item, x - itemw / 2, y + U.pixelsize * (U.pie_menu_threshold + 9.0f), itemw, itemh);
+		ui_item_position(item, x - itemw / 2, y + U.dpi_fac * (U.pie_menu_threshold + 9.0f), itemw, itemh);
 	}
 }
 
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ea588c703c6..0ffc40bdf9d 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4566,8 +4566,8 @@ void ui_draw_pie_center(uiBlock *block)
 
 	float *pie_dir = block->pie_data.pie_dir;
 
-	float pie_radius_internal = U.pixelsize * U.pie_menu_threshold;
-	float pie_radius_external = U.pixelsize * (U.pie_menu_threshold + 7.0f);
+	float pie_radius_internal = U.dpi_fac * U.pie_menu_threshold;
+	float pie_radius_external = U.dpi_fac * (U.pie_menu_threshold + 7.0f);
 
 	int subd = 40;
 
@@ -4609,8 +4609,8 @@ void ui_draw_pie_center(uiBlock *block)
 	immUnbindProgram();
 
 	if (U.pie_menu_confirm > 0 && !(block->pie_data.flags & (UI_PIE_INVALID_DIR | UI_PIE_CLICK_STYLE))) {
-		float pie_confirm_radius = U.pixelsize * (pie_radius_internal + U.pie_menu_confirm);
-		float pie_confirm_external = U.pixelsize * (pie_radius_internal + U.pie_menu_confirm + 7.0f);
+		float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm);
+		float pie_confirm_external = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm + 7.0f);
 
 		const char col[4] = {btheme->tui.wcol_pie_menu.text_sel[0],
 		                     btheme->tui.wcol_pie_menu.text_sel[1],
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 03a80ff240b..2a97ce8c904 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2612,8 +2612,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 		if (wm_action_not_handled(action)) {
 			if (event->check_drag) {
 				wmWindow *win = CTX_wm_window(C);
-				if ((abs(event->x - win->eventstate->prevclickx)) >= U.tweak_threshold ||
-				    (abs(event->y - win->eventstate->prevclicky)) >= U.tweak_threshold)
+				float tweak_threshold = U.tweak_threshold * U.dpi_fac;
+				if ((abs(event->x - win->eventstate->prevclickx)) >= tweak_threshold ||
+				    (abs(event->y - win->eventstate->prevclicky)) >= tweak_threshold)
 				{
 					int x = event->x;
 					int y = event->y;
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 06a7f3528c5..70150e40142 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -130,7 +130,8 @@ int wm_gesture_evaluate(wmGesture *gesture)
 		rcti *rect = gesture->customdata;
 		int dx = BLI_rcti_size_x(rect);
 		int dy = BLI_rcti_size_y(rect);
-		if (abs(dx) + abs(dy) > U.tweak_threshold) {
+		float tweak_threshold = U.tweak_threshold * U.dpi_fac;
+		if (abs(dx) + abs(dy) > tweak_threshold) {
 			int theta = round_fl_to_int(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI);
 			int val = EVT_GESTURE_W;



More information about the Bf-blender-cvs mailing list