Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Base class for all applications. More...
#include <geogram_gfx/gui/application.h>
Public Member Functions | |
Application (const std::string &name) | |
Application constructor. More... | |
virtual | ~Application () |
Application destructor. | |
const std::string & | name () const |
Gets the name of this application. More... | |
virtual void | start (int argc=0, char **argv=nullptr) |
Starts the main event loop of the application. More... | |
virtual void | stop () |
Stops the application. | |
const std::string & | get_style () const |
Gets the style. More... | |
virtual void | set_style (const std::string &value) |
Sets the style of the application. More... | |
void | set_font_size (index_t value) |
Sets the font size. More... | |
index_t | get_font_size () const |
Gets the font size. More... | |
virtual void | update () |
Indicates that the main window should be redrawn. | |
void | draw_dock_space () |
Draws a dockspace that fills the current window. | |
void | lock_updates () |
Lock updates. More... | |
void | unlock_updates () |
Unlock updates. | |
virtual void | draw () |
Redraws the main window. More... | |
double | scaling () const |
Gets the global scaling to be applied to all GUI elements. More... | |
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. More... | |
void | set_windowed_mode (index_t w=0, index_t h=0) |
Sets windowed mode. More... | |
void | list_video_modes () |
Lists the video modes that can be used for set_full_screen_mode() More... | |
void | iconify () |
Iconifies this application. | |
void | restore () |
Restores this application. | |
void | set_gui_state (std::string x) |
Sets the gui state. More... | |
std::string | get_gui_state () const |
Gets the gui state. More... | |
void | set_full_screen (bool x) |
Sets full-screen mode. More... | |
bool | get_full_screen () const |
Tests whether this application is in full-screen mode. More... | |
index_t | get_width () const |
Gets the width of the window. More... | |
index_t | get_height () const |
Gets the height of the window. More... | |
index_t | get_frame_buffer_width () const |
Gets the width of the window. More... | |
index_t | get_frame_buffer_height () const |
Gets the height of the window. More... | |
void | set_accept_drops (bool value) |
Sets whether drag and drop events should be taken into account. More... | |
bool | get_accept_drops () const |
Tests whether drag and drop events are taken into account. More... | |
void | set_window_icon (Image *image) |
Sets the icon of the window. More... | |
virtual void | mouse_button_callback (int button, int action, int mods=0, int source=EVENT_SOURCE_MOUSE) |
Callback called whenenver a mouse button changed. More... | |
virtual void | scroll_callback (double xoffset, double yoffset) |
Callback called whenenver the mouse wheel is moved. More... | |
virtual void | cursor_pos_callback (double x, double y, int source=EVENT_SOURCE_MOUSE) |
Callback called whenever the mouse cursor is moved. More... | |
virtual void | drop_callback (int nb, const char **f) |
Callback called whenever files are dropped in the window. More... | |
virtual void | char_callback (unsigned int c) |
Callback called whenever a key is pushed (high level version) More... | |
virtual void | key_callback (int key, int scancode, int action, int mods) |
Callback called whenever a key is pushed (low level version) More... | |
void | restart_gui () |
Restarts the gui. More... | |
ApplicationData * | impl_data () |
Gets a pointer to the implementation-specific data. More... | |
void * | impl_window () |
Gets a pointer to the implementation-specific window. More... | |
double | hidpi_scaling () const |
MacOS non-sense. More... | |
double | pixel_ratio () const |
More MacOS non-sense. More... | |
void | reset_soft_keyboard_flag () |
Used internally. | |
const char * | key_to_string (int key) |
Converts a key to a symbolic string with the name of the key. More... | |
virtual void | draw_gui () |
This function is called when the GUI should be redisplayed. More... | |
virtual void | draw_graphics () |
This function is called when the 3d content should be redisplayed. More... | |
virtual void | pre_draw () |
This function is called before starting drawing operations. More... | |
virtual void | post_draw () |
This function is called after all drawing operations. More... | |
virtual bool | needs_to_redraw () const |
Tests whether the window needs to be redrawn. More... | |
virtual void | create_window () |
Creates the window using GLFW. | |
virtual void | delete_window () |
Deletes the window created by GLFW. | |
virtual void | resize (index_t w, index_t h, index_t fb_w, index_t fb_h) |
Called whenever window size changes. More... | |
virtual void | one_frame () |
Draws one frame. More... | |
virtual void | main_loop () |
Enters the main application loop. More... | |
virtual void | GL_initialize () |
Initializes OpenGL and GLUP objects. | |
virtual void | GL_terminate () |
Deallocates OpenGL and GLUP objects. | |
virtual void | ImGui_initialize () |
Initializes the ImGui library. | |
virtual void | ImGui_load_fonts () |
Loads the fonts in ImGui. | |
virtual void | ImGui_terminate () |
Deallocates objects used by the ImGui library. | |
virtual void | ImGui_new_frame () |
Notifies ImGui that a new frame has just started. | |
virtual void | geogram_initialize (int argc, char **argv) |
void | callbacks_initialize () |
Initializes the callbacks if not already initialized. | |
const std::vector< std::string > & | filenames () const |
Gets all the filenames specified on the command line. More... | |
bool | animate () const |
bool * | animate_ptr () |
void | start_animation () |
void | stop_animation () |
Static Public Member Functions | |
static Application * | instance () |
Gets the instance. More... | |
static std::string | get_styles () |
Gets the possible styles. More... | |
Protected Attributes | |
bool | ImGui_firsttime_init_ |
bool | menubar_visible_ |
bool | phone_screen_ |
bool | soft_keyboard_visible_ |
Base class for all applications.
This class handles the cross-platform creation of a window, OpenGL context, and ImGui. Client code may use SimpleApplication instead.
Definition at line 66 of file application.h.
GEO::Application::Application | ( | const std::string & | name | ) |
Application constructor.
[in] | name | the name of the application |
|
virtual |
Callback called whenever a key is pushed (high level version)
[in] | c | the ASCII code of the character that corresponds to the pushed key. |
Reimplemented in GEO::SimpleApplication.
|
virtual |
Callback called whenever the mouse cursor is moved.
[in] | x,y | the new position of the mouse cursor. |
[in] | source | the event source (one of EVENT_SOURCE_MOUSE, EVENT_SOURCE_FINGER, EVENT_SOURCE_STYLUS) |
Reimplemented in GEO::SimpleApplication.
|
virtual |
Redraws the main window.
This function is called by commands that animate objects during computation, by the progress bar and by console output.
|
virtual |
This function is called when the 3d content should be redisplayed.
This function is meant to be overloaded by subclasses. default implementation does nothing.
Reimplemented in GEO::SimpleApplication.
|
virtual |
This function is called when the GUI should be redisplayed.
This function is meant to be overloaded by subclasses. default implementation does nothing.
Reimplemented in GEO::SimpleApplication.
|
virtual |
Callback called whenever files are dropped in the window.
[in] | nb | number of files. |
[in] | f | the array of file names. |
Reimplemented in GEO::SimpleApplication.
|
inline |
Gets all the filenames specified on the command line.
Definition at line 548 of file application.h.
|
inline |
Tests whether drag and drop events are taken into account.
true | if drag and drop events are taken into account |
false | otherwise |
Definition at line 308 of file application.h.
|
inline |
|
inline |
Gets the height of the window.
Definition at line 288 of file application.h.
|
inline |
Gets the width of the window.
Definition at line 280 of file application.h.
bool GEO::Application::get_full_screen | ( | ) | const |
Tests whether this application is in full-screen mode.
true | if full-screen mode is used. |
false | if windowed mode is used. |
std::string GEO::Application::get_gui_state | ( | ) | const |
Gets the gui state.
|
inline |
Gets the height of the window.
Definition at line 272 of file application.h.
|
inline |
Gets the style.
Definition at line 115 of file application.h.
|
static |
Gets the possible styles.
|
inline |
Gets the width of the window.
Definition at line 264 of file application.h.
|
inline |
MacOS non-sense.
Definition at line 401 of file application.h.
|
inline |
Gets a pointer to the implementation-specific data.
For internal use only.
Definition at line 383 of file application.h.
void* GEO::Application::impl_window | ( | ) |
Gets a pointer to the implementation-specific window.
For internal use only.
|
inlinestatic |
|
virtual |
Callback called whenever a key is pushed (low level version)
[in] | key | key code (window system specific) |
[in] | scancode | scan code (window system specific) |
[in] | action | push or release (window system specific) |
[in] | mods | current key modifieds (window system specific) |
Reimplemented in GEO::SimpleApplication.
const char* GEO::Application::key_to_string | ( | int | key | ) |
Converts a key to a symbolic string with the name of the key.
[in] | key | the key. |
void GEO::Application::list_video_modes | ( | ) |
Lists the video modes that can be used for set_full_screen_mode()
The video modes are listed in the terminal.
|
inline |
Lock updates.
If this function is called, updates are ignored. It is useful when a RenderingContext operation is occuring, to prevent the Console for triggering a drawing operation.
Definition at line 164 of file application.h.
|
virtual |
Enters the main application loop.
create_window() needs to be called before. This initializes OpenGL and ImGui before the first frame is displayed.
|
virtual |
Callback called whenenver a mouse button changed.
[in] | button | the button |
[in] | action | the action (one of EVENT_ACTION_UP, EVENT_ACTION_DOWN, EVENT_ACTION_DRAG) |
[in] | mods | the current key modifiers (not implemented yet) |
[in] | source | the event source (one of EVENT_SOURCE_MOUSE, EVENT_SOURCE_FINGER, EVENT_SOURCE_STYLUS) |
Reimplemented in GEO::SimpleApplication.
|
inline |
|
virtual |
Tests whether the window needs to be redrawn.
true | if the window needs to be redrawn. |
false | if the window is up to date. |
|
virtual |
Draws one frame.
This triggers a GUI and/or a scene update as needed.
|
inline |
More MacOS non-sense.
Definition at line 413 of file application.h.
|
virtual |
This function is called after all drawing operations.
It can be used to execute queued commands.
Reimplemented in GEO::SimpleApplication.
|
virtual |
This function is called before starting drawing operations.
Some implementations use it to initialize / restore graphic objects.
Called whenever window size changes.
[in] | w,h | the new window width and height in pixels. |
[in] | fb_w,fb_h | the new framebuffer width and height in pixels. |
Called whenenver the size of the window does not match the current size.
Reimplemented in GEO::SimpleApplication.
|
inline |
Restarts the gui.
A flag is set and the gui is restarted at the next frame.
Definition at line 374 of file application.h.
double GEO::Application::scaling | ( | ) | const |
Gets the global scaling to be applied to all GUI elements.
|
virtual |
Callback called whenenver the mouse wheel is moved.
[in] | xoffset,yoffset | wheel displacement |
Reimplemented in GEO::SimpleApplication.
|
inline |
Sets whether drag and drop events should be taken into account.
[in] | value | true if drag and drop events should be taken into account, false otherwise |
Definition at line 298 of file application.h.
void GEO::Application::set_font_size | ( | index_t | value | ) |
Sets the font size.
[in] | value | the font size. |
void GEO::Application::set_full_screen | ( | bool | x | ) |
Sets full-screen mode.
[in] | x | true if full-screen mode should be used, false if windowed-mode should be used. |
void GEO::Application::set_full_screen_mode | ( | index_t | w = 0 , |
index_t | h = 0 , |
||
index_t | hz = 0 , |
||
index_t | monitor = 0 |
||
) |
Sets full-screen mode.
All arguments to zero sets default mode.
[in] | w,h | width and height in pixels |
[in] | hz | refresh rate in Hz |
[in] | monitor | the id of the monitor |
void GEO::Application::set_gui_state | ( | std::string | x | ) |
Sets the gui state.
[in] | x | a string that encodes the windows geometries and docking configuration obtained through get_gui_state() |
|
virtual |
Sets the style of the application.
[in] | value | one of Dark, Light, DarkGray, LightGray |
Reimplemented in GEO::SimpleApplication.
void GEO::Application::set_window_icon | ( | Image * | image | ) |
Sets the icon of the window.
[in] | image | a pointer to the image to be used as the icon. |
Sets windowed mode.
[in] | w,h | width and height in pixels. If zero, use current dimensions. |
|
virtual |
Starts the main event loop of the application.
[in] | argc,argv | optional command line parameters. If specified then they are used to initialize geogram, else geogram is supposed to be already initialized by caller. |
|
protected |
true if ImGui was once initialized
Definition at line 594 of file application.h.
|
protected |
true if running on a phone
Definition at line 596 of file application.h.