add base dialogs
This commit is contained in:
parent
44ed461df9
commit
681327e663
@ -36,7 +36,7 @@ namespace rrr
|
||||
}
|
||||
}
|
||||
|
||||
int content::get_cursor_position(TYPE_WIN type) const
|
||||
int content::get_cursor_position(TYPE_WIN type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -47,7 +47,7 @@ namespace rrr
|
||||
return cursor_position;
|
||||
break;
|
||||
case TYPE_WIN::PREVIEW:
|
||||
return 0;
|
||||
return get_preview_cursor_position();
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -28,7 +28,7 @@ namespace rrr
|
||||
void set_pwd(std::filesystem::path);
|
||||
void fill();
|
||||
files* get(TYPE_WIN);
|
||||
int get_cursor_position(TYPE_WIN) const;
|
||||
int get_cursor_position(TYPE_WIN);
|
||||
void increment_position(int);
|
||||
void navigation_right();
|
||||
void navigation_left();
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "history.hpp"
|
||||
|
||||
#include "utils/types.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
void history::on_attach()
|
||||
@ -17,11 +19,13 @@ namespace rrr::layers::gui
|
||||
|
||||
void history::gui_render()
|
||||
{
|
||||
if (!show) return;
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y));
|
||||
ImGui::SetNextWindowSize(ImVec2(width, height));
|
||||
|
||||
ImGuiStyle& st = ImGui::GetStyle();
|
||||
st.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.18f, 1.00f);
|
||||
st.Colors[ImGuiCol_WindowBg] = func::get_IMGUI_color<ImVec4>(33.f, 36.f, 46.f);
|
||||
|
||||
BEGIN_IMGUI_WIN();
|
||||
|
||||
@ -77,8 +81,19 @@ namespace rrr::layers::gui
|
||||
width = try_engine::application::get()->get_window()->width() / 3.f;
|
||||
}
|
||||
|
||||
void history::on_event(std::any e, std::any value)
|
||||
void history::on_event(std::any event_type, std::any value)
|
||||
{
|
||||
auto et = std::any_cast<types::event_type>(event_type);
|
||||
|
||||
switch (et)
|
||||
{
|
||||
case types::event_type::NAVIGATION_LEFT:
|
||||
case types::event_type::NAVIGATION_RIGHT:
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::HISTORY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void history::on_update(time t)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "try_engine/try_engine.hpp"
|
||||
#include "rrr/content/content.hpp"
|
||||
#include "rrr/utils/func.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
@ -41,8 +42,9 @@ namespace rrr::layers::gui
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFontAtlas* atlas = io.Fonts;
|
||||
ImFont* font;
|
||||
const ImVec4 dir_color = ImVec4(0.36f, 0.5f, 0.74f, 1.0f);
|
||||
const ImVec4 file_color = ImVec4(0.9f, 0.9f, 0.9f, 1.0f);
|
||||
const ImVec4 dir_color = func::get_IMGUI_color<ImVec4>(91.f, 128.f, 191.f);
|
||||
const ImVec4 file_color = func::get_IMGUI_color<ImVec4>(186.f, 186.f, 186.f);
|
||||
const ImVec4 link_color = func::get_IMGUI_color<ImVec4>(51.f, 95.f, 165.f);
|
||||
|
||||
private:
|
||||
void resize();
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "navigation.hpp"
|
||||
|
||||
#include "try_engine/event/event_classificator.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include "logger/logger.hpp"
|
||||
@ -20,11 +21,13 @@ namespace rrr::layers::gui
|
||||
|
||||
void navigation::gui_render()
|
||||
{
|
||||
if (!show) return;
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y));
|
||||
ImGui::SetNextWindowSize(ImVec2(width, height));
|
||||
|
||||
ImGuiStyle& st = ImGui::GetStyle();
|
||||
st.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.18f, 1.00f);
|
||||
st.Colors[ImGuiCol_WindowBg] = func::get_IMGUI_color<ImVec4>(33.f, 36.f, 46.f);
|
||||
|
||||
BEGIN_IMGUI_WIN();
|
||||
|
||||
@ -46,6 +49,7 @@ namespace rrr::layers::gui
|
||||
ImGui::PushFont(font);
|
||||
ImGui::TextUnformatted(">");
|
||||
ImGui::SameLine(22.f);
|
||||
current_file = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -63,14 +67,6 @@ namespace rrr::layers::gui
|
||||
END_IMGUI_WIN();
|
||||
}
|
||||
|
||||
// HERE начинаем тут
|
||||
// нужно сделать навигацию влево и вправо
|
||||
// в прошлыq раз тут сделали стилизацию по типу файлов (скрыты ссылки и тп)
|
||||
// и затем все это нужно распространить на другие части (history, preview)
|
||||
// когда делаем навигацию влево и вправо то не меняется центральный контент
|
||||
// почему то у нас отличаются данные контента в файле content/navigation от
|
||||
// content/history и content/preview
|
||||
// там map<path, string> а у всех других файл. зачем это нужно???
|
||||
void navigation::push_style(file& f)
|
||||
{
|
||||
switch (f.type)
|
||||
@ -116,11 +112,42 @@ namespace rrr::layers::gui
|
||||
resize();
|
||||
|
||||
if (e.get_name() == try_engine::system_event::classificator::KEY_PRESSED())
|
||||
set_selected(e);
|
||||
pressed(e);
|
||||
|
||||
if (e.get_name() == try_engine::system_event::classificator::KEY_RELEASED())
|
||||
released(e);
|
||||
}
|
||||
|
||||
void navigation::on_event(std::any e, std::any value)
|
||||
void navigation::on_event(std::any event_type, std::any value)
|
||||
{
|
||||
auto et = std::any_cast<types::event_type>(event_type);
|
||||
|
||||
switch (et)
|
||||
{
|
||||
case types::event_type::FREEZE_BROWSER_ACTION:
|
||||
freeze = true;
|
||||
break;
|
||||
case types::event_type::UNFREEZE_BROWSER_ACTION:
|
||||
freeze = false;
|
||||
break;
|
||||
case types::event_type::DELETE_CURRENT_FILE:
|
||||
freeze = false;
|
||||
hack::log()("DELETE FILE");
|
||||
// HERE
|
||||
// реализовать удаление после создания
|
||||
break;
|
||||
case types::event_type::CREATE_FILE:
|
||||
{
|
||||
freeze = false;
|
||||
auto filename = std::any_cast<std::string>(value);
|
||||
// HERE начинам тут
|
||||
// реализовать через контент создание файла или директории
|
||||
// а затем его уделаение см. HERE то что выше
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void navigation::on_update(time t)
|
||||
@ -135,30 +162,61 @@ namespace rrr::layers::gui
|
||||
pos_x = try_engine::application::get()->get_window()->width() / 3.f + padding_between_window / 2.f;
|
||||
}
|
||||
|
||||
void navigation::set_selected(system_event& e)
|
||||
void navigation::pressed(system_event& e)
|
||||
{
|
||||
if (freeze) return;
|
||||
|
||||
auto key = static_cast<try_engine::system_event::key_pressed_event&>(e);
|
||||
|
||||
if (key.get_keycode() == try_engine::key::LEFTSHIFT || key.get_keycode() == try_engine::key::RIGHTSHIFT)
|
||||
shift = true;
|
||||
|
||||
if (key.get_keycode() == try_engine::key::J)
|
||||
{
|
||||
cnt->increment_position(STEP_DOWN);
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::NAVIGATION);
|
||||
em->execute(types::event_type::NAVIGATION_DOWN, nullptr);
|
||||
}
|
||||
|
||||
if (key.get_keycode() == try_engine::key::K)
|
||||
{
|
||||
cnt->increment_position(STEP_UP);
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::NAVIGATION);
|
||||
em->execute(types::event_type::NAVIGATION_UP, nullptr);
|
||||
}
|
||||
|
||||
if (key.get_keycode() == try_engine::key::H)
|
||||
{
|
||||
cnt->navigation_left();
|
||||
data = cnt->get(TYPE_WIN::NAVIGATION);
|
||||
em->execute(types::event_type::NAVIGATION_LEFT, nullptr);
|
||||
}
|
||||
|
||||
if (key.get_keycode() == try_engine::key::L)
|
||||
{
|
||||
cnt->navigation_right();
|
||||
}
|
||||
data = cnt->get(TYPE_WIN::NAVIGATION);
|
||||
em->execute(types::event_type::NAVIGATION_RIGHT, nullptr);
|
||||
}
|
||||
|
||||
if (shift && key.get_keycode() == try_engine::key::D)
|
||||
{
|
||||
em->execute(types::event_type::SHOW_DELETE_ONE_FILE_DIALOG, current_file);
|
||||
freeze = true;
|
||||
}
|
||||
|
||||
if (shift && key.get_keycode() == try_engine::key::C)
|
||||
{
|
||||
em->execute(types::event_type::SHOW_CREATE_FILE_DIALOG, nullptr);
|
||||
freeze = true;
|
||||
}
|
||||
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::NAVIGATION);
|
||||
}
|
||||
|
||||
void navigation::released(system_event& e)
|
||||
{
|
||||
auto key = static_cast<try_engine::system_event::key_pressed_event&>(e);
|
||||
|
||||
if (key.get_keycode() == try_engine::key::LEFTSHIFT || key.get_keycode() == try_engine::key::RIGHTSHIFT)
|
||||
shift = false;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace rrr::layers::gui
|
||||
FLAGS_STRUCT_DEFINED();
|
||||
|
||||
bool show = true;
|
||||
bool freeze = false; // замораживает все действия, например при открытии диалогового окна
|
||||
event_manager* em;
|
||||
content* cnt;
|
||||
files* data;
|
||||
@ -43,6 +44,8 @@ namespace rrr::layers::gui
|
||||
int cursor_position = 0;
|
||||
const int STEP_UP = -1;
|
||||
const int STEP_DOWN = 1;
|
||||
file current_file;
|
||||
bool shift = false;
|
||||
|
||||
private:
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -54,7 +57,8 @@ namespace rrr::layers::gui
|
||||
|
||||
private:
|
||||
void resize();
|
||||
void set_selected(system_event& e);
|
||||
void pressed(system_event& e);
|
||||
void released(system_event& e);
|
||||
void check_selected();
|
||||
void push_style(file&);
|
||||
void pop_style(file&);
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "preview.hpp"
|
||||
|
||||
#include "utils/types.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
void preview::on_attach()
|
||||
@ -17,11 +19,13 @@ namespace rrr::layers::gui
|
||||
|
||||
void preview::gui_render()
|
||||
{
|
||||
if (!show) return;
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y));
|
||||
ImGui::SetNextWindowSize(ImVec2(width, height));
|
||||
|
||||
ImGuiStyle& st = ImGui::GetStyle();
|
||||
st.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.14f, 0.18f, 1.00f);
|
||||
st.Colors[ImGuiCol_WindowBg] = func::get_IMGUI_color<ImVec4>(33.f, 36.f, 46.f);
|
||||
|
||||
BEGIN_IMGUI_WIN();
|
||||
|
||||
@ -83,8 +87,21 @@ namespace rrr::layers::gui
|
||||
pos_x = try_engine::application::get()->get_window()->width() - try_engine::application::get()->get_window()->width() / 3.f;
|
||||
}
|
||||
|
||||
void preview::on_event(std::any e, std::any value)
|
||||
void preview::on_event(std::any event_type, std::any value)
|
||||
{
|
||||
auto et = std::any_cast<types::event_type>(event_type);
|
||||
|
||||
switch (et)
|
||||
{
|
||||
case types::event_type::NAVIGATION_UP:
|
||||
case types::event_type::NAVIGATION_DOWN:
|
||||
case types::event_type::NAVIGATION_LEFT:
|
||||
case types::event_type::NAVIGATION_RIGHT:
|
||||
cursor_position = cnt->get_cursor_position(TYPE_WIN::PREVIEW);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void preview::on_update(time t)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "try_engine/try_engine.hpp"
|
||||
#include "rrr/content/content.hpp"
|
||||
#include "rrr/utils/func.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
@ -41,8 +42,9 @@ namespace rrr::layers::gui
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFontAtlas* atlas = io.Fonts;
|
||||
ImFont* font;
|
||||
const ImVec4 dir_color = ImVec4(0.36f, 0.5f, 0.74f, 1.0f);
|
||||
const ImVec4 file_color = ImVec4(0.9f, 0.9f, 0.9f, 1.0f);
|
||||
const ImVec4 dir_color = func::get_IMGUI_color<ImVec4>(91.f, 128.f, 191.f);
|
||||
const ImVec4 file_color = func::get_IMGUI_color<ImVec4>(186.f, 186.f, 186.f);
|
||||
const ImVec4 link_color = func::get_IMGUI_color<ImVec4>(51.f, 95.f, 165.f);
|
||||
|
||||
private:
|
||||
void resize();
|
||||
|
238
src/rrr/layers/gui/dialogs/dialogs.cpp
Normal file
238
src/rrr/layers/gui/dialogs/dialogs.cpp
Normal file
@ -0,0 +1,238 @@
|
||||
#include "dialogs.hpp"
|
||||
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui.h"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
void dialogs::on_attach()
|
||||
{
|
||||
BASE_WINDOW_FLAGS();
|
||||
}
|
||||
|
||||
void dialogs::on_detach()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void dialogs::gui_render()
|
||||
{
|
||||
if (!show) return;
|
||||
|
||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.8f));
|
||||
ImGui::SetNextWindowSize(ImVec2(width, height));
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);
|
||||
|
||||
BEGIN_IMGUI_WIN();
|
||||
|
||||
if (delete_dialog)
|
||||
draw_delete_dialog();
|
||||
|
||||
if (create_dialog)
|
||||
draw_create_dialog();
|
||||
|
||||
END_IMGUI_WIN();
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void dialogs::on_event(system_event& e)
|
||||
{
|
||||
if (e.get_name() == try_engine::system_event::classificator::WINDOW_RESIZE())
|
||||
resize();
|
||||
|
||||
if (e.get_name() == try_engine::system_event::classificator::KEY_PRESSED())
|
||||
pressed(e);
|
||||
|
||||
if (e.get_name() == try_engine::system_event::classificator::KEY_RELEASED())
|
||||
released(e);
|
||||
}
|
||||
|
||||
void dialogs::resize()
|
||||
{
|
||||
height = try_engine::application::get()->get_window()->height() / 5.f;
|
||||
width = try_engine::application::get()->get_window()->width() / 3.2f;
|
||||
}
|
||||
|
||||
void dialogs::on_event(std::any event_type, std::any value)
|
||||
{
|
||||
auto et = std::any_cast<types::event_type>(event_type);
|
||||
|
||||
switch (et)
|
||||
{
|
||||
case types::event_type::SHOW_DELETE_ONE_FILE_DIALOG:
|
||||
{
|
||||
current_file = std::any_cast<file>(value);
|
||||
show = true;
|
||||
delete_dialog = true;
|
||||
}
|
||||
break;
|
||||
case types::event_type::SHOW_CREATE_FILE_DIALOG:
|
||||
{
|
||||
show = true;
|
||||
create_dialog = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dialogs::on_update(time t)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void dialogs::pressed(system_event& e)
|
||||
{
|
||||
auto key = static_cast<try_engine::system_event::key_pressed_event&>(e);
|
||||
|
||||
if (key.get_keycode() == try_engine::key::LEFTSHIFT || key.get_keycode() == try_engine::key::RIGHTSHIFT)
|
||||
shift = true;
|
||||
|
||||
if (key.get_keycode() == try_engine::key::N)
|
||||
{
|
||||
if (delete_dialog)
|
||||
{
|
||||
delete_dialog = false;
|
||||
show = false;
|
||||
em->execute(types::event_type::UNFREEZE_BROWSER_ACTION, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (key.get_keycode() == try_engine::key::ESCAPE)
|
||||
cancel();
|
||||
|
||||
if (shift && key.get_keycode() == try_engine::key::Y)
|
||||
{
|
||||
if (delete_dialog)
|
||||
{
|
||||
show = false;
|
||||
delete_dialog = false;
|
||||
em->execute(types::event_type::DELETE_CURRENT_FILE, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (key.get_keycode() == try_engine::key::ENTER)
|
||||
{
|
||||
if (create_dialog)
|
||||
create_file();
|
||||
}
|
||||
}
|
||||
|
||||
void dialogs::released(system_event& e)
|
||||
{
|
||||
auto key = static_cast<try_engine::system_event::key_pressed_event&>(e);
|
||||
|
||||
if (key.get_keycode() == try_engine::key::LEFTSHIFT || key.get_keycode() == try_engine::key::RIGHTSHIFT)
|
||||
shift = false;
|
||||
}
|
||||
|
||||
void dialogs::draw_delete_dialog()
|
||||
{
|
||||
font = try_engine::style::fonts::get_font(font_type::MEDIUM, 18);
|
||||
ImGui::PushFont(font);
|
||||
std::string label = current_file.type == file_type::DIR ? "Даннaя директория будет удалена!" : "Данный файл будет удален!";
|
||||
|
||||
// манипуляции с тем чтобы название стояло посередлине
|
||||
// см. и ниже тоже
|
||||
auto pos = ImGui::GetCursorPos();
|
||||
pos.x = width / (current_file.type == file_type::DIR ? 5.4f : 4.8f);
|
||||
pos.y += 12.f;
|
||||
ImGui::SetCursorPos(pos);
|
||||
ImGui::TextUnformatted(label.data());
|
||||
ImGui::Separator();
|
||||
|
||||
// манипуляции с тем чтобы название стояло посередлине
|
||||
// тут и зависимость от длинны строки и размера шрифта, но не того
|
||||
// что выше при определении шрифта, а того который нужен для отрисовки
|
||||
// на самом экране
|
||||
pos = ImGui::GetCursorPos();
|
||||
auto p = current_file.path.filename().string().size() * 5.f;
|
||||
pos.x += width / 2.f - p;
|
||||
pos.y += 12.f;
|
||||
ImGui::SetCursorPos(pos);
|
||||
|
||||
ImGui::TextUnformatted(current_file.path.filename().string().data());
|
||||
|
||||
pos = ImGui::GetCursorPos();
|
||||
pos.y = height - height / 4.f;
|
||||
pos.x = width / 9.f;
|
||||
ImGui::SetCursorPos(pos);
|
||||
auto button_size = ImVec2(width / 3.f, height / 5.f);
|
||||
if (ImGui::Button("Удалить (Y)", button_size))
|
||||
{
|
||||
show = false;
|
||||
delete_dialog = false;
|
||||
em->execute(types::event_type::DELETE_CURRENT_FILE, nullptr);
|
||||
}
|
||||
|
||||
ImGui::SameLine(width / 1.8f);
|
||||
|
||||
if (ImGui::Button("Отмена (n / Esc)", button_size))
|
||||
cancel();
|
||||
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
void dialogs::draw_create_dialog()
|
||||
{
|
||||
font = try_engine::style::fonts::get_font(font_type::MEDIUM, 18);
|
||||
ImGui::PushFont(font);
|
||||
std::string label = "Создание файла/директории!";
|
||||
|
||||
// манипуляции с тем чтобы название стояло посередлине
|
||||
// см. и ниже тоже
|
||||
auto pos = ImGui::GetCursorPos();
|
||||
pos.x = width / (current_file.type == file_type::DIR ? 5.4f : 4.8f);
|
||||
pos.y += 12.f;
|
||||
ImGui::SetCursorPos(pos);
|
||||
ImGui::TextUnformatted(label.data());
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::PushItemWidth(-FLT_MIN - 10.f);
|
||||
pos = ImGui::GetCursorPos();
|
||||
pos.x = 10.f;
|
||||
ImGui::SetCursorPos(pos);
|
||||
// для фокусировки
|
||||
if (!ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) ImGui::SetKeyboardFocusHere(0);
|
||||
if (ImGui::InputText("##new_file_title", &title)) {}
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
pos = ImGui::GetCursorPos();
|
||||
pos.y = height - height / 4.f;
|
||||
pos.x = width / 9.f;
|
||||
ImGui::SetCursorPos(pos);
|
||||
auto button_size = ImVec2(width / 3.f, height / 5.f);
|
||||
if (ImGui::Button("Создать (Enter)", button_size))
|
||||
create_file();
|
||||
|
||||
ImGui::SameLine(width / 1.8f);
|
||||
|
||||
if (ImGui::Button("Отмена (Esc)", button_size))
|
||||
cancel();
|
||||
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
void dialogs::create_file()
|
||||
{
|
||||
show = false;
|
||||
create_dialog = false;
|
||||
em->execute(types::event_type::CREATE_FILE, title);
|
||||
title.clear();
|
||||
}
|
||||
|
||||
void dialogs::cancel()
|
||||
{
|
||||
delete_dialog = false;
|
||||
create_dialog = false;
|
||||
title.clear();
|
||||
show = false;
|
||||
em->execute(types::event_type::UNFREEZE_BROWSER_ACTION, nullptr);
|
||||
}
|
||||
}
|
55
src/rrr/layers/gui/dialogs/dialogs.hpp
Normal file
55
src/rrr/layers/gui/dialogs/dialogs.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "try_engine/try_engine.hpp"
|
||||
#include "rrr/content/content.hpp"
|
||||
|
||||
namespace rrr::layers::gui
|
||||
{
|
||||
class dialogs : public try_engine::layer
|
||||
{
|
||||
using font_type = try_engine::style::fonts::font_type;
|
||||
|
||||
BASE_TYPE_DEFINE();
|
||||
|
||||
public:
|
||||
CONSTRUCT_IMPL(dialogs);
|
||||
|
||||
public:
|
||||
BASE_OVERIDE_IMPL();
|
||||
|
||||
public:
|
||||
SET_EVENT_MANAGER_IMPL();
|
||||
|
||||
void set_content(content* c) { };
|
||||
|
||||
private:
|
||||
FLAGS_STRUCT_DEFINED();
|
||||
|
||||
bool show = false;
|
||||
event_manager* em;
|
||||
|
||||
float width = 0.f;
|
||||
float height = 0.f;
|
||||
bool delete_dialog = false;
|
||||
bool create_dialog = false;
|
||||
file current_file;
|
||||
bool shift = false;
|
||||
std::string title;
|
||||
|
||||
private:
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFontAtlas* atlas = io.Fonts;
|
||||
ImFont* font;
|
||||
|
||||
private:
|
||||
void resize();
|
||||
void cancel();
|
||||
void draw_delete_dialog();
|
||||
void draw_create_dialog();
|
||||
void create_file();
|
||||
void pressed(system_event& e);
|
||||
void released(system_event& e);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ headers = [
|
||||
'layers/gui/browser/history/history.hpp',
|
||||
'layers/gui/browser/navigation/navigation.hpp',
|
||||
'layers/gui/browser/preview/preview.hpp',
|
||||
'layers/gui/dialogs/dialogs.hpp',
|
||||
]
|
||||
sources = [
|
||||
'content/content.cpp',
|
||||
@ -21,6 +22,7 @@ sources = [
|
||||
'layers/gui/browser/history/history.cpp',
|
||||
'layers/gui/browser/navigation/navigation.cpp',
|
||||
'layers/gui/browser/preview/preview.cpp',
|
||||
'layers/gui/dialogs/dialogs.cpp',
|
||||
]
|
||||
|
||||
lib = library(
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "layers/gui/browser/navigation/navigation.hpp"
|
||||
#include "layers/gui/browser/history/history.hpp"
|
||||
#include "layers/gui/browser/preview/preview.hpp"
|
||||
#include "layers/gui/dialogs/dialogs.hpp"
|
||||
|
||||
namespace rrr
|
||||
{
|
||||
@ -46,7 +47,8 @@ namespace try_engine
|
||||
e.push_layer(
|
||||
new rrr::layers::gui::history{},
|
||||
new rrr::layers::gui::navigation{},
|
||||
new rrr::layers::gui::preview{}
|
||||
new rrr::layers::gui::preview{},
|
||||
new rrr::layers::gui::dialogs{}
|
||||
);
|
||||
|
||||
e.attach_layers();
|
||||
|
@ -6,7 +6,15 @@ namespace rrr::types
|
||||
{
|
||||
NONE = 0,
|
||||
NAVIGATION_UP,
|
||||
NAVIGATION_DOWN
|
||||
NAVIGATION_DOWN,
|
||||
NAVIGATION_LEFT,
|
||||
NAVIGATION_RIGHT,
|
||||
SHOW_DELETE_ONE_FILE_DIALOG,
|
||||
FREEZE_BROWSER_ACTION,
|
||||
UNFREEZE_BROWSER_ACTION,
|
||||
DELETE_CURRENT_FILE,
|
||||
SHOW_CREATE_FILE_DIALOG,
|
||||
CREATE_FILE
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user