99#include " gui.h"
1010
1111Fl_PNG_Image * FPGA::image = new Fl_PNG_Image(" Assets/FPGA.png" );
12- FPGA::FPGA (int x, int y) : Fl_Widget(x, y, image->w (), image->h()) {
13- disp = new display (x + image->w () / 2 , y + image->h () / 2 );
14- disp->position (x + image->w () / 2 - disp->w () / 2 , y + image->h () / 2 );
15-
16- board = new Board (x + image->w () / 2 - board->image ->w () / 2 , y);
17-
18- int led_offset = 30 ;
19- int led_x = x + image->w () / 2 - (leds->led_on ->w () * 8 + 7 * (led_offset - leds->led_on ->w ())) / 2 ;
20- leds = new LEDs (led_x, y + LEDS_VERTICAL_OFFSET, led_offset);
21- }
12+ FPGA::FPGA (int x, int y) : Fl_Widget(x, y, image->w (), image->h()) { }
2213
2314void FPGA::draw () {
24- if (damage () == 0x80 ) {
25- image->draw (x (), y ());
26- }
27- if (damage () & 1 ) {
28- leds->redraw ();
29- board->damage (1 );
30- disp->redraw ();
31- }
15+ image->draw (x (), y ());
16+ // board->damage(1);
3217}
3318
3419Fl_PNG_Image * Board::image = new Fl_PNG_Image(" Assets/Board.png" );
35- Board::Board (int x, int y) :
36- swis(new SWIs(x + image->w () / 2 - (8 * SWIs::swi_on->w () + 7 * (SWIS_OFFSET - SWIs::swi_on->w ()) + SegmentsDisplay::base->w()) / 2,
37- y + image->h() / 2 - SWIs::swi_on->h() / 2, SWIS_OFFSET)),
38- segments(new SegmentsDisplay(x + image->w () / 2 - segments->base->w() / 2, y + image->h() / 2 - segments->base->h() / 2)),
39- Fl_Widget(x, y, image->w (), image->h()) {
40-
41- }
20+ Board::Board (int x, int y) : Fl_Widget(x, y, image->w (), image->h()) { }
4221
4322void Board::draw () {
4423 if (damage () & 0x80 ) {
@@ -47,9 +26,7 @@ void Board::draw() {
4726 }
4827 if (damage () & 1 ) {
4928 image->draw (x (), y ());
50- // image->draw(swis->x(), swis->y(), swis->w(), swis->h(), x() + swis->x(), y() + swis->y());
5129 swis->redraw ();
52- // image->draw(segments->x(), segments->y(), segments->w(), segments->h(), x() + segments->x(), y() + segments->y());
5330 segments->redraw ();
5431 }
5532}
@@ -132,7 +109,27 @@ void init_gui(int argc, char** argv) {
132109 int window_height = FPGA::image->h ();;
133110 window = new Fl_Window (Fl::w () / 2 - window_width / 2 , Fl::h () / 2 - window_height / 2 , window_width, window_height, " Labarc FPGA Simulator" );
134111
112+ // Instance FPGA
135113 fpga = new FPGA (0 , 0 );
114+
115+ // Instance upper board of FPGA
116+ board = new Board (fpga->x () + FPGA::image->w () / 2 - Board::image->w () / 2 , fpga->y ());
117+
118+ // Instance SWITCHES
119+ swis = new SWIs (board->x () + Board::image->w () / 2 - (8 * SWIs::swi_on->w () + 7 * (SWIS_OFFSET - SWIs::swi_on->w ()) + SegmentsDisplay::base->w ()) / 2 ,
120+ board->y () + Board::image->h () / 2 - SWIs::swi_on->h () / 2 , SWIS_OFFSET);
121+
122+ // Instance 7-segment display
123+ segments = new SegmentsDisplay (board->x () + Board::image->w () / 2 - SegmentsDisplay::base->w () / 2 , board->y () + Board::image->h () / 2 - SegmentsDisplay::base->h () / 2 );
124+
125+ // Instance LED's
126+ int led_offset = 30 ;
127+ int led_x = fpga->x () + fpga->image ->w () / 2 - (LEDs::led_on->w () * 8 + 7 * (led_offset - LEDs::led_on->w ())) / 2 ;
128+ leds = new LEDs (led_x, fpga->y () + LEDS_VERTICAL_OFFSET, led_offset);
129+
130+ // Instance display
131+ disp = new display (fpga->x () + FPGA::image->w () / 2 , fpga->y () + FPGA::image->h () / 2 );
132+ disp->position (fpga->x () + FPGA::image->w () / 2 - disp->w () / 2 , fpga->y () + FPGA::image->h () / 2 );
136133
137134 int i=0 ;
138135 do { // search for an existin mono-space font
0 commit comments