40#ifndef H_GEOGRAM_GFX_GUI_APPLICATION_H
41#define H_GEOGRAM_GFX_GUI_APPLICATION_H
44#include <geogram_gfx/gui/events.h>
57#define GEO_APPLICATION_GLOBALS \
58 extern "C" { __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000000; }
60#define GEO_APPLICATION_GLOBALS
66 class ApplicationData;
101 const std::string&
name()
const {
112 virtual void start(
int argc=0,
char** argv=
nullptr);
183 if(nb_update_locks_ > 0) {
197 return (nb_update_locks_ > 0);
309 return frame_buffer_width_;
319 return frame_buffer_height_;
329 accept_drops_ = value;
339 return accept_drops_;
358 int button,
int action,
int mods=0,
int source=EVENT_SOURCE_MOUSE
378 double x,
double y,
int source=EVENT_SOURCE_MOUSE
402 virtual void key_callback(
int key,
int scancode,
int action,
int mods);
409 ImGui_restart_ =
true;
440 return hidpi_scaling_;
464 soft_keyboard_visible_ =
false;
580 virtual void geogram_initialize(
int argc,
char** argv);
603 bool animate()
const {
607 bool* animate_ptr() {
611 void start_animation() {
615 void stop_animation() {
624 return font_sizes_[font_id];
631 return font_global_scale_;
638 font_global_scale_ = s;
643 ApplicationData* data_;
651 std::atomic<index_t> nb_update_locks_;
654 bool ImGui_reload_font_;
655 bool ImGui_initialized_;
658 double hidpi_scaling_;
661 bool currently_drawing_gui_;
662 std::vector<std::string> filenames_;
665 float font_global_scale_;
669 bool menubar_visible_;
671 bool soft_keyboard_visible_;
673#ifdef GEO_OS_EMSCRIPTEN
674 friend void emscripten_one_frame();
#define geo_assert(x)
Verifies that a condition is met.
Base class for all applications.
void set_full_screen(bool x)
Sets full-screen mode.
virtual void main_loop()
Enters the main application loop.
index_t get_font_size() const
Gets the font size.
void restart_gui()
Restarts the gui.
double hidpi_scaling() const
MacOS non-sense.
virtual void ImGui_load_fonts()
Loads the fonts in ImGui.
void lock_updates()
Lock updates.
bool get_accept_drops() const
Tests whether drag and drop events are taken into account.
bool updates_locked() const
Tests whether graphic updates are locked.
index_t get_frame_buffer_width() const
Gets the width of the frame buffer.
float get_font_size(index_t font_id) const
void reset_soft_keyboard_flag()
Used internally.
void draw_dock_space()
Draws a dockspace that fills the current window.
static Application * instance()
Gets the instance.
virtual void mouse_button_callback(int button, int action, int mods=0, int source=EVENT_SOURCE_MOUSE)
Callback called whenenver a mouse button changed.
virtual void ImGui_terminate()
Deallocates objects used by the ImGui library.
virtual void GL_terminate()
Deallocates OpenGL and GLUP objects.
void set_accept_drops(bool value)
Sets whether drag and drop events should be taken into account.
void set_full_screen_mode(index_t w=0, index_t h=0, index_t hz=0, index_t monitor=0)
Sets full-screen mode.
void set_font_size(index_t value)
Sets the font size.
double scaling() const
Gets the global scaling to be applied to all GUI elements.
virtual void scroll_callback(double xoffset, double yoffset)
Callback called whenenver the mouse wheel is moved.
void list_video_modes()
Lists the video modes that can be used for set_full_screen_mode()
index_t get_height() const
Gets the height of the window.
index_t get_width() const
Gets the width of the window.
void unlock_updates()
Unlock updates.
void set_windowed_mode(index_t w=0, index_t h=0)
Sets windowed mode.
virtual void pre_draw()
This function is called before starting drawing operations.
void iconify()
Iconifies this application.
virtual void ImGui_initialize()
Initializes the ImGui library.
virtual void resize(index_t w, index_t h, index_t fb_w, index_t fb_h)
Called whenever window size changes.
virtual void drop_callback(int nb, const char **f)
Callback called whenever files are dropped in the window.
virtual void update()
Indicates that the main window should be redrawn.
virtual void stop()
Stops the application.
Application(const std::string &name)
Application constructor.
virtual void key_callback(int key, int scancode, int action, int mods)
Callback called whenever a key is pushed (low level version)
void callbacks_initialize()
Initializes the callbacks if not already initialized.
const std::string & get_style() const
Gets the style.
const char * key_to_string(int key)
Converts a key to a symbolic string with the name of the key.
virtual void start(int argc=0, char **argv=nullptr)
Starts the main event loop of the application.
const std::vector< std::string > & filenames() const
Gets all the filenames specified on the command line.
void set_gui_state(std::string x)
Sets the gui state.
virtual void declare_args()
Called by geogram_initialize(), right before parsing command line arguments.
double pixel_ratio() const
More MacOS non-sense.
bool ImGui_firsttime_init_
virtual void post_draw()
This function is called after all drawing operations.
virtual void create_window()
Creates the window using GLFW.
virtual void draw_gui()
This function is called when the GUI should be redisplayed.
virtual void delete_window()
Deletes the window created by GLFW.
void set_window_icon(Image *image)
Sets the icon of the window.
const std::string & name() const
Gets the name of this application.
virtual ~Application()
Application destructor.
index_t get_frame_buffer_height() const
Gets the height of the frame buffer.
void restore()
Restores this application.
ApplicationData * impl_data()
Gets a pointer to the implementation-specific data.
virtual void set_style(const std::string &value)
Sets the style of the application.
void set_font_global_scale(float s)
virtual void cursor_pos_callback(double x, double y, int source=EVENT_SOURCE_MOUSE)
Callback called whenever the mouse cursor is moved.
virtual void ImGui_new_frame()
Notifies ImGui that a new frame has just started.
float get_font_global_scale() const
virtual void GL_initialize()
Initializes OpenGL and GLUP objects.
virtual void one_frame(bool draw_GUI=true)
Draws one frame.
void * impl_window()
Gets a pointer to the implementation-specific window.
virtual bool needs_to_redraw() const
Tests whether the window needs to be redrawn.
std::string get_gui_state() const
Gets the gui state.
virtual void draw_graphics()
This function is called when the 3d content should be redisplayed.
bool get_full_screen() const
Tests whether this application is in full-screen mode.
static std::string get_styles()
Gets the possible styles.
virtual void char_callback(unsigned int c)
Callback called whenever a key is pushed (high level version)
virtual void draw()
Redraws the main window.
Vector with aligned memory allocation.
Common include file, providing basic definitions. Should be included before anything else by all head...
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.