diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-25 02:15:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-25 03:16:46 +0300 |
commit | e86e0aad55675a5c4473d0538146dbccda7613e8 (patch) | |
tree | f20540ba9e01cc8d7e13090df8fbf9691cb8b01b /source/blender/editors/interface/interface_region_popup.c | |
parent | 72ede30d0f970fe7d6774ce0851e3aacc82e23d8 (diff) |
Cleanup: use braces for interface code
Diffstat (limited to 'source/blender/editors/interface/interface_region_popup.c')
-rw-r--r-- | source/blender/editors/interface/interface_region_popup.c | 146 |
1 files changed, 94 insertions, 52 deletions
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 2275ee9ebf5..59223970af8 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -95,10 +95,12 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut /* widget_roundbox_set has this correction too, keep in sync */ if (but->type != UI_BTYPE_PULLDOWN) { - if (but->drawflag & UI_BUT_ALIGN_TOP) + if (but->drawflag & UI_BUT_ALIGN_TOP) { butrct.ymax += U.pixelsize; - if (but->drawflag & UI_BUT_ALIGN_LEFT) + } + if (but->drawflag & UI_BUT_ALIGN_LEFT) { butrct.xmin -= U.pixelsize; + } } handle->prev_butrct = butrct; @@ -148,44 +150,46 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut const float max_size_y = max_ff(size_y, handle->max_size_y); /* check if there's space at all */ - if (butrct.xmin - max_size_x + center_x > 0.0f) left = 1; - if (butrct.xmax + max_size_x - center_x < win_x) right = 1; - if (butrct.ymin - max_size_y + center_y > 0.0f) down = 1; - if (butrct.ymax + max_size_y - center_y < win_y) top = 1; + if (butrct.xmin - max_size_x + center_x > 0.0f) { left = 1; } + if (butrct.xmax + max_size_x - center_x < win_x) { right = 1; } + if (butrct.ymin - max_size_y + center_y > 0.0f) { down = 1; } + if (butrct.ymax + max_size_y - center_y < win_y) { top = 1; } if (top == 0 && down == 0) { - if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y) + if (butrct.ymin - max_size_y < win_y - butrct.ymax - max_size_y) { top = 1; - else + } + else { down = 1; + } } dir1 = (block->direction & UI_DIR_ALL); /* Secondary directions. */ if (dir1 & (UI_DIR_UP | UI_DIR_DOWN)) { - if (dir1 & UI_DIR_LEFT) dir2 = UI_DIR_LEFT; - else if (dir1 & UI_DIR_RIGHT) dir2 = UI_DIR_RIGHT; + if (dir1 & UI_DIR_LEFT) { dir2 = UI_DIR_LEFT; } + else if (dir1 & UI_DIR_RIGHT) { dir2 = UI_DIR_RIGHT; } dir1 &= (UI_DIR_UP | UI_DIR_DOWN); } - if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) dir2 = UI_DIR_DOWN; - if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) dir2 = UI_DIR_LEFT; + if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) { dir2 = UI_DIR_DOWN; } + if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) { dir2 = UI_DIR_LEFT; } /* no space at all? don't change */ if (left || right) { - if (dir1 == UI_DIR_LEFT && left == 0) dir1 = UI_DIR_RIGHT; - if (dir1 == UI_DIR_RIGHT && right == 0) dir1 = UI_DIR_LEFT; + if (dir1 == UI_DIR_LEFT && left == 0) { dir1 = UI_DIR_RIGHT; } + if (dir1 == UI_DIR_RIGHT && right == 0) { dir1 = UI_DIR_LEFT; } /* this is aligning, not append! */ - if (dir2 == UI_DIR_LEFT && right == 0) dir2 = UI_DIR_RIGHT; - if (dir2 == UI_DIR_RIGHT && left == 0) dir2 = UI_DIR_LEFT; + if (dir2 == UI_DIR_LEFT && right == 0) { dir2 = UI_DIR_RIGHT; } + if (dir2 == UI_DIR_RIGHT && left == 0) { dir2 = UI_DIR_LEFT; } } if (down || top) { - if (dir1 == UI_DIR_UP && top == 0) dir1 = UI_DIR_DOWN; - if (dir1 == UI_DIR_DOWN && down == 0) dir1 = UI_DIR_UP; + if (dir1 == UI_DIR_UP && top == 0) { dir1 = UI_DIR_DOWN; } + if (dir1 == UI_DIR_DOWN && down == 0) { dir1 = UI_DIR_UP; } BLI_assert(dir2 != UI_DIR_UP); -// if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN; - if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP; +// if (dir2 == UI_DIR_UP && top == 0) { dir2 = UI_DIR_DOWN; } + if (dir2 == UI_DIR_DOWN && down == 0) { dir2 = UI_DIR_UP; } } handle->prev_dir1 = dir1; @@ -203,18 +207,18 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut if (dir1 == UI_DIR_LEFT) { offset_x = butrct.xmin - block->rect.xmax; - if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; - else offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; + if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; } + else { offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; } } else if (dir1 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmin; - if (dir2 == UI_DIR_UP) offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; - else offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; + if (dir2 == UI_DIR_UP) { offset_y = butrct.ymin - block->rect.ymin - center_y - UI_MENU_PADDING; } + else { offset_y = butrct.ymax - block->rect.ymax + center_y + UI_MENU_PADDING; } } else if (dir1 == UI_DIR_UP) { offset_y = butrct.ymax - block->rect.ymin; - if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x; - else offset_x = butrct.xmin - block->rect.xmin - center_x; + if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; } + else { offset_x = butrct.xmin - block->rect.xmin - center_x; } /* changed direction? */ if ((dir1 & block->direction) == 0) { /* TODO: still do */ @@ -223,8 +227,8 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut } else if (dir1 == UI_DIR_DOWN) { offset_y = butrct.ymin - block->rect.ymax; - if (dir2 == UI_DIR_RIGHT) offset_x = butrct.xmax - block->rect.xmax + center_x; - else offset_x = butrct.xmin - block->rect.xmin - center_x; + if (dir2 == UI_DIR_RIGHT) { offset_x = butrct.xmax - block->rect.xmax + center_x; } + else { offset_x = butrct.xmin - block->rect.xmin - center_x; } /* changed direction? */ if ((dir1 & block->direction) == 0) { /* TODO: still do */ @@ -257,23 +261,43 @@ static void ui_popup_block_position(wmWindow *window, ARegion *butregion, uiBut /* when you are outside parent button, safety there should be smaller */ /* parent button to left */ - if (midx < block->rect.xmin) block->safety.xmin = block->rect.xmin - 3; - else block->safety.xmin = block->rect.xmin - 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->rect.xmax) block->safety.xmax = block->rect.xmax + 3; - else block->safety.xmax = block->rect.xmax + 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->rect.ymin) block->safety.ymin = block->rect.ymin - 3; - else block->safety.ymin = block->rect.ymin - 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->rect.ymax) block->safety.ymax = block->rect.ymax + 3; - else block->safety.ymax = block->rect.ymax + 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_DIR_RIGHT) block->safety.xmax = block->rect.xmax + 3; - if (dir2 == UI_DIR_LEFT) block->safety.xmin = block->rect.xmin - 3; + if (dir2 == UI_DIR_RIGHT) { + block->safety.xmax = block->rect.xmax + 3; + } + if (dir2 == UI_DIR_LEFT) { + block->safety.xmin = block->rect.xmin - 3; + } } block->direction = dir1; } @@ -335,8 +359,9 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) { uiBlock *block; - for (block = ar->uiblocks.first; block; block = block->next) + for (block = ar->uiblocks.first; block; block = block->next) { UI_block_draw(C, block); + } } /** @@ -409,11 +434,13 @@ void ui_popup_block_scrolltest(uiBlock *block) block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP); - for (bt = block->buttons.first; bt; bt = bt->next) + for (bt = block->buttons.first; bt; bt = bt->next) { bt->flag &= ~UI_SCROLLED; + } - if (block->buttons.first == block->buttons.last) + if (block->buttons.first == block->buttons.last) { return; + } /* mark buttons that are outside boundary */ for (bt = block->buttons.first; bt; bt = bt->next) { @@ -430,12 +457,14 @@ void ui_popup_block_scrolltest(uiBlock *block) /* mark buttons overlapping arrows, if we have them */ for (bt = block->buttons.first; bt; bt = bt->next) { if (block->flag & UI_BLOCK_CLIPBOTTOM) { - if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) + if (bt->rect.ymin < block->rect.ymin + UI_MENU_SCROLL_ARROW) { bt->flag |= UI_SCROLLED; + } } if (block->flag & UI_BLOCK_CLIPTOP) { - if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) + if (bt->rect.ymax > block->rect.ymax - UI_MENU_SCROLL_ARROW) { bt->flag |= UI_SCROLLED; + } } } } @@ -454,8 +483,9 @@ static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) WM_event_add_mousemove(C); } - if (handle->scrolltimer) + if (handle->scrolltimer) { WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer); + } } /** @@ -485,10 +515,12 @@ uiBlock *ui_popup_block_refresh( #endif /* create ui block */ - if (create_func) + if (create_func) { block = create_func(C, ar, arg); - else + } + else { block = handle_create_func(C, handle, arg); + } /* callbacks _must_ leave this for us, otherwise we can't call UI_block_update_from_old */ BLI_assert(!block->endblock); @@ -503,8 +535,9 @@ uiBlock *ui_popup_block_refresh( MEM_freeN(handle); handle = block->handle; } - else + else { block->handle = handle; + } ar->regiondata = handle; @@ -550,13 +583,21 @@ uiBlock *ui_popup_block_refresh( /* only try translation if area is large enough */ if (BLI_rctf_size_x(&block->rect) < winx - (2.0f * win_width)) { - if (block->rect.xmin < win_width ) x_offset += win_width - block->rect.xmin; - if (block->rect.xmax > winx - win_width) x_offset += winx - win_width - block->rect.xmax; + if (block->rect.xmin < win_width ) { + x_offset += win_width - block->rect.xmin; + } + if (block->rect.xmax > winx - win_width) { + x_offset += winx - win_width - block->rect.xmax; + } } if (BLI_rctf_size_y(&block->rect) < winy - (2.0f * win_width)) { - if (block->rect.ymin < win_width ) y_offset += win_width - block->rect.ymin; - if (block->rect.ymax > winy - win_width) y_offset += winy - win_width - block->rect.ymax; + if (block->rect.ymin < win_width ) { + y_offset += win_width - block->rect.ymin; + } + if (block->rect.ymax > winy - win_width) { + y_offset += winy - win_width - block->rect.ymax; + } } /* if we are offsetting set up initial data for timeout functionality */ @@ -566,8 +607,9 @@ uiBlock *ui_popup_block_refresh( UI_block_translate(block, x_offset, y_offset); - if (U.pie_initial_timeout > 0) + if (U.pie_initial_timeout > 0) { block->pie_data.flags |= UI_PIE_INITIAL_DIRECTION; + } } ar->winrct.xmin = 0; |