|
@@ -1,4 +1,7 @@
|
|
|
#include "tiny_player.h"
|
|
#include "tiny_player.h"
|
|
|
|
|
+#include "core/imgui_utility.hpp"
|
|
|
|
|
+
|
|
|
|
|
+#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
app_tiny_player::app_tiny_player(const create_config &_conf) {
|
|
app_tiny_player::app_tiny_player(const create_config &_conf) {
|
|
|
conf = _conf;
|
|
conf = _conf;
|
|
@@ -23,8 +26,82 @@ app_tiny_player::app_tiny_player(const create_config &_conf) {
|
|
|
bg_viewer = std::make_unique<image_viewer>(bg_viewer_conf);
|
|
bg_viewer = std::make_unique<image_viewer>(bg_viewer_conf);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void app_tiny_player::recorde_window_info() {
|
|
|
|
|
+ auto win = glfwGetCurrentContext();
|
|
|
|
|
+ glfwGetWindowPos(win, &win_info.x_pos, &win_info.y_pos);
|
|
|
|
|
+ glfwGetWindowSize(win, &win_info.width, &win_info.height);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void app_tiny_player::update_display() {
|
|
|
|
|
+ auto win = glfwGetCurrentContext();
|
|
|
|
|
+ if (!full_screen) {
|
|
|
|
|
+ glfwSetWindowMonitor(win, nullptr, win_info.x_pos, win_info.y_pos,
|
|
|
|
|
+ win_info.width, win_info.height, GLFW_DONT_CARE);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ assert(full_screen);
|
|
|
|
|
+ int monitor_num = 0;
|
|
|
|
|
+ auto monitors = glfwGetMonitors(&monitor_num);
|
|
|
|
|
+ assert(chose_monitor < monitor_num);
|
|
|
|
|
+ auto monitor = monitors[chose_monitor];
|
|
|
|
|
+ auto mode = glfwGetVideoMode(monitor);
|
|
|
|
|
+ glfwSetWindowMonitor(win, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void app_tiny_player::show_display_configs() {
|
|
|
|
|
+ // display mode
|
|
|
|
|
+ if (ImGui::RadioButton("Windowed", !full_screen)) {
|
|
|
|
|
+ if (full_screen) {
|
|
|
|
|
+ full_screen = false;
|
|
|
|
|
+ update_display();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::SameLine();
|
|
|
|
|
+ if (ImGui::RadioButton("Full Screen", full_screen)) {
|
|
|
|
|
+ if (!full_screen) {
|
|
|
|
|
+ recorde_window_info();
|
|
|
|
|
+ full_screen = true;
|
|
|
|
|
+ update_display();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (full_screen) {
|
|
|
|
|
+ int monitor_count;
|
|
|
|
|
+ auto monitors = glfwGetMonitors(&monitor_count);
|
|
|
|
|
+ if (chose_monitor >= monitor_count) {
|
|
|
|
|
+ chose_monitor = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ auto monitor_name_preview = glfwGetMonitorName(monitors[chose_monitor]);
|
|
|
|
|
+ if (ImGui::BeginCombo("Monitor", monitor_name_preview)) { // let user select monitors
|
|
|
|
|
+ for (int k = 0; k < monitor_count; ++k) {
|
|
|
|
|
+ auto is_selected = (chose_monitor == k);
|
|
|
|
|
+ auto monitor_name = fmt::format("{} - {}", k, glfwGetMonitorName(monitors[k]));
|
|
|
|
|
+ if (ImGui::Selectable(monitor_name.c_str(), is_selected)) {
|
|
|
|
|
+ if (chose_monitor != k) {
|
|
|
|
|
+ chose_monitor = k;
|
|
|
|
|
+ update_display();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_selected) {
|
|
|
|
|
+ ImGui::SetItemDefaultFocus();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::EndCombo();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void app_tiny_player::show_ui() {
|
|
void app_tiny_player::show_ui() {
|
|
|
- in_player->show();
|
|
|
|
|
|
|
+ if (ImGui::Begin("Tiny Player Control")) {
|
|
|
|
|
+ ImGui::PushItemWidth(200);
|
|
|
|
|
+ in_player->show();
|
|
|
|
|
+
|
|
|
|
|
+ ImGui::SeparatorText("Display Configs");
|
|
|
|
|
+ show_display_configs();
|
|
|
|
|
+
|
|
|
|
|
+ ImGui::PopItemWidth();
|
|
|
|
|
+ }
|
|
|
|
|
+ ImGui::End();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void app_tiny_player::render_background() {
|
|
void app_tiny_player::render_background() {
|