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:
authorJoshua Leung <aligorith@gmail.com>2016-03-23 14:55:37 +0300
committerJoshua Leung <aligorith@gmail.com>2016-03-23 15:00:12 +0300
commit98152624445eb5f8c6c19606cd9b0d38103a2a6c (patch)
tree23fbdeda7479781a949495706f533d52ccc2496c /source/blender/windowmanager/intern
parent0f501a73ab6181471dd9de2bd1c8c799c997caa4 (diff)
Radial Control Operator: Always show the property name + value on the header
The radial control operator is commonly used for setting sculpt brush Size and Strength settings. However, when using it, it can often be difficult to remember which hotkey is responsible for which setting, meaning that you can often accidentally modify the wrong setting without knowing it (or even what new value you've set it to). This commit makes it so that the property name and the current value are always shown on the header. Previously this info was only shown when the doing numeric input. (It also fixes a bug where the numeric input print would hang around even after it wasn't being used).
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 179677a0cb1..b6ea4204a2e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3902,12 +3902,39 @@ static void radial_control_update_header(wmOperator *op, bContext *C)
char msg[WM_RADIAL_CONTROL_HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
-
- if (sa && hasNumInput(&rc->num_input)) {
- char num_str[NUM_STR_REP_LEN];
- outputNumInput(&rc->num_input, num_str, &scene->unit);
- BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %s", RNA_property_ui_name(rc->prop), num_str);
- ED_area_headerprint(sa, msg);
+
+ if (sa) {
+ if (hasNumInput(&rc->num_input)) {
+ char num_str[NUM_STR_REP_LEN];
+ outputNumInput(&rc->num_input, num_str, &scene->unit);
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %s", RNA_property_ui_name(rc->prop), num_str);
+ ED_area_headerprint(sa, msg);
+ }
+ else {
+ const char *ui_name = RNA_property_ui_name(rc->prop);
+ switch (rc->subtype) {
+ case PROP_NONE:
+ case PROP_DISTANCE:
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %.4f", ui_name, rc->current_value);
+ break;
+ case PROP_PIXEL:
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %d", ui_name, (int)rc->current_value); /* XXX: round to nearest? */
+ break;
+ case PROP_PERCENTAGE:
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %3.1f%%", ui_name, rc->current_value);
+ break;
+ case PROP_FACTOR:
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %1.2f", ui_name, rc->current_value);
+ break;
+ case PROP_ANGLE:
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s: %3f", ui_name, RAD2DEGF(rc->current_value)); // XXX: 2dp is enough
+ break;
+ default:
+ BLI_snprintf(msg, WM_RADIAL_CONTROL_HEADER_LENGTH, "%s", ui_name); /* XXX: No value? */
+ break;
+ }
+ ED_area_headerprint(sa, msg);
+ }
}
}
@@ -4124,12 +4151,12 @@ static void radial_control_paint_cursor(bContext *C, int x, int y, void *customd
glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), rmin, 40);
BLF_size(fontid, 1.5 * fstyle_points, 1.0f / U.dpi);
- BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight);
BLF_enable(fontid, BLF_SHADOW);
BLF_shadow(fontid, 3, 0.0f, 0.0f, 0.0f, 0.5f);
BLF_shadow_offset(fontid, 1, -1);
/* draw value */
+ BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight);
BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f);
BLF_draw(fontid, str, strdrawlen);
@@ -4614,6 +4641,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even
}
ED_region_tag_redraw(CTX_wm_region(C));
+ radial_control_update_header(op, C);
if (ret != OPERATOR_RUNNING_MODAL)
radial_control_cancel(C, op);