]> code.bitgloo.com Git - clyne/stmdsp.git/commitdiff
debug flags; rendering with timer
authorClyne Sullivan <clyne@bitgloo.com>
Sat, 13 Jun 2020 16:25:58 +0000 (12:25 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Sat, 13 Jun 2020 16:25:58 +0000 (12:25 -0400)
gui/Makefile
gui/wxmain.hpp

index 7cb0315ffaef7058cb51b869b00f938ea8ecc3f6..a53d4129e71f84eef8a848b37387a141d7434dc1 100644 (file)
@@ -1,5 +1,5 @@
 CXX = g++-10
-CXXFLAGS = --std=c++20 \
+CXXFLAGS = --std=c++20 -ggdb -Og \
                   -Wall -Wextra -pedantic \
                   -Wno-deprecated-copy \
                   $(shell wx-config --cxxflags)
index 974affb76d6a53b2b2b902934b0e1bd7f213e3fd..7832bdb52ebb55c2f6bf57b1acbfa9428aecf401 100644 (file)
@@ -5,14 +5,18 @@
 #include <wx/dcclient.h>
 #include <wx/frame.h>
 #include <wx/stattext.h>
+#include <wx/timer.h>
 
 class MainFrame : public wxFrame
 {
     enum Id {
         Welcome = 1,
-        Single
+        Single,
+        RenderTimer
     };
 
+    bool m_is_rendering = false;
+    wxTimer *m_render_timer = nullptr;
     int m_radius = 10;
 
     const wxRect m_clipping_region = {20, 100, 600, 360};
@@ -22,9 +26,11 @@ public:
     {
         new wxStaticText(this, Id::Welcome, "Welcome to the GUI.", wxPoint(20, 20));
         new wxButton(this, Id::Single, "Single", wxPoint(20, 60));
+        m_render_timer = new wxTimer(this, Id::RenderTimer);
 
         Bind(wxEVT_BUTTON, &MainFrame::onSinglePressed, this, Id::Single);
         Bind(wxEVT_PAINT, &MainFrame::onPaint, this, wxID_ANY);
+        Bind(wxEVT_TIMER, &MainFrame::onRenderTimer, this, Id::RenderTimer);
     }
 
     void onPaint([[maybe_unused]] wxPaintEvent& pe) {
@@ -41,12 +47,22 @@ public:
 
     void onSinglePressed(wxCommandEvent& ce) {
         auto button = dynamic_cast<wxButton *>(ce.GetEventObject());
-        button->SetLabel("Nice");
+
+        if (!m_render_timer->IsRunning()) {
+            m_render_timer->Start(100);
+            button->SetLabel("Stop");
+        } else {
+            m_render_timer->Stop();
+            button->SetLabel("Single");
+        }
+    }
+
+    void onRenderTimer([[maybe_unused]] wxTimerEvent& te) {
         updateDrawing();
     }
 
     void updateDrawing() {
-        m_radius += 10;
+        m_radius++;
         this->RefreshRect(m_clipping_region);
     }
 };