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:
authorTon Roosendaal <ton@blender.org>2005-08-15 23:46:09 +0400
committerTon Roosendaal <ton@blender.org>2005-08-15 23:46:09 +0400
commitf1609dde1151c8b5645cf142be99a349b0482753 (patch)
tree2d0ab2c3dd0aa495c0f12ad0055a583f72f9650a
parent6bc3f4746bc5325d8e1ff54469ebb6929bf3bdb2 (diff)
Added new button type: ROUNDBOX
This replaces drawing with uiRoundBox() or glRect() in button Panels, which just fails for dynamic constructed button views where Panels are sometimes invisible. Also eliminates hack with PanelPop(). Error was visible with new Modifier panel, entering/exiting EditMode. Done Modifier and Constraints. Syntax: The last 4 free variables in the uiDefBut() call are: - float, corner-rounding (0.0-pixels), - not used, - short: roundbox type (bits, 1 2 4 8 for clockwise corners starting left/top) - short: color shade offset (color range 0-255)
-rw-r--r--source/blender/include/BIF_interface.h1
-rw-r--r--source/blender/src/buttons_editing.c37
-rw-r--r--source/blender/src/buttons_object.c71
-rw-r--r--source/blender/src/interface.c13
-rw-r--r--source/blender/src/interface_draw.c15
5 files changed, 63 insertions, 74 deletions
diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h
index db3e7c487bf..875bdbf3564 100644
--- a/source/blender/include/BIF_interface.h
+++ b/source/blender/include/BIF_interface.h
@@ -150,6 +150,7 @@ struct ScrArea;
#define ICONTEXTROW (25<<9)
#define HSVCUBE (26<<9)
#define PULLDOWN (27<<9)
+#define ROUNDBOX (28<<9)
#define BUTTYPE (31<<9)
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index 018ba024dc8..62a5338b505 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -902,6 +902,14 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
short height=26, width = 295, buttonWidth = width-120-10;
char str[128];
+ /* rounded header */
+ uiBlockSetCol(block, color);
+ /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
+ uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 26, NULL, 7.0, 0.0,
+ md->mode&eModifierMode_Expanded?3:15, -20, "");
+ uiBlockSetCol(block, TH_AUTO);
+
+ /* open/close icon */
if (isVirtual) {
uiSetButLock(1, "Modifier is virtual and cannot be edited.");
color = TH_BUT_SETTING1;
@@ -910,15 +918,8 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, B_MODIFIER_REDRAW, VICON_DISCLOSURE_TRI_RIGHT, x-10, y-2, 20, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
}
- BIF_ThemeColor(color);
uiBlockSetEmboss(block, UI_EMBOSS);
-
- /* rounded header */
- BIF_ThemeColorShade(color, -20);
- uiSetRoundBox((md->mode&eModifierMode_Expanded)?3:15);
- uiRoundBox(x+4+10, y-18, x+width+10, y+6, 5.0);
-
- BIF_ThemeColor(color);
+
if (isVirtual) {
sprintf(str, "%s (virtual)", md->name);
uiDefBut(block, LABEL, 0, str, x+10, y-1, width-120-60-10, 19, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name");
@@ -947,7 +948,6 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
if (ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
int icon, color;
- uiSetRoundBox(15);
if (index==cageIndex) {
color = TH_BUT_SETTING;
icon = VICON_EDITMODE_HLT;
@@ -979,7 +979,6 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
uiBlockSetCol(block, TH_AUTO);
}
- BIF_ThemeColor(color);
uiBlockSetEmboss(block, UI_EMBOSS);
if (!(md->mode&eModifierMode_Expanded)) {
@@ -988,8 +987,6 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
int cy = y - 8;
int lx = x + width - 60 - 15;
- y -= 18;
-
if (md->type==eModifierType_Subsurf) {
height = 106;
} else if (md->type==eModifierType_Lattice) {
@@ -1014,9 +1011,10 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
height = 26;
}
- BIF_ThemeColor(color);
- uiSetRoundBox(12);
- uiRoundBox(x+4+10, y-height, x+width+10, y, 5.0);
+ /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
+ uiDefBut(block, ROUNDBOX, 0, "", x-10, y-height-2, width, height-2, NULL, 5.0, 0.0, 12, 0, "");
+
+ y -= 18;
if (!isVirtual) {
uiBlockBeginAlign(block);
@@ -1117,9 +1115,10 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
y -= 20;
- BIF_ThemeColorShade(color, 40);
- uiSetRoundBox(15);
- uiRoundBox(x+4+10, y, x+width+10, y+20, 5.0);
+ uiBlockSetCol(block, color);
+ /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
+ uiDefBut(block, ROUNDBOX, 0, "", x-10, y, width, 20, NULL, 5.0, 0.0, 15, 40, "");
+ uiBlockSetCol(block, TH_AUTO);
sprintf(str, "Modifier Error: %s", md->error);
uiDefBut(block, LABEL, B_NOP, str, x+15, y+15, width-35, 19, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -1157,12 +1156,10 @@ static void editing_panel_modifiers(Object *ob)
md = modifiers_getVirtualModifierList(ob);
- uiPanelPush(block);
for (i=0; md; i++, md=md->next) {
draw_modifier(block, ob, md, &xco, &yco, i, cageIndex, lastCageIndex);
if (md->mode&eModifierMode_Virtual) i--;
}
- uiPanelPop(block);
if(yco < 0) uiNewPanelHeight(block, 204-yco);
}
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index a057da29531..30817c10355 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -346,6 +346,11 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
/* Draw constraint header */
uiBlockSetEmboss(block, UI_EMBOSSN);
+ /* rounded header */
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-1, width+30, 22, NULL, 5.0, 0.0,
+ (con->flag & CONSTRAINT_EXPAND)?3:15 , -20, "");
+
+ /* open/close */
uiDefIconButBitS(block, ICONTOG, CONSTRAINT_EXPAND, B_CONSTRAINT_REDRAW, ICON_DISCLOSURE_TRI_RIGHT, *xco-10, *yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Constraint");
if (con->flag & CONSTRAINT_EXPAND) {
@@ -364,17 +369,12 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
*/
uiBlockSetEmboss(block, UI_EMBOSS);
- /* rounded header */
- BIF_ThemeColorShade(curCol, -20);
- uiSetRoundBox(3);
- uiRoundBox((float)*xco+4, (float)*yco-18, (float)*xco+width+30, (float)*yco+6, 5.0);
-
- but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco-1, 100, 19, NULL, 0.0, 0.0, 0.0, 0.0, "");
+ but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(but, constraint_changed_func, con, NULL);
con->otype = con->type;
- but = uiDefBut(block, TEX, B_CONSTRAINT_REDRAW, "", *xco+120, *yco-1, 135, 19, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name");
+ but = uiDefBut(block, TEX, B_CONSTRAINT_REDRAW, "", *xco+120, *yco, 135, 18, con->name, 0.0, 29.0, 0.0, 0.0, "Constraint name");
uiButSetFunc(but, verify_constraint_name_func, con, NULL);
}
else{
@@ -386,16 +386,8 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
}
else
BIF_ThemeColor(curCol);
-
- /* coloured rectangle to hold constraint controls */
- if (con->type!=CONSTRAINT_TYPE_NULL) glRects(*xco+3, *yco-36, *xco+width+30, *yco-15);
-
- /* rounded header */
- BIF_ThemeColorShade(curCol, -20);
- uiSetRoundBox(3);
- uiRoundBox((float)*xco+4, (float)*yco-15, (float)*xco+width+30, (float)*yco+6, 5.0);
- but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco-1, 100, 19, NULL, 0.0, 0.0, 0.0, 0.0, "");
+ but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+10, *yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(but, move_constraint_func, con, NULL);
but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco-1, 135, 19, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -423,11 +415,9 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
bActionConstraint *data = con->data;
bArmature *arm;
- height = 86;
+ height = 88;
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
-
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
/* Draw target parameters */
@@ -462,10 +452,9 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
{
bLocateLikeConstraint *data = con->data;
bArmature *arm;
- height = 66;
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ height = 66;
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -493,10 +482,9 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
{
bRotateLikeConstraint *data = con->data;
bArmature *arm;
+
height = 46;
-
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -519,9 +507,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
bArmature *arm;
height = 66;
-
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -551,9 +537,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
bArmature *arm;
height = 66;
-
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -594,9 +578,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
bLockTrackConstraint *data = con->data;
bArmature *arm;
height = 66;
-
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -637,9 +619,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
bFollowPathConstraint *data = con->data;
height = 66;
-
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -676,10 +656,9 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
{
bStretchToConstraint *data = con->data;
bArmature *arm;
+
height = 105;
- BIF_ThemeColor(curCol);
-
- glRects(*xco+3, *yco-height-39, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
@@ -723,9 +702,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
case CONSTRAINT_TYPE_NULL:
{
height = 17;
-
- BIF_ThemeColor(curCol);
- glRects(*xco+3, *yco-height-17, *xco+width+30, *yco-18);
+ uiDefBut(block, ROUNDBOX, 0, "", *xco-10, *yco-height, width+30,height-1, NULL, 5.0, 0.0, 12, 0, "");
}
break;
@@ -933,6 +910,8 @@ static void object_panel_constraint(void)
/* so first we make it default height */
uiNewPanelHeight(block, 204);
+ if(G.obedit==OBACT) return;
+
conlist = get_constraint_client(ownerstr, &type, NULL);
if (conlist) {
@@ -960,16 +939,12 @@ static void object_panel_constraint(void)
/* Go through the list of constraints and draw them */
xco = 10;
yco = 160;
- // local panel coords
- uiPanelPush(block);
for (curcon = conlist->first; curcon; curcon=curcon->next) {
/* Draw default constraint header */
draw_constraint(block, conlist, curcon, &xco, &yco, type);
}
- uiPanelPop(block);
-
if(yco < 0) uiNewPanelHeight(block, 204-yco);
}
diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c
index 787ac847523..22e104711fd 100644
--- a/source/blender/src/interface.c
+++ b/source/blender/src/interface.c
@@ -2699,7 +2699,7 @@ static uiBut *ui_but_prev(uiBut *but)
{
while(but->prev) {
but= but->prev;
- if(but->type!=LABEL && but->type!=SEPR) return but;
+ if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
}
return NULL;
}
@@ -2708,7 +2708,7 @@ static uiBut *ui_but_next(uiBut *but)
{
while(but->next) {
but= but->next;
- if(but->type!=LABEL && but->type!=SEPR) return but;
+ if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
}
return NULL;
}
@@ -2719,7 +2719,7 @@ static uiBut *ui_but_first(uiBlock *block)
but= block->buttons.first;
while(but) {
- if(but->type!=LABEL && but->type!=SEPR) return but;
+ if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
but= but->next;
}
return NULL;
@@ -2731,7 +2731,7 @@ static uiBut *ui_but_last(uiBlock *block)
but= block->buttons.last;
while(but) {
- if(but->type!=LABEL && but->type!=SEPR) return but;
+ if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
but= but->prev;
}
return NULL;
@@ -4575,7 +4575,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
if ELEM8(but->type, HSVSLI , NUMSLI, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM) {
but->flag |= UI_TEXT_LEFT;
}
-
+
+ if(but->type==ROUNDBOX)
+ but->flag |= UI_NO_HILITE;
+
but->flag |= (block->flag & UI_BUT_ALIGN);
return but;
diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c
index d770409837d..92f38cbd1e8 100644
--- a/source/blender/src/interface_draw.c
+++ b/source/blender/src/interface_draw.c
@@ -1698,6 +1698,16 @@ static void ui_draw_but_HSVCUBE(uiBut *but)
fdrawbox((but->x1), (but->y1), (but->x2), (but->y2));
}
+static void ui_draw_roundbox(uiBut *but)
+{
+ BIF_ThemeColorShade(but->themecol, but->a2);
+
+ uiSetRoundBox(but->a1);
+ gl_round_box(GL_POLYGON, but->x1, but->y1, but->x2, but->y2, but->min);
+
+}
+
+
/* nothing! */
static void ui_draw_nothing(int type, int colorid, float asp, float x1, float y1, float x2, float y2, int flag)
{
@@ -1716,7 +1726,7 @@ void ui_set_embossfunc(uiBut *but, int drawtype)
but->sliderfunc= ui_draw_slider;
// standard builtin first:
- if(but->type==LABEL) but->embossfunc= ui_draw_nothing;
+ if(but->type==LABEL || but->type==ROUNDBOX) but->embossfunc= ui_draw_nothing;
else if(but->type==PULLDOWN) but->embossfunc= ui_draw_pulldown_round;
else if(drawtype==UI_EMBOSSM) but->embossfunc= ui_draw_minimal;
else if(drawtype==UI_EMBOSSN) but->embossfunc= ui_draw_nothing;
@@ -1790,6 +1800,9 @@ void ui_draw_but(uiBut *but)
case INLINK:
ui_draw_icon(but, but->icon);
break;
+
+ case ROUNDBOX:
+ ui_draw_roundbox(but);
default:
but->embossfunc(but->type, but->themecol, but->aspect, but->x1, but->y1, but->x2, but->y2, but->flag);