88 lines
2.6 KiB
C++
88 lines
2.6 KiB
C++
#pragma once
|
|
#include "../Drive/Drive.h"
|
|
|
|
#include "shared_mutex"
|
|
|
|
class ComboBox{
|
|
public:
|
|
ComboBox();
|
|
ComboBox(ComboBox&& Other) noexcept;
|
|
void AddItem(const char* str);
|
|
int Length() const;
|
|
void Draw();
|
|
void SetItems(const std::vector<const char*>& list);
|
|
template <typename Func, typename... Args>
|
|
bool Mouse_Hovered(Func&& fun, Args&&... args);
|
|
template<typename Func, typename ...Args>
|
|
bool Click(ImGuiMouseButton Mouse, Func&& fun, Args && ...args);
|
|
template<typename Func, typename ...Args>
|
|
void ValueChange(Func&& fun, Args && ...args);
|
|
//-----------------------------------------------
|
|
ImVec2 Pos = { 0,0 };
|
|
ImVec2 Size = { 150,35 };
|
|
ImVec2 SelectableTextAlign = { 0.5,0.5 };
|
|
ImVec2 Padding = { 0,3 };
|
|
int Index = 0;
|
|
int Fontsize = 18;
|
|
float Round = 5;
|
|
std::string Selected = "";
|
|
ImVec4 BGColor = { 240, 240, 240, 255 };
|
|
ImVec4 BGAColor = { 240, 240, 240, 255 };
|
|
ImVec4 BGHColor = { 240, 240, 240, 255 };
|
|
ImVec4 BtnColor = { 240, 240, 240, 255 };
|
|
ImVec4 BtnAColor = { 240, 240, 240, 255 };
|
|
ImVec4 BtnHColor = { 240, 240, 240, 255 };
|
|
ImVec4 TextColor = { 0,0,0,1 };
|
|
ImVec4 BGSelected = { 0,0,0,0 };
|
|
ImVec4 BGASelected = { 0,0,0,0 };
|
|
ImVec4 BGHSelected = { 0,0,0,0 };
|
|
ImVec4 TextHColor = { 1,0,1,1 };
|
|
|
|
private:
|
|
void POR();
|
|
mutable std::shared_mutex mutex_t;
|
|
inline static ImFont* ico_combo = nullptr;
|
|
std::string RValue = Selected;
|
|
bool num1 = true;
|
|
std::vector<const char*> Item{ nullptr };
|
|
std::vector<bool> SelectedItems{ false };
|
|
int a = -1;
|
|
std::string ID = "##" + UI_ID::UIIDSTR();
|
|
std::function<void()> task_Click_L;
|
|
std::function<void()> task_Click_Mouse;
|
|
std::function<void()> task_Click_R;
|
|
std::function<void()> task_Click_M;
|
|
std::function<void()> task_Click_Value;
|
|
};
|
|
|
|
|
|
template<typename Func, typename ...Args>
|
|
inline bool ComboBox::Mouse_Hovered(Func&& fun, Args && ...args)
|
|
{
|
|
task_Click_Mouse = std::bind(std::forward<Func>(fun), std::forward<Args>(args)...);
|
|
return true;
|
|
}
|
|
|
|
template<typename Func, typename ...Args>
|
|
inline bool ComboBox::Click(ImGuiMouseButton Mouse, Func&& fun, Args && ...args)
|
|
{
|
|
if (Mouse == IMBN::ImGuiMouseButton_Left)
|
|
{
|
|
task_Click_L = std::bind(std::forward<Func>(fun), std::forward<Args>(args)...);
|
|
}
|
|
else if (Mouse == IMBN::ImGuiMouseButton_Right)
|
|
{
|
|
task_Click_R = std::bind(std::forward<Func>(fun), std::forward<Args>(args)...);
|
|
}
|
|
else if (Mouse == IMBN::ImGuiMouseButton_Middle)
|
|
{
|
|
task_Click_M = std::bind(std::forward<Func>(fun), std::forward<Args>(args)...);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
template<typename Func, typename ...Args>
|
|
inline void ComboBox::ValueChange(Func&& fun, Args && ...args)
|
|
{
|
|
task_Click_Value = std::bind(std::forward<Func>(fun), std::forward<Args>(args)...);
|
|
} |