style cleanup
[blender.git] / source / blender / editors / interface / interface_regions.c
index dd6be9141ca431faf2faa3dffc098a48d0b6cebe..be118e1982e2f39ff46e0cb2e3095baa14d38529 100644 (file)
@@ -417,11 +417,20 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
        static ARegionType type;
        ARegion *ar;
        uiTooltipData *data;
-       IDProperty *prop;
+/*     IDProperty *prop;*/
        char buf[512];
        float fonth, fontw, aspect = but->block->aspect;
-       float x1f, x2f, y1f, y2f;
-       int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a;
+       int winx, winy, ofsx, ofsy, w, h, a;
+       rctf rect_fl;
+       rcti rect_i;
+
+       const int nbr_info = 6;
+       uiStringInfo but_tip = {BUT_GET_TIP, NULL};
+       uiStringInfo enum_label = {BUT_GET_RNAENUM_LABEL, NULL};
+       uiStringInfo enum_tip = {BUT_GET_RNAENUM_TIP, NULL};
+       uiStringInfo op_keymap = {BUT_GET_OP_KEYMAP, NULL};
+       uiStringInfo rna_struct = {BUT_GET_RNASTRUCT_IDENTIFIER, NULL};
+       uiStringInfo rna_prop = {BUT_GET_RNAPROP_IDENTIFIER, NULL};
 
        if (but->flag & UI_BUT_NO_TOOLTIP)
                return NULL;
@@ -429,8 +438,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
        /* create tooltip data */
        data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
 
+       uiButGetStrInfo(C, but, nbr_info, &but_tip, &enum_label, &enum_tip, &op_keymap, &rna_struct, &rna_prop);
+
        /* special case, enum rna buttons only have enum item description,
         * use general enum description too before the specific one */
+#if 0
        if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
                const char *descr = RNA_property_description(but->rnaprop);
                if (descr && descr[0]) {
@@ -441,7 +453,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 
                if (ELEM(but->type, ROW, MENU)) {
                        EnumPropertyItem *item;
-                       int i, totitem, free;
+                       int totitem, free;
                        int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but);
 
                        RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &item, &totitem, &free);
@@ -469,7 +481,23 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                data->color_id[data->totline] = UI_TIP_LC_MAIN;
                data->totline++;
        }
+#else
+       /* Tip */
+       if (but_tip.strinfo) {
+               BLI_strncpy(data->lines[data->totline], but_tip.strinfo, sizeof(data->lines[0]));
+               data->color_id[data->totline] = UI_TIP_LC_MAIN;
+               data->totline++;
+       }
+       /* Enum item label & tip */
+       if (enum_label.strinfo && enum_tip.strinfo) {
+               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
+                            "%s: %s", enum_label.strinfo, enum_tip.strinfo);
+               data->color_id[data->totline] = UI_TIP_LC_SUBMENU;
+               data->totline++;
+       }
+#endif
 
+#if 0
        if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) {
                /* operator keymap (not menus, they already have it) */
                prop = (but->opptr) ? but->opptr->data : NULL;
@@ -482,6 +510,14 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        data->totline++;
                }
        }
+#else
+       /* Op shortcut */
+       if (op_keymap.strinfo) {
+               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), op_keymap.strinfo);
+               data->color_id[data->totline] = UI_TIP_LC_NORMAL;
+               data->totline++;
+       }
+#endif
 
        if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
                /* full string */
@@ -515,7 +551,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                                data->totline++;
                        }
                }
-
+#if 0
                /* rna info */
                if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
                        BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s.%s"),
@@ -523,7 +559,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        data->color_id[data->totline] = UI_TIP_LC_PYTHON;
                        data->totline++;
                }
-               
+#endif
                if (but->rnapoin.id.data) {
                        ID *id = but->rnapoin.id.data;
                        if (id->lib && id->lib->name) {
@@ -538,6 +574,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                char *str;
                opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
 
+               /* 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);
 
                /* operator info */
@@ -558,10 +597,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        if (poll_msg) {
                                BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg);
                                data->color_id[data->totline] = UI_TIP_LC_ALERT; /* alert */
-                               data->totline++;                        
+                               data->totline++;
                        }
                }
        }
