Code cleanup: moving poly::ui to xe::ui
This commit is contained in:
@@ -142,7 +142,8 @@ GL4ProfilerDisplay::GL4ProfilerDisplay(WGLControl* control)
|
||||
vao_(0),
|
||||
font_texture_(0),
|
||||
font_handle_(0),
|
||||
vertex_buffer_(MICROPROFILE_MAX_VERTICES * sizeof(Vertex) * 10, sizeof(Vertex)),
|
||||
vertex_buffer_(MICROPROFILE_MAX_VERTICES * sizeof(Vertex) * 10,
|
||||
sizeof(Vertex)),
|
||||
draw_command_count_(0) {
|
||||
if (!SetupFont() || !SetupState() || !SetupShaders()) {
|
||||
// Hrm.
|
||||
@@ -150,32 +151,32 @@ GL4ProfilerDisplay::GL4ProfilerDisplay(WGLControl* control)
|
||||
}
|
||||
|
||||
// Pass through mouse events.
|
||||
control->on_mouse_down.AddListener([](poly::ui::MouseEvent& e) {
|
||||
Profiler::OnMouseDown(e.button() == poly::ui::MouseEvent::Button::kLeft,
|
||||
e.button() == poly::ui::MouseEvent::Button::kRight);
|
||||
control->on_mouse_down.AddListener([](xe::ui::MouseEvent& e) {
|
||||
Profiler::OnMouseDown(e.button() == xe::ui::MouseEvent::Button::kLeft,
|
||||
e.button() == xe::ui::MouseEvent::Button::kRight);
|
||||
e.set_handled(true);
|
||||
});
|
||||
control->on_mouse_up.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_up.AddListener([](xe::ui::MouseEvent& e) {
|
||||
Profiler::OnMouseUp();
|
||||
e.set_handled(true);
|
||||
});
|
||||
control->on_mouse_move.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_move.AddListener([](xe::ui::MouseEvent& e) {
|
||||
Profiler::OnMouseMove(e.x(), e.y());
|
||||
e.set_handled(true);
|
||||
});
|
||||
control->on_mouse_wheel.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_wheel.AddListener([](xe::ui::MouseEvent& e) {
|
||||
Profiler::OnMouseWheel(e.x(), e.y(), -e.dy());
|
||||
e.set_handled(true);
|
||||
});
|
||||
|
||||
// Watch for toggle/mode keys and such.
|
||||
control->on_key_down.AddListener([](poly::ui::KeyEvent& e) {
|
||||
control->on_key_down.AddListener([](xe::ui::KeyEvent& e) {
|
||||
Profiler::OnKeyDown(e.key_code());
|
||||
//e.set_handled(true);
|
||||
// e.set_handled(true);
|
||||
});
|
||||
control->on_key_up.AddListener([](poly::ui::KeyEvent& e) {
|
||||
control->on_key_up.AddListener([](xe::ui::KeyEvent& e) {
|
||||
Profiler::OnKeyUp(e.key_code());
|
||||
//e.set_handled(true);
|
||||
// e.set_handled(true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -258,7 +259,7 @@ struct VertexData { \n\
|
||||
};\n\
|
||||
";
|
||||
const std::string vertex_shader_source = header +
|
||||
"\n\
|
||||
"\n\
|
||||
layout(location = 0) uniform mat4 projection_matrix; \n\
|
||||
struct VertexFetch { \n\
|
||||
vec2 pos; \n\
|
||||
@@ -274,7 +275,7 @@ void main() { \n\
|
||||
} \n\
|
||||
";
|
||||
const std::string fragment_shader_source = header +
|
||||
"\n\
|
||||
"\n\
|
||||
layout(location = 1, bindless_sampler) uniform sampler2D font_texture; \n\
|
||||
layout(location = 2) uniform float font_height; \n\
|
||||
layout(location = 0) in VertexData vtx; \n\
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace gl4 {
|
||||
extern "C" GLEWContext* glewGetContext();
|
||||
extern "C" WGLEWContext* wglewGetContext();
|
||||
|
||||
WGLControl::WGLControl(poly::ui::Loop* loop)
|
||||
: poly::ui::win32::Win32Control(Flags::kFlagOwnPaint), loop_(loop) {}
|
||||
WGLControl::WGLControl(xe::ui::Loop* loop)
|
||||
: xe::ui::win32::Win32Control(Flags::kFlagOwnPaint), loop_(loop) {}
|
||||
|
||||
WGLControl::~WGLControl() = default;
|
||||
|
||||
@@ -70,7 +70,7 @@ bool WGLControl::Create() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WGLControl::OnLayout(poly::ui::UIEvent& e) { Control::ResizeToFill(); }
|
||||
void WGLControl::OnLayout(xe::ui::UIEvent& e) { Control::ResizeToFill(); }
|
||||
|
||||
LRESULT WGLControl::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
@@ -89,7 +89,7 @@ LRESULT WGLControl::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
current_paint_callback_ = nullptr;
|
||||
}
|
||||
|
||||
poly::ui::UIEvent e(this);
|
||||
xe::ui::UIEvent e(this);
|
||||
OnPaint(e);
|
||||
|
||||
// TODO(benvanik): profiler present.
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
#include <functional>
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "poly/ui/loop.h"
|
||||
#include "poly/ui/win32/win32_control.h"
|
||||
#include "xenia/gpu/gl4/gl_context.h"
|
||||
#include "xenia/ui/loop.h"
|
||||
#include "xenia/ui/win32/win32_control.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
namespace gl4 {
|
||||
|
||||
class WGLControl : public poly::ui::win32::Win32Control {
|
||||
class WGLControl : public xe::ui::win32::Win32Control {
|
||||
public:
|
||||
WGLControl(poly::ui::Loop* loop);
|
||||
WGLControl(xe::ui::Loop* loop);
|
||||
~WGLControl() override;
|
||||
|
||||
GLContext* context() { return &context_; }
|
||||
@@ -33,13 +33,13 @@ class WGLControl : public poly::ui::win32::Win32Control {
|
||||
protected:
|
||||
bool Create() override;
|
||||
|
||||
void OnLayout(poly::ui::UIEvent& e) override;
|
||||
void OnLayout(xe::ui::UIEvent& e) override;
|
||||
|
||||
LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) override;
|
||||
|
||||
private:
|
||||
poly::ui::Loop* loop_;
|
||||
xe::ui::Loop* loop_;
|
||||
GLContext context_;
|
||||
std::function<void()> current_paint_callback_;
|
||||
};
|
||||
|
||||
@@ -767,7 +767,7 @@ class TraceReader {
|
||||
|
||||
class TracePlayer : public TraceReader {
|
||||
public:
|
||||
TracePlayer(poly::ui::Loop* loop, GraphicsSystem* graphics_system)
|
||||
TracePlayer(xe::ui::Loop* loop, GraphicsSystem* graphics_system)
|
||||
: loop_(loop),
|
||||
graphics_system_(graphics_system),
|
||||
current_frame_index_(0),
|
||||
@@ -827,7 +827,7 @@ class TracePlayer : public TraceReader {
|
||||
}
|
||||
|
||||
private:
|
||||
poly::ui::Loop* loop_;
|
||||
xe::ui::Loop* loop_;
|
||||
GraphicsSystem* graphics_system_;
|
||||
int current_frame_index_;
|
||||
int current_command_index_;
|
||||
@@ -2213,7 +2213,7 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
||||
}
|
||||
|
||||
auto control = window->child(0);
|
||||
control->on_key_char.AddListener([graphics_system](poly::ui::KeyEvent& e) {
|
||||
control->on_key_char.AddListener([graphics_system](xe::ui::KeyEvent& e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
if (e.key_code() > 0 && e.key_code() < 0x10000) {
|
||||
if (e.key_code() == 0x74 /* VK_F5 */) {
|
||||
@@ -2224,41 +2224,41 @@ int trace_viewer_main(std::vector<std::wstring>& args) {
|
||||
}
|
||||
e.set_handled(true);
|
||||
});
|
||||
control->on_mouse_down.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_down.AddListener([](xe::ui::MouseEvent& e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
switch (e.button()) {
|
||||
case poly::ui::MouseEvent::Button::kLeft:
|
||||
case xe::ui::MouseEvent::Button::kLeft:
|
||||
io.MouseDown[0] = true;
|
||||
break;
|
||||
case poly::ui::MouseEvent::Button::kRight:
|
||||
case xe::ui::MouseEvent::Button::kRight:
|
||||
io.MouseDown[1] = true;
|
||||
break;
|
||||
}
|
||||
});
|
||||
control->on_mouse_move.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_move.AddListener([](xe::ui::MouseEvent& e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
});
|
||||
control->on_mouse_up.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_up.AddListener([](xe::ui::MouseEvent& e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
switch (e.button()) {
|
||||
case poly::ui::MouseEvent::Button::kLeft:
|
||||
case xe::ui::MouseEvent::Button::kLeft:
|
||||
io.MouseDown[0] = false;
|
||||
break;
|
||||
case poly::ui::MouseEvent::Button::kRight:
|
||||
case xe::ui::MouseEvent::Button::kRight:
|
||||
io.MouseDown[1] = false;
|
||||
break;
|
||||
}
|
||||
});
|
||||
control->on_mouse_wheel.AddListener([](poly::ui::MouseEvent& e) {
|
||||
control->on_mouse_wheel.AddListener([](xe::ui::MouseEvent& e) {
|
||||
auto& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(float(e.x()), float(e.y()));
|
||||
io.MouseWheel += float(e.dy() / 120.0f);
|
||||
});
|
||||
|
||||
control->on_paint.AddListener([&](poly::ui::UIEvent& e) {
|
||||
control->on_paint.AddListener([&](xe::ui::UIEvent& e) {
|
||||
static bool imgui_setup = false;
|
||||
if (!imgui_setup) {
|
||||
ImImpl_Setup();
|
||||
|
||||
Reference in New Issue
Block a user