Skip to content

Commit 5cc25ef

Browse files
authored
add functions for transparent text (#579)
* add functions for transparent text * add comments
1 parent ced8e59 commit 5cc25ef

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

source/MRViewer/ImGuiHelpers.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,30 @@ void PlotCustomHistogram( const char* str_id,
231231
}
232232
}
233233

234+
MRVIEWER_API void TransparentText( const char* fmt, ... )
235+
{
236+
auto transparentColor = ImGui::GetStyleColorVec4( ImGuiCol_Text );
237+
transparentColor.w *= 0.5f;
238+
ImGui::PushStyleColor( ImGuiCol_Text, transparentColor );
239+
va_list args;
240+
va_start( args, fmt );
241+
TextV( fmt, args );
242+
va_end( args );
243+
ImGui::PopStyleColor();
244+
}
245+
246+
MRVIEWER_API void TransparentTextWrapped( const char* fmt, ... )
247+
{
248+
auto transparentColor = ImGui::GetStyleColorVec4( ImGuiCol_Text );
249+
transparentColor.w *= 0.5f;
250+
ImGui::PushStyleColor( ImGuiCol_Text, transparentColor );
251+
va_list args;
252+
va_start( args, fmt );
253+
TextWrappedV( fmt, args );
254+
va_end( args );
255+
ImGui::PopStyleColor();
256+
}
257+
234258
bool DragFloatValid( const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags )
235259
{
236260
bool res = DragFloat( label, v, v_speed, v_min, v_max, format, flags );

source/MRViewer/ImGuiHelpers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ inline bool InputText(const char* label, std::string &str, ImGuiInputTextFlags f
7777
}
7878
return false;
7979
}
80+
/// similar to ImGui::Text but use current text color with alpha channel = 0.5
81+
MRVIEWER_API void TransparentText( const char* fmt, ... );
82+
/// similar to ImGui::TextWrapped but use current text color with alpha channel = 0.5
83+
MRVIEWER_API void TransparentTextWrapped( const char* fmt, ... );
8084

8185
/// similar to ImGui::DragFloat but
8286
/// 1) value on output is forced to be in [min,max] range;

0 commit comments

Comments
 (0)