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>2004-08-31 17:43:18 +0400
committerTon Roosendaal <ton@blender.org>2004-08-31 17:43:18 +0400
commit0a305446a58c181d2e8f9c1d0af4c7d935117b4c (patch)
tree2a1de251e2360def5f7fef03458a1d08aa3d12c5 /source/blender/src/interface_panel.c
parent19a24abcb2584c9c76c14ec32610df11a72bd0c3 (diff)
Three functionalities in one commit, but there's overlap so I can't
separate it... 1) Curve/Surface editmode undo Uses same syntax as mesh undo, so simple to integrate. Edit-curve data is also quite simpler, so no need for any hack at all. It re-uses the undo system from next point, which is nice short & clean local code 2) Framework for global undo The undo calls themselves are commented out. In a next commit I want to enable it for a couple of main features, for further feedback. The speed goes surprisingly well, especially with this new version that 'pushes' undo after a command, ensuring interactivity isnt frustrated 3) framework for texture based icons in Blender Not activated code, but tested here. Part of 2.3 UI project. btw: Johnny Matthews will assist in (and complete) the undo project
Diffstat (limited to 'source/blender/src/interface_panel.c')
-rw-r--r--source/blender/src/interface_panel.c190
1 files changed, 150 insertions, 40 deletions
diff --git a/source/blender/src/interface_panel.c b/source/blender/src/interface_panel.c
index 298f59f8386..9cac338c0f9 100644
--- a/source/blender/src/interface_panel.c
+++ b/source/blender/src/interface_panel.c
@@ -114,105 +114,225 @@ void uiSetRoundBox(int type)
}
-void gl_round_box_topshade(float minx, float miny, float maxx, float maxy, float rad)
+void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad)
{
float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
- char col[7]= {140, 165, 195, 210, 230, 245, 255};
int a;
- char alpha=255;
-
- if(roundboxtype & UI_RB_ALPHA) alpha= 128;
/* mult */
for(a=0; a<7; a++) {
vec[a][0]*= rad; vec[a][1]*= rad;
}
- /* shades from grey->white->grey */
- glBegin(GL_LINE_STRIP);
+ glBegin(mode);
+
+ /* start with corner right-bottom */
+ if(roundboxtype & 4) {
+ glVertex2f( maxx-rad, miny);
+ for(a=0; a<7; a++) {
+ glVertex2f( maxx-rad+vec[a][0], miny+vec[a][1]);
+ }
+ glVertex2f( maxx, miny+rad);
+ }
+ else glVertex2f( maxx, miny);
- if(roundboxtype & 3) {
- /* corner right-top */
- glColor4ub(140, 140, 140, alpha);
+ /* corner right-top */
+ if(roundboxtype & 2) {
glVertex2f( maxx, maxy-rad);
for(a=0; a<7; a++) {
- glColor4ub(col[a], col[a], col[a], alpha);
glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
}
- glColor4ub(225, 225, 225, alpha);
glVertex2f( maxx-rad, maxy);
+ }
+ else glVertex2f( maxx, maxy);
-
- /* corner left-top */
+ /* corner left-top */
+ if(roundboxtype & 1) {
glVertex2f( minx+rad, maxy);
for(a=0; a<7; a++) {
- glColor4ub(col[6-a], col[6-a], col[6-a], alpha);
glVertex2f( minx+rad-vec[a][0], maxy-vec[a][1]);
}
glVertex2f( minx, maxy-rad);
}
- else {
- glColor4ub(225, 225, 225, alpha);
- glVertex2f( minx, maxy);
- glVertex2f( maxx, maxy);
+ else glVertex2f( minx, maxy);
+
+ /* corner left-bottom */
+ if(roundboxtype & 8) {
+ glVertex2f( minx, miny+rad);
+ for(a=0; a<7; a++) {
+ glVertex2f( minx+vec[a][1], miny+rad-vec[a][0]);
+ }
+ glVertex2f( minx+rad, miny);
}
+ else glVertex2f( minx, miny);
glEnd();
}
+static void round_box_shade_col(float *col1, float *col2, float fac)
+{
+ float col[3];
+
+ col[0]= (fac*col1[0] + (1.0-fac)*col2[0]);
+ col[1]= (fac*col1[1] + (1.0-fac)*col2[1]);
+ col[2]= (fac*col1[2] + (1.0-fac)*col2[2]);
+
+ glColor3fv(col);
+}
-void gl_round_box(float minx, float miny, float maxx, float maxy, float rad)
+/* linear horizontal shade within button or in outline */
+void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shade)
{
float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ float div= maxy-miny;
+ float coltop[3], coldown[3], color[4];
int a;
/* mult */
for(a=0; a<7; a++) {
vec[a][0]*= rad; vec[a][1]*= rad;
}
+ /* get current color, needs to be outside of glBegin/End */
+ glGetFloatv(GL_CURRENT_COLOR, color);
+
+ /* 'shade' defines strength of shading */
+ coltop[0]= color[0]+shade; if(coltop[0]>1.0) coltop[0]= 1.0;
+ coltop[1]= color[1]+shade; if(coltop[1]>1.0) coltop[1]= 1.0;
+ coltop[2]= color[2]+shade; if(coltop[2]>1.0) coltop[2]= 1.0;
+ coldown[0]= color[0]-shade; if(coldown[0]<0.0) coldown[0]= 0.0;
+ coldown[1]= color[1]-shade; if(coldown[1]<0.0) coldown[1]= 0.0;
+ coldown[2]= color[2]-shade; if(coldown[2]<0.0) coldown[2]= 0.0;
+
+ glShadeModel(GL_SMOOTH);
+ glBegin(mode);
/* start with corner right-bottom */
if(roundboxtype & 4) {
+
+ round_box_shade_col(coltop, coldown, 0.0);
glVertex2f( maxx-rad, miny);
+
for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, vec[a][1]/div);
glVertex2f( maxx-rad+vec[a][0], miny+vec[a][1]);
}
+
+ round_box_shade_col(coltop, coldown, rad/div);
glVertex2f( maxx, miny+rad);
}
- else glVertex2f( maxx, miny);
+ else {
+ round_box_shade_col(coltop, coldown, 0.0);
+ glVertex2f( maxx, miny);
+ }
/* corner right-top */
if(roundboxtype & 2) {
+
+ round_box_shade_col(coltop, coldown, (div-rad)/div);
glVertex2f( maxx, maxy-rad);
+
for(a=0; a<7; a++) {
- glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
+ round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])/div);
+ glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][1]);
}
+ round_box_shade_col(coltop, coldown, 1.0);
glVertex2f( maxx-rad, maxy);
}
- else glVertex2f( maxx, maxy);
+ else {
+ round_box_shade_col(coltop, coldown, 1.0);
+ glVertex2f( maxx, maxy);
+ }
/* corner left-top */
if(roundboxtype & 1) {
+
+ round_box_shade_col(coltop, coldown, 1.0);
glVertex2f( minx+rad, maxy);
+
for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, (div-vec[a][1])/div);
glVertex2f( minx+rad-vec[a][0], maxy-vec[a][1]);
}
+
+ round_box_shade_col(coltop, coldown, (div-rad)/div);
glVertex2f( minx, maxy-rad);
}
- else glVertex2f( minx, maxy);
+ else {
+ round_box_shade_col(coltop, coldown, 1.0);
+ glVertex2f( minx, maxy);
+ }
/* corner left-bottom */
if(roundboxtype & 8) {
+
+ round_box_shade_col(coltop, coldown, rad/div);
glVertex2f( minx, miny+rad);
+
for(a=0; a<7; a++) {
+ round_box_shade_col(coltop, coldown, (rad-vec[a][1])/div);
glVertex2f( minx+vec[a][1], miny+rad-vec[a][0]);
}
+
+ round_box_shade_col(coltop, coldown, 0.0);
glVertex2f( minx+rad, miny);
}
- else glVertex2f( minx, miny);
+ else {
+ round_box_shade_col(coltop, coldown, 0.0);
+ glVertex2f( minx, miny);
+ }
+
+ glEnd();
+ glShadeModel(GL_FLAT);
+}
+
+/* only for headers */
+static void gl_round_box_topshade(float minx, float miny, float maxx, float maxy, float rad)
+{
+ float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ char col[7]= {140, 165, 195, 210, 230, 245, 255};
+ int a;
+ char alpha=255;
+
+ if(roundboxtype & UI_RB_ALPHA) alpha= 128;
+
+ /* mult */
+ for(a=0; a<7; a++) {
+ vec[a][0]*= rad; vec[a][1]*= rad;
+ }
+
+ /* shades from grey->white->grey */
+ glBegin(GL_LINE_STRIP);
+
+ if(roundboxtype & 3) {
+ /* corner right-top */
+ glColor4ub(140, 140, 140, alpha);
+ glVertex2f( maxx, maxy-rad);
+ for(a=0; a<7; a++) {
+ glColor4ub(col[a], col[a], col[a], alpha);
+ glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]);
+ }
+ glColor4ub(225, 225, 225, alpha);
+ glVertex2f( maxx-rad, maxy);
+
+ /* corner left-top */
+ glVertex2f( minx+rad, maxy);
+ for(a=0; a<7; a++) {
+ glColor4ub(col[6-a], col[6-a], col[6-a], alpha);
+ glVertex2f( minx+rad-vec[a][0], maxy-vec[a][1]);
+ }
+ glVertex2f( minx, maxy-rad);
+ }
+ else {
+ glColor4ub(225, 225, 225, alpha);
+ glVertex2f( minx, maxy);
+ glVertex2f( maxx, maxy);
+ }
+
+ glEnd();
}
/* for headers and floating panels */
@@ -229,9 +349,7 @@ void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad)
}
/* solid part */
- glBegin(GL_POLYGON);
- gl_round_box(minx, miny, maxx, maxy, rad);
- glEnd();
+ gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
/* set antialias line */
glEnable( GL_LINE_SMOOTH );
@@ -243,9 +361,7 @@ void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad)
/* total outline */
if(roundboxtype & UI_RB_ALPHA) glColor4ub(0,0,0, 128); else glColor4ub(0,0,0, 255);
- glBegin(GL_LINE_LOOP);
- gl_round_box(minx, miny, maxx, maxy, rad);
- glEnd();
+ gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
glDisable( GL_LINE_SMOOTH );
@@ -276,9 +392,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad)
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- glBegin(GL_LINE_LOOP);
- gl_round_box(minx, miny, maxx, maxy, rad);
- glEnd();
+ gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
glDisable( GL_BLEND );
glDisable( GL_LINE_SMOOTH );
@@ -300,18 +414,14 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
}
/* solid part */
- glBegin(GL_POLYGON);
- gl_round_box(minx, miny, maxx, maxy, rad);
- glEnd();
+ gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
/* set antialias line */
glEnable( GL_LINE_SMOOTH );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- glBegin(GL_LINE_LOOP);
- gl_round_box(minx, miny, maxx, maxy, rad);
- glEnd();
+ gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
glDisable( GL_BLEND );
glDisable( GL_LINE_SMOOTH );