Fixed ButtonOpenUrl

This commit is contained in:
Bruno
2021-04-26 18:49:01 +02:00
parent c3713c9ce7
commit 7ba87fcee8
4 changed files with 20 additions and 13 deletions

View File

@@ -25,21 +25,18 @@
#include "ImGuiToolkit.h"
#include "GstToolkit.h"
#include "SystemToolkit.h"
#include "BaseToolkit.h"
unsigned int textureicons = 0;
std::map <ImGuiToolkit::font_style, ImFont*>fontmap;
void ImGuiToolkit::ButtonOpenUrl( const char* url, const ImVec2& size_arg )
void ImGuiToolkit::ButtonOpenUrl( const char* label, const char* url, const ImVec2& size_arg )
{
char label[512];
char _label[512];
sprintf( _label, "%s %s", ICON_FA_EXTERNAL_LINK_ALT, label );
std::string str = BaseToolkit::transliterate( url );
sprintf( label, "%s %s", ICON_FA_EXTERNAL_LINK_ALT, str.c_str() );
if ( ImGui::Button(label, size_arg) )
if ( ImGui::Button(_label, size_arg) )
SystemToolkit::open(url);
}

View File

@@ -26,7 +26,7 @@ namespace ImGuiToolkit
// utility buttons
bool ButtonToggle (const char* label, bool* toggle);
bool ButtonSwitch (const char* label, bool* toggle , const char *help = nullptr);
void ButtonOpenUrl (const char* url, const ImVec2& size_arg = ImVec2(0,0));
void ButtonOpenUrl (const char* label, const char* url, const ImVec2& size_arg = ImVec2(0,0));
void ToolTip (const char* desc, const char* shortcut = nullptr);
void HelpMarker (const char* desc, const char* icon = ICON_FA_QUESTION_CIRCLE, const char* shortcut = nullptr);

View File

@@ -32,6 +32,7 @@
#include "imgui.h"
#include "ImGuiToolkit.h"
#include "BaseToolkit.h"
#include "UserInterfaceManager.h"
#include "SystemToolkit.h"
@@ -552,7 +553,12 @@ void ImGuiVisitor::visit (MediaSource& s)
if ( ImGui::Button(IMGUI_TITLE_MEDIAPLAYER, ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
UserInterface::manager().showMediaPlayer( s.mediaplayer());
ImGuiToolkit::ButtonOpenUrl( SystemToolkit::path_filename(s.path()).c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
std::string path = SystemToolkit::path_filename(s.path());
std::string label = SystemToolkit::trunc_filename(path, 25);
label = BaseToolkit::transliterate(label);
ImGuiToolkit::ButtonOpenUrl( label.c_str(), path.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
ImGui::SameLine();
ImGui::Text("Folder");
}
@@ -583,7 +589,11 @@ void ImGuiVisitor::visit (SessionFileSource& s)
ImGui::SameLine();
ImGui::Text("File");
ImGuiToolkit::ButtonOpenUrl( SystemToolkit::path_filename(s.path()).c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
std::string path = SystemToolkit::path_filename(s.path());
std::string label = SystemToolkit::trunc_filename(path, 25);
label = BaseToolkit::transliterate(label);
ImGuiToolkit::ButtonOpenUrl( label.c_str(), path.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
ImGui::SameLine();
ImGui::Text("Folder");

View File

@@ -1625,7 +1625,7 @@ void UserInterface::RenderAbout(bool* p_open)
ImGui::Text("\nvimix is licensed under the GNU GPL version 3.\nCopyright 2019-2021 Bruno Herbelin.");
ImGui::Spacing();
ImGuiToolkit::ButtonOpenUrl("https://brunoherbelin.github.io/vimix/", ImVec2(ImGui::GetContentRegionAvail().x, 0));
ImGuiToolkit::ButtonOpenUrl("Visit vimix website", "https://brunoherbelin.github.io/vimix/", ImVec2(ImGui::GetContentRegionAvail().x, 0));
ImGui::Spacing();
@@ -3688,7 +3688,7 @@ void ShowAboutOpengl(bool* p_open)
ImGui::PopFont();
ImGui::Separator();
ImGui::Text("OpenGL is the premier environment for developing portable, \ninteractive 2D and 3D graphics applications.");
ImGuiToolkit::ButtonOpenUrl("https://www.opengl.org");
ImGuiToolkit::ButtonOpenUrl("Visit website", "https://www.opengl.org");
ImGui::SameLine();
static bool show_opengl_info = false;
@@ -3752,7 +3752,7 @@ void ShowAboutGStreamer(bool* p_open)
ImGui::Separator();
ImGui::Text("A flexible, fast and multiplatform multimedia framework.");
ImGui::Text("GStreamer is licensed under the LGPL License.");
ImGuiToolkit::ButtonOpenUrl("https://gstreamer.freedesktop.org/");
ImGuiToolkit::ButtonOpenUrl("Visit website", "https://gstreamer.freedesktop.org/");
ImGui::SameLine();
static bool show_config_info = false;