mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Move dropdown button text and icon code to dropdown button class
This commit is contained in:
66
include/GsrInfo.hpp
Normal file
66
include/GsrInfo.hpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <mglpp/system/vec.hpp>
|
||||
|
||||
namespace gsr {
|
||||
struct SupportedVideoCodecs {
|
||||
bool h264 = false;
|
||||
bool hevc = false;
|
||||
bool av1 = false;
|
||||
bool vp8 = false;
|
||||
bool vp9 = false;
|
||||
};
|
||||
|
||||
struct GsrMonitor {
|
||||
std::string name;
|
||||
mgl::vec2i size;
|
||||
};
|
||||
|
||||
struct SupportedCaptureOptions {
|
||||
bool window = false;
|
||||
bool focused = false;
|
||||
bool screen = false;
|
||||
bool portal = false;
|
||||
std::vector<GsrMonitor> monitors;
|
||||
};
|
||||
|
||||
enum class DisplayServer {
|
||||
UNKNOWN,
|
||||
X11,
|
||||
WAYLAND
|
||||
};
|
||||
|
||||
struct SystemInfo {
|
||||
DisplayServer display_server = DisplayServer::UNKNOWN;
|
||||
};
|
||||
|
||||
enum class GpuVendor {
|
||||
UNKNOWN,
|
||||
AMD,
|
||||
INTEL,
|
||||
NVIDIA
|
||||
};
|
||||
|
||||
struct GpuInfo {
|
||||
GpuVendor vendor = GpuVendor::UNKNOWN;
|
||||
};
|
||||
|
||||
struct GsrInfo {
|
||||
SystemInfo system_info;
|
||||
GpuInfo gpu_info;
|
||||
SupportedVideoCodecs supported_video_codecs;
|
||||
SupportedCaptureOptions supported_capture_options;
|
||||
};
|
||||
|
||||
enum class GsrInfoExitStatus {
|
||||
OK,
|
||||
FAILED_TO_RUN_COMMAND,
|
||||
OPENGL_FAILED,
|
||||
NO_DRM_CARD
|
||||
};
|
||||
|
||||
GsrInfoExitStatus get_gpu_screen_recorder_info(GsrInfo *gsr_info);
|
||||
}
|
||||
18
include/Theme.hpp
Normal file
18
include/Theme.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <mglpp/graphics/Color.hpp>
|
||||
|
||||
namespace gsr {
|
||||
struct GsrInfo;
|
||||
|
||||
struct Theme {
|
||||
Theme() = default;
|
||||
Theme(const Theme&) = delete;
|
||||
Theme& operator=(const Theme&) = delete;
|
||||
|
||||
mgl::Color tint_color = mgl::Color(118, 185, 0);
|
||||
};
|
||||
|
||||
void init_theme(const gsr::GsrInfo &gsr_info);
|
||||
const Theme& get_theme();
|
||||
}
|
||||
54
include/gui/DropdownButton.hpp
Normal file
54
include/gui/DropdownButton.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include "Widget.hpp"
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <mglpp/graphics/Text.hpp>
|
||||
#include <mglpp/graphics/Sprite.hpp>
|
||||
|
||||
namespace gsr {
|
||||
class DropdownButton : public Widget {
|
||||
public:
|
||||
DropdownButton(mgl::Font *title_font, mgl::Font *description_font, const char *title, const char *description_activated, const char *description_deactivated, mgl::Texture *icon_texture, mgl::vec2f size);
|
||||
DropdownButton(const DropdownButton&) = delete;
|
||||
DropdownButton& operator=(const DropdownButton&) = delete;
|
||||
|
||||
bool on_event(mgl::Event &event, mgl::Window &window) override;
|
||||
void draw(mgl::Window &window) override;
|
||||
|
||||
void add_item(const std::string &text, const std::string &id);
|
||||
void set_item_label(const std::string &id, const std::string &new_label);
|
||||
|
||||
void set_activated(bool activated);
|
||||
|
||||
mgl::vec2f get_size();
|
||||
|
||||
std::function<void(const std::string &id)> on_click;
|
||||
private:
|
||||
void update_if_dirty();
|
||||
private:
|
||||
struct Item {
|
||||
mgl::Text text;
|
||||
std::string id;
|
||||
};
|
||||
|
||||
std::vector<Item> items;
|
||||
mgl::Font *title_font;
|
||||
mgl::Font *description_font;
|
||||
mgl::vec2f size;
|
||||
bool mouse_inside = false;
|
||||
bool show_dropdown = false;
|
||||
bool dirty = true;
|
||||
mgl::vec2f max_size;
|
||||
int mouse_inside_item = -1;
|
||||
|
||||
mgl::Text title;
|
||||
mgl::Text description;
|
||||
mgl::Sprite icon_sprite;
|
||||
|
||||
std::string description_activated;
|
||||
std::string description_deactivated;
|
||||
bool activated = false;
|
||||
};
|
||||
}
|
||||
13
include/gui/Utils.hpp
Normal file
13
include/gui/Utils.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <mglpp/system/vec.hpp>
|
||||
#include <mglpp/graphics/Color.hpp>
|
||||
|
||||
namespace mgl {
|
||||
class Window;
|
||||
}
|
||||
|
||||
namespace gsr {
|
||||
// Inner border
|
||||
void draw_rectangle_outline(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::Color color, float border_size);
|
||||
}
|
||||
Reference in New Issue
Block a user