mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 08:09:19 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
115
uilayer.h
115
uilayer.h
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
@@ -5,54 +14,78 @@
|
||||
|
||||
// GuiLayer -- basic user interface class. draws requested information on top of openGL screen
|
||||
|
||||
struct ui_panel {
|
||||
class ui_panel {
|
||||
|
||||
public:
|
||||
// constructor
|
||||
ui_panel( std::string const &Identifier, bool const Isopen );
|
||||
// methods
|
||||
virtual void update() {};
|
||||
virtual void render();
|
||||
// temporary access
|
||||
// types
|
||||
struct text_line {
|
||||
|
||||
std::string data;
|
||||
glm::vec4 color;
|
||||
|
||||
text_line( std::string const &Data, glm::vec4 const &Color):
|
||||
data(Data), color(Color)
|
||||
text_line( std::string const &Data, glm::vec4 const &Color)
|
||||
: data(Data), color(Color)
|
||||
{}
|
||||
};
|
||||
|
||||
ui_panel( const int X, const int Y):
|
||||
origin_x(X), origin_y(Y)
|
||||
{}
|
||||
|
||||
bool enabled = true;
|
||||
// members
|
||||
std::string title;
|
||||
bool is_open;
|
||||
glm::ivec2 size { -1, -1 };
|
||||
glm::ivec2 size_min { -1, -1 };
|
||||
glm::ivec2 size_max { -1, -1 };
|
||||
std::deque<text_line> text_lines;
|
||||
int origin_x;
|
||||
int origin_y;
|
||||
|
||||
protected:
|
||||
// members
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class ui_layer {
|
||||
|
||||
public:
|
||||
// parameters:
|
||||
|
||||
// constructors:
|
||||
// constructors
|
||||
ui_layer() = default;
|
||||
// destructor:
|
||||
~ui_layer();
|
||||
// destructor
|
||||
virtual ~ui_layer();
|
||||
|
||||
// methods:
|
||||
// methods
|
||||
static
|
||||
bool
|
||||
init( GLFWwindow *Window );
|
||||
// assign texturing hardware unit
|
||||
static
|
||||
void
|
||||
set_unit( GLint const Textureunit ) { m_textureunit = Textureunit; }
|
||||
static
|
||||
void
|
||||
shutdown();
|
||||
// potentially processes provided input key. returns: true if the input was processed, false otherwise
|
||||
virtual
|
||||
bool
|
||||
on_key( int const Key, int const Action );
|
||||
// potentially processes provided mouse movement. returns: true if the input was processed, false otherwise
|
||||
virtual
|
||||
bool
|
||||
on_cursor_pos( double const Horizontal, double const Vertical );
|
||||
// potentially processes provided mouse button. returns: true if the input was processed, false otherwise
|
||||
virtual
|
||||
bool
|
||||
on_mouse_button( int const Button, int const Action );
|
||||
// updates state of UI elements
|
||||
virtual
|
||||
void
|
||||
update();
|
||||
// draws requested UI elements
|
||||
void
|
||||
render();
|
||||
//
|
||||
static
|
||||
void
|
||||
set_cursor( int const Mode );
|
||||
// stores operation progress
|
||||
@@ -68,14 +101,30 @@ public:
|
||||
void
|
||||
set_tooltip( std::string const &Tooltip ) { m_tooltip = Tooltip; }
|
||||
void
|
||||
clear_texts() { m_panels.clear(); }
|
||||
clear_panels() { m_panels.clear(); }
|
||||
void
|
||||
push_back( std::shared_ptr<ui_panel> Panel ) { m_panels.emplace_back( Panel ); }
|
||||
push_back( ui_panel *Panel ) { m_panels.emplace_back( Panel ); }
|
||||
|
||||
// members:
|
||||
// callback functions for imgui input
|
||||
// returns true if input is consumed
|
||||
static bool key_callback(int key, int scancode, int action, int mods);
|
||||
static bool char_callback(unsigned int c);
|
||||
static bool scroll_callback(double xoffset, double yoffset);
|
||||
static bool mouse_button_callback(int button, int action, int mods);
|
||||
|
||||
|
||||
protected:
|
||||
// members
|
||||
static GLFWwindow *m_window;
|
||||
static ImGuiIO *m_imguiio;
|
||||
static bool m_cursorvisible;
|
||||
|
||||
private:
|
||||
// methods:
|
||||
// methods
|
||||
// render() subclass details
|
||||
virtual
|
||||
void
|
||||
render_() {};
|
||||
// draws background quad with specified earlier texture
|
||||
void
|
||||
render_background();
|
||||
@@ -88,36 +137,20 @@ private:
|
||||
render_panels();
|
||||
void
|
||||
render_tooltip();
|
||||
// prints specified text, using display lists font
|
||||
void
|
||||
print( std::string const &Text );
|
||||
// draws a quad between coordinates x,y and z,w with uv-coordinates spanning 0-1
|
||||
void
|
||||
quad( glm::vec4 const &Coordinates, glm::vec4 const &Color );
|
||||
|
||||
// members:
|
||||
GLFWwindow *m_window { nullptr };
|
||||
GLint m_textureunit{ GL_TEXTURE0 };
|
||||
GLuint m_fontbase { (GLuint)-1 }; // numer DL dla znaków w napisach
|
||||
// members
|
||||
static GLint m_textureunit;
|
||||
|
||||
// progress bar config. TODO: put these together into an object
|
||||
float m_progress { 0.0f }; // percentage of filled progres bar, to indicate lengthy operations.
|
||||
float m_subtaskprogress{ 0.0f }; // percentage of filled progres bar, to indicate lengthy operations.
|
||||
std::string m_progresstext; // label placed over the progress bar
|
||||
bool m_progressbottom { false }; // location of the progress bar
|
||||
bool m_progressbottom { true }; // location of the progress bar
|
||||
|
||||
texture_handle m_background { null_handle }; // path to texture used as the background. size depends on mAspect.
|
||||
GLuint m_texture { 0 };
|
||||
std::vector<std::shared_ptr<ui_panel> > m_panels;
|
||||
std::vector<ui_panel *> m_panels;
|
||||
std::string m_tooltip;
|
||||
// TODO: clean these legacy components up
|
||||
std::shared_ptr<ui_panel> UIHeader; // header ui panel
|
||||
std::shared_ptr<ui_panel> UITable; // schedule or scan table
|
||||
std::shared_ptr<ui_panel> UITranscripts; // voice transcripts
|
||||
int tprev; // poprzedni czas
|
||||
double VelPrev; // poprzednia prędkość
|
||||
double Acc; // przyspieszenie styczne
|
||||
bool m_cursorvisible { false };
|
||||
};
|
||||
|
||||
extern ui_layer UILayer;
|
||||
|
||||
Reference in New Issue
Block a user