update platform OnEntry, move MasterFrame to Controller
This commit is contained in:
@@ -21,6 +21,34 @@ namespace core {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr ImGuiWindowFlags kMainEditorFlags =
|
||||||
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
|
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_MenuBar |
|
||||||
|
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoTitleBar;
|
||||||
|
|
||||||
|
using ::ImVec2;
|
||||||
|
using ImGui::Begin;
|
||||||
|
using ImGui::End;
|
||||||
|
using ImGui::GetIO;
|
||||||
|
using ImGui::NewFrame;
|
||||||
|
using ImGui::SetNextWindowPos;
|
||||||
|
using ImGui::SetNextWindowSize;
|
||||||
|
|
||||||
|
void NewMasterFrame() {
|
||||||
|
const ImGuiIO &io = GetIO();
|
||||||
|
ImGui_ImplSDLRenderer2_NewFrame();
|
||||||
|
ImGui_ImplSDL2_NewFrame();
|
||||||
|
NewFrame();
|
||||||
|
SetNextWindowPos(gui::kZeroPos);
|
||||||
|
ImVec2 dimensions(io.DisplaySize.x, io.DisplaySize.y);
|
||||||
|
SetNextWindowSize(dimensions, ImGuiCond_Always);
|
||||||
|
|
||||||
|
if (!Begin("##YazeMain", nullptr, kMainEditorFlags)) {
|
||||||
|
End();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InitializeKeymap() {
|
void InitializeKeymap() {
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
io.KeyMap[ImGuiKey_LeftSuper] = SDL_GetScancodeFromKey(SDLK_LGUI);
|
io.KeyMap[ImGuiKey_LeftSuper] = SDL_GetScancodeFromKey(SDLK_LGUI);
|
||||||
@@ -235,10 +263,28 @@ void HandleMouseMovement(int &wheel) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
absl::Status Controller::OnEntry(std::string filename) {
|
absl::Status Controller::OnEntry(std::string filename) {
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
#if TARGET_IPHONE_SIMULATOR == 1
|
||||||
|
/* iOS in Xcode simulator */
|
||||||
|
platform_ = Platform::kiOS;
|
||||||
|
#elif TARGET_OS_IPHONE == 1
|
||||||
|
/* iOS */
|
||||||
|
platform_ = Platform::kiOS;
|
||||||
|
#elif TARGET_OS_MAC == 1
|
||||||
|
/* macOS */
|
||||||
|
platform_ = Platform::kMacOS;
|
||||||
|
#endif
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
platform_ = Platform::kWindows;
|
||||||
|
#elif defined(__linux__)
|
||||||
|
platform_ = Platform::kLinux;
|
||||||
|
#else
|
||||||
|
platform_ = Platform::kUnknown;
|
||||||
|
#endif
|
||||||
|
|
||||||
RETURN_IF_ERROR(CreateSDL_Window())
|
RETURN_IF_ERROR(CreateSDL_Window())
|
||||||
RETURN_IF_ERROR(CreateRenderer())
|
RETURN_IF_ERROR(CreateRenderer())
|
||||||
RETURN_IF_ERROR(CreateGuiContext())
|
RETURN_IF_ERROR(CreateGuiContext())
|
||||||
RETURN_IF_ERROR(CreateTestContext())
|
|
||||||
if (flags()->kLoadAudioDevice) {
|
if (flags()->kLoadAudioDevice) {
|
||||||
RETURN_IF_ERROR(LoadAudioDevice())
|
RETURN_IF_ERROR(LoadAudioDevice())
|
||||||
master_editor_.emulator().set_audio_buffer(audio_buffer_);
|
master_editor_.emulator().set_audio_buffer(audio_buffer_);
|
||||||
@@ -293,6 +339,7 @@ absl::Status Controller::OnLoad() {
|
|||||||
if (master_editor_.quit()) {
|
if (master_editor_.quit()) {
|
||||||
active_ = false;
|
active_ = false;
|
||||||
}
|
}
|
||||||
|
NewMasterFrame();
|
||||||
RETURN_IF_ERROR(master_editor_.Update());
|
RETURN_IF_ERROR(master_editor_.Update());
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
@@ -398,7 +445,6 @@ absl::Status Controller::CreateGuiContext() {
|
|||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
absl::Status Controller::LoadFontFamilies() const {
|
absl::Status Controller::LoadFontFamilies() const {
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
|
|
||||||
|
|||||||
@@ -40,29 +40,9 @@ namespace editor {
|
|||||||
using namespace ImGui;
|
using namespace ImGui;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr ImGuiWindowFlags kMainEditorFlags =
|
bool BeginCentered(const char *name) {
|
||||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiIO const &io = GetIO();
|
||||||
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_MenuBar |
|
|
||||||
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoTitleBar;
|
|
||||||
|
|
||||||
void NewMasterFrame() {
|
|
||||||
const ImGuiIO& io = GetIO();
|
|
||||||
ImGui_ImplSDLRenderer2_NewFrame();
|
|
||||||
ImGui_ImplSDL2_NewFrame();
|
|
||||||
NewFrame();
|
|
||||||
SetNextWindowPos(gui::kZeroPos);
|
|
||||||
ImVec2 dimensions(io.DisplaySize.x, io.DisplaySize.y);
|
|
||||||
SetNextWindowSize(dimensions, ImGuiCond_Always);
|
|
||||||
|
|
||||||
if (!Begin("##YazeMain", nullptr, kMainEditorFlags)) {
|
|
||||||
End();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BeginCentered(const char* name) {
|
|
||||||
ImGuiIO const& io = GetIO();
|
|
||||||
ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
||||||
SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||||
ImGuiWindowFlags flags =
|
ImGuiWindowFlags flags =
|
||||||
@@ -89,8 +69,6 @@ void MasterEditor::SetupScreen(std::shared_ptr<SDL_Renderer> renderer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status MasterEditor::Update() {
|
absl::Status MasterEditor::Update() {
|
||||||
NewMasterFrame();
|
|
||||||
|
|
||||||
ManageKeyboardShortcuts();
|
ManageKeyboardShortcuts();
|
||||||
|
|
||||||
DrawYazeMenu();
|
DrawYazeMenu();
|
||||||
|
|||||||
Reference in New Issue
Block a user