diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-12-20 07:06:22 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-12-20 07:06:22 +0300 |
commit | 3143b2f9424a10b1baf960c6a0bbb274cdeffe1d (patch) | |
tree | 9d2095cc94207268aa0160a34db0eb27317e5af7 /source/blender | |
parent | b3bcbc9e85aaad3c6262e8203c69d4089d5d8154 (diff) | |
parent | 51f0c3fadf085b087a9f98a59db41af6aa632a57 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_font.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 25 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/font.c | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 11 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_region_tooltip.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 2 |
9 files changed, 43 insertions, 25 deletions
diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 60ad061bf77..e5eea4423c9 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -86,7 +86,7 @@ struct VFont *BKE_vfont_load_exists(struct Main *bmain, const char *filepath); void BKE_vfont_make_local(struct Main *bmain, struct VFont *vfont, const bool lib_local); -bool BKE_vfont_to_curve_ex(struct Main *bmain, struct Object *ob, int mode, +bool BKE_vfont_to_curve_ex(struct Main *bmain, struct Object *ob, struct Curve *cu, int mode, struct ListBase *r_nubase, const wchar_t **r_text, int *r_text_len, bool *r_text_free, struct CharTrans **r_chartransdata); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index ba9ccf94303..5a284761814 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -4938,12 +4938,27 @@ void BKE_curve_nurb_vert_active_validate(Curve *cu) bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3]) { ListBase *nurb_lb = BKE_curve_nurbs_get(cu); - Nurb *nu; - - for (nu = nurb_lb->first; nu; nu = nu->next) + ListBase temp_nurb_lb = {NULL, NULL}; + const bool is_font = (BLI_listbase_is_empty(nurb_lb)) && (cu->len != 0); + /* For font curves we generate temp list of splines. + * + * This is likely to be fine, this function is not supposed to be called + * often, and it's the only way to get meaningful bounds for fonts. + */ + if (is_font) { + nurb_lb = &temp_nurb_lb; + BKE_vfont_to_curve_ex(G.main, NULL, cu, FO_EDIT, nurb_lb, + NULL, NULL, NULL, NULL); + use_radius = false; + } + /* Do bounding box based on splines. */ + for (Nurb *nu = nurb_lb->first; nu; nu = nu->next) { BKE_nurb_minmax(nu, use_radius, min, max); - - return (BLI_listbase_is_empty(nurb_lb) == false); + } + const bool result = (BLI_listbase_is_empty(nurb_lb) == false); + /* Cleanup if needed. */ + BKE_nurbList_free(&temp_nurb_lb); + return result; } bool BKE_curve_center_median(Curve *cu, float cent[3]) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index d6b28cfaf70..ef479d77915 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -635,11 +635,10 @@ struct TempLineInfo { int wspace_nr; /* number of whitespaces of line */ }; -bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase, +bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, Curve *cu, int mode, ListBase *r_nubase, const wchar_t **r_text, int *r_text_len, bool *r_text_free, struct CharTrans **r_chartransdata) { - Curve *cu = ob->data; EditFont *ef = cu->editfont; EditFontSelBox *selboxes = NULL; VFont *vfont, *oldvfont; @@ -670,7 +669,7 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase /* remark: do calculations including the trailing '\0' of a string * because the cursor can be at that location */ - BLI_assert(ob->type == OB_FONT); + BLI_assert(ob == NULL || ob->type == OB_FONT); /* Set font data */ vfont = cu->vfont; @@ -708,7 +707,7 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase if (cu->tb == NULL) cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat"); - if (ef) { + if (ef != NULL && ob != NULL) { if (ef->selboxes) MEM_freeN(ef->selboxes); @@ -1258,7 +1257,7 @@ makebreak: cha = towupper(cha); } - if (info->mat_nr > (ob->totcol)) { + if (ob == NULL || info->mat_nr > (ob->totcol)) { /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ info->mat_nr = 0; } @@ -1334,7 +1333,7 @@ bool BKE_vfont_to_curve_nubase(Main *bmain, Object *ob, int mode, ListBase *r_nu { BLI_assert(ob->type == OB_FONT); - return BKE_vfont_to_curve_ex(bmain, ob, mode, r_nubase, + return BKE_vfont_to_curve_ex(bmain, ob, ob->data, mode, r_nubase, NULL, NULL, NULL, NULL); } @@ -1342,7 +1341,7 @@ bool BKE_vfont_to_curve(Main *bmain, Object *ob, int mode) { Curve *cu = ob->data; - return BKE_vfont_to_curve_ex(bmain, ob, mode, &cu->nurb, NULL, NULL, NULL, NULL); + return BKE_vfont_to_curve_ex(bmain, ob, ob->data, mode, &cu->nurb, NULL, NULL, NULL, NULL); } diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 9b25a1db6ff..13589866e48 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -613,7 +613,7 @@ static void make_duplis_font(const DupliContext *ctx) /* in par the family name is stored, use this to find the other objects */ - BKE_vfont_to_curve_ex(G.main, par, FO_DUPLI, NULL, + BKE_vfont_to_curve_ex(G.main, par, par->data, FO_DUPLI, NULL, &text, &text_len, &text_free, &chartransdata); if (text == NULL || chartransdata == NULL) { diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 4fc72200c04..8fc455e446f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1135,6 +1135,12 @@ void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p); bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src); void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p); +/* ui_interface_region_tooltip.c */ +struct ARegion *UI_tooltip_create_from_button(struct bContext *C, struct ARegion *butregion, uiBut *but); +void UI_tooltip_free(struct bContext *C, struct ARegion *ar); + +/* How long before a tool-tip shows. */ +#define UI_TOOLTIP_DELAY 0.5 /* Float precision helpers */ #define UI_PRECISION_FLOAT_MAX 6 diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b06e787329b..5218a9b8216 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -130,7 +130,6 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve /***************** structs and defines ****************/ -#define BUTTON_TOOLTIP_DELAY 0.500 #define BUTTON_FLASH_DELAY 0.020 #define MENU_SCROLL_INTERVAL 0.1 #define PIE_MENU_INTERVAL 0.01 @@ -7697,8 +7696,8 @@ void UI_but_tooltip_refresh(bContext *C, uiBut *but) data = but->active; if (data && data->tooltip) { - ui_tooltip_free(C, data->tooltip); - data->tooltip = ui_tooltip_create_from_button(C, data->region, but); + UI_tooltip_free(C, data->tooltip); + data->tooltip = UI_tooltip_create_from_button(C, data->region, but); } } @@ -7715,7 +7714,7 @@ void UI_but_tooltip_timer_remove(bContext *C, uiBut *but) data->tooltiptimer = NULL; } if (data->tooltip) { - ui_tooltip_free(C, data->tooltip); + UI_tooltip_free(C, data->tooltip); data->tooltip = NULL; } @@ -7741,7 +7740,7 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but) if ((U.flag & USER_TOOLTIPS) || (data->tooltip_force)) { if (!but->block->tooltipdisabled) { if (!wm->drags.first) { - data->tooltiptimer = WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_TOOLTIP_DELAY); + data->tooltiptimer = WM_event_add_timer(data->wm, data->window, TIMER, UI_TOOLTIP_DELAY); } } } @@ -8443,7 +8442,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but) data->tooltiptimer = NULL; if (!data->tooltip) - data->tooltip = ui_tooltip_create_from_button(C, data->region, but); + data->tooltip = UI_tooltip_create_from_button(C, data->region, but); } /* handle menu auto open timer */ else if (event->customdata == data->autoopentimer) { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 21e72053ded..8d7f9d47ab5 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -590,8 +590,7 @@ struct uiPopupBlockHandle { /* interface_region_*.c */ /* interface_region_tooltip.c */ -struct ARegion *ui_tooltip_create_from_button(struct bContext *C, struct ARegion *butregion, uiBut *but); -void ui_tooltip_free(struct bContext *C, struct ARegion *ar); +/* exposed as public API in UI_interface.h */ /* interface_region_color_picker.c */ void ui_rgb_to_color_picker_compat_v(const float rgb[3], float r_cp[3]); diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 959d4ae86f5..bdc13f58226 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -781,7 +781,7 @@ static ARegion *ui_tooltip_create_with_data( * \{ */ -ARegion *ui_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *but) +ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *but) { wmWindow *win = CTX_wm_window(C); /* aspect values that shrink text are likely unreadable */ @@ -827,7 +827,7 @@ ARegion *ui_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *b return ui_tooltip_create_with_data(C, data, init_position, aspect); } -void ui_tooltip_free(bContext *C, ARegion *ar) +void UI_tooltip_free(bContext *C, ARegion *ar) { ui_region_temp_remove(C, CTX_wm_screen(C), ar); } diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index da4eea41223..38149734bc2 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -337,7 +337,7 @@ static void rna_Struct_property_tags_begin(CollectionPropertyIterator *iter, Poi /* here ptr->data should always be the same as iter->parent.type */ StructRNA *srna = (StructRNA *)ptr->data; const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna); - unsigned int tag_count = RNA_enum_items_count(tag_defines); + unsigned int tag_count = tag_defines ? RNA_enum_items_count(tag_defines) : 0; rna_iterator_array_begin(iter, (void *)tag_defines, sizeof(EnumPropertyItem), tag_count, 0, NULL); } |