mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 03:39:57 +01:00
New buttons and icon modes
This commit is contained in:
@@ -124,7 +124,10 @@ void ImGuiToolkit::Icon(int i, int j, bool enabled)
|
||||
|
||||
ImVec2 uv0( static_cast<float>(i) * 0.05, static_cast<float>(j) * 0.05 );
|
||||
ImVec2 uv1( uv0.x + 0.05, uv0.y + 0.05 );
|
||||
ImVec4 tint_color = ImVec4(1.f,1.f,1.f, enabled ? 1.f : 0.6f);
|
||||
|
||||
ImVec4 tint_color = ImGui::GetStyle().Colors[ImGuiCol_Text];
|
||||
if (!enabled)
|
||||
tint_color.w = 0.6f;
|
||||
ImGui::Image((void*)(intptr_t)textureicons, ImVec2(ImGui::GetTextLineHeightWithSpacing(), ImGui::GetTextLineHeightWithSpacing()), uv0, uv1, tint_color);
|
||||
}
|
||||
|
||||
@@ -262,6 +265,42 @@ bool ImGuiToolkit::ButtonIconMultistate(std::vector<std::pair<int, int> > icons,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ImGuiToolkit::ComboIcon (std::vector<std::pair<int, int> > icons, int* state)
|
||||
{
|
||||
bool ret = false;
|
||||
Sum id = std::for_each(icons.begin(), icons.end(), Sum());
|
||||
ImGui::PushID( id.sum );
|
||||
|
||||
ImVec2 draw_pos = ImGui::GetCursorScreenPos();
|
||||
float w = ImGui::GetTextLineHeight();
|
||||
ImGui::SetNextItemWidth(w * 2.8f);
|
||||
if (ImGui::BeginCombo("##ComboIcon", " ") )
|
||||
{
|
||||
std::vector<std::pair<int, int> >::iterator it = icons.begin();
|
||||
for(int i = 0 ; it != icons.end(); i++, it++) {
|
||||
ImGui::PushID( id.sum + i + 1);
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
// combo selectable item
|
||||
if ( ImGui::Selectable(" ", i == *state )){
|
||||
*state = i;
|
||||
ret = true;
|
||||
}
|
||||
// draw item icon
|
||||
ImGui::SetCursorScreenPos( pos + ImVec2(w/6.f,0) );
|
||||
Icon( (*it).first, (*it).second );
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
// redraw current ad preview value
|
||||
ImGui::SetCursorScreenPos(draw_pos + ImVec2(w/9.f,w/9.f));
|
||||
Icon(icons[*state].first, icons[*state].second );
|
||||
|
||||
ImGui::PopID();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ImGuiToolkit::ShowIconsWindow(bool* p_open)
|
||||
{
|
||||
@@ -328,6 +367,21 @@ void ImGuiToolkit::HelpMarker(const char* desc, const char* icon)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiToolkit::HelpIcon(const char* desc, int i, int j)
|
||||
{
|
||||
ImGuiToolkit::Icon(i, j, false);
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_DEFAULT);
|
||||
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
|
||||
ImGui::TextUnformatted(desc);
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::PopFont();
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
// Draws a timeline showing
|
||||
// 1) a cursor at position *time in the range [0 duration]
|
||||
// 2) a line of tick marks indicating time, every step if possible
|
||||
|
||||
@@ -11,21 +11,25 @@
|
||||
namespace ImGuiToolkit
|
||||
{
|
||||
// Icons from resource icon.dds
|
||||
void Icon(int i, int j, bool enabled = true);
|
||||
bool IconButton(int i, int j, const char *tooltips = nullptr);
|
||||
void Icon (int i, int j, bool enabled = true);
|
||||
bool IconButton (int i, int j, const char *tooltips = nullptr);
|
||||
bool IconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle, const char *tooltips[] = nullptr);
|
||||
void ShowIconsWindow(bool* p_open);
|
||||
|
||||
// utility buttons
|
||||
// icon buttons
|
||||
bool ButtonIcon (int i, int j, const char* tooltip = nullptr);
|
||||
bool ButtonIconToggle (int i, int j, int i_toggle, int j_toggle, bool* toggle);
|
||||
bool ButtonIconMultistate (std::vector<std::pair<int, int> > icons, int* state);
|
||||
bool ButtonToggle(const char* label, bool* toggle);
|
||||
bool ComboIcon (std::vector<std::pair<int, int> > icons, int* state);
|
||||
|
||||
// utility buttons
|
||||
bool ButtonToggle (const char* label, bool* toggle);
|
||||
void ButtonSwitch (const char* label, bool* toggle , const char *help = nullptr);
|
||||
void ButtonOpenUrl (const char* url, const ImVec2& size_arg = ImVec2(0,0));
|
||||
|
||||
void ToolTip (const char* desc);
|
||||
void ToolTip (const char* desc);
|
||||
void HelpMarker (const char* desc, const char* icon = ICON_FA_QUESTION_CIRCLE);
|
||||
void HelpIcon (const char* desc, int i, int j);
|
||||
|
||||
// utility sliders
|
||||
bool TimelineSlider (const char* label, guint64 *time, guint64 start, guint64 end, guint64 step, const float width);
|
||||
|
||||
Reference in New Issue
Block a user