diff --git a/README.md b/README.md index b10958bc7131ba2bbc3d21fe19886b1800365a82..50b3b3e93bb669746ac099e53348f02e87c00f01 100644 --- a/README.md +++ b/README.md @@ -514,7 +514,6 @@ Represents a rectangular block. Scaled down version of the previous `Block`, opt - **Notes**: - **Private Function Members** N/A @@ -540,68 +539,305 @@ Todo ### EventLogger ([event_logger.hpp](include/event_logger.hpp), [event_logger.cpp](src/event_logger.cpp)) **Description** -Todo +Logs events directly from the `Toolbox` and sorts them by type in 16-deep circular buffers. Used exclusively for debugging. **Usage** -Todo +- Construct object +- Once the events are collected in the `Toolbox`, call `push_events` +- Convert `Pevent`s to strings using `ptos` **Constructors and Destructors** -Todo +- `EventLogger()` +- `EventLogger(const EventLogger&)` **Public Function Members** -Todo +- `void push_events(Toolbox&)` + + - **Description**: + + Catch events from `Toolbox` + + - **Preconditions**: + + New events have been captured by the `Toolbox` + + - **Postconditions**: + + The events have been sorted into their corresponding circular buffer + + - **Notes**: + + N/A + + +**Non-Member Functions** + +- `std::string ptos(const Pevent&, const Toolbox&)` + + - **Description**: + + Convert a `Pevent` to a `std::string`. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Returns a `std::string` that describes the `Pevent`. + + - **Notes**: + + The `Toolbox` argument is used for coordinate transformation. + **Private Function Members** -Todo +N/A **Public Data Members** -Todo +- `unsigned i_down, i_up, i_move, i_other` + + Index where next event is to be inserted. + +- `std::array<Pevent, 16> events_down` + + Events of down-type. + +- `std::array<Pevent, 16> events_up` + + Events of up-type. + +- `std::array<Pevent, 16> events_move` + + Events of move-type. + +- `std::array<Pevent, 16> events_other` + + Events of other-type. + **Private Data Members** -Todo +N/A **Notes** -Todo +N/A ### GuiHandler ([gui_handler.hpp](include/gui_handler.hpp), [gui_handler.cpp](src/gui_handler.cpp)) **Description** -Todo +Draws and controls all functionality related to the GUI. **Usage** -Todo +- Construct object with fraction of screen occupied by the gui +- Call `init` with a `Toolbox` that has a fully initialized `Infrastructure` +- In each frame, call + - `update` to queue drawing and update state + - `render` to draw the GUI before swapping screen buffers **Constructors and Destructors** -Todo +- `GuiHandler(float)` **Public Function Members** -Todo +- `void init(Toolbox& tb, const std::string path_img, const std::string path_ttf)` + + - **Description**: + + Initialize all GUI related infrastructure + + - **Preconditions**: + + Fully setup `Toolbox` + + - **Postconditions**: + + Fonts and images have been loaded, ImGui is fully initialized. + + - **Notes**: + + + +- `void update(Toolbox& tb)` + + - **Description**: + + Update the GUI + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Tasks performed: + - Check if application has to quit and handle this + - Check if there is a new finger that controls the GUI, or if the controlling finger was released + - Handle any input to the GUI, pass it on to ImGui for processing + - Construct the GUI + + - **Notes**: + + N/A + +- `void render(Toolbox& tb)` + + - **Description**: + + Render the GUI to the screenbuffer. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + The GUI is drawn on the screenbuffer. + + - **Notes**: + + N/A + **Private Function Members** -Todo +- `bool isInGuiWindow_(const Pevent&) const` + + - **Description**: + + Check if a `Pevent` is within the GUI window. + + - **Preconditions**: + + N/A + + - **Postconditions**: + + Returns `true` if the `Pevent` is within the GUI window, `false` else. + + - **Notes**: + + N/A + +- `void draw_gui_(Toolbox& tb)` + + - **Description**: + + Construct a semi-old version of the GUI + + - **Preconditions**: + + All resources have been loaded + + - **Postconditions**: + + N/A + + - **Notes**: + + N/A + +- `void draw_gui_ft_(Toolbox& tb)` + + - **Description**: + + Construct the GUI used at FocusTerra + + - **Preconditions**: + + All resources have been loaded. + + - **Postconditions**: + + N/A + + - **Notes**: + + N/A + +- `void draw_old_gui_(Toolbox& tb)` + + - **Description**: + + Construct the old GUI. + + - **Preconditions**: + + All resources have been loaded + + - **Postconditions**: + + N/A + + - **Notes**: + + N/A + +- `void load_button_textures_(const std::string path)` + + - **Description**: + + Load all necessary images into textures. + + - **Preconditions**: + + All images can be found in `path`, and they all have the correct format. + + - **Postconditions**: + + All images have been uploaded to the GPU as textures and can be accessed with the corresponding private members `btex_*_*`. + + - **Notes**: + + N/A + +- `void load_image_to_texture_(const std::string file, GLuint& texture)` + + - **Description**: + + Load an image (rgba) from file into an OpenGL texture using stbi. + + - **Preconditions**: + + The target image has format RGBA + + - **Postconditions**: + + The image has been uploaded to the GPU as a texture, and its handle has been copied into the address specified by `texture` + + - **Notes**: + + + **Public Data Members** -Todo +N/A **Private Data Members** -Todo +- `float gui_pos_`: Portion of screen occupied by GUI +- `ImGuiIO io_`: ImGui IO object +- `SDL_Event next_event_`: Next event for event chains that span several frames (raising, lowering finger) +- `SDL_FingerID fingerID_`: Finger currently controlling the GUI +- `SDL_TouchID deviceID_`: ID of the currently connected touch device (read: touchscreen) +- `bool lowering_finger_`: Are we in the event chain of lowering a finger? +- `bool raising_finger_`: Are we in the event chain of raising a finger? +- `ImFont* font_`: Font used by ImGui +- `GLuint btex_*_on, btex_*_off`: 12 OpenGL texture handles corresponding to images drawn in GUI +- `EventLogger evlog`: EventLogger, only present while debugging **Notes** -Todo +N/A ### Infrastructure ([infrastructure.hpp](include/infrastructure.hpp), [infrastructure.cpp](src/infrastructure.cpp)) **Description**