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:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c67
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c16
-rw-r--r--source/blender/editors/interface/interface_handlers.c313
-rw-r--r--source/blender/editors/interface/interface_intern.h20
-rw-r--r--source/blender/editors/interface/interface_layout.c76
-rw-r--r--source/blender/editors/interface/interface_regions.c20
-rw-r--r--source/blender/editors/interface/interface_templates.c36
-rw-r--r--source/blender/editors/interface/interface_widgets.c116
-rw-r--r--source/blender/editors/interface/resources.c10
-rw-r--r--source/blender/editors/interface/view2d_ops.c11
10 files changed, 463 insertions, 222 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3bad2577409..3f48446f029 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -78,8 +78,8 @@
#include "interface_intern.h"
-#define PRECISION_FLOAT_MAX 6
-#define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */
+#define PRECISION_FLOAT_MAX 7
+#define PRECISION_FLOAT_MAX_POW 10000000 /* pow(10, PRECISION_FLOAT_MAX) */
/* avoid unneeded calls to ui_get_but_val */
#define UI_BUT_VALUE_UNSET DBL_MAX
@@ -443,7 +443,7 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max
static int ui_but_float_precision(uiBut *but, double value)
{
int prec;
- const double pow10_neg[PRECISION_FLOAT_MAX + 1] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001};
+ const double pow10_neg[PRECISION_FLOAT_MAX + 1] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001};
/* first check if prec is 0 and fallback to a simple default */
if ((prec = (int)but->a2) == -1) {
@@ -613,6 +613,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
{
/* flags from the buttons we want to refresh, may want to add more here... */
const int flag_copy = UI_BUT_REDALERT;
+ const int drawflag_copy = 0; /* None currently. */
uiBlock *oldblock;
uiBut *oldbut, *but = *butpp;
@@ -670,8 +671,9 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
SWAP(char *, oldbut->poin, but->poin);
SWAP(void *, oldbut->func_argN, but->func_argN);
}
-
+
oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
+ oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
/* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
* when scrolling without moving mouse (see [#28432]) */
@@ -2604,7 +2606,7 @@ static void ui_block_do_align_but(uiBut *first, short nr)
next = NULL;
/* clear old flag */
- but->flag &= ~UI_BUT_ALIGN;
+ but->drawflag &= ~UI_BUT_ALIGN;
if (flag == 0) { /* first case */
if (next) {
@@ -2683,7 +2685,7 @@ static void ui_block_do_align_but(uiBut *first, short nr)
}
}
- but->flag |= flag;
+ but->drawflag |= flag;
/* merge coordinates */
if (prev) {
@@ -2863,10 +2865,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
if ((block->flag & UI_BLOCK_LOOP) ||
ELEM8(but->type, MENU, TEX, LABEL, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR, SEARCH_MENU_UNLINK))
{
- but->flag |= (UI_TEXT_LEFT | UI_ICON_LEFT);
+ but->drawflag |= (UI_BUT_TEXT_LEFT | UI_BUT_ICON_LEFT);
}
- but->flag |= (block->flag & UI_BUT_ALIGN);
+ but->drawflag |= (block->flag & UI_BUT_ALIGN);
if (but->lock == TRUE) {
if (but->lockstr) {
@@ -3041,7 +3043,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
if (icon) {
but->icon = (BIFIconID)icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
}
if (!RNA_property_editable(&but->rnapoin, prop)) {
@@ -3158,9 +3160,14 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, in
return but;
}
-/* if _x_ is a power of two (only one bit) return the power,
+/**
+ * if \a _x_ is a power of two (only one bit) return the power,
* otherwise return -1.
- * (1<<findBitIndex(x))==x for powers of two.
+ *
+ * for powers of two:
+ * \code{.c}
+ * ((1 << findBitIndex(x)) == x);
+ * \endcode
*/
static int findBitIndex(unsigned int x)
{
@@ -3183,6 +3190,7 @@ static int findBitIndex(unsigned int x)
/* autocomplete helper functions */
struct AutoComplete {
size_t maxlen;
+ int matches;
char *truncate;
const char *startname;
};
@@ -3193,6 +3201,7 @@ AutoComplete *autocomplete_begin(const char *startname, size_t maxlen)
autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
autocpl->maxlen = maxlen;
+ autocpl->matches = 0;
autocpl->truncate = MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate");
autocpl->startname = startname;
@@ -3211,6 +3220,7 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name)
}
/* found a match */
if (startname[a] == 0) {
+ autocpl->matches++;
/* first match */
if (truncate[0] == 0)
BLI_strncpy(truncate, name, autocpl->maxlen);
@@ -3228,21 +3238,27 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name)
}
}
-bool autocomplete_end(AutoComplete *autocpl, char *autoname)
+int autocomplete_end(AutoComplete *autocpl, char *autoname)
{
- bool change = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
if (autocpl->truncate[0]) {
+ if (autocpl->matches == 1) {
+ match = AUTOCOMPLETE_FULL_MATCH;
+ }
+ else {
+ match = AUTOCOMPLETE_PARTIAL_MATCH;
+ }
BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen);
- change = true;
}
else {
if (autoname != autocpl->startname) { /* don't copy a string over its self */
BLI_strncpy(autoname, autocpl->startname, autocpl->maxlen);
}
}
+
MEM_freeN(autocpl->truncate);
MEM_freeN(autocpl);
- return change;
+ return match;
}
static void ui_check_but_and_iconize(uiBut *but, int icon)
@@ -3416,7 +3432,7 @@ uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const ch
{
uiBut *but = ui_def_but(block, type, retval, str, x, y, width, height, poin, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
@@ -3467,7 +3483,7 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const c
uiBut *but;
but = ui_def_but_rna_propname(block, type, retval, str, x, y, width, height, ptr, propname, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
@@ -3475,7 +3491,7 @@ uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, co
uiBut *but;
but = ui_def_but_rna(block, type, retval, str, x, y, width, height, ptr, prop, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
@@ -3483,7 +3499,7 @@ uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int o
uiBut *but;
but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x, y, width, height, tip);
ui_check_but_and_iconize(but, icon);
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x, int y, short width, short height, const char *tip)
@@ -3539,7 +3555,7 @@ void uiBlockFlipOrder(uiBlock *block)
return;
for (but = block->buttons.first; but; but = but->next) {
- if (but->flag & UI_BUT_ALIGN) return;
+ if (but->drawflag & UI_BUT_ALIGN) return;
if (but->rect.ymin < miny) miny = but->rect.ymin;
if (but->rect.ymax > maxy) maxy = but->rect.ymax;
}
@@ -3780,7 +3796,7 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
but->flag |= UI_ICON_SUBMENU;
but->menu_create_func = func;
@@ -3795,7 +3811,7 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag &= ~UI_ICON_LEFT;
+ but->drawflag &= ~UI_BUT_ICON_LEFT;
but->menu_create_func = func;
ui_check_but(but);
@@ -3811,7 +3827,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
/* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */
if (icon != ICON_RIGHTARROW_THIN) {
but->icon = (BIFIconID) icon;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
}
but->flag |= UI_HAS_ICON;
but->flag |= UI_ICON_SUBMENU;
@@ -3830,7 +3846,7 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT;
but->block_create_func = func;
ui_check_but(but);
@@ -3865,7 +3881,7 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle
but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
ui_check_but(but);
@@ -4186,5 +4202,6 @@ void UI_reinit_font(void)
void UI_exit(void)
{
ui_resources_free();
+ ui_button_clipboard_free();
}
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 783a777a2fe..a01c7eecda1 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -122,10 +122,9 @@ static void eyedropper_exit(bContext *C, wmOperator *op)
}
}
-static int eyedropper_cancel(bContext *C, wmOperator *op)
+static void eyedropper_cancel(bContext *C, wmOperator *op)
{
eyedropper_exit(C, op);
- return OPERATOR_CANCELLED;
}
/* *** eyedropper_color_ helper functions *** */
@@ -243,7 +242,8 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
- return eyedropper_cancel(C, op);
+ eyedropper_cancel(C, op);
+ return OPERATOR_CANCELLED;
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
if (eye->accum_tot == 0) {
@@ -439,7 +439,9 @@ static void datadropper_exit(bContext *C, wmOperator *op)
if (op->customdata) {
DataDropper *ddr = (DataDropper *)op->customdata;
- ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel);
+ if (ddr->art) {
+ ED_region_draw_cb_exit(ddr->art, ddr->draw_handle_pixel);
+ }
MEM_freeN(op->customdata);
@@ -447,10 +449,9 @@ static void datadropper_exit(bContext *C, wmOperator *op)
}
}
-static int datadropper_cancel(bContext *C, wmOperator *op)
+static void datadropper_cancel(bContext *C, wmOperator *op)
{
datadropper_exit(C, op);
- return OPERATOR_CANCELLED;
}
/* *** datadropper id helper functions *** */
@@ -552,7 +553,8 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
- return datadropper_cancel(C, op);
+ datadropper_cancel(C, op);
+ return OPERATOR_CANCELLED;
case LEFTMOUSE:
if (event->val == KM_RELEASE) {
bool success;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c5faa99e067..db53809c7c4 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -242,7 +242,29 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *userd
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
static void button_timers_tooltip_remove(bContext *C, uiBut *but);
+/* buttons clipboard */
+static ColorBand but_copypaste_coba = {0};
+static CurveMapping but_copypaste_curve = {0};
+static bool but_copypaste_curve_alive = false;
+
/* ******************** menu navigation helpers ************** */
+enum eSnapType {
+ SNAP_OFF = 0,
+ SNAP_ON,
+ SNAP_ON_SMALL,
+};
+
+static enum eSnapType ui_event_to_snap(const wmEvent *event)
+{
+ return (event->ctrl) ? (event->shift) ? SNAP_ON_SMALL : SNAP_ON : SNAP_OFF;
+}
+
+static void ui_color_snap_hue(const enum eSnapType snap, float *r_hue)
+{
+ const float snap_increment = (snap == SNAP_ON_SMALL) ? 24 : 12;
+ BLI_assert(snap != SNAP_OFF);
+ *r_hue = floorf(0.5f + ((*r_hue) * snap_increment)) / snap_increment;
+}
/* assumes event type is MOUSEPAN */
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
@@ -279,7 +301,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
static bool ui_but_editable(uiBut *but)
{
- return ELEM6(but->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
+ return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
}
static uiBut *ui_but_prev(uiBut *but)
@@ -335,7 +357,7 @@ static bool ui_is_a_warp_but(uiBut *but)
return false;
}
-static float ui_mouse_scale_warp_factor(const short shift)
+static float ui_mouse_scale_warp_factor(const bool shift)
{
return shift ? 0.05f : 1.0f;
}
@@ -343,7 +365,7 @@ static float ui_mouse_scale_warp_factor(const short shift)
static void ui_mouse_scale_warp(uiHandleButtonData *data,
const float mx, const float my,
float *r_mx, float *r_my,
- const short shift)
+ const bool shift)
{
const float fac = ui_mouse_scale_warp_factor(shift);
@@ -837,6 +859,13 @@ static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void
}
}
+static bool ui_is_but_drag_toggle(uiBut *but)
+{
+ return ((ui_is_but_bool(but) == true) &&
+ /* menu check is importnt so the button dragged over isn't removed instantly */
+ (ui_block_is_menu(but->block) == false));
+}
+
#endif /* USE_DRAG_TOGGLE */
@@ -852,7 +881,7 @@ static bool ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, const wmEvent *eve
if (but->imb) {
/* use button size itself */
}
- else if (but->flag & UI_ICON_LEFT) {
+ else if (but->drawflag & UI_BUT_ICON_LEFT) {
rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect));
}
else {
@@ -1324,7 +1353,6 @@ static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleB
/* c = copy, v = paste */
static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char mode)
{
- static ColorBand but_copypaste_coba = {0};
char buf[UI_MAX_DRAW_STR + 1] = {0};
if (mode == 'v' && but->lock == TRUE) {
@@ -1372,6 +1400,32 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
}
+ /* NORMAL button */
+ else if (but->type == BUT_NORMAL) {
+ float xyz[3];
+
+ if (but->poin == NULL && but->rnapoin.data == NULL) {
+ /* pass */
+ }
+ else if (mode == 'c') {
+ ui_get_but_vectorf(but, xyz);
+ BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]);
+ WM_clipboard_text_set(buf, 0);
+ }
+ else {
+ if (sscanf(buf, "[%f, %f, %f]", &xyz[0], &xyz[1], &xyz[2]) == 3) {
+ if (normalize_v3(xyz) == 0.0f) {
+ /* better set Z up then have a zero vector */
+ xyz[2] = 1.0;
+ }
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ ui_set_but_vectorf(but, xyz);
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ }
+ }
+
+
/* RGB triple */
else if (but->type == COLOR) {
float rgba[4];
@@ -1458,6 +1512,28 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
+ else if (but->type == BUT_CURVE) {
+ if (mode == 'c') {
+ if (but->poin == NULL)
+ return;
+
+ but_copypaste_curve_alive = true;
+ curvemapping_free_data(&but_copypaste_curve);
+ curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *) but->poin);
+ }
+ else {
+ if (!but_copypaste_curve_alive)
+ return;
+
+ if (!but->poin)
+ but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
+
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ curvemapping_free_data((CurveMapping *) but->poin);
+ curvemapping_copy_data((CurveMapping *) but->poin, &but_copypaste_curve);
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ }
/* operator button (any type) */
else if (but->optype) {
if (mode == 'c') {
@@ -1465,7 +1541,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
char *str;
opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
- str = WM_operator_pystring(C, but->optype, opptr, 0);
+ str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr);
WM_clipboard_text_set(str, 0);
@@ -1716,7 +1792,7 @@ static bool ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char as
}
static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJumpDirection direction,
- int select, strCursorJumpType jump)
+ const bool select, strCursorJumpType jump)
{
const char *str = data->str;
const int len = strlen(str);
@@ -2021,7 +2097,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->next; but; but = but->next) {
@@ -2049,7 +2125,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->prev; but; but = but->prev) {
@@ -2137,7 +2213,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* only select a word in button if there was no selection before */
if (event->val == KM_DBL_CLICK && had_selection == false) {
- ui_textedit_move(but, data, STRCUR_DIR_PREV, 0, STRCUR_JUMP_DELIM);
+ ui_textedit_move(but, data, STRCUR_DIR_PREV, false, STRCUR_JUMP_DELIM);
ui_textedit_move(but, data, STRCUR_DIR_NEXT, true, STRCUR_JUMP_DELIM);
retval = WM_UI_HANDLER_BREAK;
changed = true;
@@ -2171,12 +2247,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
break;
case RIGHTARROWKEY:
ui_textedit_move(but, data, STRCUR_DIR_NEXT,
- event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
case LEFTARROWKEY:
ui_textedit_move(but, data, STRCUR_DIR_PREV,
- event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ event->shift != 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
case WHEELDOWNMOUSE:
@@ -2191,7 +2267,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* fall-through */
case ENDKEY:
ui_textedit_move(but, data, STRCUR_DIR_NEXT,
- event->shift, STRCUR_JUMP_ALL);
+ event->shift != 0, STRCUR_JUMP_ALL);
retval = WM_UI_HANDLER_BREAK;
break;
case WHEELUPMOUSE:
@@ -2206,7 +2282,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* fall-through */
case HOMEKEY:
ui_textedit_move(but, data, STRCUR_DIR_PREV,
- event->shift, STRCUR_JUMP_ALL);
+ event->shift != 0, STRCUR_JUMP_ALL);
retval = WM_UI_HANDLER_BREAK;
break;
case PADENTER:
@@ -2648,7 +2724,9 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
/* unlink icon is on right */
- if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS) {
+ if (ELEM4(event->type, LEFTMOUSE, EVT_BUT_OPEN, PADENTER, RETKEY) && event->val == KM_PRESS &&
+ ui_is_but_search_unlink_visible(but))
+ {
ARegion *ar = data->region;
rcti rect;
int x = event->x, y = event->y;
@@ -2659,9 +2737,14 @@ static int ui_do_but_SEARCH_UNLINK(bContext *C, uiBlock *block, uiBut *but, uiHa
rect.xmin = rect.xmax - (BLI_rcti_size_y(&rect));
if (BLI_rcti_isect_pt(&rect, x, y)) {
- ui_set_but_string(C, but, "");
+ /* most likely NULL, but let's check, and give it temp zero string */
+ if (data->str == NULL)
+ data->str = MEM_callocN(1, "temp str");
+ data->str[0] = 0;
+
+ ui_apply_but_TEX(C, but, data);
button_activate_state(C, but, BUTTON_STATE_EXIT);
-
+
return WM_UI_HANDLER_BREAK;
}
}
@@ -2672,7 +2755,7 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, cons
{
#ifdef USE_DRAG_TOGGLE
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_bool(but)) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS && ui_is_but_drag_toggle(but)) {
#if 0 /* UNUSED */
data->togdual = event->ctrl;
data->togonly = !event->shift;
@@ -2721,7 +2804,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && ui_is_but_bool(but)) {
+ if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -2763,9 +2846,10 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, con
}
/* var names match ui_numedit_but_NUM */
-static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap)
+static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange,
+ const enum eSnapType snap)
{
- if (tempf == softmin || tempf == softmax || snap == 0) {
+ if (tempf == softmin || tempf == softmax || snap == SNAP_OFF) {
/* pass */
}
else {
@@ -2791,16 +2875,19 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
softrange /= fac;
}
- if (snap == 1) {
+ if (snap == SNAP_ON) {
if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
else if (softrange < 21.0f) tempf = floorf(tempf);
else tempf = 10.0f * floorf(tempf / 10.0f);
}
- else if (snap == 2) {
+ else if (snap == SNAP_ON_SMALL) {
if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
else tempf = floor(tempf);
}
+ else {
+ BLI_assert(0);
+ }
if (fac != 1.0f)
tempf *= fac;
@@ -2809,18 +2896,19 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
return tempf;
}
-static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int snap)
+static float ui_numedit_apply_snap(int temp, float softmin, float softmax,
+ const enum eSnapType snap)
{
if (temp == softmin || temp == softmax)
return temp;
switch (snap) {
- case 0:
+ case SNAP_OFF:
break;
- case 1:
+ case SNAP_ON:
temp = 10 * (temp / 10);
break;
- case 2:
+ case SNAP_ON_SMALL:
temp = 100 * (temp / 100);
break;
}
@@ -2828,7 +2916,9 @@ static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int s
return temp;
}
-static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx)
+static bool ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data,
+ int mx,
+ const enum eSnapType snap, float fac)
{
float deler, tempf, softmin, softmax, softrange;
int lvalue, temp;
@@ -3037,16 +3127,14 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
click = 1;
}
else if (event->type == MOUSEMOVE) {
+ const enum eSnapType snap = ui_event_to_snap(event);
float fac;
- int snap;
fac = 1.0f;
if (event->shift) fac /= 10.0f;
if (event->alt) fac /= 20.0f;
-
- snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0;
- if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx : mx)))
+ if (ui_numedit_but_NUM(but, data, (ui_is_a_warp_but(but) ? screen_mx : mx), snap, fac))
ui_numedit_apply(C, block, but, data);
}
retval = WM_UI_HANDLER_BREAK;
@@ -3127,7 +3215,8 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data,
- const bool is_horizontal, const bool shift, const bool ctrl, int mx)
+ int mx, const bool is_horizontal,
+ const bool snap, const bool shift)
{
float deler, f, tempf, softmin, softmax, softrange;
int temp, lvalue;
@@ -3182,7 +3271,7 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data,
tempf = softmin + f * softrange;
temp = floorf(tempf + 0.5f);
- if (ctrl) {
+ if (snap) {
if (tempf == softmin || tempf == softmax) {
/* pass */
}
@@ -3303,7 +3392,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
click = 1;
}
else if (event->type == MOUSEMOVE) {
- if (ui_numedit_but_SLI(but, data, true, event->shift, event->ctrl, mx))
+ if (ui_numedit_but_SLI(but, data, mx, true, event->ctrl != 0, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
retval = WM_UI_HANDLER_BREAK;
@@ -3419,7 +3508,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (ui_numedit_but_SLI(but, data, horizontal, false, false, (horizontal) ? mx : my))
+ if (ui_numedit_but_SLI(but, data, (horizontal) ? mx : my, horizontal, false, false))
ui_numedit_apply(C, block, but, data);
}
@@ -3541,7 +3630,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
}
#ifdef USE_DRAG_TOGGLE
- if (event->type == LEFTMOUSE && ui_is_but_bool(but)) {
+ if (event->type == LEFTMOUSE && ui_is_but_drag_toggle(but)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
@@ -3610,7 +3699,9 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
return WM_UI_HANDLER_CONTINUE;
}
-static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my)
+static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data,
+ int mx, int my,
+ const enum eSnapType snap)
{
float dx, dy, rad, radsq, mrad, *fp;
int mdx, mdy;
@@ -3666,6 +3757,23 @@ static bool ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx,
}
normalize_v3(fp);
+ if (snap != SNAP_OFF) {
+ const int snap_steps = (snap == SNAP_ON) ? 4 : 12; /* 45 or 15 degree increments */
+ const float snap_steps_angle = M_PI / snap_steps;
+ float angle, angle_snap;
+ int i;
+
+ /* round each axis of 'fp' to the next increment
+ * do this in "angle" space - this gives increments of same size */
+ for (i = 0; i < 3; i++) {
+ angle = asinf(fp[i]);
+ angle_snap = floorf(0.5f + (angle / snap_steps_angle)) * snap_steps_angle;
+ fp[i] = sinf(angle_snap);
+ }
+ normalize_v3(fp);
+ changed = !compare_v3v3(fp, data->origvec, FLT_EPSILON);
+ }
+
data->draglastx = mx;
data->draglasty = my;
@@ -3717,6 +3825,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ const enum eSnapType snap = ui_event_to_snap(event);
data->dragstartx = mx;
data->dragstarty = my;
data->draglastx = mx;
@@ -3724,7 +3833,7 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_NORMAL(but, data, mx, my))
+ if (ui_numedit_but_NORMAL(but, data, mx, my, snap))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
@@ -3733,7 +3842,8 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_NORMAL(but, data, mx, my))
+ const enum eSnapType snap = ui_event_to_snap(event);
+ if (ui_numedit_but_NORMAL(but, data, mx, my, snap))
ui_numedit_apply(C, block, but, data);
}
}
@@ -3760,15 +3870,17 @@ static void clamp_axis_max_v3(float v[3], const float max)
}
}
-static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my, const short shift)
+static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
+ int mx, int my,
+ const enum eSnapType snap, const bool shift)
{
float rgb[3];
float *hsv = ui_block_hsv_get(but->block);
float x, y;
float mx_fl, my_fl;
bool changed = true;
- int color_profile = but->block->color_profile;
-
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
+
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
#ifdef USE_CONT_MOUSE_CORRECT
@@ -3780,14 +3892,9 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
}
#endif
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
- }
-
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3801,7 +3908,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
/* calculate original hsv again */
copy_v3_v3(rgb, data->origvec);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
copy_v3_v3(hsvo, ui_block_hsv_get(but->block));
@@ -3854,9 +3961,15 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
break;
}
+ if (snap != SNAP_OFF) {
+ if (ELEM3((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+ }
+
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && ((int)but->a1 != UI_GRAD_SV))
+ if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
/* clamp because with color conversion we can exceed range [#34295] */
@@ -3872,22 +3985,18 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
return changed;
}
-static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, const short shift)
+static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data,
+ wmNDOFMotionData *ndof,
+ const enum eSnapType snap, const bool shift)
{
float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
-
- int color_profile = but->block->color_profile;
-
- if (but->rnaprop) {
- if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
- }
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv);
@@ -3927,9 +4036,15 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
break;
}
+ if (snap != SNAP_OFF) {
+ if (ELEM3((int)but->a1, UI_GRAD_HV, UI_GRAD_HS, UI_GRAD_H)) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+ }
+
hsv_to_rgb_v(hsv, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_scene_linear_v3(but->block, rgb);
copy_v3_v3(data->vec, rgb);
@@ -3946,6 +4061,8 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ const enum eSnapType snap = ui_event_to_snap(event);
+
data->dragstartx = mx;
data->dragstarty = my;
data->draglastx = mx;
@@ -3953,15 +4070,16 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift))
+ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
}
else if (event->type == NDOF_MOTION) {
wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
+ const enum eSnapType snap = ui_event_to_snap(event);
- ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift);
+ ui_ndofedit_but_HSVCUBE(but, data, ndof, snap, event->shift != 0);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_button(C, but->block, but, data, true);
@@ -4012,7 +4130,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_HSVCUBE(but, data, mx, my, event->shift))
+ const enum eSnapType snap = ui_event_to_snap(event);
+
+ if (ui_numedit_but_HSVCUBE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
}
@@ -4026,7 +4146,9 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
return WM_UI_HANDLER_CONTINUE;
}
-static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float mx, float my, int shift)
+static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
+ float mx, float my,
+ const enum eSnapType snap, const bool shift)
{
rcti rect;
bool changed = true;
@@ -4084,6 +4206,10 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
if (but->flag & UI_BUT_COLOR_CUBIC)
hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]);
+ if (snap != SNAP_OFF) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+
hsv_to_rgb_v(hsv, rgb);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
@@ -4099,7 +4225,9 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float
return changed;
}
-static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, const short shift)
+static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data,
+ wmNDOFMotionData *ndof,
+ const enum eSnapType snap, const bool shift)
{
float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
@@ -4140,7 +4268,11 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
if (but->flag & UI_BUT_COLOR_LOCK) { // lock
if (hsv[2] == 0.0f) hsv[2] = 0.0001f;
}
-
+
+ if (snap != SNAP_OFF) {
+ ui_color_snap_hue(snap, &hsv[0]);
+ }
+
hsv_to_rgb_v(hsv, data->vec);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
@@ -4161,6 +4293,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ const enum eSnapType snap = ui_event_to_snap(event);
data->dragstartx = mx;
data->dragstarty = my;
data->draglastx = mx;
@@ -4168,15 +4301,16 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
+ if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
}
else if (event->type == NDOF_MOTION) {
+ const enum eSnapType snap = ui_event_to_snap(event);
wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
- ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift);
+ ui_ndofedit_but_HSVCIRCLE(but, data, ndof, snap, event->shift != 0);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_button(C, but->block, but, data, true);
@@ -4238,8 +4372,11 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
+ const enum eSnapType snap = ui_event_to_snap(event);
+
+ if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, snap, event->shift != 0)) {
ui_numedit_apply(C, block, but, data);
+ }
}
}
else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
@@ -4334,8 +4471,9 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
return WM_UI_HANDLER_CONTINUE;
}
-static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data, int snap,
- int evtx, int evty, const short shift)
+static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData *data,
+ int evtx, int evty,
+ bool snap, const bool shift)
{
CurveMapping *cumap = (CurveMapping *)but->poin;
CurveMap *cuma = cumap->cm + cumap->cur;
@@ -4363,7 +4501,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block, uiBut *but, uiHandleButtonData
d[1] = my - data->dragstarty;
if (len_v2(d) < 3.0f)
- snap = 0;
+ snap = false;
}
if (data->dragsel != -1) {
@@ -4558,7 +4696,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
if (event->type == MOUSEMOVE) {
if (event->x != data->draglastx || event->y != data->draglasty) {
- if (ui_numedit_but_CURVE(block, but, data, event->ctrl, event->x, event->y, event->shift))
+ if (ui_numedit_but_CURVE(block, but, data, event->x, event->y, event->ctrl != 0, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
}
@@ -4867,7 +5005,8 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, con
}
static bool ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data,
- int mx, int my, const short shift)
+ int mx, int my,
+ const bool shift)
{
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
bool changed = true;
@@ -4923,7 +5062,7 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
- if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
+ if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0))
ui_numedit_apply(C, block, but, data);
return WM_UI_HANDLER_BREAK;
@@ -4939,7 +5078,7 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
}
else if (event->type == MOUSEMOVE) {
if (mx != data->draglastx || my != data->draglasty) {
- if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
+ if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift != 0))
ui_numedit_apply(C, block, but, data);
}
}
@@ -5536,7 +5675,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
break;
case ROUNDBOX:
case LABEL:
- case LISTLABEL:
case ROW:
case LISTROW:
case BUT_IMAGE:
@@ -5749,7 +5887,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
bool ui_is_but_interactive(uiBut *but)
{
/* note, LABEL is included for highlights, this allows drags */
- if (ELEM(but->type, LABEL, LISTLABEL) && but->dragpoin == NULL)
+ if ((but->type == LABEL) && but->dragpoin == NULL)
return false;
if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
return false;
@@ -5761,6 +5899,13 @@ bool ui_is_but_interactive(uiBut *but)
return true;
}
+bool ui_is_but_search_unlink_visible(uiBut *but)
+{
+ BLI_assert(but->type == SEARCH_MENU_UNLINK);
+ return ((but->editstr == NULL) &&
+ (but->drawstr[0] != '\0'));
+}
+
uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
{
uiBlock *block;
@@ -6572,6 +6717,8 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
// retval = WM_UI_HANDLER_BREAK; XXX why ?
}
+ /* may have been re-allocated above (eyedropper for eg) */
+ data = but->active;
if (data->state == BUTTON_STATE_EXIT) {
uiBut *post_but = data->postbut;
uiButtonActivateType post_type = data->posttype;
@@ -6635,7 +6782,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar)
is_over_dragbut = true;
}
- if (is_over_dragbut && type == LEFTMOUSE && val == KM_PRESS) {
+ if (is_over_dragbut && type == LEFTMOUSE && val == KM_PRESS && !(but->flag & UI_BUT_DISABLED)) {
uiHandleButtonData *data;
int *size = (int *)but->poin;
@@ -7296,7 +7443,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH
for (but = block->buttons.first; but; but = but->next) {
int doit = FALSE;
- if (but->type != LABEL && but->type != LISTLABEL && but->type != SEPR)
+ if (!ELEM(but->type, LABEL, SEPR))
count++;
/* exception for rna layer buts */
@@ -7842,3 +7989,7 @@ bool UI_textbutton_activate_event(const bContext *C, ARegion *ar,
}
}
+void ui_button_clipboard_free(void)
+{
+ curvemapping_free_data(&but_copypaste_curve);
+}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 9cc16d82810..30d8535e471 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -95,7 +95,6 @@ typedef enum {
UI_WTYPE_SCROLL,
UI_WTYPE_LISTITEM,
UI_WTYPE_PROGRESSBAR,
- UI_WTYPE_LISTLABEL,
} uiWidgetTypeEnum;
/* menu scrolling */
@@ -108,13 +107,15 @@ typedef enum {
#define UI_PANEL_MINY 70
/* uiBut->flag */
-#define UI_SELECT 1 /* use when the button is pressed */
-#define UI_SCROLLED 2 /* temp hidden, scrolled away */
-#define UI_ACTIVE 4
-#define UI_HAS_ICON 8
-#define UI_TEXTINPUT 16
-#define UI_HIDDEN 32
-/* warn: rest of uiBut->flag in UI_interface.h */
+enum {
+ UI_SELECT = (1 << 0), /* use when the button is pressed */
+ UI_SCROLLED = (1 << 1), /* temp hidden, scrolled away */
+ UI_ACTIVE = (1 << 2),
+ UI_HAS_ICON = (1 << 3),
+ UI_TEXTINPUT = (1 << 4),
+ UI_HIDDEN = (1 << 5),
+ /* warn: rest of uiBut->flag in UI_interface.h */
+};
/* internal panel drawing defines */
#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */
@@ -385,6 +386,7 @@ extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rc
const float mx, const float my);
extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xpos, float *ypos);
extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp);
+bool ui_hsvcube_use_display_colorspace(struct uiBut *but);
extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision);
extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen);
@@ -402,6 +404,7 @@ extern bool ui_is_but_unit(uiBut *but);
extern bool ui_is_but_rna_valid(uiBut *but);
extern bool ui_is_but_utf8(uiBut *but);
extern bool ui_is_but_interactive(uiBut *but);
+extern bool ui_is_but_search_unlink_visible(uiBut *but);
extern int ui_is_but_push_ex(uiBut *but, double *value);
extern int ui_is_but_push(uiBut *but);
@@ -522,6 +525,7 @@ extern void ui_button_active_free(const struct bContext *C, uiBut *but);
extern bool ui_button_is_active(struct ARegion *ar);
extern int ui_button_open_menu_direction(uiBut *but);
extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore);
+void ui_button_clipboard_free(void);
/* interface_widgets.c */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b453a3b8363..b85c30b8710 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -54,6 +54,8 @@
#include "UI_interface.h"
+#include "ED_armature.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -375,6 +377,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
int cols = (len >= 20) ? 2 : 1;
const unsigned int colbuts = len / (2 * cols);
unsigned int layer_used = 0;
+ unsigned int layer_active = 0;
uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE));
@@ -384,27 +387,59 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
if (ptr->type == &RNA_Armature) {
bArmature *arm = (bArmature *)ptr->data;
+
layer_used = arm->layer_used;
+
+ if (arm->edbo) {
+ if (arm->act_edbone) {
+ layer_active |= arm->act_edbone->layer;
+ }
+ }
+ else {
+ if (arm->act_bone) {
+ layer_active |= arm->act_bone->layer;
+ }
+ }
}
for (b = 0; b < cols; b++) {
uiBlockBeginAlign(block);
for (a = 0; a < colbuts; a++) {
- if (layer_used & (1 << (a + b * colbuts))) icon = ICON_LAYER_USED;
- else icon = ICON_BLANK1;
+ int layer_num = a + b * colbuts;
+ int layer_flag = 1 << layer_num;
+
+ if (layer_used & layer_flag) {
+ if (layer_active & layer_flag)
+ icon = ICON_LAYER_ACTIVE;
+ else
+ icon = ICON_LAYER_USED;
+ }
+ else {
+ icon = ICON_BLANK1;
+ }
- but = uiDefAutoButR(block, ptr, prop, a + b * colbuts, "", icon, x + butw * a, y + buth, butw, buth);
+ but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + b * colbuts));
+ uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
}
for (a = 0; a < colbuts; a++) {
- if (layer_used & (1 << (a + len / 2 + b * colbuts))) icon = ICON_LAYER_USED;
- else icon = ICON_BLANK1;
+ int layer_num = a + len / 2 + b * colbuts;
+ int layer_flag = 1 << layer_num;
+
+ if (layer_used & layer_flag) {
+ if (layer_active & layer_flag)
+ icon = ICON_LAYER_ACTIVE;
+ else
+ icon = ICON_LAYER_USED;
+ }
+ else {
+ icon = ICON_BLANK1;
+ }
- but = uiDefAutoButR(block, ptr, prop, a + len / 2 + b * colbuts, "", icon, x + butw * a, y, butw, buth);
+ but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + len / 2 + b * colbuts));
+ uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num));
}
uiBlockEndAlign(block);
@@ -549,7 +584,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt
}
if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL)
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
}
uiBlockSetCurLayout(block, layout);
@@ -731,7 +766,7 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam
/* text alignment for toolbar buttons */
if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon)
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
if (flag & UI_ITEM_R_NO_BG)
uiBlockSetEmboss(block, UI_EMBOSS);
@@ -881,7 +916,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
uiItemL(column, item->name, ICON_NONE);
but = block->buttons.last;
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
ui_but_tip_from_enum_item(but, item);
}
else { /* XXX bug here, colums draw bottom item badly */
@@ -1305,7 +1340,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
uiItemL(column, item[i].name, ICON_NONE);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
ui_but_tip_from_enum_item(bt, &item[i]);
}
@@ -1455,7 +1490,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
but->hardmax = MAX2(but->hardmax, 256.0f);
but->rnasearchpoin = *searchptr;
but->rnasearchprop = searchprop;
- but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT;
if (RNA_property_type(prop) == PROP_ENUM) {
/* XXX, this will have a menu string,
@@ -1598,7 +1633,7 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
(force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */
{
but->type = MENU;
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
}
}
@@ -1650,13 +1685,13 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
* make text aligned right if the layout is aligned right.
*/
if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) {
- but->flag &= ~UI_TEXT_LEFT; /* default, needs to be unset */
- but->flag |= UI_TEXT_RIGHT;
+ but->drawflag &= ~UI_BUT_TEXT_LEFT; /* default, needs to be unset */
+ but->drawflag |= UI_BUT_TEXT_RIGHT;
}
/* Mark as a label inside a listbox. */
if (block->flag & UI_BLOCK_LIST_ITEM) {
- but->type = LISTLABEL;
+ but->flag |= UI_BUT_LIST_ITEM;
}
return but;
@@ -2423,7 +2458,10 @@ void ui_layout_list_set_labels_active(uiLayout *layout)
{
uiButtonItem *bitem;
for (bitem = layout->items.first; bitem; bitem = bitem->item.next) {
- if (bitem->item.type == ITEM_BUTTON && bitem->but->type == LISTLABEL) {
+ if (bitem->item.type != ITEM_BUTTON) {
+ ui_layout_list_set_labels_active((uiLayout *)(&bitem->item));
+ }
+ else if (bitem->but->flag & UI_BUT_LIST_ITEM) {
uiButSetFlag(bitem->but, UI_SELECT);
}
}
@@ -2931,7 +2969,7 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem)
BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); /* not exactly needed, rna has this */
if (but->optype) {
- char *opstr = WM_operator_pystring(but->block->evil_C, but->optype, but->opptr, 0);
+ char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, but->optype, but->opptr);
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
MEM_freeN(opstr);
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 15fbd51c6fc..f869c5de8e6 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -443,7 +443,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
- if (but->flag & UI_BUT_NO_TOOLTIP)
+ if (but->drawflag & UI_BUT_NO_TOOLTIP)
return NULL;
/* create tooltip data */
@@ -539,7 +539,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* so the context is passed to itemf functions (some py itemf functions use it) */
WM_operator_properties_sanitize(opptr, false);
- str = WM_operator_pystring(C, but->optype, opptr, 0);
+ str = WM_operator_pystring_ex(C, NULL, false, but->optype, opptr);
/* operator info */
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
@@ -1054,17 +1054,17 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, const bool reset)
bool ui_searchbox_autocomplete(bContext *C, ARegion *ar, uiBut *but, char *str)
{
uiSearchboxData *data = ar->regiondata;
- bool changed = false;
+ int match = AUTOCOMPLETE_NO_MATCH;
if (str[0]) {
data->items.autocpl = autocomplete_begin(str, ui_get_but_string_max_length(but));
but->search_func(C, but->search_arg, but->editstr, &data->items);
- changed = autocomplete_end(data->items.autocpl, str);
+ match = autocomplete_end(data->items.autocpl, str);
data->items.autocpl = NULL;
}
- return changed;
+ return match != AUTOCOMPLETE_NO_MATCH;
}
static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
@@ -1389,9 +1389,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
/* widget_roundbox_set has this correction too, keep in sync */
if (but->type != PULLDOWN) {
- if (but->flag & UI_BUT_ALIGN_TOP)
+ if (but->drawflag & UI_BUT_ALIGN_TOP)
butrct.ymax += U.pixelsize;
- if (but->flag & UI_BUT_ALIGN_LEFT)
+ if (but->drawflag & UI_BUT_ALIGN_LEFT)
butrct.xmin -= U.pixelsize;
}
@@ -1840,7 +1840,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
else {
uiItemL(layout, md->title, ICON_NONE);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
}
}
@@ -1876,7 +1876,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
if (entry->str[0]) {
uiItemL(column, entry->str, entry->icon);
bt = block->buttons.last;
- bt->flag = UI_TEXT_LEFT;
+ bt->drawflag = UI_BUT_TEXT_LEFT;
}
else {
uiItemS(column);
@@ -2560,7 +2560,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
}
else {
but = uiDefBut(pup->block, LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- but->flag = UI_TEXT_LEFT;
+ but->drawflag = UI_BUT_TEXT_LEFT;
}
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6b6b7114c84..1d1b7dbb835 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -443,7 +443,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
but->icon = RNA_struct_ui_icon(type);
/* default dragging of icon for id browse buttons */
uiButSetDragID(but, id);
- uiButSetFlag(but, UI_HAS_ICON | UI_ICON_LEFT);
+ uiButSetFlag(but, UI_HAS_ICON);
+ uiButSetDrawFlag(but, UI_BUT_ICON_LEFT);
}
if ((idfrom && idfrom->lib) || !editable)
@@ -967,11 +968,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
if (md->type == eModifierType_ParticleSystem) {
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
- if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) {
+ if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_duplicates_make_real");
- else if (psys->part->ren_as == PART_DRAW_PATH)
+ else if (psys->part->ren_as == PART_DRAW_PATH && psys->pathcache)
uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE,
"OBJECT_OT_modifier_convert");
}
@@ -1921,7 +1922,7 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
case UICURVE_FUNC_RESET_NEG:
case UICURVE_FUNC_RESET_POS: /* reset */
curvemap_reset(cuma, &cumap->clipr, cumap->preset,
- (event == -1) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE);
+ (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : CURVEMAP_SLOPE_POSITIVE);
curvemapping_changed(cumap, FALSE);
break;
case UICURVE_FUNC_RESET_VIEW:
@@ -2855,6 +2856,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
items_shown = dyn_data->items_shown;
if (items_shown >= 0) {
+ bool activei_mapping_pending = true;
items_ptr = MEM_mallocN(sizeof(_uilist_item) * items_shown, AT);
//printf("%s: items shown: %d.\n", __func__, items_shown);
RNA_PROP_BEGIN (dataptr, itemptr, prop)
@@ -2875,8 +2877,10 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
items_ptr[ii].org_idx = i;
items_ptr[ii].flt_flag = dyn_data->items_filter_flags ? dyn_data->items_filter_flags[i] : 0;
- if (activei == i) {
+ if (activei_mapping_pending && activei == i) {
activei = ii;
+ /* So that we do not map again activei! */
+ activei_mapping_pending = false;
}
# if 0 /* For now, do not alter active element, even if it will be hidden... */
else if (activei < i) {
@@ -2936,7 +2940,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL);
- uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
+ uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP);
sub = uiLayoutRow(overlap, FALSE);
@@ -3023,7 +3027,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y,
active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL);
- uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
+ uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP);
sub = uiLayoutRow(overlap, FALSE);
@@ -3065,11 +3069,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
if (ui_list->filter_flag & UILST_FLT_SHOW) {
but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_DOWN, 0, 0,
- UI_UNIT_X, UI_UNIT_Y * 0.6f, &(ui_list->filter_flag), 0, 0, 0, 0,
+ UI_UNIT_X, UI_UNIT_Y * 0.8f, &(ui_list->filter_flag), 0, 0, 0, 0,
TIP_("Hide filtering options"));
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
- but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.6f, ui_list,
+ but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.8f, ui_list,
0.0, 0.0, 0, -1, "");
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
@@ -3083,11 +3087,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co
}
else {
but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0,
- UI_UNIT_X, UI_UNIT_Y * 0.6f, &(ui_list->filter_flag), 0, 0, 0, 0,
+ UI_UNIT_X, UI_UNIT_Y * 0.8f, &(ui_list->filter_flag), 0, 0, 0, 0,
TIP_("Show filtering options"));
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
- but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.6f, ui_list,
+ but = uiDefIconBut(subblock, BUT, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.8f, ui_list,
0.0, 0.0, 0, -1, "");
uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
@@ -3236,6 +3240,16 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
handle_event = B_STOPCOMPO;
break;
}
+ else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) {
+ /* Skip bake jobs in compositor to avoid compo header displaying
+ * progress bar which is not being updated (bake jobs only need
+ * to update NC_IMAGE context.
+ */
+ if (sa->spacetype != SPACE_NODE) {
+ handle_event = B_STOPOTHER;
+ break;
+ }
+ }
else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) {
handle_event = B_STOPOTHER;
break;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 4be8812d68c..3058888c012 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -882,7 +882,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti
}
/* extra feature allows more alpha blending */
- if (ELEM(but->type, LABEL, LISTLABEL) && but->a1 == 1.0f)
+ if ((but->type == LABEL) && but->a1 == 1.0f)
alpha *= but->a2;
glEnable(GL_BLEND);
@@ -890,7 +890,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti
if (icon && icon != ICON_BLANK1) {
float ofs = 1.0f / aspect;
- if (but->flag & UI_ICON_LEFT) {
+ if (but->drawflag & UI_BUT_ICON_LEFT) {
if (but->block->flag & UI_BLOCK_LOOP) {
if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK))
xs = rect->xmin + 4.0f * ofs;
@@ -956,12 +956,12 @@ static void ui_text_clip_give_next_off(uiBut *but)
*/
static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
int okwidth = BLI_rcti_size_x(rect) - border;
if (but->flag & UI_HAS_ICON)
okwidth -= UI_DPI_ICON_SIZE;
- if (but->type == SEARCH_MENU_UNLINK && !but->editstr)
+ if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but))
okwidth -= BLI_rcti_size_y(rect);
okwidth = max_ii(okwidth, 0);
@@ -991,7 +991,7 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
*/
static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
@@ -1055,7 +1055,7 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
*/
static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
{
- int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int border = (but->drawflag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
char *cpoin = NULL;
int drawstr_len = strlen(but->drawstr);
@@ -1140,9 +1140,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
uiStyleFontSet(fstyle);
- if (but->editstr || (but->flag & UI_TEXT_LEFT))
+ if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT))
fstyle->align = UI_STYLE_TEXT_LEFT;
- else if (but->flag & UI_TEXT_RIGHT)
+ else if (but->drawflag & UI_BUT_TEXT_RIGHT)
fstyle->align = UI_STYLE_TEXT_RIGHT;
else
fstyle->align = UI_STYLE_TEXT_CENTER;
@@ -1310,22 +1310,22 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
/* icons default draw 0.8f x height */
rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect));
- if (but->editstr || (but->flag & UI_TEXT_LEFT)) {
+ if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
- else if ((but->flag & UI_TEXT_RIGHT)) {
+ else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
}
- else if ((but->flag & UI_TEXT_LEFT)) {
+ else if ((but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
- else if ((but->flag & UI_TEXT_RIGHT)) {
+ else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) {
rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
}
/* unlink icon for this button type */
- if (but->type == SEARCH_MENU_UNLINK && !but->editstr && but->drawstr[0]) {
+ if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but)) {
rcti temp = *rect;
temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f);
@@ -2004,10 +2004,11 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *
/* ************ custom buttons, old stuff ************** */
-/* draws in resolution of 20x4 colors */
+/* draws in resolution of 48x4 colors */
void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha)
{
- const float color_step = (type == UI_GRAD_H) ? 0.02f : 0.05f;
+ /* allows for 4 steps (red->yellow) */
+ const float color_step = (1.0 / 48.0);
int a;
float h = hsv[0], s = hsv[1], v = hsv[2];
float dx, dy, sx1, sx2, sy;
@@ -2066,6 +2067,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
/* old below */
for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */
+ const float dx_next = dx + color_step;
+
/* previous color */
copy_v3_v3(col0[0], col1[0]);
copy_v3_v3(col0[1], col1[1]);
@@ -2081,22 +2084,22 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
hsv_to_rgb(h, 1.0, dx, &col1[3][0], &col1[3][1], &col1[3][2]);
break;
case UI_GRAD_HV:
- hsv_to_rgb(dx, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
- hsv_to_rgb(dx, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
- hsv_to_rgb(dx, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
- hsv_to_rgb(dx, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
+ hsv_to_rgb(dx_next, s, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(dx_next, s, 0.333, &col1[1][0], &col1[1][1], &col1[1][2]);
+ hsv_to_rgb(dx_next, s, 0.666, &col1[2][0], &col1[2][1], &col1[2][2]);
+ hsv_to_rgb(dx_next, s, 1.0, &col1[3][0], &col1[3][1], &col1[3][2]);
break;
case UI_GRAD_HS:
- hsv_to_rgb(dx, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
- hsv_to_rgb(dx, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
- hsv_to_rgb(dx, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
- hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
+ hsv_to_rgb(dx_next, 0.0, v, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(dx_next, 0.333, v, &col1[1][0], &col1[1][1], &col1[1][2]);
+ hsv_to_rgb(dx_next, 0.666, v, &col1[2][0], &col1[2][1], &col1[2][2]);
+ hsv_to_rgb(dx_next, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]);
break;
case UI_GRAD_H:
{
/* annoying but without this the color shifts - could be solved some other way
* - campbell */
- hsv_to_rgb(dx + color_step, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
+ hsv_to_rgb(dx_next, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]);
copy_v3_v3(col1[1], col1[0]);
copy_v3_v3(col1[2], col1[0]);
copy_v3_v3(col1[3], col1[0]);
@@ -2117,8 +2120,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
/* rect */
- sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
- sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect);
+ sx1 = rect->xmin + dx * BLI_rcti_size_x(rect);
+ sx2 = rect->xmin + dx_next * BLI_rcti_size_x(rect);
sy = rect->ymin;
dy = (float)BLI_rcti_size_y(rect) / 3.0f;
@@ -2143,6 +2146,19 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons
}
+bool ui_hsvcube_use_display_colorspace(uiBut *but)
+{
+ bool color_profile = but->block->color_profile;
+
+ if (but->rnaprop) {
+ if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
+ color_profile = FALSE;
+ }
+
+ /* SV+H gradient does not use display colorspace */
+ return color_profile && !ELEM((int)but->a1, UI_GRAD_SV, UI_GRAD_H);
+}
+
void ui_hsvcube_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp)
{
float x, y;
@@ -2179,16 +2195,13 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
float x = 0.0f, y = 0.0f;
float *hsv = ui_block_hsv_get(but->block);
float hsv_n[3];
- int color_profile = but->block->color_profile;
-
- if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
- color_profile = FALSE;
+ bool use_display_colorspace = ui_hsvcube_use_display_colorspace(but);
copy_v3_v3(hsv_n, hsv);
ui_get_but_vectorf(but, rgb);
- if (color_profile && (int)but->a1 != UI_GRAD_SV)
+ if (use_display_colorspace)
ui_block_to_display_space_v3(but->block, rgb);
rgb_to_hsv_compat_v(rgb, hsv_n);
@@ -2853,12 +2866,21 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
/* labels use Editor theme colors for text */
static void widget_state_label(uiWidgetType *wt, int state)
{
- /* call this for option button */
- widget_state(wt, state);
- if (state & UI_SELECT)
- UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
- else
- UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
+ if (state & UI_BUT_LIST_ITEM) {
+ /* Override default label theme's colors. */
+ bTheme *btheme = UI_GetTheme();
+ wt->wcol_theme = &btheme->tui.wcol_list_item;
+ /* call this for option button */
+ widget_state(wt, state);
+ }
+ else {
+ /* call this for option button */
+ widget_state(wt, state);
+ if (state & UI_SELECT)
+ UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
+ else
+ UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
+ }
}
static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -2978,11 +3000,6 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
case UI_WTYPE_REGULAR:
break;
- case UI_WTYPE_LISTLABEL:
- wt.wcol_theme = &btheme->tui.wcol_list_item;
- wt.draw = NULL;
- /* Can't use usual label code. */
- break;
case UI_WTYPE_LABEL:
wt.draw = NULL;
wt.state = widget_state_label;
@@ -3126,15 +3143,15 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
int roundbox = UI_CNR_ALL;
/* alignment */
- if ((but->flag & UI_BUT_ALIGN) && but->type != PULLDOWN) {
+ if ((but->drawflag & UI_BUT_ALIGN) && but->type != PULLDOWN) {
/* ui_block_position has this correction too, keep in sync */
- if (but->flag & UI_BUT_ALIGN_TOP)
+ if (but->drawflag & UI_BUT_ALIGN_TOP)
rect->ymax += U.pixelsize;
- if (but->flag & UI_BUT_ALIGN_LEFT)
+ if (but->drawflag & UI_BUT_ALIGN_LEFT)
rect->xmin -= U.pixelsize;
- switch (but->flag & UI_BUT_ALIGN) {
+ switch (but->drawflag & UI_BUT_ALIGN) {
case UI_BUT_ALIGN_TOP:
roundbox = UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT;
break;
@@ -3232,11 +3249,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
fstyle = &style->widgetlabel;
}
break;
-
- case LISTLABEL:
- wt = widget_type(UI_WTYPE_LISTLABEL);
- fstyle = &style->widgetlabel;
- break;
case SEPR:
break;
@@ -3282,7 +3294,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case OPTIONN:
if (!(but->flag & UI_HAS_ICON)) {
wt = widget_type(UI_WTYPE_OPTION);
- but->flag |= UI_TEXT_LEFT;
+ but->drawflag |= UI_BUT_TEXT_LEFT;
}
else
wt = widget_type(UI_WTYPE_TOGGLE);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index ace35f0276e..55b353b1031 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1406,6 +1406,7 @@ void init_userdef_do_versions(void)
}
if (U.pad_rot_angle == 0)
U.pad_rot_angle = 15;
+
/* graph editor - unselected F-Curve visibility */
if (U.fcu_inactive_alpha == 0) {
U.fcu_inactive_alpha = 0.25f;
@@ -2224,7 +2225,14 @@ void init_userdef_do_versions(void)
rgba_char_args_test_set(btheme->tima.uv_shadow, 112, 112, 112, 255);
}
}
-
+
+ if (U.versionfile < 270) {
+ /* grease pencil - new layer color */
+ if (U.gpencil_new_layer_col[3] < 0.1f) {
+ /* defaults to black, but must at least be visible! */
+ U.gpencil_new_layer_col[3] = 0.9f;
+ }
+ }
if (U.pixelsize == 0.0f)
U.pixelsize = 1.0f;
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 00113666872..c5c9b1c8ce4 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -284,10 +284,9 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
-static int view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
+static void view_pan_cancel(bContext *UNUSED(C), wmOperator *op)
{
view_pan_exit(op);
- return OPERATOR_CANCELLED;
}
static void VIEW2D_OT_pan(wmOperatorType *ot)
@@ -906,11 +905,9 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
}
}
-static int view_zoomdrag_cancel(bContext *C, wmOperator *op)
+static void view_zoomdrag_cancel(bContext *C, wmOperator *op)
{
view_zoomdrag_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
/* for 'redo' only, with no user input */
@@ -1579,11 +1576,9 @@ static void scroller_activate_exit(bContext *C, wmOperator *op)
}
}
-static int scroller_activate_cancel(bContext *C, wmOperator *op)
+static void scroller_activate_cancel(bContext *C, wmOperator *op)
{
scroller_activate_exit(C, op);
-
- return OPERATOR_CANCELLED;
}
/* apply transform to view (i.e. adjust 'cur' rect) */