vpr: Add pause button to GUI
Also partially fixes save/proceed button sizes.
diff --git a/vpr/main.ui b/vpr/main.ui
index cf856fe..5b9d651 100644
--- a/vpr/main.ui
+++ b/vpr/main.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="MainWindow">
@@ -9,6 +9,9 @@
<property name="default_width">800</property>
<property name="default_height">600</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkGrid" id="OuterGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -22,7 +25,7 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">7</property>
+ <property name="width">4</property>
<property name="height">3</property>
</packing>
</child>
@@ -39,102 +42,25 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">2</property>
- <property name="height">1</property>
+ <property name="top_attach">1</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
+ <object class="GtkButton" id="ZoomFitButton">
+ <property name="label" translatable="yes">Zoom Fit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
</child>
</object>
<packing>
- <property name="left_attach">7</property>
+ <property name="left_attach">4</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="ZoomFitButton">
- <property name="label">gtk-zoom-fit</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="left_attach">7</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -146,8 +72,7 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
- <property name="width">7</property>
- <property name="height">1</property>
+ <property name="width">4</property>
</packing>
</child>
<child>
@@ -159,8 +84,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -168,19 +91,17 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">search</property>
- <property name="halign">start</property>
<property name="primary_icon_stock">gtk-find</property>
<property name="placeholder_text" translatable="yes">Search...</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="Search">
+ <property name="label" translatable="yes">Search</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -188,40 +109,55 @@
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="SaveGraphics">
- <property name="label">gtk-save</property>
+ <object class="GtkGrid" id="ControlGrid">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton" id="ProceedButton">
+ <property name="label" translatable="yes">Proceed</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image_position">right</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="SaveGraphics">
+ <property name="label" translatable="yes">Save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image_position">right</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="PauseButton">
+ <property name="label" translatable="yes">Pause</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image_position">right</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="left_attach">7</property>
- <property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="ProceedButton">
- <property name="label">Proceed</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- <property name="image_position">right</property>
- </object>
- <packing>
- <property name="left_attach">7</property>
+ <property name="left_attach">4</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -236,9 +172,6 @@
<child>
<placeholder/>
</child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
</object>
diff --git a/vpr/src/draw/draw.cpp b/vpr/src/draw/draw.cpp
index 2430c8b..1e09950 100644
--- a/vpr/src/draw/draw.cpp
+++ b/vpr/src/draw/draw.cpp
@@ -143,6 +143,7 @@
void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path(ezgl::application* app, bool is_new_window);
void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/);
void setup_default_ezgl_callbacks(ezgl::application* app);
+void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
/************************** File Scope Variables ****************************/
@@ -278,7 +279,9 @@
/* function below intializes the interface window with a set of buttons and links
* signals to corresponding functions for situation where the window is opened from
* NO_PICTURE_to_PLACEMENT */
-void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool /*is_new_window*/) {
+void initial_setup_NO_PICTURE_to_PLACEMENT(ezgl::application* app, bool is_new_window) {
+ if (!is_new_window) return;
+
//button to enter window_mode, created in main.ui
GtkButton* window = (GtkButton*)app->get_object("Window");
gtk_button_set_label(window, "Window");
@@ -352,7 +355,9 @@
/* function below intializes the interface window with a set of buttons and links
* signals to corresponding functions for situation where the window is opened from
* NO_PICTURE_to_ROUTING */
-void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool /*is_new_window*/) {
+void initial_setup_NO_PICTURE_to_ROUTING(ezgl::application* app, bool is_new_window) {
+ if (!is_new_window) return;
+
GtkButton* window = (GtkButton*)app->get_object("Window");
gtk_button_set_label(window, "Window");
g_signal_connect(window, "clicked", G_CALLBACK(toggle_window_mode), app);
@@ -407,11 +412,10 @@
ezgl::set_disable_event_loop(false);
//Has the user asked us to pause at the next screen updated?
- bool forced_pause = g_vpr_ctx.forced_pause();
- if (int(priority) >= draw_state->gr_automode || forced_pause) {
- if (forced_pause) {
- VTR_LOG("Starting interactive graphics (due to user interrupt)\n");
- g_vpr_ctx.set_forced_pause(false); //Reset pause flag
+ if (int(priority) >= draw_state->gr_automode || draw_state->forced_pause) {
+ if (draw_state->forced_pause) {
+ VTR_LOG("Pausing in interactive graphics (user pressed 'Pause')\n");
+ draw_state->forced_pause = false; //Reset pause flag
}
vtr::strncpy(draw_state->default_message, msg, vtr::bufsize);
@@ -490,6 +494,9 @@
application.run(initial_setup_NO_PICTURE_to_ROUTING, act_on_mouse_press, act_on_mouse_move, act_on_key_press);
}
}
+ } else {
+ //No change (e.g. paused)
+ application.run(nullptr, act_on_mouse_press, act_on_mouse_move, act_on_key_press);
}
}
@@ -3716,6 +3723,16 @@
// Connect press_zoom_fit function to the Zoom-fit button
GObject* zoom_fit_button = app->get_object("ZoomFitButton");
g_signal_connect(zoom_fit_button, "clicked", G_CALLBACK(ezgl::press_zoom_fit), app);
+
+ // Connect Pause button
+ GObject* pause_button = app->get_object("PauseButton");
+ g_signal_connect(pause_button, "clicked", G_CALLBACK(set_force_pause), app);
+}
+
+void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/) {
+ t_draw_state* draw_state = get_draw_state_vars();
+
+ draw_state->forced_pause = true;
}
#endif /* NO_GRAPHICS */
diff --git a/vpr/src/draw/draw_types.h b/vpr/src/draw/draw_types.h
index 522c63d..f6e507a 100644
--- a/vpr/src/draw/draw_types.h
+++ b/vpr/src/draw/draw_types.h
@@ -178,6 +178,7 @@
const t_arch* arch_info = nullptr;
std::unique_ptr<const vtr::ColorMap> color_map = nullptr;
bool save_graphics = false;
+ bool forced_pause = false;
t_draw_state() = default;