I am trying to create my own GUI library, and I am having some difficulty with Super class (This is kind of new to me, and couldn't find a good source to learn from). But I have all my components extend from "GGUI", which are then stored in an ArrayList for easy access. My problem is that I get an error: "Implicit super constructor GrimGUI.GGUI() is undefined. must explicitly invoke another constructor".
GrimGUI:
Button testScreen;
Slider firstSlider;
Slider secondSlider;
Text firstSliderText;
Text secondSliderText;
boolean onHome;
boolean onTest;
ArrayList<GGUI> gguiScreen = new ArrayList<GGUI>();
void setup() {
size(500, 500);
onHome = true;
background(255);
gguiScreen.add(new Button(75, 50, 40, 20));
testScreen = new Button(115, 50, 40, 20);
testScreen.cNormal = color(0, 255, 125);
firstSlider = new Slider(250, 250, 100);
secondSlider = new Slider(250, 280, 100);
firstSliderText = new Text(280, 250, "0");
secondSliderText = new Text(280, 280, "0");
}
void draw() {
background(255);
HomeScreen();
TestScreen();
endFix();
}
void HomeScreen() {
if (onHome) {
testScreen.Update();
firstSlider.Update();
firstSliderText.content = str(firstSlider.value);
firstSliderText.Update();
if (testScreen.released) {
onTest = true;
onHome = false;
}
}
}
void TestScreen() {
if (onTest) {
Button trash = (Button)gguiScreen.get(0);//Testing that I can get the only object placed in it to view on screen
trash.Update();
secondSlider.Update();
secondSliderText.content = str(secondSlider.value);
secondSliderText.Update();
if (trash.WasClicked()) {
onTest = false;
onHome = true;
}
}
}
Button:
class Button extends GGUI {
boolean visible, pressed, released, hovering;
color cNormal, cPressed, cReleased, cHovering;
float x, y, w, h;
Button(float X, float Y, float W, float H) {
visible = true;
x = X;
y = Y;
w = W;
h = H;
cNormal = color(75, 75, 75);
cPressed = color(100, 100, 100);
cReleased = color(125, 125, 125);
cHovering = color(175, 175, 175);
}
Button(boolean visibility, float X, float Y, float W, float H) {
visible = visibility;
x = X;
y = Y;
w = W;
h = H;
cNormal = color(75, 75, 75);
cPressed = color(100, 100, 100);
cReleased = color(125, 125, 125);
cHovering = color(175, 175, 175);
}
Button(boolean visibility, float X, float Y, float W, float H, color CNORMAL, color CPRESSED) {
visible = visibility;
x = X;
y = Y;
w = W;
h = H;
cNormal = CNORMAL;
cPressed = CPRESSED;
cReleased = color(125, 125, 125);
cHovering = color(175, 175, 175);
}
Button(boolean visibility, float X, float Y, float W, float H, color CNORMAL, color CPRESSED, color CHOVERING) {
visible = visibility;
x = X;
y = Y;
w = W;
h = H;
cNormal = CNORMAL;
cPressed = CPRESSED;
cHovering = CHOVERING;
cReleased = color(125, 125, 125);
}
Button(boolean visibility, float X, float Y, float W, float H, color CNORMAL, color CPRESSED, color CHOVERING, color CRELEASED) {
visible = visibility;
x = X;
y = Y;
w = W;
h = H;
cNormal = CNORMAL;
cPressed = CPRESSED;
cHovering = CHOVERING;
cReleased = CRELEASED;
}
void Update() {
CheckState();
if (visible) {//WILL NOT RENDER IF NOT VISIBLE
if (pressed && !released) {// IF PRESSED
fill(cPressed);
}
if (released && !pressed) {// IF RELEASED
fill(cReleased);
}
if (hovering && !released && !pressed) {// IF HOVERING
fill(cHovering);
}
if (!hovering && !released && !pressed) {// IF NORMAL / NOT ACTIVE
fill(cNormal);
}
stroke(1);
rect(x, y, w, h);
}
}
void CheckState() {
hovering = false;
released = false;
if (mouseX > x && mouseX < x + w) {
if (mouseY > y && mouseY < y + h) {
hovering = true;
}
}
if (hovering) {
if (mPressed) {
pressed = true;
released = false;
}
if (mClicked) {
released = true;
pressed = false;
}
} else {
pressed = false;
released = false;
hovering = false;
}
}
boolean WasClicked() {
return pressed;
}
}
GGUI:
class GGUI {
int x, y;
boolean visible;
color cBase, cSecondary;
GGUI(int _x, int _y, boolean _visible, color _cBase, color _cSecondary) {
x = _x;
y = _y;
visible = _visible;
cBase = _cBase;
cSecondary = _cSecondary;
}
void Update() {
println("Updated");
}
}