mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-09-27 15:56:48 -04:00
Borders, mixed coordinate preparations
This commit is contained in:
parent
adbb853c6d
commit
f2601edaa1
@ -9,10 +9,24 @@ GLPanel::GLPanel() : fillType(GLPANEL_FILL_SOLID), coord(GLPANEL_Y_DOWN_ZERO_ONE
|
|||||||
size[1] = 1.0f;
|
size[1] = 1.0f;
|
||||||
fill[0] = RGB(0.5,0.5,0.5);
|
fill[0] = RGB(0.5,0.5,0.5);
|
||||||
fill[1] = RGB(0.1,0.1,0.1);
|
fill[1] = RGB(0.1,0.1,0.1);
|
||||||
|
borderColor = RGB(0.8, 0.8, 0.8);
|
||||||
genArrays();
|
genArrays();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLPanel::genArrays() {
|
void GLPanel::genArrays() {
|
||||||
|
|
||||||
|
float min, mid, max;
|
||||||
|
|
||||||
|
if (coord == GLPANEL_Y_DOWN || coord == GLPANEL_Y_UP) {
|
||||||
|
min = -1;
|
||||||
|
mid = 0;
|
||||||
|
max = 1;
|
||||||
|
} else {
|
||||||
|
min = 0;
|
||||||
|
mid = 0.5;
|
||||||
|
max = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (fillType == GLPANEL_FILL_SOLID || fillType == GLPANEL_FILL_GRAD_X || fillType == GLPANEL_FILL_GRAD_Y) {
|
if (fillType == GLPANEL_FILL_SOLID || fillType == GLPANEL_FILL_GRAD_X || fillType == GLPANEL_FILL_GRAD_Y) {
|
||||||
glPoints.reserve(2 * 4);
|
glPoints.reserve(2 * 4);
|
||||||
glPoints.resize(2 * 4);
|
glPoints.resize(2 * 4);
|
||||||
@ -20,10 +34,10 @@ void GLPanel::genArrays() {
|
|||||||
glColors.resize(3 * 4);
|
glColors.resize(3 * 4);
|
||||||
|
|
||||||
float pts[2 * 4] = {
|
float pts[2 * 4] = {
|
||||||
0.0f, 0.0f,
|
min, min,
|
||||||
0.0f, 1.0f,
|
min, max,
|
||||||
1.0f, 1.0f,
|
max, max,
|
||||||
1.0f, 0.0f
|
max, min
|
||||||
};
|
};
|
||||||
|
|
||||||
RGB c[4];
|
RGB c[4];
|
||||||
@ -57,15 +71,15 @@ void GLPanel::genArrays() {
|
|||||||
|
|
||||||
if (fillType == GLPANEL_FILL_GRAD_BAR_X) {
|
if (fillType == GLPANEL_FILL_GRAD_BAR_X) {
|
||||||
float pts[2 * 8] = {
|
float pts[2 * 8] = {
|
||||||
0.0f, 0.0f,
|
min, min,
|
||||||
0.0f, 1.0f,
|
min, max,
|
||||||
0.5f, 1.0f,
|
mid, max,
|
||||||
0.5f, 0.0f,
|
mid, min,
|
||||||
|
|
||||||
0.5f, 0.0f,
|
mid, min,
|
||||||
0.5f, 1.0f,
|
mid, max,
|
||||||
1.0f, 1.0f,
|
max, max,
|
||||||
1.0f, 0.0f
|
max, min
|
||||||
};
|
};
|
||||||
glPoints.assign(pts, pts + (2 * 8));
|
glPoints.assign(pts, pts + (2 * 8));
|
||||||
|
|
||||||
@ -77,15 +91,15 @@ void GLPanel::genArrays() {
|
|||||||
|
|
||||||
} else if (fillType == GLPANEL_FILL_GRAD_BAR_Y) {
|
} else if (fillType == GLPANEL_FILL_GRAD_BAR_Y) {
|
||||||
float pts[2 * 8] = {
|
float pts[2 * 8] = {
|
||||||
0.0f, 0.0f,
|
min, min,
|
||||||
0.0f, 0.5f,
|
min, mid,
|
||||||
1.0f, 0.5f,
|
max, mid,
|
||||||
1.0f, 0.0f,
|
max, min,
|
||||||
|
|
||||||
0.0f, 0.5f,
|
min, mid,
|
||||||
0.0f, 1.0f,
|
min, max,
|
||||||
1.0f, 1.0f,
|
max, max,
|
||||||
1.0f, 0.5f
|
max, mid
|
||||||
};
|
};
|
||||||
glPoints.assign(pts, pts + (2 * 8));
|
glPoints.assign(pts, pts + (2 * 8));
|
||||||
|
|
||||||
@ -153,7 +167,6 @@ void GLPanel::setFillColor(RGB color1, RGB color2) {
|
|||||||
genArrays();
|
genArrays();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GLPanel::setMargin(float marg) {
|
void GLPanel::setMargin(float marg) {
|
||||||
margin.left = margin.right = margin.top = margin.bottom = marg;
|
margin.left = margin.right = margin.top = margin.bottom = marg;
|
||||||
}
|
}
|
||||||
@ -165,6 +178,20 @@ void GLPanel::setMargin(float margl, float margr, float margt, float margb) {
|
|||||||
margin.bottom = margb;
|
margin.bottom = margb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLPanel::setBorderColor(RGB clr) {
|
||||||
|
borderColor = clr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLPanel::setBorder(float bord) {
|
||||||
|
border.left = border.right = border.top = border.bottom = bord;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLPanel::setBorder(float bordl, float bordr, float bordt, float bordb) {
|
||||||
|
border.left = bordl;
|
||||||
|
border.right = bordr;
|
||||||
|
border.top = bordt;
|
||||||
|
border.bottom = bordb;
|
||||||
|
}
|
||||||
|
|
||||||
void GLPanel::addChild(GLPanel *childPanel) {
|
void GLPanel::addChild(GLPanel *childPanel) {
|
||||||
children.push_back(childPanel);
|
children.push_back(childPanel);
|
||||||
@ -185,6 +212,18 @@ void GLPanel::drawPanelContents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GLPanel::draw(GLPanel *parent) {
|
void GLPanel::draw(GLPanel *parent) {
|
||||||
|
float min, mid, max;
|
||||||
|
|
||||||
|
if (coord == GLPANEL_Y_DOWN || coord == GLPANEL_Y_UP) {
|
||||||
|
min = -1;
|
||||||
|
mid = 0;
|
||||||
|
max = 1;
|
||||||
|
} else {
|
||||||
|
min = 0;
|
||||||
|
mid = 0.5;
|
||||||
|
max = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
if (coord == GLPANEL_Y_DOWN_ZERO_ONE) {
|
if (coord == GLPANEL_Y_DOWN_ZERO_ONE) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
@ -218,6 +257,45 @@ void GLPanel::draw(GLPanel *parent) {
|
|||||||
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
|
if (border.left || border.right || border.top || border.bottom) {
|
||||||
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
glColor3f(borderColor.r, borderColor.g, borderColor.b);
|
||||||
|
|
||||||
|
if (border.left) {
|
||||||
|
glLineWidth(border.left);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(min, min);
|
||||||
|
glVertex2f(min, max);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border.right) {
|
||||||
|
glLineWidth(border.right);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(max, min);
|
||||||
|
glVertex2f(max, max);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border.top) {
|
||||||
|
glLineWidth(border.top);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(min, min);
|
||||||
|
glVertex2f(max, min);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border.bottom) {
|
||||||
|
glLineWidth(border.bottom);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(min, max);
|
||||||
|
glVertex2f(max, max);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_LINE_SMOOTH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contentsVisible) {
|
if (contentsVisible) {
|
||||||
@ -235,8 +313,6 @@ void GLPanel::draw(GLPanel *parent) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GLTestPanel::drawPanelContents() {
|
void GLTestPanel::drawPanelContents() {
|
||||||
glColor3f(1.0,1.0,1.0);
|
glColor3f(1.0,1.0,1.0);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
GLPanelEdges margin;
|
GLPanelEdges margin;
|
||||||
GLPanelEdges border;
|
GLPanelEdges border;
|
||||||
RGB fill[2];
|
RGB fill[2];
|
||||||
|
RGB borderColor;
|
||||||
bool contentsVisible;
|
bool contentsVisible;
|
||||||
|
|
||||||
std::vector<GLPanel *> children;
|
std::vector<GLPanel *> children;
|
||||||
@ -57,7 +58,11 @@ public:
|
|||||||
void setFillColor(RGB color1, RGB color2);
|
void setFillColor(RGB color1, RGB color2);
|
||||||
void setMargin(float marg);
|
void setMargin(float marg);
|
||||||
void setMargin(float margl, float margr, float margt, float margb);
|
void setMargin(float margl, float margr, float margt, float margb);
|
||||||
|
|
||||||
|
void setBorderColor(RGB clr);
|
||||||
|
void setBorder(float bord);
|
||||||
|
void setBorder(float bordl, float bordr, float bordt, float bordb);
|
||||||
|
|
||||||
void addChild(GLPanel *childPanel);
|
void addChild(GLPanel *childPanel);
|
||||||
|
|
||||||
void drawChildren();
|
void drawChildren();
|
||||||
|
@ -16,12 +16,15 @@ PrimaryGLContext(canvas, sharedContext) {
|
|||||||
testChildPanel.setSize(1.0, 0.3);
|
testChildPanel.setSize(1.0, 0.3);
|
||||||
testChildPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X);
|
testChildPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X);
|
||||||
testChildPanel.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0));
|
testChildPanel.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0));
|
||||||
|
testChildPanel.setBorder(1);
|
||||||
|
|
||||||
testChildPanel2.setPosition(0.0, 0.3);
|
testChildPanel2.setPosition(0.0, 0.3);
|
||||||
testChildPanel2.setSize(1.0, 0.3);
|
testChildPanel2.setSize(1.0, 0.3);
|
||||||
testChildPanel2.setMargin(0.05);
|
testChildPanel2.setMargin(0.05);
|
||||||
testChildPanel2.setFill(GLPanel::GLPANEL_FILL_GRAD_X);
|
testChildPanel2.setFill(GLPanel::GLPANEL_FILL_GRAD_X);
|
||||||
testChildPanel2.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0));
|
testChildPanel2.setFillColor(RGB(0.0,0.0,1.0), RGB(0.0,1.0,0.0));
|
||||||
|
testChildPanel2.setBorderColor(RGB(1.0,0.0,0.0));
|
||||||
|
testChildPanel2.setBorder(2,4,6,8);
|
||||||
|
|
||||||
testPanel.addChild(&testChildPanel);
|
testPanel.addChild(&testChildPanel);
|
||||||
testPanel.addChild(&testChildPanel2);
|
testPanel.addChild(&testChildPanel2);
|
||||||
|
Loading…
Reference in New Issue
Block a user