overlays: Allow for non-interactable UI components

* Also fix a few warnings in overlay_controls
This commit is contained in:
VelocityRa 2018-05-30 00:37:59 +03:00 committed by kd-11
parent 8981227644
commit 33b01d9306
5 changed files with 34 additions and 24 deletions

View File

@ -523,7 +523,7 @@ namespace gl
}
}
void run(u16 w, u16 h, GLuint target, rsx::overlays::user_interface& ui)
void run(u16 w, u16 h, GLuint target, rsx::overlays::overlay& ui)
{
program_handle.uniforms["ui_scale"] = color4f((f32)ui.virtual_width, (f32)ui.virtual_height, 1.f, 1.f);
program_handle.uniforms["time"] = (f32)(get_system_time() / 1000) * 0.005f;

View File

@ -627,6 +627,7 @@ namespace rsx
overlay_element() {}
overlay_element(u16 _w, u16 _h) : w(_w), h(_h) {}
virtual ~overlay_element() = default;
virtual void refresh()
{
@ -949,7 +950,7 @@ namespace rsx
struct vertical_layout : public layout_container
{
overlay_element* add_element(std::unique_ptr<overlay_element>& item, int offset = -1)
overlay_element* add_element(std::unique_ptr<overlay_element>& item, int offset = -1) override
{
if (auto_resize)
{
@ -1023,7 +1024,7 @@ namespace rsx
struct horizontal_layout : public layout_container
{
overlay_element* add_element(std::unique_ptr<overlay_element>& item, int offset = -1)
overlay_element* add_element(std::unique_ptr<overlay_element>& item, int offset = -1) override
{
if (auto_resize)
{
@ -1490,7 +1491,7 @@ namespace rsx
m_cancel_btn->translate(_x, _y);
}
compiled_resource& get_compiled()
compiled_resource& get_compiled() override
{
if (!is_compiled)
{

View File

@ -20,12 +20,12 @@ namespace rsx
on_close(return_code);
}
void user_interface::refresh()
void overlay::refresh()
{
if (auto rsxthr = rsx::get_current_renderer())
{
rsxthr->native_ui_flip_request.store(true);
}
}
}
}
} // namespace overlays
} // namespace rsx

View File

@ -21,7 +21,25 @@ namespace rsx
{
namespace overlays
{
struct user_interface
// Non-interactable UI element
struct overlay
{
u32 uid = UINT32_MAX;
u32 type_index = UINT32_MAX;
u16 virtual_width = 1280;
u16 virtual_height = 720;
virtual ~overlay() = default;
void refresh();
virtual void update() {}
virtual compiled_resource get_compiled() = 0;
};
// Interactable UI element
struct user_interface : overlay
{
//Move this somewhere to avoid duplication
enum selection_code
@ -43,24 +61,15 @@ namespace rsx
cross
};
u32 uid = UINT32_MAX;
u32 type_index = UINT32_MAX;
u16 virtual_width = 1280;
u16 virtual_height = 720;
u64 input_timestamp = 0;
bool exit = false;
s32 return_code = CELL_OK;
std::function<void(s32 status)> on_close;
virtual compiled_resource get_compiled() = 0;
void close();
void refresh();
virtual void update(){}
virtual void update() override {}
virtual void on_button_pressed(pad_button /*button_press*/)
{
@ -168,8 +177,8 @@ namespace rsx
{
private:
atomic_t<u32> m_uid_ctr { 0u };
std::vector<std::unique_ptr<user_interface>> m_iface_list;
std::vector<std::unique_ptr<user_interface>> m_dirty_list;
std::vector<std::unique_ptr<overlay>> m_iface_list;
std::vector<std::unique_ptr<overlay>> m_dirty_list;
shared_mutex m_list_mutex;
std::vector<u32> m_uids_to_remove;
@ -312,14 +321,14 @@ namespace rsx
}
// Returns current list for reading. Caller must ensure synchronization by first locking the list
const std::vector<std::unique_ptr<user_interface>>& get_views() const
const std::vector<std::unique_ptr<overlay>>& get_views() const
{
return m_iface_list;
}
// Returns current list of removed objects not yet deallocated for reading.
// Caller must ensure synchronization by first locking the list
const std::vector<std::unique_ptr<user_interface>>& get_dirty() const
const std::vector<std::unique_ptr<overlay>>& get_dirty() const
{
return m_dirty_list;
}
@ -344,7 +353,7 @@ namespace rsx
}
// Returns pointer to the object matching the given uid
user_interface* get(u32 uid)
overlay* get(u32 uid)
{
reader_lock lock(m_list_mutex);

View File

@ -654,7 +654,7 @@ namespace vk
}
void run(vk::command_buffer &cmd, u16 w, u16 h, vk::framebuffer* target, VkRenderPass render_pass,
vk::vk_data_heap &upload_heap, rsx::overlays::user_interface &ui)
vk::vk_data_heap &upload_heap, rsx::overlays::overlay &ui)
{
m_scale_offset = color4f((f32)ui.virtual_width, (f32)ui.virtual_height, 1.f, 1.f);
m_time = (f32)(get_system_time() / 1000) * 0.005f;