diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-18 04:48:59 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-18 04:48:59 +0400 |
commit | c1ceab1281ccf061f03f8000bf190a082a5385d8 (patch) | |
tree | 01b9a9cfca80432d316bdad6c18c74eb025e9eb0 /source/blender/editors/interface | |
parent | 0d9c98c4bbfbc8c70c4772086dd09a51d01921ef (diff) | |
parent | 66a35e089a64d27bfc09c2225a530069eca05875 (diff) |
Merged changes in the trunk up to revision 55357.
Resolved conflicts:
release/datafiles/startup.blend
source/blender/editors/space_nla/nla_buttons.c
Also updated source/blender/blenkernel/intern/linestyle.c as a follow-up of
recent changes for the use of bool.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 86 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 38 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 30 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 22 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 26 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 44 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 9 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 20 |
15 files changed, 194 insertions, 125 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2c17a629ed4..4f0d788d733 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -231,7 +231,9 @@ static void ui_text_bounds_block(uiBlock *block, float offset) nextcol = 1; col++; } - else nextcol = 0; + else { + nextcol = 0; + } bt->rect.xmin = x1addval; bt->rect.xmax = bt->rect.xmin + i + block->bounds; @@ -1461,6 +1463,8 @@ double ui_get_but_val(uiBut *but) if (but->rnaprop) { prop = but->rnaprop; + BLI_assert(but->rnaindex != -1); + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_check(prop)) @@ -1642,6 +1646,9 @@ static double ui_get_but_scale_unit(uiBut *but, double value) if (unit_type == PROP_UNIT_LENGTH) { return value * (double)unit->scale_length; } + else if (unit_type == PROP_UNIT_CAMERA) { + return value * (double)unit->scale_length; + } else if (unit_type == PROP_UNIT_AREA) { return value * pow(unit->scale_length, 2); } @@ -1674,18 +1681,28 @@ void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) } } -static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad) +/** + * \param float_precision Override the button precision. + */ +static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad, int float_precision) { UnitSettings *unit = but->block->unit; int do_split = unit->flag & USER_UNIT_OPT_SPLIT; int unit_type = uiButGetUnitType(but); - int precision = but->a2; + int precision; if (unit->scale_length < 0.0001f) unit->scale_length = 1.0f; // XXX do_versions - /* Sanity checks */ - if (precision > PRECISION_FLOAT_MAX) precision = PRECISION_FLOAT_MAX; - else if (precision == 0) precision = 2; + /* Use precision override? */ + if (float_precision == -1) { + /* Sanity checks */ + precision = (int)but->a2; + if (precision > PRECISION_FLOAT_MAX) precision = PRECISION_FLOAT_MAX; + else if (precision == 0) precision = 2; + } + else { + precision = float_precision; + } bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type), do_split, pad); @@ -1706,8 +1723,10 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) } } - -void ui_get_but_string(uiBut *but, char *str, size_t maxlen) +/** + * \param float_precision For number buttons the precission to use or -1 to fallback to the button default. + */ +void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision) { if (but->rnaprop && ELEM4(but->type, TEX, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { PropertyType type; @@ -1779,10 +1798,10 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) if (ui_is_but_float(but)) { if (ui_is_but_unit(but)) { - ui_get_but_string_unit(but, str, maxlen, value, 0); + ui_get_but_string_unit(but, str, maxlen, value, 0, float_precision); } else { - const int prec = ui_but_float_precision(but, value); + const int prec = (float_precision == -1) ? ui_but_float_precision(but, value) : float_precision; BLI_snprintf(str, maxlen, "%.*f", prec, value); } } @@ -1790,6 +1809,10 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) BLI_snprintf(str, maxlen, "%d", (int)value); } } +void ui_get_but_string(uiBut *but, char *str, const size_t maxlen) +{ + ui_get_but_string_ex(but, str, maxlen, -1); +} #ifdef WITH_PYTHON @@ -1984,7 +2007,8 @@ static double soft_range_round_down(double value, double max) return newmax; } -void ui_set_but_soft_range(uiBut *but, double value) +/* note: this could be split up into functions which handle arrays and not */ +static void ui_set_but_soft_range(uiBut *but) { /* ideally we would not limit this but practically, its more then * enough worst case is very long vectors wont use a smart soft-range @@ -1993,14 +2017,14 @@ void ui_set_but_soft_range(uiBut *but, double value) if (but->rnaprop) { const PropertyType type = RNA_property_type(but->rnaprop); double softmin, softmax /*, step, precision*/; - double value_min = value; - double value_max = value; + double value_min; + double value_max; /* clamp button range to something reasonable in case * we get -inf/inf from RNA properties */ if (type == PROP_INT) { + const bool is_array = RNA_property_array_check(but->rnaprop); int imin, imax, istep; - const int array_len = RNA_property_array_length(&but->rnapoin, but->rnaprop); RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep); softmin = (imin == INT_MIN) ? -1e4 : imin; @@ -2008,16 +2032,19 @@ void ui_set_but_soft_range(uiBut *but, double value) /*step = istep;*/ /*UNUSED*/ /*precision = 1;*/ /*UNUSED*/ - if (array_len >= 2) { + if (is_array) { int value_range[2]; RNA_property_int_get_array_range(&but->rnapoin, but->rnaprop, value_range); value_min = (double)value_range[0]; value_max = (double)value_range[1]; } + else { + value_min = value_max = (double)RNA_property_int_get(&but->rnapoin, but->rnaprop); + } } else if (type == PROP_FLOAT) { + const bool is_array = RNA_property_array_check(but->rnaprop); float fmin, fmax, fstep, fprecision; - const int array_len = RNA_property_array_length(&but->rnapoin, but->rnaprop); RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision); softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin; @@ -2025,15 +2052,19 @@ void ui_set_but_soft_range(uiBut *but, double value) /*step = fstep;*/ /*UNUSED*/ /*precision = fprecision;*/ /*UNUSED*/ - if (array_len >= 2) { + if (is_array) { float value_range[2]; RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range); value_min = (double)value_range[0]; value_max = (double)value_range[1]; } + else { + value_min = value_max = (double)RNA_property_float_get(&but->rnapoin, but->rnaprop); + } } - else + else { return; + } /* if the value goes out of the soft/max range, adapt the range */ if (value_min + 1e-10 < softmin) { @@ -2260,8 +2291,7 @@ void ui_check_but(uiBut *but) /* only update soft range while not editing */ if (but->rnaprop && !(but->editval || but->editstr || but->editvec)) { - UI_GET_BUT_VALUE_INIT(but, value); - ui_set_but_soft_range(but, value); + ui_set_but_soft_range(but); } /* test for min and max, icon sliders, etc */ @@ -2345,7 +2375,7 @@ void ui_check_but(uiBut *but) /* support length type buttons */ else if (ui_is_but_unit(but)) { char new_str[sizeof(but->drawstr)]; - ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); + ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE, -1); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); } else { @@ -2530,7 +2560,9 @@ static void ui_block_do_align_but(uiBut *first, short nr) else flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT; } - else flag = UI_BUT_ALIGN_TOP; + else { + flag = UI_BUT_ALIGN_TOP; + } } } else if (buts_are_horiz(but, next)) { @@ -2550,7 +2582,9 @@ static void ui_block_do_align_but(uiBut *first, short nr) if (bt == NULL || bt->alignnr != nr) flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT; } } - else flag |= UI_BUT_ALIGN_LEFT; + else { + flag |= UI_BUT_ALIGN_LEFT; + } } else { if (cols == 0) { @@ -2712,8 +2746,8 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->retval = retval; slen = strlen(str); - if (slen >= UI_MAX_NAME_STR - 1) { - but->str = MEM_mallocN(slen + 2, "ui_def_but str"); /* why +2 ? */ + if (slen >= UI_MAX_NAME_STR) { + but->str = MEM_mallocN(slen + 1, "ui_def_but str"); } else { but->str = but->strdata; @@ -3016,7 +3050,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * } #if 0 /* UNUSED */ -static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock * block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) +static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip) { wmOperatorType *ot = WM_operatortype_find(opname, 0); if (str == NULL && ot == NULL) str = opname; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index e19e89af5da..5486e12c6bf 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -97,7 +97,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r } glVertex2f(maxx, miny + rad); } - else glVertex2f(maxx, miny); + else { + glVertex2f(maxx, miny); + } /* corner right-top */ if (roundboxtype & UI_CNR_TOP_RIGHT) { @@ -107,7 +109,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r } glVertex2f(maxx - rad, maxy); } - else glVertex2f(maxx, maxy); + else { + glVertex2f(maxx, maxy); + } /* corner left-top */ if (roundboxtype & UI_CNR_TOP_LEFT) { @@ -117,7 +121,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r } glVertex2f(minx, maxy - rad); } - else glVertex2f(minx, maxy); + else { + glVertex2f(minx, maxy); + } /* corner left-bottom */ if (roundboxtype & UI_CNR_BOTTOM_LEFT) { @@ -127,7 +133,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r } glVertex2f(minx + rad, miny); } - else glVertex2f(minx, miny); + else { + glVertex2f(minx, miny); + } glEnd(); } @@ -381,16 +389,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad) /* (old, used in outliner) plain antialiased filled box */ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) { - float color[4]; - - if (roundboxtype & UI_RB_ALPHA) { - glGetFloatv(GL_CURRENT_COLOR, color); - color[3] = 0.5; - glColor4fv(color); - glEnable(GL_BLEND); - } - - ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad); + ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, roundboxtype & UI_RB_ALPHA); } @@ -454,8 +453,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w float facy = (float)h / (float)ibuf->y; glPixelZoom(facx, facy); } - glaDrawPixelsSafe((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - //glaDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsAuto((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect); glPixelZoom(1.0f, 1.0f); @@ -1301,8 +1299,10 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) glEndList(); } - else glCallList(displist); - + else { + glCallList(displist); + } + /* restore */ glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); @@ -1602,7 +1602,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height, scopes->track_search, scopes->track, - &scopes->undist_marker, scopes->use_track_mask, + &scopes->undist_marker, TRUE, scopes->use_track_mask, width, height, scopes->track_pos); if (tmpibuf) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e0d6c293be5..12a6343c7e7 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -235,14 +235,13 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val) BLI_assert(*type == MOUSEPAN); /* sign differs, reset */ - if ((dy > 0 && lastdy < 0) || (dy < 0 && lastdy > 0)) + if ((dy > 0 && lastdy < 0) || (dy < 0 && lastdy > 0)) { lastdy = dy; + } else { lastdy += dy; if (ABS(lastdy) > (int)UI_UNIT_Y) { - int dy = event->prevy - event->y; - if (U.uiflag2 & USER_TRACKPAD_NATURAL) dy = -dy; @@ -804,8 +803,6 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const * button we mouse over is X or Y aligned, then lock the mouse to that axis after. */ if (drag_info->xy_lock[0] == false && drag_info->xy_lock[1] == false) { - ARegion *ar = CTX_wm_region(C); - /* first store the buttons original coords */ uiBut *but = ui_but_find_mouse_over(ar, xy_input[0], xy_input[1]); if (but) { @@ -1402,7 +1399,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* pass */ } else if (mode == 'c') { - ui_get_but_string(but, buf, sizeof(buf)); + /* Get many decimal places, then strip trailing zeros. + * note: too high values start to give strange results (6 or so is ok) */ + ui_get_but_string_ex(but, buf, sizeof(buf), 6); + BLI_str_rstrip_float_zero(buf, '\0'); + WM_clipboard_text_set(buf, 0); } else { @@ -1984,6 +1985,10 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) data->str = MEM_callocN(sizeof(char) * data->maxlen + 1, "textedit str"); ui_get_but_string(but, data->str, data->maxlen); + if (ui_is_but_float(but) && !ui_is_but_unit(but)) { + BLI_str_rstrip_float_zero(data->str, '\0'); + } + if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { ui_convert_to_unit_alt_name(but, data->str, data->maxlen); } @@ -2327,7 +2332,7 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) data->coba = (ColorBand *)but->poin; but->editcoba = data->coba; } - else if (ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) { + else if (ELEM4(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE, COLOR)) { ui_get_but_vectorf(but, data->origvec); copy_v3_v3(data->vec, data->origvec); but->editvec = data->vec; @@ -3149,9 +3154,6 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, BLI_rctf_clamp_pt_v(&but->rect, data->ungrab_mval); } #endif - if (is_horizontal == false) { - mx_fl = my_fl; - } /* done correcting mouse */ @@ -5013,7 +5015,7 @@ static int ui_but_menu(bContext *C, uiBut *but) uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); if (but->rnapoin.data && but->rnaprop) { - short is_anim = RNA_property_animateable(&but->rnapoin, but->rnaprop); + bool is_anim = RNA_property_animateable(&but->rnapoin, but->rnaprop); /* second slower test, saved people finding keyframe items in menus when its not possible */ if (is_anim) @@ -6294,7 +6296,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) { uiHandleButtonData *data = but->active; - const uiButtonActivateType state_orig = data->state; + const uiHandleButtonState state_orig = data->state; uiBlock *block; ARegion *ar; int retval; @@ -6466,9 +6468,9 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) * This is needed to make sure if a button was active, * it stays active while the mouse is over it. * This avoids adding mousemoves, see: [#33466] */ - if (ELEM(state_orig, BUTTON_ACTIVATE, BUTTON_ACTIVATE_OVER)) { + if (ELEM(state_orig, BUTTON_STATE_INIT, BUTTON_STATE_HIGHLIGHT)) { if (ui_but_find_mouse_over(ar, event->x, event->y) == but) { - button_activate_init(C, ar, but, state_orig); + button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); } } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 086e9dad895..09686d7b416 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -47,6 +47,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLI_fileops_types.h" #include "DNA_brush_types.h" #include "DNA_dynamicpaint_types.h" @@ -703,10 +704,8 @@ static void init_iconfile_list(struct ListBase *list) { IconFile *ifile; struct direntry *dir; - int restoredir = 1; /* restore to current directory */ int totfile, i, index = 1; const char *icondir; - char olddir[FILE_MAX]; list->first = list->last = NULL; icondir = BLI_get_folder(BLENDER_DATAFILES, "icons"); @@ -714,12 +713,7 @@ static void init_iconfile_list(struct ListBase *list) if (icondir == NULL) return; - /* since BLI_dir_contents changes the current working directory, restore it - * back to old value afterwards */ - if (!BLI_current_working_dir(olddir, sizeof(olddir))) - restoredir = 0; totfile = BLI_dir_contents(icondir, &dir); - if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */ for (i = 0; i < totfile; i++) { if ((dir[i].type & S_IFREG)) { @@ -766,18 +760,8 @@ static void init_iconfile_list(struct ListBase *list) } } } - - /* free temporary direntry structure that's been created by BLI_dir_contents() */ - i = totfile - 1; - - for (; i >= 0; i--) { - MEM_freeN(dir[i].relname); - MEM_freeN(dir[i].path); - if (dir[i].string) { - MEM_freeN(dir[i].string); - } - } - free(dir); + + BLI_free_filelist(dir, totfile); dir = NULL; } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9093e8f8d30..6065fcfe574 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -394,7 +394,8 @@ extern void ui_set_but_vectorf(uiBut *but, const float vec[3]); extern void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rect, const float mx, const float my); -extern void ui_get_but_string(uiBut *but, char *str, size_t maxlen); +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); extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen); extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str); extern int ui_get_but_string_max_length(uiBut *but); @@ -402,8 +403,6 @@ extern int ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char extern void ui_set_but_default(struct bContext *C, short all); -extern void ui_set_but_soft_range(uiBut *but, double value); - extern void ui_check_but(uiBut *but); extern int ui_is_but_float(uiBut *but); extern int ui_is_but_bool(uiBut *but); @@ -523,7 +522,7 @@ extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiB /* interface_widgets.c */ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); -void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad); +void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); uiWidgetColors *ui_tooltip_get_theme(void); void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock * block, rcti * rect); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1e95b4df762..2ca26ae5317 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1567,7 +1567,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const } if (!name) { - name = IFACE_(mt->label); + name = CTX_IFACE_(mt->translation_context, mt->label); } if (layout->root->type == UI_LAYOUT_MENU && !icon) @@ -2369,6 +2369,7 @@ uiLayout *uiLayoutAbsolute(uiLayout *layout, int align) litem->active = 1; litem->enabled = 1; litem->context = layout->context; + litem->redalert = layout->redalert; BLI_addtail(&layout->items, litem); uiBlockSetCurLayout(layout->root->block, litem); @@ -2396,6 +2397,7 @@ uiLayout *uiLayoutOverlap(uiLayout *layout) litem->active = 1; litem->enabled = 1; litem->context = layout->context; + litem->redalert = layout->redalert; BLI_addtail(&layout->items, litem); uiBlockSetCurLayout(layout->root->block, litem); @@ -2415,6 +2417,7 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) split->litem.enabled = 1; split->litem.context = layout->context; split->litem.space = layout->root->style->columnspace; + split->litem.redalert = layout->redalert; split->litem.w = layout->w; split->percentage = percentage; BLI_addtail(&layout->items, split); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 3298859ee0c..145deb35667 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -239,7 +239,7 @@ static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, } /* main modal status check */ -static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event) +static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) { Eyedropper *eye = (Eyedropper *)op->customdata; @@ -285,7 +285,7 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event) } /* Modal Operator init */ -static int eyedropper_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { /* init */ if (eyedropper_init(C, op)) { @@ -853,7 +853,7 @@ static int editsource_exec(bContext *C, wmOperator *op) ED_region_do_draw(C, ar); for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash); - !BLI_ghashIterator_isDone(&ghi); + BLI_ghashIterator_notDone(&ghi); BLI_ghashIterator_step(&ghi)) { uiBut *but_key = BLI_ghashIterator_getKey(&ghi); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index e466c481151..a741ea432a5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -191,7 +191,7 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar) Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open) { Panel *pa, *patab, *palast, *panext; - char *drawname = pt->label; + const char *drawname = CTX_IFACE_(pt->translation_context, pt->label); char *idname = pt->idname; char *tabname = pt->idname; char *hookname = NULL; @@ -469,7 +469,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r Panel *panel = block->panel; rcti hrect; int pnl_icons; - const char *activename = IFACE_(panel->drawname[0] ? panel->drawname : panel->panelname); + const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname; /* + 0.001f to avoid flirting with float inaccuracy */ if (panel->control & UI_PNL_CLOSE) pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 03c127f33c8..febd1820e5c 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -663,9 +663,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* since the text has beens caled already, the size of tooltips is defined now */ /* here we try to figure out the right location */ if (butregion) { - float ofsx = rect_fl.xmin, ofsy = rect_fl.ymax; - ui_block_to_window_fl(butregion, but->block, &ofsx, &ofsy); - BLI_rctf_translate(&rect_fl, ofsx - rect_fl.xmin, ofsy - rect_fl.ymax); + float ofsx_fl = rect_fl.xmin, ofsy_fl = rect_fl.ymax; + ui_block_to_window_fl(butregion, but->block, &ofsx_fl, &ofsy_fl); + BLI_rctf_translate(&rect_fl, ofsx_fl - rect_fl.xmin, ofsy_fl - rect_fl.ymax); } BLI_rcti_rctf_copy(&rect_i, &rect_fl); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index ef24ea951e3..dd4886a7243 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -216,7 +216,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) /* rotate counter-clockwise for now (assumes left-to-right language)*/ xofs += height; yofs = BLF_width(fs->uifont_id, str) + 5; - angle = 90.0f; + angle = (float)M_PI / 2.0f; /* translate rect to vertical */ txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect); @@ -330,6 +330,8 @@ void uiStyleInit(void) { uiFont *font = U.uifonts.first; uiStyle *style = U.uistyles.first; + int monofont_size = datatoc_bmonofont_ttf_size; + unsigned char *monofont_ttf = (unsigned char *)datatoc_bmonofont_ttf; /* recover from uninitialized dpi */ if (U.dpi == 0) @@ -400,15 +402,33 @@ void uiStyleInit(void) ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT); } +#ifdef WITH_INTERNATIONAL + /* use unicode font for text editor and interactive console */ + if (U.transopts & USER_DOTRANSLATE) { + monofont_ttf = BLF_get_unifont_mono(&monofont_size); + + if (!monofont_ttf) { + /* fall back if not found */ + monofont_size = datatoc_bmonofont_ttf_size; + monofont_ttf = (unsigned char *)datatoc_bmonofont_ttf; + } + } + + /* reload */ + BLF_unload("monospace"); + blf_mono_font = -1; + blf_mono_font_render = -1; +#endif + /* XXX, this should be moved into a style, but for now best only load the monospaced font once. */ if (blf_mono_font == -1) - blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + blf_mono_font = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size); BLF_size(blf_mono_font, 12 * U.pixelsize, 72); /* second for rendering else we get threading problems */ if (blf_mono_font_render == -1) - blf_mono_font_render = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + blf_mono_font_render = BLF_load_mem_unique("monospace", monofont_ttf, monofont_size); BLF_size(blf_mono_font_render, 12 * U.pixelsize, 72 ); } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 83540cef9fc..afb44101910 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -281,11 +281,13 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) if (id->flag & LIB_FAKEUSER) id_us_plus(id); else id_us_min(id); } - else return; + else { + return; + } break; case UI_ID_LOCAL: if (id) { - if (id_make_local(id, 0)) { + if (id_make_local(id, false)) { /* reassign to get get proper updates/notifiers */ idptr = RNA_property_pointer_get(&template->ptr, template->prop); RNA_property_pointer_set(&template->ptr, template->prop, idptr); @@ -465,7 +467,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str else { but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local")); - if (!id_make_local(id, 1 /* test */) || (idfrom && idfrom->lib)) + if (!id_make_local(id, true /* test */) || (idfrom && idfrom->lib)) uiButSetFlag(but, UI_BUT_DISABLED); } @@ -483,7 +485,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); if (/* test only */ - (id_copy(id, NULL, 1) == FALSE) || + (id_copy(id, NULL, true) == false) || (idfrom && idfrom->lib) || (editable == FALSE) || /* object in editmode - don't change data */ @@ -676,7 +678,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co const char *text) { PropertyRNA *propID, *propType; - uiLayout *row; + uiLayout *split, *row, *sub; /* get properties... */ propID = RNA_struct_find_property(ptr, propname); @@ -692,22 +694,34 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, TRUE); + split = uiLayoutSplit(layout, 0.33f, FALSE); /* NOTE: split amount here needs to be synced with normal labels */ + + /* FIRST PART ................................................ */ + row = uiLayoutRow(split, FALSE); /* Label - either use the provided text, or will become "ID-Block:" */ if (text) { if (text[0]) uiItemL(row, text, ICON_NONE); } - else + else { uiItemL(row, IFACE_("ID-Block:"), ICON_NONE); + } + + /* SECOND PART ................................................ */ + row = uiLayoutRow(split, TRUE); /* ID-Type Selector - just have a menu of icons */ - /* FIXME: the icon-only setting doesn't work when we supply a blank name */ - uiItemFullR(row, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + sub = uiLayoutRow(row, TRUE); /* HACK: special group just for the enum, otherwise we */ + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */ + + uiItemFullR(sub, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* ID-Block Selector - just use pointer widget... */ - uiItemFullR(row, ptr, propID, 0, 0, 0, "", ICON_NONE); + sub = uiLayoutRow(row, TRUE); /* HACK: special group to counteract the effects of the previous */ + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */ + + uiItemFullR(sub, ptr, propID, 0, 0, 0, "", ICON_NONE); } /********************* RNA Path Builder Template ********************/ @@ -2135,10 +2149,10 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiLayoutRow(layout, TRUE); uiBlockSetNFunc(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap); - bt = uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, - &cmp->x, bounds.xmin, bounds.xmax, 1, 5, ""); - bt = uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, - &cmp->y, bounds.ymin, bounds.ymax, 1, 5, ""); + uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, + &cmp->x, bounds.xmin, bounds.xmax, 1, 5, ""); + uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, + &cmp->y, bounds.ymin, bounds.ymax, 1, 5, ""); } /* black/white levels */ @@ -2727,7 +2741,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char { GHashIterator *iter = WM_operatortype_iter(); - for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for (; BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter)) { wmOperatorType *ot = BLI_ghashIterator_getValue(iter); if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index dd7b1d0ee06..78b6d2541fd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -218,13 +218,16 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y glDisable(GL_BLEND); } -void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad) +void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha) { float color[4]; int j; glEnable(GL_BLEND); glGetFloatv(GL_CURRENT_COLOR, color); + if (use_alpha) { + color[3] = 0.5f; + } color[3] *= 0.125f; glColor4fv(color); @@ -1289,7 +1292,9 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) { ui_text_clip_left(fstyle, but, rect); } - else but->ofs = 0; + else { + but->ofs = 0; + } /* check for button text label */ if (but->type == ICONTEXTROW) { diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index acea6e133f4..09122737373 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -279,6 +279,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->vertex; break; case TH_VERTEX_SELECT: cp = ts->vertex_select; break; + case TH_VERTEX_UNREFERENCED: + cp = ts->vertex_unreferenced; break; case TH_VERTEX_SIZE: cp = &ts->vertex_size; break; case TH_OUTLINE_WIDTH: @@ -445,7 +447,6 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case TH_HANDLE_VERTEX_SIZE: cp = &ts->handle_vertex_size; break; - case TH_DOPESHEET_CHANNELOB: cp = ts->ds_channel; break; @@ -718,6 +719,8 @@ void ui_theme_init_default(void) /* space view3d */ btheme->tv3d.panelcolors.show_back = FALSE; btheme->tv3d.panelcolors.show_header = FALSE; + rgba_char_args_set_fl(btheme->tv3d.panelcolors.back, 0.45, 0.45, 0.45, 0.5); + rgba_char_args_set_fl(btheme->tv3d.panelcolors.header, 0, 0, 0, 0.01); rgba_char_args_set_fl(btheme->tv3d.back, 0.225, 0.225, 0.225, 1.0); rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255); @@ -742,6 +745,7 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255); rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255); + rgba_char_args_set(btheme->tv3d.vertex_unreferenced, 0, 0, 0, 255); btheme->tv3d.vertex_size = 3; btheme->tv3d.outline_width = 1; rgba_char_args_set(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255); @@ -1376,7 +1380,7 @@ void init_userdef_do_versions(void) /* signal for derivedmesh to use colorband */ /* run in case this was on and is now off in the user prefs [#28096] */ - vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL); + vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL, UI_GetTheme()->tv3d.vertex_unreferenced); if (bmain->versionfile <= 191) { strcpy(U.sounddir, "/"); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index ad6428c7e80..8a6de9a549b 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -457,8 +457,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, int resize, int mask_ if (ABS(winx - v2d->oldwinx) > ABS(winy - v2d->oldwiny)) do_y = FALSE; else do_x = FALSE; } - else if (winRatio > 1.0f) do_x = FALSE; - else do_x = TRUE; + else if (winRatio > 1.0f) { + do_x = FALSE; + } + else { + do_x = TRUE; + } } do_cur = do_x; /* do_win = do_y; */ /* UNUSED */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index daa78957231..e283bd1351a 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -187,7 +187,7 @@ static int view_pan_exec(bContext *C, wmOperator *op) } /* set up modal operator and relevant settings */ -static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *window = CTX_wm_window(C); v2dViewPanData *vpd; @@ -231,7 +231,7 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) } /* handle user input - calculations of mouse-movement need to be done here, not in the apply callback! */ -static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) +static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event) { v2dViewPanData *vpd = op->customdata; @@ -700,7 +700,7 @@ static int view_zoomin_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int view_zoomin_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int view_zoomin_invoke(bContext *C, wmOperator *op, const wmEvent *event) { v2dViewZoomData *vzd; @@ -769,7 +769,7 @@ static int view_zoomout_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int view_zoomout_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int view_zoomout_invoke(bContext *C, wmOperator *op, const wmEvent *event) { v2dViewZoomData *vzd; @@ -924,7 +924,7 @@ static int view_zoomdrag_exec(bContext *C, wmOperator *op) } /* set up modal operator and relevant settings */ -static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *window = CTX_wm_window(C); v2dViewZoomData *vzd; @@ -1005,7 +1005,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) } /* handle user input - calculations of mouse-movement need to be done here, not in the apply callback! */ -static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) +static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event) { v2dViewZoomData *vzd = op->customdata; View2D *v2d = vzd->v2d; @@ -1328,7 +1328,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar, } /* only meant for timer usage */ -static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) +static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; @@ -1488,7 +1488,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ } /* initialize customdata for scroller manipulation operator */ -static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event, short in_scroller) +static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *event, short in_scroller) { v2dScrollerMove *vsm; View2DScrollers *scrollers; @@ -1637,7 +1637,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) } /* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */ -static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) +static int scroller_activate_modal(bContext *C, wmOperator *op, const wmEvent *event) { v2dScrollerMove *vsm = op->customdata; @@ -1707,7 +1707,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) /* a click (or click drag in progress) should have occurred, so check if it happened in scrollbar */ -static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) +static int scroller_activate_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; |