UserInterface tracking of keyboard modifier and fullscreen.

This commit is contained in:
brunoherbelin
2020-05-16 12:18:38 +02:00
parent 20cafa388f
commit 4527d0dd1f
4 changed files with 30 additions and 11 deletions

View File

@@ -385,10 +385,17 @@ float Rendering::MonitorHeight()
return height;
}
bool Rendering::IsFullscreen ()
{
return (glfwGetWindowMonitor(main_window_) != nullptr);
}
void Rendering::ToggleFullscreen()
{
// if in fullscreen mode
if (glfwGetWindowMonitor(main_window_) != nullptr) {
if (IsFullscreen()) {
// set to window mode
glfwSetWindowMonitor( main_window_, nullptr, Settings::application.windows.front().x,
Settings::application.windows.front().y,

View File

@@ -69,6 +69,7 @@ public:
class Screenshot *CurrentScreenshot();
// request fullscreen
bool IsFullscreen ();
void ToggleFullscreen();
// get width of rendering area
float Width();

View File

@@ -203,6 +203,7 @@ void UserInterface::handleKeyboard()
// Application "CTRL +"" Shortcuts
if ( io.KeyCtrl ) {
keyboard_modifier_active = true;
if (ImGui::IsKeyPressed( GLFW_KEY_Q )) {
// Quit
@@ -240,9 +241,13 @@ void UserInterface::handleKeyboard()
}
else {
// Normal keys
keyboard_modifier_active = false;
// Action keys
if (ImGui::IsKeyPressed( GLFW_KEY_BACKSPACE ))
Mixer::manager().deleteCurrentSource();
else if (ImGui::IsKeyPressed( GLFW_KEY_GRAVE_ACCENT ))
navigator.toggleMenu();
// Application F-Keys
else if (ImGui::IsKeyPressed( GLFW_KEY_F1 ))
Mixer::manager().setCurrentView(View::MIXING);
@@ -250,10 +255,12 @@ void UserInterface::handleKeyboard()
Mixer::manager().setCurrentView(View::GEOMETRY);
else if (ImGui::IsKeyPressed( GLFW_KEY_F12 ))
Rendering::manager().ToggleFullscreen();
else if (ImGui::IsKeyPressed( GLFW_KEY_ESCAPE )){
if (Rendering::manager().IsFullscreen())
Rendering::manager().ToggleFullscreen();
}
else if (ImGui::IsKeyPressed( GLFW_KEY_PRINT_SCREEN ))
toolbox.StartScreenshot();
else if (ImGui::IsKeyPressed( GLFW_KEY_GRAVE_ACCENT ))
navigator.toggleMenu();
}
}

View File

@@ -59,7 +59,6 @@ public:
void Render();
};
// TODO: class ShaderEditor
class UserInterface
{
@@ -67,16 +66,12 @@ class UserInterface
Navigator navigator;
ToolBox toolbox;
bool keyboard_modifier_active;
bool show_about;
bool show_imgui_about;
bool show_gst_about;
bool show_opengl_about;
std::string currentTextEdit;
void handleKeyboard();
void handleMouse();
void showMenuFile();
// typedef enum {
// FILE_DIALOG_INACTIVE = 0,
@@ -109,14 +104,23 @@ public:
void Render();
// Post-loop termination
void Terminate();
//
// status querries
inline bool keyboardModifier() { return keyboard_modifier_active; }
// TODO implement the shader editor
std::string currentTextEdit;
void fillShaderEditor(std::string text);
protected:
void showMenuFile();
void RenderPreview();
void RenderMediaPlayer();
void RenderShaderEditor();
void handleKeyboard();
void handleMouse();
};