Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-09-10 11:03:30 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-10 11:03:30 +0400
commitccaf475422460bb10870689f6b6ddd09c94aa2af (patch)
tree9da101dcbd34c8824a041b4e123631dd70fc03cd
parentb1ff5651fbd8e392c616fba55d3fb4455fe9d3a7 (diff)
code cleanup: use typedef'd enum for block bounds types.
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface.c60
-rw-r--r--source/blender/editors/interface/interface_intern.h3
3 files changed, 47 insertions, 19 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2b4ee325e46..06fb3b9f7d3 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -397,7 +397,8 @@ void uiBlockBeginAlign(uiBlock *block);
void uiBlockEndAlign(uiBlock *block);
/* block bounds/position calculation */
-enum {
+typedef enum {
+ UI_BLOCK_BOUNDS_NONE = 0,
UI_BLOCK_BOUNDS = 1,
UI_BLOCK_BOUNDS_TEXT,
UI_BLOCK_BOUNDS_POPUP_MOUSE,
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e98b7cddfa6..718ed40cad9 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -317,7 +317,7 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
ui_bounds_block(block);
}
-static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_calc)
+static void ui_popup_bounds_block(const bContext *C, uiBlock *block, eBlockBoundsCalc bounds_calc)
{
wmWindow *window = CTX_wm_window(C);
int startx, starty, endx, endy, width, height, oldwidth, oldheight;
@@ -388,21 +388,21 @@ void uiBoundsBlock(uiBlock *block, int addval)
return;
block->bounds = addval;
- block->dobounds = UI_BLOCK_BOUNDS;
+ block->bounds_type = UI_BLOCK_BOUNDS;
}
/* used for pulldowns */
void uiTextBoundsBlock(uiBlock *block, int addval)
{
block->bounds = addval;
- block->dobounds = UI_BLOCK_BOUNDS_TEXT;
+ block->bounds_type = UI_BLOCK_BOUNDS_TEXT;
}
/* used for block popups */
void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
{
block->bounds = addval;
- block->dobounds = UI_BLOCK_BOUNDS_POPUP_MOUSE;
+ block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MOUSE;
block->mx = mx;
block->my = my;
}
@@ -411,7 +411,7 @@ void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
{
block->bounds = addval;
- block->dobounds = UI_BLOCK_BOUNDS_POPUP_MENU;
+ block->bounds_type = UI_BLOCK_BOUNDS_POPUP_MENU;
block->mx = mx;
block->my = my;
}
@@ -420,7 +420,7 @@ void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
void uiCenteredBoundsBlock(uiBlock *block, int addval)
{
block->bounds = addval;
- block->dobounds = UI_BLOCK_BOUNDS_POPUP_CENTER;
+ block->bounds_type = UI_BLOCK_BOUNDS_POPUP_CENTER;
}
void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy)
@@ -429,7 +429,7 @@ void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int max
block->rect.ymin = miny;
block->rect.xmax = maxx;
block->rect.ymax = maxy;
- block->dobounds = 0;
+ block->bounds_type = UI_BLOCK_BOUNDS_NONE;
}
/* ************** LINK LINE DRAWING ************* */
@@ -934,21 +934,45 @@ void uiEndBlock(const bContext *C, uiBlock *block)
}
/* handle pending stuff */
- if (block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL);
+ if (block->layouts.first) {
+ uiBlockLayoutResolve(block, NULL, NULL);
+ }
ui_block_do_align(block);
if ((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) {
ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
}
- if (block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
+
+ if (block->flag & UI_BLOCK_LOOP) {
+ ui_menu_block_set_keymaps(C, block);
+ }
/* after keymaps! */
- if (block->dobounds == UI_BLOCK_BOUNDS) ui_bounds_block(block);
- else if (block->dobounds == UI_BLOCK_BOUNDS_TEXT) ui_text_bounds_block(block, 0.0f);
- 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);
+ switch (block->bounds_type) {
+ case UI_BLOCK_BOUNDS_NONE:
+ break;
+ case UI_BLOCK_BOUNDS:
+ ui_bounds_block(block);
+ break;
+ case UI_BLOCK_BOUNDS_TEXT:
+ ui_text_bounds_block(block, 0.0f);
+ break;
+ case UI_BLOCK_BOUNDS_POPUP_CENTER:
+ ui_centered_bounds_block(C, block);
+ break;
- if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) uiBoundsBlock(block, 0);
- if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
+ /* fallback */
+ case UI_BLOCK_BOUNDS_POPUP_MOUSE:
+ case UI_BLOCK_BOUNDS_POPUP_MENU:
+ ui_popup_bounds_block(C, block, block->bounds_type);
+ break;
+ }
+
+ 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;
}
@@ -2540,11 +2564,13 @@ void ui_block_do_align(uiBlock *block)
/* skip with same number */
for (; but && but->alignnr == nr; but = but->next) ;
- if (!but)
+ if (!but) {
break;
+ }
}
- else
+ else {
but = but->next;
+ }
}
}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e242df54b90..d308f7d852e 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -316,7 +316,8 @@ struct uiBlock {
char endblock; /* uiEndBlock done? */
float xofs, yofs; /* offset to parent button */
- int dobounds, mx, my; /* for doing delayed */
+ eBlockBoundsCalc bounds_type; /* for doing delayed */
+ int mx, my;
int bounds, minbounds; /* for doing delayed */
rctf safety; /* pulldowns, to detect outside, can differ per case how it is created */