mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
BugFix IconButton (pop id)
This commit is contained in:
@@ -192,8 +192,11 @@ bool ImGuiToolkit::IconButton(int i, int j, const char *tooltip)
|
|||||||
ImVec2 draw_pos = window->DC.CursorPos;
|
ImVec2 draw_pos = window->DC.CursorPos;
|
||||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||||
ImGui::ItemSize(size);
|
ImGui::ItemSize(size);
|
||||||
if (!ImGui::ItemAdd(bb, id))
|
|
||||||
|
if (!ImGui::ItemAdd(bb, id)){
|
||||||
|
ImGui::PopID();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ImGuiButtonFlags flags = 0;
|
ImGuiButtonFlags flags = 0;
|
||||||
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
|
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
|
||||||
|
|||||||
@@ -1556,110 +1556,114 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode)
|
|||||||
|
|
||||||
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
||||||
|
|
||||||
if (ImGui::Begin("Metrics", NULL, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
|
if (!ImGui::Begin("Metrics", NULL, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav))
|
||||||
{
|
{
|
||||||
ImGui::SetNextItemWidth(200);
|
|
||||||
ImGui::Combo("##mode", p_mode,
|
|
||||||
ICON_FA_TACHOMETER_ALT " Performance\0"
|
|
||||||
ICON_FA_HOURGLASS_HALF " Timers\0"
|
|
||||||
ICON_FA_VECTOR_SQUARE " Source\0");
|
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGuiToolkit::IconButton(5,8))
|
|
||||||
ImGui::OpenPopup("metrics_menu");
|
|
||||||
ImGui::Spacing();
|
|
||||||
|
|
||||||
if (*p_mode > 1) {
|
|
||||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO);
|
|
||||||
Source *s = Mixer::manager().currentSource();
|
|
||||||
if (s) {
|
|
||||||
float rightalign = -2.5f * ImGui::GetTextLineHeightWithSpacing();
|
|
||||||
std::ostringstream info;
|
|
||||||
info << s->name() << ": ";
|
|
||||||
|
|
||||||
float v = s->alpha();
|
|
||||||
ImGui::SetNextItemWidth(rightalign);
|
|
||||||
if ( ImGui::DragFloat("Alpha", &v, 0.01f, 0.f, 1.f) )
|
|
||||||
s->setAlpha(v);
|
|
||||||
if ( ImGui::IsItemDeactivatedAfterEdit() ) {
|
|
||||||
info << "Alpha " << std::fixed << std::setprecision(3) << v;
|
|
||||||
Action::manager().store(info.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
Group *n = s->group(View::GEOMETRY);
|
|
||||||
float translation[2] = { n->translation_.x, n->translation_.y};
|
|
||||||
ImGui::SetNextItemWidth(rightalign);
|
|
||||||
if ( ImGui::DragFloat2("Pos", translation, 0.01f, -MAX_SCALE, MAX_SCALE, "%.2f") ) {
|
|
||||||
n->translation_.x = translation[0];
|
|
||||||
n->translation_.y = translation[1];
|
|
||||||
s->touch();
|
|
||||||
}
|
|
||||||
if ( ImGui::IsItemDeactivatedAfterEdit() ){
|
|
||||||
info << "Position " << std::setprecision(3) << n->translation_.x << ", " << n->translation_.y;
|
|
||||||
Action::manager().store(info.str());
|
|
||||||
}
|
|
||||||
float scale[2] = { n->scale_.x, n->scale_.y} ;
|
|
||||||
ImGui::SetNextItemWidth(rightalign);
|
|
||||||
if ( ImGui::DragFloat2("Scale", scale, 0.01f, -MAX_SCALE, MAX_SCALE, "%.2f") )
|
|
||||||
{
|
|
||||||
n->scale_.x = CLAMP_SCALE(scale[0]);
|
|
||||||
n->scale_.y = CLAMP_SCALE(scale[1]);
|
|
||||||
s->touch();
|
|
||||||
}
|
|
||||||
if ( ImGui::IsItemDeactivatedAfterEdit() ){
|
|
||||||
info << "Scale " << std::setprecision(3) << n->scale_.x << " x " << n->scale_.y;
|
|
||||||
Action::manager().store(info.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(rightalign);
|
|
||||||
if ( ImGui::SliderAngle("Angle", &(n->rotation_.z), -180.f, 180.f) )
|
|
||||||
s->touch();
|
|
||||||
if ( ImGui::IsItemDeactivatedAfterEdit() ) {
|
|
||||||
info << "Angle " << std::setprecision(3) << n->rotation_.z * 180.f / M_PI;
|
|
||||||
Action::manager().store(info.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ImGui::Text("No source selected");
|
|
||||||
ImGui::PopFont();
|
|
||||||
}
|
|
||||||
else if (*p_mode > 0) {
|
|
||||||
guint64 time_ = gst_util_get_timestamp ();
|
|
||||||
|
|
||||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
|
|
||||||
ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_1_, GstToolkit::TIME_STRING_FIXED).c_str());
|
|
||||||
ImGui::PopFont();
|
|
||||||
ImGui::SameLine(0, 10);
|
|
||||||
if (ImGuiToolkit::IconButton(12, 14))
|
|
||||||
start_time_1_ = time_; // reset timer 1
|
|
||||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
|
|
||||||
ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_2_, GstToolkit::TIME_STRING_FIXED).c_str());
|
|
||||||
ImGui::PopFont();
|
|
||||||
ImGui::SameLine(0, 10);
|
|
||||||
if (ImGuiToolkit::IconButton(12, 14))
|
|
||||||
start_time_2_ = time_; // reset timer 2
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO);
|
|
||||||
ImGui::Text("Window %.0f x %.0f", io.DisplaySize.x, io.DisplaySize.y);
|
|
||||||
// ImGui::Text("HiDPI (retina) %s", io.DisplayFramebufferScale.x > 1.f ? "on" : "off");
|
|
||||||
ImGui::Text("Refresh %.1f FPS", io.Framerate);
|
|
||||||
ImGui::Text("Memory %s", BaseToolkit::byte_to_string( SystemToolkit::memory_usage()).c_str() );
|
|
||||||
ImGui::PopFont();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::BeginPopup("metrics_menu"))
|
|
||||||
{
|
|
||||||
if (ImGui::MenuItem( ICON_FA_ANGLE_UP " Top", NULL, corner == 1)) *p_corner = 1;
|
|
||||||
if (ImGui::MenuItem( ICON_FA_ANGLE_DOWN " Bottom", NULL, corner == 3)) *p_corner = 3;
|
|
||||||
if (ImGui::MenuItem( ICON_FA_EXPAND_ARROWS_ALT " Free position", NULL, corner == -1)) *p_corner = -1;
|
|
||||||
if (p_open && ImGui::MenuItem( ICON_FA_TIMES " Close")) *p_open = false;
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::SetNextItemWidth(200);
|
||||||
|
ImGui::Combo("##mode", p_mode,
|
||||||
|
ICON_FA_TACHOMETER_ALT " Performance\0"
|
||||||
|
ICON_FA_HOURGLASS_HALF " Timers\0"
|
||||||
|
ICON_FA_VECTOR_SQUARE " Source\0");
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGuiToolkit::IconButton(5,8))
|
||||||
|
ImGui::OpenPopup("metrics_menu");
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
if (*p_mode > 1) {
|
||||||
|
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO);
|
||||||
|
Source *s = Mixer::manager().currentSource();
|
||||||
|
if (s) {
|
||||||
|
float rightalign = -2.5f * ImGui::GetTextLineHeightWithSpacing();
|
||||||
|
std::ostringstream info;
|
||||||
|
info << s->name() << ": ";
|
||||||
|
|
||||||
|
float v = s->alpha();
|
||||||
|
ImGui::SetNextItemWidth(rightalign);
|
||||||
|
if ( ImGui::DragFloat("Alpha", &v, 0.01f, 0.f, 1.f) )
|
||||||
|
s->setAlpha(v);
|
||||||
|
if ( ImGui::IsItemDeactivatedAfterEdit() ) {
|
||||||
|
info << "Alpha " << std::fixed << std::setprecision(3) << v;
|
||||||
|
Action::manager().store(info.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
Group *n = s->group(View::GEOMETRY);
|
||||||
|
float translation[2] = { n->translation_.x, n->translation_.y};
|
||||||
|
ImGui::SetNextItemWidth(rightalign);
|
||||||
|
if ( ImGui::DragFloat2("Pos", translation, 0.01f, -MAX_SCALE, MAX_SCALE, "%.2f") ) {
|
||||||
|
n->translation_.x = translation[0];
|
||||||
|
n->translation_.y = translation[1];
|
||||||
|
s->touch();
|
||||||
|
}
|
||||||
|
if ( ImGui::IsItemDeactivatedAfterEdit() ){
|
||||||
|
info << "Position " << std::setprecision(3) << n->translation_.x << ", " << n->translation_.y;
|
||||||
|
Action::manager().store(info.str());
|
||||||
|
}
|
||||||
|
float scale[2] = { n->scale_.x, n->scale_.y} ;
|
||||||
|
ImGui::SetNextItemWidth(rightalign);
|
||||||
|
if ( ImGui::DragFloat2("Scale", scale, 0.01f, -MAX_SCALE, MAX_SCALE, "%.2f") )
|
||||||
|
{
|
||||||
|
n->scale_.x = CLAMP_SCALE(scale[0]);
|
||||||
|
n->scale_.y = CLAMP_SCALE(scale[1]);
|
||||||
|
s->touch();
|
||||||
|
}
|
||||||
|
if ( ImGui::IsItemDeactivatedAfterEdit() ){
|
||||||
|
info << "Scale " << std::setprecision(3) << n->scale_.x << " x " << n->scale_.y;
|
||||||
|
Action::manager().store(info.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetNextItemWidth(rightalign);
|
||||||
|
if ( ImGui::SliderAngle("Angle", &(n->rotation_.z), -180.f, 180.f) )
|
||||||
|
s->touch();
|
||||||
|
if ( ImGui::IsItemDeactivatedAfterEdit() ) {
|
||||||
|
info << "Angle " << std::setprecision(3) << n->rotation_.z * 180.f / M_PI;
|
||||||
|
Action::manager().store(info.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ImGui::Text("No source selected");
|
||||||
|
ImGui::PopFont();
|
||||||
|
}
|
||||||
|
else if (*p_mode > 0) {
|
||||||
|
guint64 time_ = gst_util_get_timestamp ();
|
||||||
|
|
||||||
|
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
|
||||||
|
ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_1_, GstToolkit::TIME_STRING_FIXED).c_str());
|
||||||
|
ImGui::PopFont();
|
||||||
|
ImGui::SameLine(0, 10);
|
||||||
|
if (ImGuiToolkit::IconButton(12, 14))
|
||||||
|
start_time_1_ = time_; // reset timer 1
|
||||||
|
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
|
||||||
|
ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_2_, GstToolkit::TIME_STRING_FIXED).c_str());
|
||||||
|
ImGui::PopFont();
|
||||||
|
ImGui::SameLine(0, 10);
|
||||||
|
if (ImGuiToolkit::IconButton(12, 14))
|
||||||
|
start_time_2_ = time_; // reset timer 2
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO);
|
||||||
|
ImGui::Text("Window %.0f x %.0f", io.DisplaySize.x, io.DisplaySize.y);
|
||||||
|
// ImGui::Text("HiDPI (retina) %s", io.DisplayFramebufferScale.x > 1.f ? "on" : "off");
|
||||||
|
ImGui::Text("Refresh %.1f FPS", io.Framerate);
|
||||||
|
ImGui::Text("Memory %s", BaseToolkit::byte_to_string( SystemToolkit::memory_usage()).c_str() );
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginPopup("metrics_menu"))
|
||||||
|
{
|
||||||
|
if (ImGui::MenuItem( ICON_FA_ANGLE_UP " Top", NULL, corner == 1)) *p_corner = 1;
|
||||||
|
if (ImGui::MenuItem( ICON_FA_ANGLE_DOWN " Bottom", NULL, corner == 3)) *p_corner = 3;
|
||||||
|
if (ImGui::MenuItem( ICON_FA_EXPAND_ARROWS_ALT " Free position", NULL, corner == -1)) *p_corner = -1;
|
||||||
|
if (p_open && ImGui::MenuItem( ICON_FA_TIMES " Close")) *p_open = false;
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserInterface::RenderAbout(bool* p_open)
|
void UserInterface::RenderAbout(bool* p_open)
|
||||||
|
|||||||
Reference in New Issue
Block a user