From 167e63926ec8b06511bc03a897731c17e4564719 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Wed, 24 Jun 2020 11:21:58 +0930 Subject: possibly fix logic bug and add options panel the option panel shows input types and output state. logic now updates when a new link is made --- MainWindow.cpp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'MainWindow.cpp') diff --git a/MainWindow.cpp b/MainWindow.cpp index ccd1b12..91fd4a4 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -111,6 +111,27 @@ MainWindow::create_ui() new FXButton(toolsFrame, "XOR", XOR_icon, this, MainWindow::ID_BUTTON_XOR, BUTTON_NORMAL|LAYOUT_FILL_X); new FXButton(toolsFrame, "XNOR", XNOR_icon, this, MainWindow::ID_BUTTON_XNOR, BUTTON_NORMAL|LAYOUT_FILL_X); new FXButton(toolsFrame, "NOT", NOT_icon, this, MainWindow::ID_BUTTON_NOT, BUTTON_NORMAL|LAYOUT_FILL_X); + + optionsFrame = new FXVerticalFrame(contents, FRAME_SUNKEN|LAYOUT_FILL_Y|LAYOUT_TOP, 0, 0, 0, 0, 10, 10, 10, 10); + new FXLabel(optionsFrame, "Options", NULL, JUSTIFY_CENTER_X|LAYOUT_FILL_X); + new FXHorizontalSeparator(optionsFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X); + + input1_frame = new FXHorizontalFrame(optionsFrame, LAYOUT_SIDE_TOP); + input2_frame = new FXHorizontalFrame(optionsFrame, LAYOUT_SIDE_TOP); + output_state_frame = new FXHorizontalFrame(optionsFrame, LAYOUT_SIDE_TOP); + + + new FXLabel(input1_frame, "Input 1: ", NULL, JUSTIFY_CENTER_X); + input_1_details = new FXLabel(input1_frame, "", NULL, JUSTIFY_CENTER_X); + input_1_details->setText("(None)"); + + new FXLabel(input2_frame, "Input 2: ", NULL, JUSTIFY_CENTER_X); + input_2_details = new FXLabel(input2_frame, "", NULL, JUSTIFY_CENTER_X); + input_2_details->setText("(None)"); + + new FXLabel(output_state_frame, "Output state: ", NULL, JUSTIFY_CENTER_X); + output_details = new FXLabel(output_state_frame, "", NULL, JUSTIFY_CENTER_X); + output_details->setText("(None)"); } void @@ -278,6 +299,20 @@ MainWindow::draw() } + /* update options panel */ + if (selected_gate) + { + input_1_details->setText((selected_gate->get_input_gate1() ? selected_gate->get_input_gate1()->get_output_type_text().c_str() : "(None)")); + input_2_details->setText((selected_gate->get_input_gate2() ? selected_gate->get_input_gate2()->get_output_type_text().c_str() : "(None)")); + output_details->setText(selected_gate->get_output_state() ? "ON" : "OFF"); + } + else + { + input_1_details->setText("(None)"); + input_2_details->setText("(None)"); + output_details->setText("(None)"); + } + FXDCWindow dc_canvas(canvas); dc_canvas.drawImage(canvas_image, 0, 0); } @@ -356,6 +391,7 @@ MainWindow::on_left_mouse_down(FXObject*, FXSelector, void *ptr) { dragging_link = true; } + gate->update_state(); } else { @@ -407,7 +443,8 @@ MainWindow::on_left_mouse_up(FXObject*, FXSelector, void *ptr) gate->set_input_gate1(selected_gate); } } - selected_gate->set_output_gate(gate); + //selected_gate->set_output_gate(gate); + gate->update_state(); } dragging_link = false; } @@ -428,6 +465,7 @@ MainWindow::on_right_mouse_down(FXObject*, FXSelector, void *ptr) gate->set_state(!gate->get_output_state()); } } + gate->update_state(); draw(); return 1; -- cgit v1.2.3