+#if 0
        else if (ELEM(but->type, MENU, PULLDOWN)) {
                if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
                        MenuType *mt = uiButGetMenuType(but);
@@ -571,8 +611,34 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                                data->totline++;
                        }
                }
-
        }
+#else
+       if ((U.flag & USER_TOOLTIPS_PYTHON) == 0 && !but->optype && rna_struct.strinfo) {
+               if (rna_prop.strinfo)
+                       /* Struct and prop */
+                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
+                                    TIP_("Python: %s.%s"), rna_struct.strinfo, rna_prop.strinfo);
+               else
+                       /* Only struct (e.g. menus) */
+                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), rna_struct.strinfo);
+               data->color_id[data->totline] = UI_TIP_LC_PYTHON;
+               data->totline++;
+       }
+#endif
+
+       /* Free strinfo's... */
+       if (but_tip.strinfo)
+               MEM_freeN(but_tip.strinfo);
+       if (enum_label.strinfo)
+               MEM_freeN(enum_label.strinfo);
+       if (enum_tip.strinfo)
+               MEM_freeN(enum_tip.strinfo);
+       if (op_keymap.strinfo)
+               MEM_freeN(op_keymap.strinfo);
+       if (rna_struct.strinfo)
+               MEM_freeN(rna_struct.strinfo);
+       if (rna_prop.strinfo)
+               MEM_freeN(rna_prop.strinfo);
 
        assert(data->totline < MAX_TOOLTIP_LINES);
        
@@ -620,62 +686,59 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
        ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
        ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
 
-       x1f = (but->x1 + but->x2) * 0.5f + ofsx - (TIP_BORDER_X * aspect);
-       x2f = x1f + fontw + (TIP_BORDER_X * aspect);
-       y2f = but->y1 + ofsy - (TIP_BORDER_Y * aspect);
-       y1f = y2f - fonth * aspect - (TIP_BORDER_Y * aspect);
+       rect_fl.xmin = (but->rect.xmin + but->rect.xmax) * 0.5f + ofsx - (TIP_BORDER_X * aspect);
+       rect_fl.xmax = rect_fl.xmin + fontw + (TIP_BORDER_X * aspect);
+       rect_fl.ymax = but->rect.ymin + ofsy - (TIP_BORDER_Y * aspect);
+       rect_fl.ymin = rect_fl.ymax - fonth * aspect - (TIP_BORDER_Y * aspect);
        
 #undef TIP_MARGIN_Y
 #undef TIP_BORDER_X
 #undef TIP_BORDER_Y
 
        /* copy to int, gets projected if possible too */
-       x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f;
+       BLI_rcti_rctf_copy(&rect_i, &rect_fl);
        
        if (butregion) {
                /* XXX temp, region v2ds can be empty still */
                if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
-                       UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
-                       UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax);
                }
 
-               x1 += butregion->winrct.xmin;
-               x2 += butregion->winrct.xmin;
-               y1 += butregion->winrct.ymin;
-               y2 += butregion->winrct.ymin;
+               BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
        }
 
        wm_window_get_size(CTX_wm_window(C), &winx, &winy);
 
