Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/MRViewer/ImGuiHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ void Separator( float scaling, const std::string& text )
{
ImGui::Separator();
}
else if ( ImGui::BeginTable( "SeparatorTable", 2 ) )
else if ( ImGui::BeginTable( (std::string("SeparatorTable_") + text).c_str(), 2, ImGuiTableFlags_SizingFixedFit ) )
{
ImGui::TableNextColumn();
ImGui::Text( "%s", text.c_str());
Expand Down
42 changes: 42 additions & 0 deletions source/MRViewer/MRRibbonButtonDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,48 @@ bool RibbonButtonDrawer::GradientButton( const char* label, const ImVec2& size /
return res;
}

bool RibbonButtonDrawer::GradientButtonValid( const char* label, bool valid, const ImVec2& size /* = ImVec2(0, 0) */ )
{
auto& texture = GetGradientTexture();
if ( !texture )
return ImGui::ButtonValid( label, valid, size );

ImGui::PushStyleColor( ImGuiCol_Button, ImVec4( 0, 0, 0, 0 ) );
ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1, 1, 1, 1 ) );

auto window = ImGui::GetCurrentContext()->CurrentWindow;
const ImGuiStyle& style = ImGui::GetStyle();
const ImVec2 labelSize = ImGui::CalcTextSize( label, NULL, true );

int pushedStyleNum = 1;
ImGui::PushStyleVar( ImGuiStyleVar_FrameBorderSize, 0.0f );
if ( size.y == 0 )
{
auto framePadding = style.FramePadding;
framePadding.y = cGradientButtonFramePadding;
if ( auto menu = getViewerInstance().getMenuPlugin() )
framePadding.y *= menu->menu_scaling();
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, framePadding );
++pushedStyleNum;
}

ImVec2 pos = window->DC.CursorPos;
ImVec2 realSize = ImGui::CalcItemSize( size, labelSize.x + style.FramePadding.x * 2.0f, labelSize.y + style.FramePadding.y * 2.0f );
const ImRect bb( pos, ImVec2( pos.x + realSize.x, pos.y + realSize.y ) );

ImGui::GetCurrentContext()->CurrentWindow->DrawList->AddImageRounded(
texture->getImTextureId(),
bb.Min, bb.Max,
ImVec2( 0.5f, 0.25f ), ImVec2( 0.5f, 0.75f ),
Color::white().getUInt32(), style.FrameRounding );

auto res = ImGui::ButtonValid( label, valid, size );

ImGui::PopStyleVar( pushedStyleNum );
ImGui::PopStyleColor( 2 );
return res;
}

bool RibbonButtonDrawer::GradientCheckbox( const char* label, bool* value )
{
auto& texture = GetGradientTexture();
Expand Down
2 changes: 2 additions & 0 deletions source/MRViewer/MRRibbonButtonDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class MRVIEWER_CLASS RibbonButtonDrawer

/// draw gradient button
MRVIEWER_API static bool GradientButton( const char* label, const ImVec2& size = ImVec2( 0, 0 ) );
/// draw gradient button, which can be disabled (valid = false)
MRVIEWER_API static bool GradientButtonValid( const char* label, bool valid, const ImVec2& size = ImVec2( 0, 0 ) );
/// draw gradient checkbox
MRVIEWER_API static bool GradientCheckbox( const char* label, bool* value );
/// draw gradient checkbox
Expand Down
1 change: 1 addition & 0 deletions source/MRViewer/MRRibbonConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ constexpr float cBigIconSize = 20.0f;
constexpr int cSmallFontSize = 11;
constexpr int cDefaultFontSize = 13;
constexpr int cBigFontSize = 15;
constexpr int cHeadlineFontSize = 24;

constexpr float cPaletteDiscretizationScaling = 5.0f / 18.0f;

Expand Down
31 changes: 30 additions & 1 deletion source/MRViewer/MRRibbonFontManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace MR

void RibbonFontManager::loadAllFonts( ImWchar* charRanges, float scaling )
{
fonts_ = { nullptr,nullptr,nullptr,nullptr };
fonts_ = {};

const ImWchar iconRanges[] = { 0xe005, 0xf8ff, 0 };

Expand Down Expand Up @@ -40,6 +40,11 @@ float RibbonFontManager::getFontSizeByType( FontType type ) const
return cSmallFontSize;
case MR::RibbonFontManager::FontType::Icons:
return cBigIconSize;
case MR::RibbonFontManager::FontType::Headline:
return cHeadlineFontSize;
case MR::RibbonFontManager::FontType::Big:
case MR::RibbonFontManager::FontType::BigSemiBold:
return cBigFontSize;
case MR::RibbonFontManager::FontType::Count:
default:
return 0.f;
Expand Down Expand Up @@ -108,6 +113,30 @@ void RibbonFontManager::loadFont_( FontType type, const ImWchar* ranges, float s
&config, ranges );
fonts_[int( type )] = ImGui::GetIO().Fonts->Fonts.back();
}
else if ( type == FontType::BigSemiBold )
{
auto fontPath = getMenuFontPath();
fontPath = fontPath.parent_path() / "NotoSans-SemiBold.ttf";
ImFontConfig config;
config.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_Bitmap;
config.GlyphOffset = ImVec2( 0, -4 * scaling );
ImGui::GetIO().Fonts->AddFontFromFileTTF(
utf8string( fontPath ).c_str(), cBigFontSize * scaling,
&config, ranges );
fonts_[int( type )] = ImGui::GetIO().Fonts->Fonts.back();
}
else if ( type == FontType::Headline )
{
auto fontPath = getMenuFontPath();
fontPath = fontPath.parent_path() / "NotoSans-SemiBold.ttf";
ImFontConfig config;
config.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_Bitmap;
config.GlyphOffset = ImVec2( 0, -4 * scaling );
ImGui::GetIO().Fonts->AddFontFromFileTTF(
utf8string( fontPath ).c_str(), cHeadlineFontSize * scaling,
&config, ranges );
fonts_[int( type )] = ImGui::GetIO().Fonts->Fonts.back();
}
}

void RibbonFontManager::loadDefaultFont_( float fontSize, float yOffset )
Expand Down
2 changes: 2 additions & 0 deletions source/MRViewer/MRRibbonFontManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class MRVIEWER_CLASS RibbonFontManager
SemiBold,
Icons,
Big,
BigSemiBold,
Headline,
Count
};

Expand Down