CubicSDR/src/ui/GLPanel.h

87 lines
2.1 KiB
C
Raw Normal View History

#pragma once
#include <vector>
#include "GLExt.h"
2015-06-21 11:58:14 -04:00
#include "ColorTheme.h"
#include "cubic_math.h"
class GLPanelEdges {
public:
float left;
float right;
float top;
float bottom;
GLPanelEdges(): left(0), right(0), top(0), bottom(0) {
}
GLPanelEdges(float l, float r, float t, float b) {
left = l;
right = r;
top = t;
bottom = b;
}
};
class GLPanel {
private:
std::vector<float> glPoints;
std::vector<float> glColors;
2015-06-21 11:58:14 -04:00
void genArrays();
void setViewport();
public:
2015-06-21 10:51:13 -04:00
typedef enum GLPanelFillType { GLPANEL_FILL_NONE, GLPANEL_FILL_SOLID, GLPANEL_FILL_GRAD_X, GLPANEL_FILL_GRAD_Y, GLPANEL_FILL_GRAD_BAR_X, GLPANEL_FILL_GRAD_BAR_Y } GLPanelFillType;
typedef enum GLPanelCoordinateSystem { GLPANEL_Y_DOWN_ZERO_ONE, GLPANEL_Y_UP_ZERO_ONE, GLPANEL_Y_UP, GLPANEL_Y_DOWN } GLPanelCoordinateSystem;
float pos[2];
float size[2];
float view[2];
2015-06-21 11:58:14 -04:00
GLPanelFillType fillType;
GLPanelCoordinateSystem coord;
2015-06-27 01:26:07 -04:00
GLPanelEdges marginPx;
GLPanelEdges borderPx;
2015-06-21 11:58:14 -04:00
RGB fill[2];
2015-06-22 22:07:46 -04:00
RGB borderColor;
bool contentsVisible;
CubicVR::mat4 transform;
CubicVR::mat4 localTransform;
float min, mid, max;
std::vector<GLPanel *> children;
GLPanel();
void setPosition(float x, float y);
void setSize(float w, float h);
float getWidthPx();
float getHeightPx();
void setCoordinateSystem(GLPanelCoordinateSystem coord);
void setFill(GLPanelFillType fill_mode);
2015-06-21 11:58:14 -04:00
void setFillColor(RGB color1);
void setFillColor(RGB color1, RGB color2);
2015-06-27 01:26:07 -04:00
void setMarginPx(float marg);
void setMarginPx(float margl, float margr, float margt, float margb);
2015-06-22 22:07:46 -04:00
void setBorderColor(RGB clr);
2015-06-27 01:26:07 -04:00
void setBorderPx(float bord);
void setBorderPx(float bordl, float bordr, float bordt, float bordb);
2015-06-22 22:07:46 -04:00
void addChild(GLPanel *childPanel);
void drawChildren();
virtual void drawPanelContents();
void draw(CubicVR::mat4 transform, GLPanel *parent=NULL);
};
class GLTestPanel : public GLPanel {
public:
GLTestPanel() : GLPanel() {
}
2015-06-21 11:58:14 -04:00
void drawPanelContents();
};