-       if (x2 > winx) {
+       if (rect_i.xmax > winx) {
                /* super size */
-               if (x2 > winx + x1) {
-                       x2 = winx;
-                       x1 = 0;
+               if (rect_i.xmax > winx + rect_i.xmin) {
+                       rect_i.xmax = winx;
+                       rect_i.xmin = 0;
                }
                else {
-                       x1 -= x2 - winx;
-                       x2 = winx;
+                       rect_i.xmin -= rect_i.xmax - winx;
+                       rect_i.xmax = winx;
                }
        }
        /* ensure at least 5 px above screen bounds
         * 25 is just a guess to be above the menu item */
-       if (y1 < 5) {
-               y2 += (-y1) + 30;
-               y1 = 30;
+       if (rect_i.ymin < 5) {
+               rect_i.ymax += (-rect_i.ymin) + 30;
+               rect_i.ymin = 30;
        }
 
        /* widget rect, in region coords */
        data->bbox.xmin = MENU_SHADOW_SIDE;
-       data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE;
+       data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE;
        data->bbox.ymin = MENU_SHADOW_BOTTOM;
-       data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM;
+       data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM;
        
        /* region bigger for shadow */
-       ar->winrct.xmin = x1 - MENU_SHADOW_SIDE;
-       ar->winrct.xmax = x2 + MENU_SHADOW_SIDE;
-       ar->winrct.ymin = y1 - MENU_SHADOW_BOTTOM;
-       ar->winrct.ymax = y2 + MENU_TOP;
+       ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
+       ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE;
+       ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM;
+       ar->winrct.ymax = rect_i.ymax + MENU_TOP;
 
        /* adds subwindow */
        ED_region_init(C, ar);
@@ -1069,8 +1132,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
        ARegion *ar;
        uiSearchboxData *data;
        float aspect = but->block->aspect;
-       float x1f, x2f, y1f, y2f;
-       int x1, x2, y1, y2, winx, winy, ofsx, ofsy;
+       rctf rect_fl;
+       rcti rect_i;
+       int winx, winy, ofsx, ofsy;
+       int i;
        
        /* create area region */
        ar = ui_add_temporary_region(CTX_wm_screen(C));
@@ -1116,77 +1181,73 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
                data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM;
                
                /* check if button is lower half */
-               if (but->y2 < (but->block->miny + but->block->maxy) / 2) {
-                       data->bbox.ymin += (but->y2 - but->y1);
+               if (but->rect.ymax < (but->block->rect.ymin + but->block->rect.ymax) / 2) {
+                       data->bbox.ymin += (but->rect.ymax - but->rect.ymin);
                }
                else {
-                       data->bbox.ymax -= (but->y2 - but->y1);
+                       data->bbox.ymax -= (but->rect.ymax - but->rect.ymin);
                }
        }
        else {
-               x1f = but->x1 - 5;   /* align text with button */
-               x2f = but->x2 + 5;   /* symmetrical */
-               y2f = but->y1;
-               y1f = y2f - uiSearchBoxhHeight();
+               rect_fl.xmin = but->rect.xmin - 5;   /* align text with button */
+               rect_fl.xmax = but->rect.xmax + 5;   /* symmetrical */
+               rect_fl.ymax = but->rect.ymin;
+               rect_fl.ymin = rect_fl.ymax - uiSearchBoxhHeight();
 
                ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
                ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
 
-               x1f += ofsx;
-               x2f += ofsx;
-               y1f += ofsy;
-               y2f += ofsy;
+               BLI_rctf_translate(&rect_fl, ofsx, ofsy);
        
                /* minimal width */
-               if (x2f - x1f < 150) x2f = x1f + 150;  // XXX arbitrary
+               if (rect_fl.xmax - rect_fl.xmin < 150) {
+                       rect_fl.xmax = rect_fl.xmin + 150;  /* XXX arbitrary */
+               }
                
                /* copy to int, gets projected if possible too */
-               x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f;
+               BLI_rcti_rctf_copy(&rect_i, &rect_fl);
                
                if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
-                       UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
-                       UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmin, rect_fl.ymin, &rect_i.xmin, &rect_i.ymin);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, rect_fl.xmax, rect_fl.ymax, &rect_i.xmax, &rect_i.ymax);
                }
 
-               x1 += butregion->winrct.xmin;
-               x2 += butregion->winrct.xmin;
-               y1 += butregion->winrct.ymin;
-               y2 += butregion->winrct.ymin;
+               BLI_rcti_translate(&rect_i, butregion->winrct.xmin, butregion->winrct.ymin);
 
                wm_window_get_size(CTX_wm_window(C), &winx, &winy);
                
-               if (x2 > winx) {
+               if (rect_i.xmax > winx) {
                        /* super size */
-                       if (x2 > winx + x1) {
-                               x2 = winx;
-                               x1 = 0;
+                       if (rect_i.xmax > winx + rect_i.xmin) {
+                               rect_i.xmax = winx;
+                               rect_i.xmin = 0;
                        }
                        else {
-                               x1 -= x2 - winx;
-                               x2 = winx;
+                               rect_i.xmin -= rect_i.xmax - winx;
+                               rect_i.xmax = winx;
                        }
                }
 
-               if (y1 < 0) {
+               if (rect_i.ymin < 0) {
                        int newy1;
-                       UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1);
+                       UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1);
                        newy1 += butregion->winrct.ymin;
 
-                       y2 = y2 - y1 + newy1;
-                       y1 = newy1;
+                       rect_i.ymax = rect_i.ymax - rect_i.ymin + newy1;
+                       rect_i.ymin = newy1;
                }
 
                /* widget rect, in region coords */
                data->bbox.xmin = MENU_SHADOW_SIDE;
-               data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE;
+               data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE;
                data->bbox.ymin = MENU_SHADOW_BOTTOM;
-               data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM;
+               data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM;
                
                /* region bigger for shadow */
-               ar->winrct.xmin = x1 - MENU_SHADOW_SIDE;
-               ar->winrct.xmax = x2 + MENU_SHADOW_SIDE;
-               ar->winrct.ymin = y1 - MENU_SHADOW_BOTTOM;
-               ar->winrct.ymax = y2;
+               ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE;
+               ar->winrct.xmax = rect_i.xmax + MENU_SHADOW_SIDE;
+               ar->winrct.ymin = rect_i.ymin - MENU_SHADOW_BOTTOM;
+               ar->winrct.ymax = rect_i.ymax;
        }
        
        /* adds subwindow */
@@ -1207,8 +1268,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
        data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names");
        data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers");
        data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons");
-       for (x1 = 0; x1 < data->items.maxitem; x1++)
-               data->items.names[x1] = MEM_callocN(but->hardmax + 1, "search pointers");
+       for (i = 0; i < data->items.maxitem; i++)
+               data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers");
        
        return ar;
 }
