Hi,
I made a GUI for my project a few months ago and it worked fine. I left it alone for a few months and then went back to add to it. But now the window is empty. I have a class called GUIWindow that is a subclass of Fl_Window and I put widgets on it in the constructor. Then in main I just call the constructor and return Fl::run(). The code I have is -
GUIWindow constructor -
Code:
GUIWindow::GUIWindow(Robot& r) : Fl_Window(500, 400, "iRobot Create"), robot(&r) {
begin(); //make the widgets, button for each option
fullMode = new Fl_Button(25, 300, 90, 30, "Full Mode");
fullMode->when(FL_WHEN_RELEASE);
fullMode->callback(cb_fullmode, this);
fullMode->shortcut('f');
safeMode = new Fl_Button(25, 350, 90, 30, "Safe Mode");
safeMode->when(FL_WHEN_RELEASE);
safeMode->callback(cb_safemode, this);
safeMode->shortcut('s');
velocity = new Fl_Input(230, 25, 50, 30, "Velocity");
drive = new Fl_Button(25, 75, 70, 30, "Drive");
drive->when(FL_WHEN_RELEASE);
drive->callback(cb_drive, this);
drive->shortcut('d');
driveRadius = new Fl_Input(150, 75, 50, 30, "Radius");
turn = new Fl_Button(300, 75, 60, 30, "Turn");
turn->when(FL_WHEN_RELEASE);
turn->callback(cb_turn, this);
turn->shortcut('t');
//more widgets...
end(); //end making widgets
robot->fullMode();
robot->streamSensors();
Fl::add_idle(IdleCallback, this);
resizable(this);
show(); //show it
}
in main -
Code:
Robot robot(robot_port, ROBOT_BAUDRATE, direction[0]);
GUIWindow window(robot);
return Fl::run();
Whenever I run, the window comes up and the idle callback works, but the window has no widgets and it closes if I click in it.
I don't think this is an issue, but I made it using Ubuntu and now I'm using Debian.
I tried a basic example from the web and it works. And I can't see what is that much different from my code.
Code:
void but_cb( Fl_Widget* o, void* ) {
Fl_Button* b=(Fl_Button*)o;
b->label("Good job"); //redraw not necessary
b->resize(10,150,140,30); //redraw needed
b->redraw();
}
int main() {
Fl_Window win( 300,200,"Testing" );
win.begin();
Fl_Button but( 10, 150, 70, 30, "Click me" );
win.end();
but.callback( but_cb );
win.show();
return Fl::run();
}
If anyone can help me see whats going wrong here I would be grateful.