Cleanup: comment length in interface

This commit is contained in:
Campbell Barton 2019-04-17 08:44:38 +02:00
parent 41d4a19865
commit 6b26024ea4
17 changed files with 203 additions and 132 deletions

View File

@ -2422,8 +2422,10 @@ static float ui_get_but_step_unit(uiBut *but, float step_default)
}
/**
* \param float_precision: For number buttons the precision to use or -1 to fallback to the button default.
* \param use_exp_float: Use exponent representation of floats when out of reasonable range (outside of 1e3/1e-3).
* \param float_precision: For number buttons the precision
* to use or -1 to fallback to the button default.
* \param use_exp_float: Use exponent representation of floats
* when out of reasonable range (outside of 1e3/1e-3).
*/
void ui_but_string_get_ex(uiBut *but,
char *str,
@ -2752,10 +2754,10 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
/* This is kind of hackish, in theory think we could only ever use the second member of
* this if/else, since ui_searchbox_apply() is supposed to always set that pointer when
* we are storing pointers... But keeping str search first for now, to try to break as little as
* possible existing code. All this is band-aids anyway.
* Fact remains, using editstr as main 'reference' over whole search button thingy is utterly weak
* and should be redesigned imho, but that's not a simple task. */
* we are storing pointers... But keeping str search first for now,
* to try to break as little as possible existing code. All this is band-aids anyway.
* Fact remains, using editstr as main 'reference' over whole search button thingy
* is utterly weak and should be redesigned imho, but that's not a simple task. */
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
}
@ -6184,9 +6186,9 @@ static void operator_enum_call_cb(struct bContext *UNUSED(C), void *but, void *a
if (ot->prop) {
RNA_property_enum_set(opptr, ot->prop, POINTER_AS_INT(arg2));
/* We do not call op from here, will be called by button code.
* ui_apply_but_funcs_after() (in interface_handlers.c) called this func before checking operators,
* because one of its parameters is the button itself!
*/
* ui_apply_but_funcs_after() (in interface_handlers.c)
* called this func before checking operators,
* because one of its parameters is the button itself! */
}
else {
printf("%s: op->prop for '%s' is NULL\n", __func__, ot->idname);
@ -6195,8 +6197,8 @@ static void operator_enum_call_cb(struct bContext *UNUSED(C), void *but, void *a
}
/**
* Same parameters as for uiDefSearchBut, with additional operator type and properties, used by callback
* to call again the right op with the right options (properties values).
* Same parameters as for uiDefSearchBut, with additional operator type and properties,
* used by callback to call again the right op with the right options (properties values).
*/
uiBut *uiDefSearchButO_ptr(uiBlock *block,
wmOperatorType *ot,

View File

@ -139,10 +139,11 @@ int ui_but_align_opposite_to_area_align_get(const ARegion *ar)
}
/**
* This function checks a pair of buttons (assumed in a same align group), and if they are neighbors,
* set needed data accordingly.
* This function checks a pair of buttons (assumed in a same align group),
* and if they are neighbors, set needed data accordingly.
*
* \note It is designed to be called in total random order of buttons. Order-based optimizations are done by caller.
* \note It is designed to be called in total random order of buttons.
* Order-based optimizations are done by caller.
*/
static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other)
{
@ -268,13 +269,15 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
* +-----------+
* </pre>
*
* Here, BUT 3 RIGHT side would not get 'dragged' to align with BUT 1 RIGHT side, since BUT 3 has not RIGHT neighbor.
* So, this function, when called with BUT 1, will 'walk' the whole column in \a side_s1 direction (TOP or DOWN when
* called for RIGHT side), and force buttons like BUT 3 to align as needed, if BUT 1 and BUT 3 were detected as needing
* top-right corner stitching in #block_align_proximity_compute() step.
* Here, BUT 3 RIGHT side would not get 'dragged' to align with BUT 1 RIGHT side,
* since BUT 3 has not RIGHT neighbor.
* So, this function, when called with BUT 1, will 'walk' the whole column in \a side_s1 direction
* (TOP or DOWN when called for RIGHT side), and force buttons like BUT 3 to align as needed,
* if BUT 1 and BUT 3 were detected as needing top-right corner stitching in
* #block_align_proximity_compute() step.
*
* \note To avoid doing this twice, some stitching flags are cleared to break the 'stitching connection'
* between neighbors.
* \note To avoid doing this twice, some stitching flags are cleared to break the
* 'stitching connection' between neighbors.
*/
static void block_align_stitch_neighbors(ButAlign *butal,
const int side,
@ -290,16 +293,17 @@ static void block_align_stitch_neighbors(ButAlign *butal,
const int stitch_s1 = STITCH(side_s1);
const int stitch_s2 = STITCH(side_s2);
/* We have to check stitching flags on both sides of the stitching, since we only clear one of them flags to break
* any future loop on same 'columns/side' case.
* Also, if butal is spanning over several rows or columns of neighbors, it may have both of its stitching flags
/* We have to check stitching flags on both sides of the stitching,
* since we only clear one of them flags to break any future loop on same 'columns/side' case.
* Also, if butal is spanning over several rows or columns of neighbors,
* it may have both of its stitching flags
* set, but would not be the case of its immediate neighbor! */
while ((butal->flags[side] & stitch_s1) && (butal = butal->neighbors[side_s1]) &&
(butal->flags[side] & stitch_s2)) {
butal_neighbor = butal->neighbors[side];
/* If we actually do have a neighbor, we directly set its values accordingly, and clear its matching 'dist'
* to prevent it being set again later... */
/* If we actually do have a neighbor, we directly set its values accordingly,
* and clear its matching 'dist' to prevent it being set again later... */
if (butal_neighbor) {
butal->but->drawflag |= align;
butal_neighbor->but->drawflag |= align_opp;
@ -389,7 +393,8 @@ static void ui_block_align_but_to_region(uiBut *but, const ARegion *region)
/**
* Compute the alignment of all 'align groups' of buttons in given block.
*
* This is using an order-independent algorithm, i.e. alignment of buttons should be OK regardless of order in which
* This is using an order-independent algorithm,
* i.e. alignment of buttons should be OK regardless of order in which
* they are added to the block.
*/
void ui_block_align_calc(uiBlock *block, const ARegion *region)
@ -404,7 +409,8 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
int side;
int i, j;
/* First loop: we count number of buttons belonging to an align group, and clear their align flag.
/* First loop: we count number of buttons belonging to an align group,
* and clear their align flag.
* Tabs get some special treatment here, they get aligned to region border. */
for (but = block->buttons.first; but; but = but->next) {
/* special case: tabs need to be aligned to a region border, drawflag tells which one */

View File

@ -205,14 +205,20 @@ static void ui_selectcontext_apply(bContext *C,
# define DRAG_MULTINUM_THRESHOLD_DRAG_X (UI_UNIT_Y / 4)
/**
* how far to drag horizontally before we stop checking which buttons the gesture spans (in pixels),
* locking down the buttons so we can drag freely without worrying about vertical movement. */
* How far to drag horizontally
* before we stop checking which buttons the gesture spans (in pixels),
* locking down the buttons so we can drag freely without worrying about vertical movement.
*/
# define DRAG_MULTINUM_THRESHOLD_DRAG_Y (UI_UNIT_Y / 4)
/**
* how strict to be when detecting a vertical gesture, [0.5 == sloppy], [0.9 == strict], (unsigned dot-product)
* note: we should be quite strict here, since doing a vertical gesture by accident should be avoided,
* however with some care a user should be able to do a vertical movement without *missing*. */
* How strict to be when detecting a vertical gesture:
* [0.5 == sloppy], [0.9 == strict], (unsigned dot-product).
*
* \note We should be quite strict here,
* since doing a vertical gesture by accident should be avoided,
* however with some care a user should be able to do a vertical movement without _missing_.
*/
# define DRAG_MULTINUM_THRESHOLD_VERTICAL (0.75f)
/* a simple version of uiHandleButtonData when accessing multiple buttons */
@ -912,8 +918,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
* feature used for bone renaming, channels, etc.
* afterfunc frees rename_orig */
if (data->origstr && (but->flag & UI_BUT_TEXTEDIT_UPDATE)) {
/* In this case, we need to keep origstr available, to restore real org string in case we cancel after
* having typed something already. */
/* In this case, we need to keep origstr available,
* to restore real org string in case we cancel after having typed something already. */
but->rename_orig = BLI_strdup(data->origstr);
}
/* only if there are afterfuncs, otherwise 'renam_orig' isn't freed */
@ -1314,8 +1320,8 @@ static bool ui_drag_toggle_set_xy_xy(
ui_window_to_block_fl(ar, block, &xy_b_block[0], &xy_b_block[1]);
for (but = block->buttons.first; but; but = but->next) {
/* Note: ctrl is always true here because (at least for now) we always want to consider text control
* in this case, even when not embossed. */
/* Note: ctrl is always true here because (at least for now)
* we always want to consider text control in this case, even when not embossed. */
if (ui_but_is_interactive(but, true)) {
if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) {
@ -5302,12 +5308,14 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_but(C, but->block, but, data, true);
/* button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't lead
* to cancel changes made to this button, but changing state to EXIT also makes no button active for
* a while which leads to triggering operator when doing fast scrolling mouse wheel.
* using post activate stuff from button allows to make button be active again after checking for all
* all that mouse leave and cancel stuff, so quick scroll wouldn't be an issue anymore.
* same goes for scrolling wheel in another direction below (sergey)
/* Button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't
* lead to cancel changes made to this button, but changing state to EXIT also makes no
* button active for a while which leads to triggering operator
* when doing fast scrolling mouse wheel.
* using post activate stuff from button allows to make button be active again after
* checking for all all that mouse leave and cancel stuff,
* so quick scroll wouldn't be an issue anymore.
* Same goes for scrolling wheel in another direction below (sergey).
*/
data->postbut = but;
data->posttype = BUTTON_ACTIVATE_OVER;
@ -9905,7 +9913,8 @@ static int ui_handle_menus_recursive(bContext *C,
}
/**
* Allow setting menu return value from externals. E.g. WM might need to do this for exiting files correctly.
* Allow setting menu return value from externals.
* E.g. WM might need to do this for exiting files correctly.
*/
void UI_popup_menu_retval_set(const uiBlock *block, const int retval, const bool enable)
{

View File

@ -731,7 +731,9 @@ static void init_internal_icons(void)
bbuf = IMB_loadiffname(iconfilestr, IB_rect, NULL);
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
printf("\n***WARNING***\n"
"Icons file '%s' too small.\n"
"Using built-in Icons instead\n", iconfilestr);
IMB_freeImBuf(bbuf);
bbuf = NULL;
}

View File

@ -172,21 +172,25 @@ struct uiBut {
/* both these values use depends on the button type
* (polymorphic struct or union would be nicer for this stuff) */
/* (type == UI_BTYPE_HSVCUBE), Use UI_GRAD_* values.
* (type == UI_BTYPE_NUM), Use to store RNA 'step' value, for dragging and click-step.
* (type == UI_BTYPE_LABEL), Use (a1 == 1.0f) to use a2 as a blending factor (wow, this is imaginative!).
* (type == UI_BTYPE_SCROLL) Use as scroll size.
* (type == UI_BTYPE_SEARCH_MENU) Use as number or rows.
* (type == UI_BTYPE_COLOR) Use as indication of color palette
* (type == UI_BTYPE_PROGRESS_BAR) Use to store progress (0..1).
/**
* For #uiBut.type:
* - UI_BTYPE_HSVCUBE: Use UI_GRAD_* values.
* - UI_BTYPE_NUM: Use to store RNA 'step' value, for dragging and click-step.
* - UI_BTYPE_LABEL: Use `(a1 == 1.0f)` to use a2 as a blending factor (imaginative!).
* - UI_BTYPE_SCROLL: Use as scroll size.
* - UI_BTYPE_SEARCH_MENU: Use as number or rows.
* - UI_BTYPE_COLOR: Use as indication of color palette.
* - UI_BTYPE_PROGRESS_BAR: Use to store progress (0..1).
*/
float a1;
/* (type == UI_BTYPE_HSVCIRCLE ), Use to store the luminosity.
* (type == UI_BTYPE_NUM), Use to store RNA 'precision' value, for dragging and click-step.
* (type == UI_BTYPE_LABEL), If (a1 == 1.0f) use a2 as a blending factor.
* (type == UI_BTYPE_SEARCH_MENU) Use as number or columns.
* (type == UI_BTYPE_COLOR) Use as index in palette (not so good, needs refactor)
/**
* For #uiBut.type:
* - UI_BTYPE_HSVCIRCLE: Use to store the luminosity.
* - UI_BTYPE_NUM: Use to store RNA 'precision' value, for dragging and click-step.
* - UI_BTYPE_LABEL: If `(a1 == 1.0f)` use a2 as a blending factor.
* - UI_BTYPE_SEARCH_MENU: Use as number or columns.
* - UI_BTYPE_COLOR: Use as index in palette (not so good, needs refactor).
*/
float a2;

View File

@ -731,12 +731,16 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
int but_type,
bool icon_only)
{
/* XXX The way this function currently handles uiname parameter is insane and inconsistent with general UI API:
* * uiname is the *enum property* label.
* * when it is NULL or empty, we do not draw *enum items* labels, this doubles the icon_only parameter.
* * we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
* Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/
* --mont29
/* XXX: The way this function currently handles uiname parameter
* is insane and inconsistent with general UI API:
*
* - uiname is the *enum property* label.
* - when it is NULL or empty, we do not draw *enum items* labels,
* this doubles the icon_only parameter.
* - we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
*
* Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/
* - mont29
*/
uiBut *but;
@ -1533,9 +1537,10 @@ void uiItemsFullEnumO(uiLayout *layout,
bool free;
if (ui_layout_is_radial(layout)) {
/* XXX: While "_all()" guarantees spatial stability, it's bad when an enum has > 8 items total,
* but only a small subset will ever be shown at once (e.g. Mode Switch menu, after the
* introduction of GP editing modes)
/* XXX: While "_all()" guarantees spatial stability,
* it's bad when an enum has > 8 items total,
* but only a small subset will ever be shown at once
* (e.g. Mode Switch menu, after the introduction of GP editing modes).
*/
#if 0
RNA_property_enum_items_gettexted_all(
@ -3964,9 +3969,10 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
return;
}
/* Even in varying column width case, we fix our columns number from weighted average width of items,
* a proper solving of required width would be too costly, and this should give reasonably good results
* in all reasonable cases... */
/* Even in varying column width case,
* we fix our columns number from weighted average width of items,
* a proper solving of required width would be too costly,
* and this should give reasonably good results in all reasonable cases. */
if (gflow->columns_len > 0) {
gflow->tot_columns = gflow->columns_len;
}
@ -4435,7 +4441,8 @@ uiLayout *uiLayoutBox(uiLayout *layout)
}
/**
* Check all buttons defined in this layout, and set any button flagged as UI_BUT_LIST_ITEM as active/selected.
* Check all buttons defined in this layout,
* and set any button flagged as UI_BUT_LIST_ITEM as active/selected.
* Needed to handle correctly text colors of active (selected) list item.
*/
void ui_layout_list_set_labels_active(uiLayout *layout)

View File

@ -267,7 +267,8 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar)
}
/**
* XXX Disabled paneltab handling for now. Old 2.4x feature, *DO NOT* confuse it with new tool tabs in 2.70. ;)
* XXX Disabled paneltab handling for now. Old 2.4x feature,
* *DO NOT* confuse it with new tool tabs in 2.70. ;)
* See also T41704.
*/
/* #define UI_USE_PANELTAB */

View File

@ -663,7 +663,8 @@ static void ui_block_colorpicker(uiBlock *block, uiBut *from_but, float rgba[4],
UI_but_func_set(bt, ui_colorpicker_rna_cb, bt, NULL);
bt->custom_data = cpicker;
/* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
/* Could use:
* uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND | UI_ITEM_R_SLIDER, "", ICON_NONE);
* but need to use UI_but_func_set for updating other fake buttons */
/* HSV values */

View File

@ -193,7 +193,8 @@ static void hud_region_layout(const bContext *C, ARegion *ar)
UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
/* Weak, but needed to avoid glitches, especially with hi-dpi (where resizing the view glitches often).
/* Weak, but needed to avoid glitches, especially with hi-dpi
* (where resizing the view glitches often).
* Fortunately this only happens occasionally. */
ED_region_panels_layout(C, ar);
}

View File

@ -310,12 +310,14 @@ int UI_pie_menu_invoke_from_rna_enum(struct bContext *C,
/**
* \name Pie Menu Levels
*
* Pie menus can't contain more than 8 items (yet). When using #uiItemsFullEnumO, a "More" button is created that calls
* Pie menus can't contain more than 8 items (yet).
* When using #uiItemsFullEnumO, a "More" button is created that calls
* a new pie menu if the enum has too many items. We call this a new "level".
* Indirect recursion is used, so that a theoretically unlimited number of items is supported.
*
* This is a implementation specifically for operator enums, needed since the object mode pie now has more than 8
* items. Ideally we'd have some way of handling this for all kinds of pie items, but that's tricky.
* This is a implementation specifically for operator enums,
* needed since the object mode pie now has more than 8 items.
* Ideally we'd have some way of handling this for all kinds of pie items, but that's tricky.
*
* - Julian (Feb 2016)
*

View File

@ -539,9 +539,10 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but
data->prv_cols = but->a2;
}
/* Only show key shortcuts when needed (checking RNA prop pointer is useless here, a lot of buttons are about data
* without having that pointer defined, let's rather try with optype!). One can also enforce that behavior by
* setting UI_BUT_HAS_SHORTCUT drawflag of search button. */
/* Only show key shortcuts when needed (checking RNA prop pointer is useless here, a lot of
* buttons are about data without having that pointer defined, let's rather try with optype!).
* One can also enforce that behavior by setting
* UI_BUT_HAS_SHORTCUT drawflag of search button. */
if (but->optype != NULL || (but->drawflag & UI_BUT_HAS_SHORTCUT) != 0) {
data->use_sep = true;
}

View File

@ -26,7 +26,8 @@
/* TODO(campbell):
* We may want to have a higher level API that initializes a timer,
* checks for mouse motion and clears the tool-tip afterwards.
* We never want multiple tool-tips at once so this could be handled on the window / window-manager level.
* We never want multiple tool-tips at once
* so this could be handled on the window / window-manager level.
*
* For now it's not a priority, so leave as-is.
*/
@ -461,7 +462,8 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
*
* - Direct access to the tool (as if the toolbar button is pressed).
* - The key is bound to a brush type (not the exact brush name).
* - The key is assigned to the operator it's self (bypassing the tool, executing the operator).
* - The key is assigned to the operator it's self
* (bypassing the tool, executing the operator).
*
* Either way case it's useful to show the shortcut.
*/

View File

@ -1371,10 +1371,12 @@ void uiTemplateIDTabs(uiLayout *layout,
/************************ ID Chooser Template ***************************/
/**
* This is for selecting the type of ID-block to use, and then from the relevant type choosing the block to use
* This is for selecting the type of ID-block to use,
* and then from the relevant type choosing the block to use.
*
* - propname: property identifier for property that ID-pointer gets stored to
* - proptypename: property identifier for property used to determine the type of ID-pointer that can be used
* \param propname: property identifier for property that ID-pointer gets stored to.
* \param proptypename: property identifier for property
* used to determine the type of ID-pointer that can be used.
*/
void uiTemplateAnyID(uiLayout *layout,
PointerRNA *ptr,
@ -4807,9 +4809,9 @@ void uiTemplateLayers(uiLayout *layout,
/* the number of layers determines the way we group them
* - we want 2 rows only (for now)
* - the number of columns (cols) is the total number of buttons per row
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
* - for now, only split into groups if group will have at least 5 items
* - The number of columns (cols) is the total number of buttons per row the 'remainder'
* is added to this, as it will be ok to have first row slightly wider if need be.
* - For now, only split into groups if group will have at least 5 items.
*/
layers = RNA_property_array_length(ptr, prop);
cols = (layers / 2) + (layers % 2);
@ -5630,14 +5632,17 @@ void uiTemplateList(uiLayout *layout,
if (glob) {
/* About UI_BTYPE_GRIP drag-resize:
* We can't directly use results from a grip button, since we have a rather complex behavior here
* (sizing by discrete steps and, overall, autosize feature).
* Since we *never* know whether we are grip-resizing or not (because there is no callback for when a
* button enters/leaves its "edit mode"), we use the fact that grip-controlled value (dyn_data->resize)
* is completely handled by the grip during the grab resize, so settings its value here has no effect
* at all.
* It is only meaningful when we are not resizing, in which case this gives us the correct "init drag" value.
* Note we cannot affect dyn_data->resize_prev here, since this value is not controlled by the grip!
* We can't directly use results from a grip button, since we have a
* rather complex behavior here (sizing by discrete steps and, overall, autosize feature).
* Since we *never* know whether we are grip-resizing or not
* (because there is no callback for when a button enters/leaves its "edit mode"),
* we use the fact that grip-controlled value (dyn_data->resize) is completely handled
* by the grip during the grab resize, so settings its value here has no effect at all.
*
* It is only meaningful when we are not resizing,
* in which case this gives us the correct "init drag" value.
* Note we cannot affect dyn_data->resize_prev here,
* since this value is not controlled by the grip!
*/
dyn_data->resize = dyn_data->resize_prev +
(dyn_data->visual_height - ui_list->list_grip) * UI_UNIT_Y;
@ -5880,7 +5885,8 @@ static bool ui_layout_operator_buts_poll_property(struct PointerRNA *UNUSED(ptr)
/**
* Draw Operator property buttons for redoing execution with different settings.
* This function does not initialize the layout, functions can be called on the layout before and after.
* This function does not initialize the layout,
* functions can be called on the layout before and after.
*/
eAutoPropButsReturn uiTemplateOperatorPropertyButs(const bContext *C,
uiLayout *layout,
@ -5896,8 +5902,8 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs(const bContext *C,
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
/* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
* just fails silently */
/* poll() on this operator may still fail,
* at the moment there is no nice feedback when this happens just fails silently. */
if (!WM_operator_repeat_check(C, op)) {
UI_block_lock_set(block, true, "Operator can't' redo");
return return_info;

View File

@ -508,7 +508,8 @@ int UI_icon_from_report_type(int type)
/********************************** Misc **************************************/
/**
* Returns the best "UI" precision for given floating value, so that e.g. 10.000001 rather gets drawn as '10'...
* Returns the best "UI" precision for given floating value,
* so that e.g. 10.000001 rather gets drawn as '10'...
*/
int UI_calc_float_precision(int prec, double value)
{
@ -519,7 +520,8 @@ int UI_calc_float_precision(int prec, double value)
BLI_assert(prec <= UI_PRECISION_FLOAT_MAX);
BLI_assert(fabs(pow10_neg[prec] - pow(10, -prec)) < 1e-16);
/* check on the number of decimal places need to display the number, this is so 0.00001 is not displayed as 0.00,
/* Check on the number of decimal places need to display the number,
* this is so 0.00001 is not displayed as 0.00,
* _but_, this is only for small values si 10.0001 will not get the same treatment.
*/
value = ABS(value);
@ -631,8 +633,10 @@ uiButStore *UI_butstore_create(uiBlock *block)
void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
{
/* Workaround for button store being moved into new block,
* which then can't use the previous buttons state ('ui_but_update_from_old_block' fails to find a match),
* keeping the active button in the old block holding a reference to the button-state in the new block: see T49034.
* which then can't use the previous buttons state
* ('ui_but_update_from_old_block' fails to find a match),
* keeping the active button in the old block holding a reference
* to the button-state in the new block: see T49034.
*
* Ideally we would manage moving the 'uiButStore', keeping a correct state.
* All things considered this is the most straightforward fix - Campbell.

View File

@ -1604,9 +1604,14 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
/**
* Cut off the middle of the text to fit into the given width.
* Note in case this middle clipping would just remove a few chars, it rather clips right, which is more readable.
* If rpart_sep is not Null, the part of str starting to first occurrence of rpart_sep is preserved at all cost (useful
* for strings with shortcuts, like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
*
* \note in case this middle clipping would just remove a few chars,
* it rather clips right, which is more readable.
*
* If rpart_sep is not Null, the part of str starting to first occurrence of rpart_sep
* is preserved at all cost.
* Useful for strings with shortcuts
* (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
*/
float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
char *str,
@ -1691,8 +1696,8 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */
if (l_end + sep_len + r_len + rpart_len > max_len) {
/* Corner case, the str already takes all available mem, and the ellipsis chars would actually
* add more chars...
/* Corner case, the str already takes all available mem,
* and the ellipsis chars would actually add more chars.
* Better to just trim one or two letters to the right in this case...
* Note: with a single-char ellipsis, this should never happen! But better be safe here...
*/
@ -1753,8 +1758,10 @@ static void ui_text_clip_middle(const uiFontStyle *fstyle, uiBut *but, const rct
}
/**
* Like ui_text_clip_middle(), but protect/preserve at all cost the right part of the string after sep.
* Useful for strings with shortcuts (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
* Like #ui_text_clip_middle(), but protect/preserve at all cost
* the right part of the string after sep.
* Useful for strings with shortcuts
* (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O').
*/
static void ui_text_clip_middle_protect_right(const uiFontStyle *fstyle,
uiBut *but,

View File

@ -212,11 +212,14 @@ static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scr
/* Refresh and Validation */
/**
* Initialize all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize
* - for some of these presets, it is expected that the region will have defined some
* Initialize all relevant View2D data (including view rects if first time)
* and/or refresh mask sizes after view resize.
*
* - For some of these presets, it is expected that the region will have defined some
* additional settings necessary for the customization of the 2D viewport to its requirements
* - this function should only be called from region init() callbacks, where it is expected that
* this is called before UI_view2d_size_update(), as this one checks that the rects are properly initialized.
* - This function should only be called from region init() callbacks, where it is expected that
* this is called before #UI_view2d_size_update(),
* as this one checks that the rects are properly initialized.
*/
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
{
@ -238,7 +241,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->minzoom = 0.01f;
v2d->maxzoom = 1000.0f;
/* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
/* View2D tot rect and cur should be same size,
* and aligned using 'standard' OpenGL coordinates for now:
* - region can resize 'tot' later to fit other data
* - keeptot is only within bounds, as strict locking is not that critical
* - view is aligned for (0,0) -> (winx-1, winy-1) setup
@ -271,8 +275,9 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
/* scroller settings are currently not set here... that is left for regions... */
break;
}
/* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
* zoom, aspect ratio, and alignment restrictions are set here */
/* 'stack view' - practically the same as list/channel view,
* except is located in the pos y half instead.
* Zoom, aspect ratio, and alignment restrictions are set here. */
case V2D_COMMONVIEW_STACK: {
/* zoom + aspect ratio are locked */
v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
@ -545,10 +550,12 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
if (do_cur) {
if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) {
/* special exception for Outliner (and later channel-lists):
* - The view may be moved left to avoid contents being pushed out of view when view shrinks.
* - The keeptot code will make sure cur->xmin will not be less than tot->xmin (which cannot be allowed)
* - width is not adjusted for changed ratios here...
/* Special exception for Outliner (and later channel-lists):
* - The view may be moved left to avoid contents
* being pushed out of view when view shrinks.
* - The keeptot code will make sure cur->xmin will not be less than tot->xmin
* (which cannot be allowed).
* - width is not adjusted for changed ratios here.
*/
if (winx < v2d->oldwinx) {
float temp = v2d->oldwinx - winx;
@ -906,8 +913,9 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
}
/**
* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot)
* This does not take into account if zooming the view on an axis will improve the view (if allowed)
* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot).
* This does not take into account if zooming the view on an axis
* will improve the view (if allowed).
*/
void UI_view2d_curRect_reset(View2D *v2d)
{
@ -1149,8 +1157,9 @@ void UI_view2d_view_ortho(View2D *v2d)
const float eps = 0.001f;
float xofs = 0.0f, yofs = 0.0f;
/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
* but only applied where requested
/* Pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1
* correspondence with pixels for smooth UI drawing,
* but only applied where requested.
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
@ -1184,15 +1193,17 @@ void UI_view2d_view_ortho(View2D *v2d)
/**
* Set view matrices to only use one axis of 'cur' only
*
* \param xaxis: if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x)
* \param xaxis: if non-zero, only use cur x-axis,
* otherwise use cur-yaxis (mostly this will be used for x).
*/
void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis)
{
rctf curmasked;
float xofs, yofs;
/* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing,
* but only applied where requested
/* Pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1
* correspondence with pixels for smooth UI drawing,
* but only applied where requested.
*/
/* XXX temp (ton) */
xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f;
@ -2198,7 +2209,8 @@ void UI_view2d_listview_cell_to_view(View2D *v2d,
}
/**
* Get the 'cell' (row, column) that the given 2D-view coordinates (i.e. in 'tot' rect space) lie in.
* Get the 'cell' (row, column) that the given 2D-view coordinates
* (i.e. in 'tot' rect space) lie in.
*
* \param columnwidth, rowheight: size of each 'cell'
* \param startx, starty: coordinates (in 'tot' rect space) that the list starts from.
@ -2255,7 +2267,8 @@ void UI_view2d_listview_view_to_cell(View2D *v2d,
* Get the 'extreme' (min/max) column and row indices which are visible within the 'cur' rect
*
* \param columnwidth, rowheight: Size of each 'cell'
* \param startx, starty: Coordinates that the list starts from, which should be (0,0) for most views
* \param startx, starty: Coordinates that the list starts from,
* which should be (0,0) for most views.
* \param column_min, column_max, row_min, row_max: The starting and ending column/row indices
*/
void UI_view2d_listview_visible_cells(View2D *v2d,

View File

@ -1183,8 +1183,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
vzd->dx += dx;
vzd->dy += dy;
/* store mouse coordinates for next time, if not doing continuous zoom
* - continuous zoom only depends on distance of mouse to starting point to determine rate of change
/* Store mouse coordinates for next time, if not doing continuous zoom:
* - Continuous zoom only depends on distance of mouse
* to starting point to determine rate of change.
*/
if (U.viewzoom != USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
vzd->lastx = event->x;
@ -1647,9 +1648,11 @@ typedef struct v2dScrollerMove {
/**
* #View2DScrollers is typedef'd in UI_view2d.h
* This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c, as we only need focus bubble info
* This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c,
* as we only need focus bubble info.
*
* \warning: The start of this struct must not change, so that it stays in sync with the 'real' version
* \warning: The start of this struct must not change,
* so that it stays in sync with the 'real' version.
* For now, we don't need to have a separate (internal) header for structs like this...
*/
struct View2DScrollers {