@@ -1274,45 +1335,36 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
        short dir1 = 0, dir2 = 0;
        
        /* transform to window coordinates, using the source button region/block */
-       butrct.xmin = but->x1; butrct.xmax = but->x2;
-       butrct.ymin = but->y1; butrct.ymax = but->y2;
+       butrct = but->rect;
 
        ui_block_to_window_fl(butregion, but->block, &butrct.xmin, &butrct.ymin);
        ui_block_to_window_fl(butregion, but->block, &butrct.xmax, &butrct.ymax);
 
        /* calc block rect */
-       if (block->minx == 0.0f && block->maxx == 0.0f) {
+       if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
                if (block->buttons.first) {
-                       block->minx = block->miny = 10000;
-                       block->maxx = block->maxy = -10000;
-                       
-                       bt = block->buttons.first;
-                       while (bt) {
-                               if (bt->x1 < block->minx) block->minx = bt->x1;
-                               if (bt->y1 < block->miny) block->miny = bt->y1;
+                       BLI_rctf_init_minmax(&block->rect);
 
-                               if (bt->x2 > block->maxx) block->maxx = bt->x2;
-                               if (bt->y2 > block->maxy) block->maxy = bt->y2;
-                               
-                               bt = bt->next;
+                       for (bt = block->buttons.first; bt; bt = bt->next) {
+                               BLI_rctf_union(&block->rect, &bt->rect);
                        }
                }
                else {
                        /* we're nice and allow empty blocks too */
-                       block->minx = block->miny = 0;
-                       block->maxx = block->maxy = 20;
+                       block->rect.xmin = block->rect.ymin = 0;
+                       block->rect.xmax = block->rect.ymax = 20;
                }
        }
        
-       /* aspect = (float)(block->maxx - block->minx + 4);*/ /*UNUSED*/
-       ui_block_to_window_fl(butregion, but->block, &block->minx, &block->miny);
-       ui_block_to_window_fl(butregion, but->block, &block->maxx, &block->maxy);
+       /* aspect = (float)(block->rect.xmax - block->rect.xmin + 4);*/ /*UNUSED*/
+       ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
+       ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
 
-       //block->minx -= 2.0; block->miny -= 2.0;
-       //block->maxx += 2.0; block->maxy += 2.0;
+       //block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
+       //block->rect.xmax += 2.0; block->rect.ymax += 2.0;
        
-       xsize = block->maxx - block->minx + 4; // 4 for shadow
-       ysize = block->maxy - block->miny + 4;
+       xsize = block->rect.xmax - block->rect.xmin + 4;  /* 4 for shadow */
+       ysize = block->rect.ymax - block->rect.ymin + 4;
        /* aspect /= (float)xsize;*/ /*UNUSED*/
 
        {
@@ -1366,20 +1418,20 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                }
 
                if (dir1 == UI_LEFT) {
-                       xof = butrct.xmin - block->maxx;
-                       if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center;
-                       else yof = butrct.ymax - block->maxy + center;
+                       xof = butrct.xmin - block->rect.xmax;
+                       if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center;
+                       else yof = butrct.ymax - block->rect.ymax + center;
                }
                else if (dir1 == UI_RIGHT) {
-                       xof = butrct.xmax - block->minx;
-                       if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center;
-                       else yof = butrct.ymax - block->maxy + center;
+                       xof = butrct.xmax - block->rect.xmin;
+                       if (dir2 == UI_TOP) yof = butrct.ymin - block->rect.ymin - center;
+                       else yof = butrct.ymax - block->rect.ymax + center;
                }
                else if (dir1 == UI_TOP) {
-                       yof = butrct.ymax - block->miny;
-                       if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx;
-                       else xof = butrct.xmin - block->minx;
-                       // changed direction? 
+                       yof = butrct.ymax - block->rect.ymin;
+                       if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax;
+                       else xof = butrct.xmin - block->rect.xmin;
+                       /* changed direction? */
                        if ((dir1 & block->direction) == 0) {
                                if (block->direction & UI_SHIFT_FLIPPED)
                                        xof += dir2 == UI_LEFT ? 25 : -25;
@@ -1387,10 +1439,10 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                        }
                }
                else if (dir1 == UI_DOWN) {
-                       yof = butrct.ymin - block->maxy;
-                       if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx;
-                       else xof = butrct.xmin - block->minx;
-                       // changed direction?
+                       yof = butrct.ymin - block->rect.ymax;
+                       if (dir2 == UI_RIGHT) xof = butrct.xmax - block->rect.xmax;
+                       else xof = butrct.xmin - block->rect.xmin;
+                       /* changed direction? */
                        if ((dir1 & block->direction) == 0) {
                                if (block->direction & UI_SHIFT_FLIPPED)
                                        xof += dir2 == UI_LEFT ? 25 : -25;
@@ -1401,7 +1453,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                /* and now we handle the exception; no space below or to top */
                if (top == 0 && down == 0) {
                        if (dir1 == UI_LEFT || dir1 == UI_RIGHT) {
-                               // align with bottom of screen 
+                               /* align with bottom of screen */
                                // yof= ysize; (not with menu scrolls)
                        }
                }
@@ -1409,43 +1461,37 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                /* or no space left or right */
                if (left == 0 && right == 0) {
                        if (dir1 == UI_TOP || dir1 == UI_DOWN) {
-                               // align with left size of screen 
-                               xof = -block->minx + 5;
+                               /* align with left size of screen */
+                               xof = -block->rect.xmin + 5;
                        }
                }
                
-               // apply requested offset in the block
+               /* apply requested offset in the block */
                xof += block->xofs / block->aspect;
                yof += block->yofs / block->aspect;
 #if 0
                /* clamp to window bounds, could be made into an option if its ever annoying */
-               if (     (offscreen = (block->miny + yof)) < 0) yof -= offscreen;   /* bottom */
-               else if ((offscreen = (block->maxy + yof) - winy) > 0) yof -= offscreen;  /* top */
-               if (     (offscreen = (block->minx + xof)) < 0) xof -= offscreen;   /* left */
-               else if ((offscreen = (block->maxx + xof) - winx) > 0) xof -= offscreen;  /* right */
+               if (     (offscreen = (block->rect.ymin + yof)) < 0) yof -= offscreen;   /* bottom */
+               else if ((offscreen = (block->rect.ymax + yof) - winy) > 0) yof -= offscreen;  /* top */
+               if (     (offscreen = (block->rect.xmin + xof)) < 0) xof -= offscreen;   /* left */
+               else if ((offscreen = (block->rect.xmax + xof) - winx) > 0) xof -= offscreen;  /* right */
 #endif
        }
        
        /* apply offset, buttons in window coords */
        
        for (bt = block->buttons.first; bt; bt = bt->next) {
-               ui_block_to_window_fl(butregion, but->block, &bt->x1, &bt->y1);
-               ui_block_to_window_fl(butregion, but->block, &bt->x2, &bt->y2);
+               ui_block_to_window_fl(butregion, but->block, &bt->rect.xmin, &bt->rect.ymin);
+               ui_block_to_window_fl(butregion, but->block, &bt->rect.xmax, &bt->rect.ymax);
 
-               bt->x1 += xof;
-               bt->x2 += xof;
-               bt->y1 += yof;
-               bt->y2 += yof;
+               BLI_rctf_translate(&bt->rect, xof, yof);
 
-               bt->aspect = 1.0;
-               // ui_check_but recalculates drawstring size in pixels
+               bt->aspect = 1.0f;
+               /* ui_check_but recalculates drawstring size in pixels */
                ui_check_but(bt);
        }
        
-       block->minx += xof;
-       block->miny += yof;
-       block->maxx += xof;
-       block->maxy += yof;
+       BLI_rctf_translate(&block->rect, xof, yof);
 
        /* safety calculus */
        if (but) {
@@ -1454,32 +1500,32 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
                
                /* when you are outside parent button, safety there should be smaller */
                
-               // parent button to left
-               if (midx < block->minx) block->safety.xmin = block->minx - 3;
-               else block->safety.xmin = block->minx - 40;
-               // parent button to right
-               if (midx > block->maxx) block->safety.xmax = block->maxx + 3;
-               else block->safety.xmax = block->maxx + 40;
-               
-               // parent button on bottom
-               if (midy < block->miny) block->safety.ymin = block->miny - 3;
-               else block->safety.ymin = block->miny - 40;
-               // parent button on top
-               if (midy > block->maxy) block->safety.ymax = block->maxy + 3;
-               else block->safety.ymax = block->maxy + 40;
-               
-               // exception for switched pulldowns...
+               /* parent button to left */
+               if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3;
+               else block->safety.xmin = block->rect.xmin - 40;
+               /* parent button to right */
+               if (midx > block->rect.xmax) block->safety.xmax = block->rect.xmax + 3;
+               else block->safety.xmax = block->rect.xmax + 40;
+
+               /* parent button on bottom */
+               if (midy < block->rect.ymin) block->safety.ymin = block->rect.ymin - 3;
+               else block->safety.ymin = block->rect.ymin - 40;
+               /* parent button on top */
+               if (midy > block->rect.ymax) block->safety.ymax = block->rect.ymax + 3;
+               else block->safety.ymax = block->rect.ymax + 40;
+
+               /* exception for switched pulldowns... */
                if (dir1 && (dir1 & block->direction) == 0) {
-                       if (dir2 == UI_RIGHT) block->safety.xmax = block->maxx + 3;
-                       if (dir2 == UI_LEFT) block->safety.xmin = block->minx - 3;
+                       if (dir2 == UI_RIGHT) block->safety.xmax = block->rect.xmax + 3;
+                       if (dir2 == UI_LEFT) block->safety.xmin = block->rect.xmin - 3;
                }
                block->direction = dir1;
        }
        else {
-               block->safety.xmin = block->minx - 40;
-               block->safety.ymin = block->miny - 40;
-               block->safety.xmax = block->maxx + 40;
-               block->safety.ymax = block->maxy + 40;
+               block->safety.xmin = block->rect.xmin - 40;
+               block->safety.ymin = block->rect.ymin - 40;
+               block->safety.xmax = block->rect.xmax + 40;
+               block->safety.ymax = block->rect.ymax + 40;
        }
 
        /* keep a list of these, needed for pulldown menus */
@@ -1506,15 +1552,15 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
        
        wm_window_get_size(window, &winx, &winy);
        
-       if (block->minx < MENU_SHADOW_SIDE)
-               block->minx = MENU_SHADOW_SIDE;
-       if (block->maxx > winx - MENU_SHADOW_SIDE)
-               block->maxx = winx - MENU_SHADOW_SIDE;
+       if (block->rect.xmin < MENU_SHADOW_SIDE)
+               block->rect.xmin = MENU_SHADOW_SIDE;
+       if (block->rect.xmax > winx - MENU_SHADOW_SIDE)
+               block->rect.xmax = winx - MENU_SHADOW_SIDE;
        
-       if (block->miny < MENU_SHADOW_BOTTOM)
-               block->miny = MENU_SHADOW_BOTTOM;
-       if (block->maxy > winy - MENU_TOP)
-               block->maxy = winy - MENU_TOP;
+       if (block->rect.ymin < MENU_SHADOW_BOTTOM)
+               block->rect.ymin = MENU_SHADOW_BOTTOM;
+       if (block->rect.ymax > winy - MENU_TOP)
+               block->rect.ymax = winy - MENU_TOP;
 }
 
 void ui_popup_block_scrolltest(uiBlock *block)
@@ -1533,25 +1579,25 @@ void ui_popup_block_scrolltest(uiBlock *block)
        
        /* mark buttons that are outside boundary and the ones next to it for arrow(s) */
        for (bt = block->buttons.first; bt; bt = bt->next) {
-               if (bt->y1 < block->miny) {
+               if (bt->rect.ymin < block->rect.ymin) {
                        bt->flag |= UI_SCROLLED;
                        block->flag |= UI_BLOCK_CLIPBOTTOM;
                        /* make space for arrow */
-                       if (bt->y2 < block->miny + 10) {
-                               if (is_flip && bt->next && bt->next->y1 > bt->y1)
+                       if (bt->rect.ymax < block->rect.ymin + 10) {
+                               if (is_flip && bt->next && bt->next->rect.ymin > bt->rect.ymin)
                                        bt->next->flag |= UI_SCROLLED;
-                               else if (!is_flip && bt->prev && bt->prev->y1 > bt->y1)
+                               else if (!is_flip && bt->prev && bt->prev->rect.ymin > bt->rect.ymin)
                                        bt->prev->flag |= UI_SCROLLED;
                        }
                }
-               if (bt->y2 > block->maxy) {
+               if (bt->rect.ymax > block->rect.ymax) {
                        bt->flag |= UI_SCROLLED;
                        block->flag |= UI_BLOCK_CLIPTOP;
                        /* make space for arrow */
-                       if (bt->y1 > block->maxy - 10) {
-                               if (!is_flip && bt->next && bt->next->y2 < bt->y2)
+                       if (bt->rect.ymin > block->rect.ymax - 10) {
+                               if (!is_flip && bt->next && bt->next->rect.ymax < bt->rect.ymax)
                                        bt->next->flag |= UI_SCROLLED;
-                               else if (is_flip && bt->prev && bt->prev->y2 < bt->y2)
+                               else if (is_flip && bt->prev && bt->prev->rect.ymax < bt->rect.ymax)
                                        bt->prev->flag |= UI_SCROLLED;
                        }
                }
@@ -1566,7 +1612,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
        static ARegionType type;
        ARegion *ar;
        uiBlock *block;
-       uiBut *bt;
        uiPopupBlockHandle *handle;
        uiSafetyRct *saferct;
 
@@ -1629,22 +1674,12 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
        /* the block and buttons were positioned in window space as in 2.4x, now
         * these menu blocks are regions so we bring it back to region space.
         * additionally we add some padding for the menu shadow or rounded menus */
-       ar->winrct.xmin = block->minx - MENU_SHADOW_SIDE;
-       ar->winrct.xmax = block->maxx + MENU_SHADOW_SIDE;
-       ar->winrct.ymin = block->miny - MENU_SHADOW_BOTTOM;
-       ar->winrct.ymax = block->maxy + MENU_TOP;
+       ar->winrct.xmin = block->rect.xmin - MENU_SHADOW_SIDE;
+       ar->winrct.xmax = block->rect.xmax + MENU_SHADOW_SIDE;
+       ar->winrct.ymin = block->rect.ymin - MENU_SHADOW_BOTTOM;
+       ar->winrct.ymax = block->rect.ymax + MENU_TOP;
        
-       block->minx -= ar->winrct.xmin;
-       block->maxx -= ar->winrct.xmin;
-       block->miny -= ar->winrct.ymin;
-       block->maxy -= ar->winrct.ymin;
-
-       for (bt = block->buttons.first; bt; bt = bt->next) {
-               bt->x1 -= ar->winrct.xmin;
-               bt->x2 -= ar->winrct.xmin;
-               bt->y1 -= ar->winrct.ymin;
-               bt->y2 -= ar->winrct.ymin;
-       }
+       ui_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin);
        
        block->flag |= UI_BLOCK_LOOP;
 
@@ -1729,7 +1764,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
        }
 
        /* create items */
-       split = uiLayoutSplit(layout, 0, 0);
+       split = uiLayoutSplit(layout, 0.0f, FALSE);
 
        for (a = 0; a < md->nitems; a++) {
                if (a == column_end) {
@@ -1748,7 +1783,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
                                }
                        }
 
-                       column = uiLayoutColumn(split, 0);
+                       column = uiLayoutColumn(split, FALSE);
                }
 
                if (block->flag & UI_BLOCK_NO_FLIP)
@@ -1862,7 +1897,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3])
         */
        rgb_to_hsv_compat_v(rgb, hsv);
        
-       // this updates button strings, is hackish... but button pointers are on stack of caller function
+       /* this updates button strings, is hackish... but button pointers are on stack of caller function */
        for (bt = block->buttons.first; bt; bt = bt->next) {
                if (bt->rnaprop) {
                        
@@ -2130,8 +2165,8 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
        bt = uiDefButR_prop(block, NUMSLI, 0, IFACE_("B "),  0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, TIP_("Blue"));
        uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
 
-       // could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
-       // but need to use uiButSetFunc for updating other fake buttons
+       /* could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
+        * but need to use uiButSetFunc for updating other fake buttons */
        
        /* HSV values */
        uiBlockBeginAlign(block);
@@ -2306,7 +2341,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
 
        if (pup->but) {
                /* minimum width to enforece */
-               minwidth = pup->but->x2 - pup->but->x1;
+               minwidth = pup->but->rect.xmax - pup->but->rect.xmin;
 
                if (pup->but->type == PULLDOWN || pup->but->menu_create_func) {
                        direction = UI_DOWN;
@@ -2348,15 +2383,15 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
                         * button, so it doesn't overlap the text too much, also note
                         * the offset is negative because we are inverse moving the
                         * block to be under the mouse */
-                       offset[0] = -(bt->x1 + 0.8f * (bt->x2 - bt->x1));
-                       offset[1] = -(bt->y1 + 0.5f * UI_UNIT_Y);
+                       offset[0] = -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin));
+                       offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y);
                }
                else {
                        /* position mouse at 0.8*width of the button and below the tile
                         * on the first item */
                        offset[0] = 0;
                        for (bt = block->buttons.first; bt; bt = bt->next)
-                               offset[0] = MIN2(offset[0], -(bt->x1 + 0.8f * (bt->x2 - bt->x1)));
+                               offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin)));
 
                        offset[1] = 1.5 * UI_UNIT_Y;
                }
@@ -2587,7 +2622,7 @@ void uiPupMenuOkee(bContext *C, const char *opname, const char *str, ...)
  * The operator state for this is implicitly OPERATOR_RUNNING_MODAL */
 void uiPupMenuSaveOver(bContext *C, wmOperator *op, const char *filename)
 {
-       confirm_operator(C, op, "Save Over", filename);
+       confirm_operator(C, op, "Save Over?", filename);
 }
 
 void uiPupMenuNotice(bContext *C, const char *str, ...)