/* src/example1.cpp -- C++ version of an example application that shows how to use the various widget classes. For a Python implementation, see '../python/example1.py'. NanoGUI was developed by Wenzel Jakob . The widget drawing code is based on the NanoVG demo application by Mikko Mononen. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.txt file. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define STB_IMAGE_STATIC #define STB_IMAGE_IMPLEMENTATION #if defined(_MSC_VER) # pragma warning (disable: 4505) // don't warn about dead code in stb_image.h #elif defined(__GNUC__) # pragma GCC diagnostic ignored "-Wunused-function" #endif #include #include "grbl.h" #include #include "grbl_communication.h" #include "machine.h" using namespace nanogui; grbl::machine cnc{}; class SenderApp : public Screen { public: Window *window; Window *left_window; Window *right_window; grbl::jog_state jog; SenderApp() : Screen(Vector2i(1024, 768), "GRBL Sender") { inc_ref(); window = new Window(this, "Button demo"); // window->set_fixed_height(Screen::size().y()); window->set_position(Vector2i(0, 0)); window->set_layout(new GridLayout(nanogui::Orientation::Horizontal, 2, Alignment::Fill, 0, 0)); window->set_size(Screen::size()); left_window = new Window(window, "Left sidebar"); left_window->set_modal(true); right_window = new Window(window, "Right sidebar"); right_window->set_modal(true); left_window->set_layout(new GroupLayout()); // No need to store a pointer, the data structure will be automatically // freed when the parent window is deleted new Label(left_window, "Push buttons", "sans-bold"); Button *b = new Button(left_window, "Plain button"); b->set_callback([&] { auto path = file_dialog( {{"nc", "G-Code files"}, {"ngc", "G-Code files"}}, false); grbl::program pgm{path}; if (pgm.is_loaded) { cnc.run_program(pgm); } }); b->set_tooltip("short tooltip"); /* Alternative construction notation using variadic template */ b = left_window->add