diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-18 20:53:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-18 20:53:46 +0400 |
commit | 63f143a3ccf1a411951730f85efbdd84d2076a12 (patch) | |
tree | 6d5fd69566525ab88a685ecf4e82dcdb473e9f11 /source | |
parent | 27b4b45543c0f7690a1978a60591a0b5c0f1adbb (diff) |
use rctf struct for UI buttons and blocks, easier to read and means we can use BLI_rctf functions.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface.c | 170 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 170 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 24 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 34 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 199 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_logic/logic_buttons.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_templates.c | 2 |
10 files changed, 308 insertions, 315 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7b1150669e8..55d78ae1307 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -196,19 +196,13 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y) void ui_block_translate(uiBlock *block, int x, int y) { - uiBut *bt; + uiBut *but; - for (bt = block->buttons.first; bt; bt = bt->next) { - bt->x1 += x; - bt->y1 += y; - bt->x2 += x; - bt->y2 += y; + for (but = block->buttons.first; but; but = but->next) { + BLI_rctf_translate(&but->rect, x, y); } - block->minx += x; - block->miny += y; - block->maxx += x; - block->maxy += y; + BLI_rctf_translate(&block->rect, x, y); } static void ui_text_bounds_block(uiBlock *block, float offset) @@ -227,24 +221,24 @@ static void ui_text_bounds_block(uiBlock *block, float offset) if (j > i) i = j; } - if (bt->next && bt->x1 < bt->next->x1) + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) lastcol++; } /* cope with multi collumns */ bt = block->buttons.first; while (bt) { - if (bt->next && bt->x1 < bt->next->x1) { + if (bt->next && bt->rect.xmin < bt->next->rect.xmin) { nextcol = 1; col++; } else nextcol = 0; - bt->x1 = x1addval; - bt->x2 = bt->x1 + i + block->bounds; + bt->rect.xmin = x1addval; + bt->rect.xmax = bt->rect.xmin + i + block->bounds; if (col == lastcol) - bt->x2 = MAX2(bt->x2, offset + block->minbounds); + bt->rect.xmax = MAX2(bt->rect.xmax, offset + block->minbounds); ui_check_but(bt); // clips text again @@ -262,43 +256,43 @@ void ui_bounds_block(uiBlock *block) if (block->buttons.first == NULL) { if (block->panel) { - block->minx = 0.0; block->maxx = block->panel->sizex; - block->miny = 0.0; block->maxy = block->panel->sizey; + block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex; + block->rect.ymin = 0.0; block->rect.ymax = block->panel->sizey; } } else { - block->minx = block->miny = 10000; - block->maxx = block->maxy = -10000; - + block->rect.xmin = block->rect.ymin = 10000; + block->rect.xmax = block->rect.ymax = -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; + if (bt->rect.xmin < block->rect.xmin) block->rect.xmin = bt->rect.xmin; + if (bt->rect.ymin < block->rect.ymin) block->rect.ymin = bt->rect.ymin; - if (bt->x2 > block->maxx) block->maxx = bt->x2; - if (bt->y2 > block->maxy) block->maxy = bt->y2; + if (bt->rect.xmax > block->rect.xmax) block->rect.xmax = bt->rect.xmax; + if (bt->rect.ymax > block->rect.ymax) block->rect.ymax = bt->rect.ymax; bt = bt->next; } - block->minx -= block->bounds; - block->miny -= block->bounds; - block->maxx += block->bounds; - block->maxy += block->bounds; + block->rect.xmin -= block->bounds; + block->rect.ymin -= block->bounds; + block->rect.xmax += block->bounds; + block->rect.ymax += block->bounds; } - block->maxx = block->minx + MAX2(block->maxx - block->minx, block->minbounds); + block->rect.xmax = block->rect.xmin + MAX2(block->rect.xmax - block->rect.xmin, block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; if (bt && strncmp(bt->str, "ERROR", 5) == 0) xof = 10; else xof = 40; - block->safety.xmin = block->minx - xof; - block->safety.ymin = block->miny - xof; - block->safety.xmax = block->maxx + xof; - block->safety.ymax = block->maxy + xof; + block->safety.xmin = block->rect.xmin - xof; + block->safety.ymin = block->rect.ymin - xof; + block->safety.xmax = block->rect.xmax + xof; + block->safety.ymax = block->rect.ymax + xof; } static void ui_centered_bounds_block(const bContext *C, uiBlock *block) @@ -316,13 +310,13 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block) ui_bounds_block(block); - width = block->maxx - block->minx; - height = block->maxy - block->miny; + width = block->rect.xmax - block->rect.xmin; + height = block->rect.ymax - block->rect.ymin; startx = (xmax * 0.5f) - (width * 0.5f); starty = (ymax * 0.5f) - (height * 0.5f); - ui_block_translate(block, startx - block->minx, starty - block->miny); + ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); /* now recompute bounds and safety */ ui_bounds_block(block); @@ -341,14 +335,14 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ wm_window_get_size(window, &xmax, &ymax); - oldwidth = block->maxx - block->minx; - oldheight = block->maxy - block->miny; + oldwidth = block->rect.xmax - block->rect.xmin; + oldheight = block->rect.ymax - block->rect.ymin; /* first we ensure wide enough text bounds */ if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) { if (block->flag & UI_BLOCK_LOOP) { block->bounds = 50; - ui_text_bounds_block(block, block->minx); + ui_text_bounds_block(block, block->rect.xmin); } } @@ -357,8 +351,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ ui_bounds_block(block); /* and we adjust the position to fit within window */ - width = block->maxx - block->minx; - height = block->maxy - block->miny; + width = block->rect.xmax - block->rect.xmin; + height = block->rect.ymax - block->rect.ymin; /* avoid divide by zero below, caused by calling with no UI, but better not crash */ oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width); @@ -366,8 +360,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ /* offset block based on mouse position, user offset is scaled * along in case we resized the block in ui_text_bounds_block */ - startx = window->eventstate->x + block->minx + (block->mx * width) / oldwidth; - starty = window->eventstate->y + block->miny + (block->my * height) / oldheight; + startx = window->eventstate->x + block->rect.xmin + (block->mx * width) / oldwidth; + starty = window->eventstate->y + block->rect.ymin + (block->my * height) / oldheight; if (startx < 10) startx = 10; @@ -386,7 +380,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ starty = endy - height; } - ui_block_translate(block, startx - block->minx, starty - block->miny); + ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); /* now recompute bounds and safety */ ui_bounds_block(block); @@ -436,10 +430,10 @@ void uiCenteredBoundsBlock(uiBlock *block, int addval) void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy) { - block->minx = minx; - block->miny = miny; - block->maxx = maxx; - block->maxy = maxy; + block->rect.xmin = minx; + block->rect.ymin = miny; + block->rect.xmax = maxx; + block->rect.ymax = maxy; block->dobounds = 0; } @@ -504,10 +498,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) if (line->from == NULL || line->to == NULL) return; - rect.xmin = (line->from->x1 + line->from->x2) / 2.0f; - rect.ymin = (line->from->y1 + line->from->y2) / 2.0f; - rect.xmax = (line->to->x1 + line->to->x2) / 2.0f; - rect.ymax = (line->to->y1 + line->to->y2) / 2.0f; + rect.xmin = (line->from->rect.xmin + line->from->rect.xmax) / 2.0f; + rect.ymin = (line->from->rect.ymin + line->from->rect.ymax) / 2.0f; + rect.xmax = (line->to->rect.xmin + line->to->rect.xmax) / 2.0f; + rect.ymax = (line->to->rect.ymin + line->to->rect.ymax) / 2.0f; if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); @@ -653,8 +647,8 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut *butpp = oldbut; /* still stuff needs to be copied */ - oldbut->x1 = but->x1; oldbut->y1 = but->y1; - oldbut->x2 = but->x2; oldbut->y2 = but->y2; + oldbut->rect.xmin = but->rect.xmin; oldbut->rect.ymin = but->rect.ymin; + oldbut->rect.xmax = but->rect.xmax; oldbut->rect.ymax = but->rect.ymax; oldbut->context = but->context; /* set by Layout */ /* typically the same pointers, but not on undo/redo */ @@ -764,7 +758,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) int tot_missing = 0; /* only do it before bounding */ - if (block->minx != block->maxx) + if (block->rect.xmin != block->rect.xmax) return; for (pass = 0; pass < 2; pass++) { @@ -865,7 +859,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) IDProperty *prop_menu_name = NULL; /* only do it before bounding */ - if (block->minx != block->maxx) + if (block->rect.xmin != block->rect.xmax) return; for (but = block->buttons.first; but; but = but->next) { @@ -960,7 +954,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) else if (block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); else if (block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); - if (block->minx == 0.0f && block->maxx == 0.0f) uiBoundsBlock(block, 0); + if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) uiBoundsBlock(block, 0); if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->endblock = 1; @@ -993,14 +987,14 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u getsizex = ar->winx; getsizey = ar->winy; - gx = (but ? but->x1 : block->minx) + (block->panel ? block->panel->ofsx : 0.0f); - gy = (but ? but->y1 : block->miny) + (block->panel ? block->panel->ofsy : 0.0f); + gx = (but ? but->rect.xmin : block->rect.xmin) + (block->panel ? block->panel->ofsx : 0.0f); + gy = (but ? but->rect.ymin : block->rect.ymin) + (block->panel ? block->panel->ofsy : 0.0f); rect->xmin = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]))); rect->ymin = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]))); - gx = (but ? but->x2 : block->maxx) + (block->panel ? block->panel->ofsx : 0.0f); - gy = (but ? but->y2 : block->maxy) + (block->panel ? block->panel->ofsy : 0.0f); + gx = (but ? but->rect.xmax : block->rect.xmax) + (block->panel ? block->panel->ofsx : 0.0f); + gy = (but ? but->rect.ymax : block->rect.ymax) + (block->panel ? block->panel->ofsy : 0.0f); rect->xmax = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]))); rect->ymax = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]))); @@ -2221,7 +2215,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - // okwidth= -4 + (but->x2 - but->x1); // UNUSED + // okwidth= -4 + (but->rect.xmax - but->rect.xmin); // UNUSED /* name: */ switch (but->type) { @@ -2229,7 +2223,7 @@ void ui_check_but(uiBut *but) case MENU: case ICONTEXTROW: - if (but->x2 - but->x1 > 24) { + if (but->rect.xmax - but->rect.xmin > 24) { UI_GET_BUT_VALUE_INIT(but, value); ui_set_name_menu(but, (int)value); } @@ -2373,8 +2367,8 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2) { float dx, dy; - dx = fabs(but1->x2 - but2->x1); - dy = fabs(but1->y1 - but2->y2); + dx = fabs(but1->rect.xmax - but2->rect.xmin); + dy = fabs(but1->rect.ymin - but2->rect.ymax); if (dx > dy) return 0; return 1; @@ -2492,32 +2486,32 @@ static void ui_block_do_align_but(uiBut *first, short nr) if (prev) { /* simple cases */ if (rows == 0) { - but->x1 = (prev->x2 + but->x1) / 2.0f; - prev->x2 = but->x1; + but->rect.xmin = (prev->rect.xmax + but->rect.xmin) / 2.0f; + prev->rect.xmax = but->rect.xmin; } else if (cols == 0) { - but->y2 = (prev->y1 + but->y2) / 2.0f; - prev->y1 = but->y2; + but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f; + prev->rect.ymin = but->rect.ymax; } else { if (buts_are_horiz(prev, but)) { - but->x1 = (prev->x2 + but->x1) / 2.0f; - prev->x2 = but->x1; + but->rect.xmin = (prev->rect.xmax + but->rect.xmin) / 2.0f; + prev->rect.xmax = but->rect.xmin; /* copy height too */ - but->y2 = prev->y2; + but->rect.ymax = prev->rect.ymax; } else if (prev->prev && buts_are_horiz(prev->prev, prev) == 0) { /* the previous button is a single one in its row */ - but->y2 = (prev->y1 + but->y2) / 2.0f; - prev->y1 = but->y2; + but->rect.ymax = (prev->rect.ymin + but->rect.ymax) / 2.0f; + prev->rect.ymin = but->rect.ymax; - but->x1 = prev->x1; + but->rect.xmin = prev->rect.xmin; if (next && buts_are_horiz(but, next) == 0) - but->x2 = prev->x2; + but->rect.xmax = prev->rect.xmax; } else { /* the previous button is not a single one in its row */ - but->y2 = prev->y1; + but->rect.ymax = prev->rect.ymin; } } } @@ -2586,10 +2580,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } memcpy(but->str, str, slen + 1); - but->x1 = x1; - but->y1 = y1; - but->x2 = (x1 + x2); - but->y2 = (y1 + y2); + but->rect.xmin = x1; + but->rect.ymin = y1; + but->rect.xmax = (x1 + x2); + but->rect.ymax = (y1 + y2); but->poin = poin; but->hardmin = but->softmin = min; @@ -3296,8 +3290,8 @@ int uiBlocksGetYMin(ListBase *lb) int min = 0; for (block = lb->first; block; block = block->next) - if (block == lb->first || block->miny < min) - min = block->miny; + if (block == lb->first || block->rect.ymin < min) + min = block->rect.ymin; return min; } @@ -3321,15 +3315,15 @@ void uiBlockFlipOrder(uiBlock *block) for (but = block->buttons.first; but; but = but->next) { if (but->flag & UI_BUT_ALIGN) return; - if (but->y1 < miny) miny = but->y1; - if (but->y2 > maxy) maxy = but->y2; + if (but->rect.ymin < miny) miny = but->rect.ymin; + if (but->rect.ymax > maxy) maxy = but->rect.ymax; } /* mirror trick */ centy = (miny + maxy) / 2.0f; for (but = block->buttons.first; but; but = but->next) { - but->y1 = centy - (but->y1 - centy); - but->y2 = centy - (but->y2 - centy); - SWAP(float, but->y1, but->y2); + but->rect.ymin = centy - (but->rect.ymin - centy); + but->rect.ymax = centy - (but->rect.ymax - centy); + SWAP(float, but->rect.ymin, but->rect.ymax); } /* also flip order in block itself, for example for arrowkey */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 90f8bb52826..ec41c821c04 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -686,8 +686,8 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) ui_window_to_block(ar, but->block, &x, &y); - rect.xmin = but->x1; rect.xmax = but->x2; - rect.ymin = but->y1; rect.ymax = but->y2; + rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; + rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; if (but->imb) ; /* use button size itself */ else if (but->flag & UI_ICON_LEFT) { @@ -715,7 +715,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but)); if (but->imb) - WM_event_drag_image(drag, but->imb, but->imb_scale, but->x2 - but->x1, but->y2 - but->y1); + WM_event_drag_image(drag, but->imb, but->imb_scale, but->rect.xmax - but->rect.xmin, but->rect.ymax - but->rect.ymin); return 1; } @@ -1282,7 +1282,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho { uiStyle *style = UI_GetStyle(); // XXX pass on as arg uiFontStyle *fstyle = &style->widget; - int startx = but->x1; + int startx = but->rect.xmin; char *origstr; uiStyleFontSet(fstyle); @@ -1296,7 +1296,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho /* XXX solve generic */ if (but->type == NUM || but->type == NUMSLI) - startx += (int)(0.5f * (but->y2 - but->y1)); + startx += (int)(0.5f * (but->rect.ymax - but->rect.ymin)); else if (ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) @@ -2537,11 +2537,11 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ if (event->type == WHEELDOWNMOUSE && event->alt) { - mx = but->x1; + mx = but->rect.xmin; click = 1; } else if (event->type == WHEELUPMOUSE && event->alt) { - mx = but->x2; + mx = but->rect.xmax; click = 1; } else if (event->val == KM_PRESS) { @@ -2611,7 +2611,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton softmax = but->softmax; if (!ui_is_but_float(but)) { - if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) { + if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value - 1; @@ -2622,7 +2622,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > (but->x1 + (2 * (but->x2 - but->x1) / 3) + 3)) { + else if (mx > (but->rect.xmin + (2 * (but->rect.xmax - but->rect.xmin) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp = (int)data->value + 1; @@ -2637,7 +2637,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); } else { - if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) { + if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value - 0.01f * but->a1; @@ -2646,7 +2646,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if (mx > but->x1 + (2 * ((but->x2 - but->x1) / 3) + 3)) { + else if (mx > but->rect.xmin + (2 * ((but->rect.xmax - but->rect.xmin) / 3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf = (float)data->value + 0.01f * but->a1; @@ -2674,14 +2674,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short softmax = but->softmax; softrange = softmax - softmin; - if (but->type == NUMSLI) deler = ((but->x2 - but->x1) - 5.0f * but->aspect); - else if (but->type == HSVSLI) deler = ((but->x2 - but->x1) / 2.0f - 5.0f * but->aspect); + if (but->type == NUMSLI) deler = ((but->rect.xmax - but->rect.xmin) - 5.0f * but->aspect); + else if (but->type == HSVSLI) deler = ((but->rect.xmax - but->rect.xmin) / 2.0f - 5.0f * but->aspect); else if (but->type == SCROLL) { - int horizontal = (but->x2 - but->x1 > but->y2 - but->y1); - float size = (horizontal) ? (but->x2 - but->x1) : -(but->y2 - but->y1); + int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin); + float size = (horizontal) ? (but->rect.xmax - but->rect.xmin) : -(but->rect.ymax - but->rect.ymin); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); } - else deler = (but->x2 - but->x1 - 5.0f * but->aspect); + else deler = (but->rect.xmax - but->rect.xmin - 5.0f * but->aspect); f = (float)(mx - data->dragstartx) / deler + data->dragfstart; @@ -2750,11 +2750,11 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ if (event->type == WHEELDOWNMOUSE && event->alt) { - mx = but->x1; + mx = but->rect.xmin; click = 2; } else if (event->type == WHEELUPMOUSE && event->alt) { - mx = but->x2; + mx = but->rect.xmax; click = 2; } else if (event->val == KM_PRESS) { @@ -2764,12 +2764,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */ else if (event->type == LEFTMOUSE && event->alt) { - int halfpos = (but->x1 + but->x2) / 2; + int halfpos = (but->rect.xmin + but->rect.xmax) / 2; click = 2; if (mx < halfpos) - mx = but->x1; + mx = but->rect.xmin; else - mx = but->x2; + mx = but->rect.xmax; } else if (event->type == LEFTMOUSE) { data->dragstartx = mx; @@ -2831,12 +2831,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton #if 0 if (but->type == SLI) { - f = (float)(mx - but->x1) / (but->x2 - but->x1); /* same as below */ + f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); /* same as below */ } else #endif { - f = (float)(mx - but->x1) / (but->x2 - but->x1); + f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); } f = softmin + f * softrange; @@ -2877,7 +2877,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut { int mx, my /*, click= 0 */; int retval = WM_UI_HANDLER_CONTINUE; - int horizontal = (but->x2 - but->x1 > but->y2 - but->y1); + int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin); mx = event->x; my = event->y; @@ -3034,7 +3034,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i * else we'll get a harmless but annoying jump when first clicking */ fp = data->origvec; - rad = (but->x2 - but->x1); + rad = (but->rect.xmax - but->rect.xmin); radsq = rad * rad; if (fp[2] > 0.0f) { @@ -3142,8 +3142,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* relative position within box */ - x = ((float)mx_fl - but->x1) / (but->x2 - but->x1); - y = ((float)my_fl - but->y1) / (but->y2 - but->y1); + x = ((float)mx_fl - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); + y = ((float)my_fl - but->rect.ymin) / (but->rect.ymax - but->rect.ymin); CLAMP(x, 0.0f, 1.0f); CLAMP(y, 0.0f, 1.0f); @@ -3348,8 +3348,8 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift); - rect.xmin = but->x1; rect.xmax = but->x2; - rect.ymin = but->y1; rect.ymax = but->y2; + rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; + rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; ui_get_but_vectorf(but, rgb); copy_v3_v3(hsv, ui_block_hsv_get(but->block)); @@ -3541,7 +3541,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx if (data->draglastx == mx) return changed; - dx = ((float)(mx - data->draglastx)) / (but->x2 - but->x1); + dx = ((float)(mx - data->draglastx)) / (but->rect.xmax - but->rect.xmin); data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); @@ -3570,7 +3570,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle if (event->ctrl) { /* insert new key on mouse location */ - float pos = ((float)(mx - but->x1)) / (but->x2 - but->x1); + float pos = ((float)(mx - but->rect.xmin)) / (but->rect.xmax - but->rect.xmin); colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -3582,7 +3582,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle /* activate new key when mouse is close */ for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) { - xco = but->x1 + (cbd->pos * (but->x2 - but->x1)); + xco = but->rect.xmin + (cbd->pos * (but->rect.xmax - but->rect.xmin)); xco = ABS(xco - mx); if (a == coba->cur) xco += 5; // selected one disadvantage if (xco < mindist) { @@ -3623,8 +3623,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */; int a, changed = 0; - zoomx = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin); + zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin); /* offsx= cumap->curr.xmin; */ /* offsy= cumap->curr.ymin; */ @@ -3719,14 +3719,14 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt float dist, mindist = 200.0f; // 14 pixels radius int sel = -1; - zoomx = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin); - zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin); + zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin); + zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin); offsx = cumap->curr.xmin; offsy = cumap->curr.ymin; if (event->ctrl) { - fx = ((float)mx - but->x1) / zoomx + offsx; - fy = ((float)my - but->y1) / zoomy + offsy; + fx = ((float)mx - but->rect.xmin) / zoomx + offsx; + fy = ((float)my - but->rect.ymin) / zoomy + offsy; curvemap_insert(cuma, fx, fy); curvemapping_changed(cumap, 0); @@ -3736,8 +3736,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* check for selecting of a point */ cmp = cuma->curve; /* ctrl adds point, new malloc */ for (a = 0; a < cuma->totpoint; a++) { - fx = but->x1 + zoomx * (cmp[a].x - offsx); - fy = but->y1 + zoomy * (cmp[a].y - offsy); + fx = but->rect.xmin + zoomx * (cmp[a].x - offsx); + fy = but->rect.ymin + zoomy * (cmp[a].y - offsy); dist = (fx - mx) * (fx - mx) + (fy - my) * (fy - my); if (dist < mindist) { sel = a; @@ -3750,8 +3750,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* if the click didn't select anything, check if it's clicked on the * curve itself, and if so, add a point */ - fx = ((float)mx - but->x1) / zoomx + offsx; - fy = ((float)my - but->y1) / zoomy + offsy; + fx = ((float)mx - but->rect.xmin) / zoomx + offsx; + fy = ((float)my - but->rect.ymin) / zoomy + offsy; cmp = cuma->table; @@ -3846,8 +3846,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { - /* bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); */ - return (y < but->y1 + SCOPE_RESIZE_PAD); + /* bottom corner return (x > but->rect.xmax - SCOPE_RESIZE_PAD) && (y < but->rect.ymin + SCOPE_RESIZE_PAD); */ + return (y < but->rect.ymin + SCOPE_RESIZE_PAD); } static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my) @@ -3857,15 +3857,15 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx int changed = 1; float /* dx, */ dy; /* UNUSED */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ + /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize histogram widget itself */ - hist->height = (but->y2 - but->y1) + (data->dragstarty - my); + hist->height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } else { /* scale histogram values (dy / 10 for better control) */ @@ -3941,8 +3941,8 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int changed = 1; float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ + /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -3950,7 +3950,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize waveform widget itself */ - scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->wavefrm_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } else { /* scale waveform values */ @@ -4025,15 +4025,15 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int int changed = 1; /* float dx, dy; */ - /* rect.xmin = but->x1; rect.xmax = but->x2; */ - /* rect.ymin = but->y1; rect.ymax = but->y2; */ + /* rect.xmin = but->rect.xmin; rect.xmax = but->rect.xmax; */ + /* rect.ymin = but->rect.ymin; rect.ymax = but->rect.ymax; */ /* dx = mx - data->draglastx; */ /* dy = my - data->draglasty; */ if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize vectorscope widget itself */ - scopes->vecscope_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->vecscope_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } data->draglastx = mx; @@ -4103,17 +4103,17 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) { /* Calculate the size of the button */ - width = abs(but->x2 - but->x1); - height = abs(but->y2 - but->y1); + width = abs(but->rect.xmax - but->rect.xmin); + height = abs(but->rect.ymax - but->rect.ymin); butw = floor(width / 12); buth = floor(height / 6); /* Initialize variables */ - sx = but->x1; - ex = but->x1 + butw; - sy = but->y1 + height - buth; - ey = but->y1 + height; + sx = but->rect.xmin; + ex = but->rect.xmin + butw; + sy = but->rect.ymin + height - buth; + ey = but->rect.ymin + height; cs = G.charstart; @@ -4236,7 +4236,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize preview widget itself */ - scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my); + scopes->track_preview_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my); } else { if (!scopes->track_locked) { @@ -4244,8 +4244,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr); scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED); - scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->maxx - but->block->minx); - scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->maxy - but->block->miny); + scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->rect.xmax - but->block->rect.xmin); + scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->rect.ymax - but->block->rect.ymin); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } @@ -4921,7 +4921,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) static int ui_but_contains_pt(uiBut *but, int mx, int my) { - return ((but->x1 < mx && but->x2 >= mx) && (but->y1 < my && but->y2 >= my)); + return ((but->rect.xmin < mx && but->rect.xmax >= mx) && (but->rect.ymin < my && but->rect.ymax >= my)); } static uiBut *ui_but_find_activated(ARegion *ar) @@ -5092,8 +5092,8 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) /* CLIP_EVENTS prevents the event from reaching other blocks */ if (block->flag & UI_BLOCK_CLIP_EVENTS) { /* check if mouse is inside block */ - if (block->minx <= mx && block->maxx >= mx && - block->miny <= my && block->maxy >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx && + block->rect.ymin <= my && block->rect.ymax >= my) { break; } @@ -5979,17 +5979,17 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men /* verify that we are moving towards one of the edges of the * menu block, in other words, in the triangle formed by the * initial mouse location and two edge points. */ - p1[0] = block->minx - 20; - p1[1] = block->miny - 20; + p1[0] = block->rect.xmin - 20; + p1[1] = block->rect.ymin - 20; - p2[0] = block->maxx + 20; - p2[1] = block->miny - 20; + p2[0] = block->rect.xmax + 20; + p2[1] = block->rect.ymin - 20; - p3[0] = block->maxx + 20; - p3[1] = block->maxy + 20; + p3[0] = block->rect.xmax + 20; + p3[1] = block->rect.ymax + 20; - p4[0] = block->minx - 20; - p4[1] = block->maxy + 20; + p4[0] = block->rect.xmin - 20; + p4[1] = block->rect.ymax + 20; oldp[0] = menu->towardsx; oldp[1] = menu->towardsy; @@ -6019,10 +6019,10 @@ static char ui_menu_scroll_test(uiBlock *block, int my) { if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) { if (block->flag & UI_BLOCK_CLIPTOP) - if (my > block->maxy - 14) + if (my > block->rect.ymax - 14) return 't'; if (block->flag & UI_BLOCK_CLIPBOTTOM) - if (my < block->miny + 14) + if (my < block->rect.ymin + 14) return 'b'; } return 0; @@ -6053,25 +6053,25 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) if (test == 't') { /* bottom button is first button */ - if (b1->y1 < b2->y1) - dy = bnext->y1 - b1->y1; + if (b1->rect.ymin < b2->rect.ymin) + dy = bnext->rect.ymin - b1->rect.ymin; /* bottom button is last button */ else - dy = bprev->y1 - b2->y1; + dy = bprev->rect.ymin - b2->rect.ymin; } else if (test == 'b') { /* bottom button is first button */ - if (b1->y1 < b2->y1) - dy = b1->y1 - bnext->y1; + if (b1->rect.ymin < b2->rect.ymin) + dy = b1->rect.ymin - bnext->rect.ymin; /* bottom button is last button */ else - dy = b2->y1 - bprev->y1; + dy = b2->rect.ymin - bprev->rect.ymin; } if (dy) { for (b1 = block->buttons.first; b1; b1 = b1->next) { - b1->y1 -= dy; - b1->y2 -= dy; + b1->rect.ymin -= dy; + b1->rect.ymax -= dy; } /* set flags again */ ui_popup_block_scrolltest(block); @@ -6104,8 +6104,8 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* check if mouse is inside block */ inside = 0; - if (block->minx <= mx && block->maxx >= mx) - if (block->miny <= my && block->maxy >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx) + if (block->rect.ymin <= my && block->rect.ymax >= my) inside = 1; /* if there's an active modal button, don't check events or outside, except for search menu */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 95049857d49..13d05ca617c 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -158,7 +158,7 @@ struct uiBut { char strdata[UI_MAX_NAME_STR]; char drawstr[UI_MAX_DRAW_STR]; - float x1, y1, x2, y2; + rctf rect; char *poin; float hardmin, hardmax, softmin, softmax; @@ -264,8 +264,8 @@ struct uiBlock { char name[UI_MAX_NAME_STR]; float winmat[4][4]; - - float minx, miny, maxx, maxy; + + rctf rect; float aspect; int puphash; /* popup menu hash for memory */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 10fde402acc..32bad26f2c0 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -238,8 +238,8 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_w) *r_w = bitem->but->x2 - bitem->but->x1; - if (r_h) *r_h = bitem->but->y2 - bitem->but->y1; + if (r_w) *r_w = bitem->but->rect.xmax - bitem->but->rect.xmin; + if (r_h) *r_h = bitem->but->rect.ymax - bitem->but->rect.ymin; } else { uiLayout *litem = (uiLayout *)item; @@ -254,8 +254,8 @@ static void ui_item_offset(uiItem *item, int *r_x, int *r_y) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_x) *r_x = bitem->but->x1; - if (r_y) *r_y = bitem->but->y1; + if (r_x) *r_x = bitem->but->rect.xmin; + if (r_y) *r_y = bitem->but->rect.ymin; } else { if (r_x) *r_x = 0; @@ -268,10 +268,10 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - bitem->but->x1 = x; - bitem->but->y1 = y; - bitem->but->x2 = x + w; - bitem->but->y2 = y + h; + bitem->but->rect.xmin = x; + bitem->but->rect.ymin = y; + bitem->but->rect.xmax = x + w; + bitem->but->rect.ymax = y + h; ui_check_but(bitem->but); /* for strlen */ } @@ -1898,10 +1898,10 @@ static void ui_litem_layout_box(uiLayout *litem) /* roundbox around the sublayout */ but = box->roundbox; - but->x1 = litem->x; - but->y1 = litem->y; - but->x2 = litem->x + litem->w; - but->y2 = litem->y + litem->h; + but->rect.xmin = litem->x; + but->rect.ymin = litem->y; + but->rect.xmax = litem->x + litem->w; + but->rect.ymax = litem->y + litem->h; } /* multi-column layout, automatically flowing to the next */ diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index b3b48cb3a46..98df612a6af 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -729,10 +729,10 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) /* this just needs to be a 'good-enough' comparison so we can know beyond * reasonable doubt that these buttons are the same between redraws. * if this fails it only means edit-source fails - campbell */ - if ((but_a->x1 == but_b->x1) && - (but_a->x2 == but_b->x2) && - (but_a->y1 == but_b->y1) && - (but_a->y2 == but_b->y2) && + if ((but_a->rect.xmin == but_b->rect.xmin) && + (but_a->rect.xmax == but_b->rect.xmax) && + (but_a->rect.ymin == but_b->rect.ymin) && + (but_a->rect.ymax == but_b->rect.ymax) && (but_a->type == but_b->type) && (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) && diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d04c1af2769..79aff82fe6f 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -315,13 +315,13 @@ static void ui_offset_panel_block(uiBlock *block) ofsy = block->panel->sizey - style->panelspace; for (but = block->buttons.first; but; but = but->next) { - but->y1 += ofsy; - but->y2 += ofsy; + but->rect.ymin += ofsy; + but->rect.ymax += ofsy; } - block->maxx = block->panel->sizex; - block->maxy = block->panel->sizey; - block->minx = block->miny = 0.0; + block->rect.xmax = block->panel->sizex; + block->rect.ymax = block->panel->sizey; + block->rect.xmin = block->rect.ymin = 0.0; } /**************************** drawing *******************************/ @@ -1033,14 +1033,14 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else if (event == AKEY) button = 1; else if (block->panel->flag & PNL_CLOSEDX) { - if (my >= block->maxy) button = 1; + if (my >= block->rect.ymax) button = 1; } else if (block->panel->control & UI_PNL_CLOSE) { /* whole of header can be used to collapse panel (except top-right corner) */ - if (mx <= block->maxx - 8 - PNL_ICON) button = 2; - //else if (mx <= block->minx + 10 + 2 * PNL_ICON + 2) button = 1; + if (mx <= block->rect.xmax - 8 - PNL_ICON) button = 2; + //else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) button = 1; } - else if (mx <= block->maxx - PNL_ICON - 12) { + else if (mx <= block->rect.xmax - PNL_ICON - 12) { button = 1; } @@ -1078,7 +1078,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in else ED_region_tag_redraw(ar); } - else if (mx <= (block->maxx - PNL_ICON - 12) + PNL_ICON + 2) { + else if (mx <= (block->rect.xmax - PNL_ICON - 12) + PNL_ICON + 2) { panel_activate_state(C, block->panel, PANEL_STATE_DRAG); } } @@ -1109,15 +1109,15 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. continue; - if (block->minx <= mx && block->maxx >= mx) - if (block->miny <= my && block->maxy + PNL_HEADER >= my) + if (block->rect.xmin <= mx && block->rect.xmax >= mx) + if (block->rect.ymin <= my && block->rect.ymax + PNL_HEADER >= my) inside = 1; if (inside && event->val == KM_PRESS) { if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) { if (pa->flag & PNL_CLOSEDY) { - if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) + if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) ui_handle_panel_header(C, block, mx, my, event->type); } else @@ -1134,15 +1134,15 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) if (inside) { /* clicked at panel header? */ if (pa->flag & PNL_CLOSEDX) { - if (block->minx <= mx && block->minx + PNL_HEADER >= mx) + if (block->rect.xmin <= mx && block->rect.xmin + PNL_HEADER >= mx) inside_header = 1; } - else if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) { + else if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { inside_header = 1; } else if (pa->control & UI_PNL_SCALE) { - if (block->maxx - PNL_HEADER <= mx) - if (block->miny + PNL_HEADER >= my) + if (block->rect.xmax - PNL_HEADER <= mx) + if (block->rect.ymin + PNL_HEADER >= my) inside_scale = 1; } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index ce4043eea6a..1941dc66967 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -685,9 +685,9 @@ 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); + x1f = (but->rect.xmin + but->rect.xmax) * 0.5f + ofsx - (TIP_BORDER_X * aspect); x2f = x1f + fontw + (TIP_BORDER_X * aspect); - y2f = but->y1 + ofsy - (TIP_BORDER_Y * aspect); + y2f = but->rect.ymin + ofsy - (TIP_BORDER_Y * aspect); y1f = y2f - fonth * aspect - (TIP_BORDER_Y * aspect); #undef TIP_MARGIN_Y @@ -1181,17 +1181,17 @@ 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; + x1f = but->rect.xmin - 5; /* align text with button */ + x2f = but->rect.xmax + 5; /* symmetrical */ + y2f = but->rect.ymin; y1f = y2f - uiSearchBoxhHeight(); ofsx = (but->block->panel) ? but->block->panel->ofsx : 0; @@ -1234,7 +1234,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) if (y1 < 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; @@ -1339,45 +1339,44 @@ 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; + block->rect.xmin = block->rect.ymin = 10000; + block->rect.xmax = block->rect.ymax = -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; + if (bt->rect.xmin < block->rect.xmin) block->rect.xmin = bt->rect.xmin; + if (bt->rect.ymin < block->rect.ymin) block->rect.ymin = bt->rect.ymin; - if (bt->x2 > block->maxx) block->maxx = bt->x2; - if (bt->y2 > block->maxy) block->maxy = bt->y2; + if (bt->rect.xmax > block->rect.xmax) block->rect.xmax = bt->rect.xmax; + if (bt->rect.ymax > block->rect.ymax) block->rect.ymax = bt->rect.ymax; bt = bt->next; } } 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*/ { @@ -1431,19 +1430,19 @@ 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; + 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) @@ -1452,9 +1451,9 @@ 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; + 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) @@ -1475,7 +1474,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if (left == 0 && right == 0) { if (dir1 == UI_TOP || dir1 == UI_DOWN) { // align with left size of screen - xof = -block->minx + 5; + xof = -block->rect.xmin + 5; } } @@ -1484,33 +1483,33 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, 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; + bt->rect.xmin += xof; + bt->rect.xmax += xof; + bt->rect.ymin += yof; + bt->rect.ymax += yof; bt->aspect = 1.0; // ui_check_but recalculates drawstring size in pixels ui_check_but(bt); } - block->minx += xof; - block->miny += yof; - block->maxx += xof; - block->maxy += yof; + block->rect.xmin += xof; + block->rect.ymin += yof; + block->rect.xmax += xof; + block->rect.ymax += yof; /* safety calculus */ if (but) { @@ -1520,31 +1519,31 @@ 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; + 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->maxx) block->safety.xmax = block->maxx + 3; - else block->safety.xmax = block->maxx + 40; + 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->miny) block->safety.ymin = block->miny - 3; - else block->safety.ymin = block->miny - 40; + 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->maxy) block->safety.ymax = block->maxy + 3; - else block->safety.ymax = block->maxy + 40; + 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 */ @@ -1571,15 +1570,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) @@ -1598,25 +1597,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; } } @@ -1694,21 +1693,21 @@ 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; + block->rect.xmin -= ar->winrct.xmin; + block->rect.xmax -= ar->winrct.xmin; + block->rect.ymin -= ar->winrct.ymin; + block->rect.ymax -= 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; + bt->rect.xmin -= ar->winrct.xmin; + bt->rect.xmax -= ar->winrct.xmin; + bt->rect.ymin -= ar->winrct.ymin; + bt->rect.ymax -= ar->winrct.ymin; } block->flag |= UI_BLOCK_LOOP; @@ -2371,7 +2370,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; @@ -2413,15 +2412,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] = mini(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; } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 51bd4e16d06..b8ca0deb770 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -274,7 +274,7 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ - BLI_rctf_init(&dispf, 15.0f, (block->maxx - block->minx) - 15.0f, 15.0f, (block->maxy - block->miny) - 15.0f); + BLI_rctf_init(&dispf, 15.0f, (block->rect.xmax - block->rect.xmin) - 15.0f, 15.0f, (block->rect.ymax - block->rect.ymin) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 1595889f596..999a8baf34b 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot) int i, b; rcti rectlink; - rectlink.xmin = (int) (line->from->x1 + line->from->x2) / 2; - rectlink.ymin = (int) (line->from->y1 + line->from->y2) / 2; - rectlink.xmax = (int) (line->to->x1 + line->to->x2) / 2; - rectlink.ymax = (int) (line->to->y1 + line->to->y2) / 2; + rectlink.xmin = (int) (line->from->rect.xmin + line->from->rect.xmax) / 2; + rectlink.ymin = (int) (line->from->rect.ymin + line->from->rect.ymax) / 2; + rectlink.xmax = (int) (line->to->rect.xmin + line->to->rect.xmax) / 2; + rectlink.ymax = (int) (line->to->rect.ymin + line->to->rect.ymax) / 2; if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) { for (i=0; i<tot-1; i++) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index a8fe8318f22..989b3999018 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -596,7 +596,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiItemL(row, "", ICON_BLANK1); bt = block->buttons.last; - bt->x2 = UI_UNIT_X / 2; + bt->rect.xmax = UI_UNIT_X / 2; uiBlockSetEmboss(block, UI_EMBOSS); } |