fix(ui): enlarge top toolbar actions
This commit is contained in:
@@ -3030,7 +3030,7 @@ bool toolbar_action(const char* id, const char* label, const char* icon, const c
|
|||||||
bool* dropdown_clicked = nullptr) {
|
bool* dropdown_clicked = nullptr) {
|
||||||
ImGui::PushID(id);
|
ImGui::PushID(id);
|
||||||
if (!enabled) ImGui::BeginDisabled();
|
if (!enabled) ImGui::BeginDisabled();
|
||||||
const bool raw_clicked = ImGui::InvisibleButton("##action", {ui(logical_width), ui(46.0f)});
|
const bool raw_clicked = ImGui::InvisibleButton("##action", {ui(logical_width), ui(54.0f)});
|
||||||
const ImVec2 minimum = ImGui::GetItemRectMin();
|
const ImVec2 minimum = ImGui::GetItemRectMin();
|
||||||
const ImVec2 maximum = ImGui::GetItemRectMax();
|
const ImVec2 maximum = ImGui::GetItemRectMax();
|
||||||
const bool clicked_dropdown = raw_clicked && dropdown &&
|
const bool clicked_dropdown = raw_clicked && dropdown &&
|
||||||
@@ -3042,7 +3042,7 @@ bool toolbar_action(const char* id, const char* label, const char* icon, const c
|
|||||||
draw->AddRectFilled(minimum, maximum, IM_COL32(62, 66, 75, 210));
|
draw->AddRectFilled(minimum, maximum, IM_COL32(62, 66, 75, 210));
|
||||||
const ImU32 text_color = enabled ? IM_COL32(218, 221, 226, 255) : IM_COL32(139, 144, 153, 255);
|
const ImU32 text_color = enabled ? IM_COL32(218, 221, 226, 255) : IM_COL32(139, 144, 153, 255);
|
||||||
const float label_font_size = ImGui::GetFontSize() * 0.62f;
|
const float label_font_size = ImGui::GetFontSize() * 0.62f;
|
||||||
const float icon_font_size = ImGui::GetFontSize() * 1.34f;
|
const float icon_font_size = ImGui::GetFontSize() * 1.62f;
|
||||||
const ImVec2 label_size = g_regular_font
|
const ImVec2 label_size = g_regular_font
|
||||||
? g_regular_font->CalcTextSizeA(label_font_size, std::numeric_limits<float>::max(), 0.0f, label)
|
? g_regular_font->CalcTextSizeA(label_font_size, std::numeric_limits<float>::max(), 0.0f, label)
|
||||||
: ImGui::CalcTextSize(label);
|
: ImGui::CalcTextSize(label);
|
||||||
@@ -3050,20 +3050,20 @@ bool toolbar_action(const char* id, const char* label, const char* icon, const c
|
|||||||
? g_regular_font->CalcTextSizeA(icon_font_size, std::numeric_limits<float>::max(), 0.0f, icon)
|
? g_regular_font->CalcTextSizeA(icon_font_size, std::numeric_limits<float>::max(), 0.0f, icon)
|
||||||
: ImGui::CalcTextSize(icon);
|
: ImGui::CalcTextSize(icon);
|
||||||
draw->AddText(g_regular_font, label_font_size,
|
draw->AddText(g_regular_font, label_font_size,
|
||||||
{minimum.x + (maximum.x - minimum.x - label_size.x) * 0.5f, minimum.y + ui(4.0f)},
|
{minimum.x + (maximum.x - minimum.x - label_size.x) * 0.5f, minimum.y + ui(5.0f)},
|
||||||
text_color, label);
|
text_color, label);
|
||||||
const float icon_x = minimum.x + (maximum.x - minimum.x - icon_size.x) * 0.5f - (dropdown ? ui(4.0f) : 0.0f);
|
const float icon_x = minimum.x + (maximum.x - minimum.x - icon_size.x) * 0.5f - (dropdown ? ui(4.0f) : 0.0f);
|
||||||
if (spinning) {
|
if (spinning) {
|
||||||
const ImVec2 center{
|
const ImVec2 center{
|
||||||
minimum.x + (maximum.x - minimum.x) * 0.5f - (dropdown ? ui(4.0f) : 0.0f),
|
minimum.x + (maximum.x - minimum.x) * 0.5f - (dropdown ? ui(4.0f) : 0.0f),
|
||||||
minimum.y + ui(27.0f)
|
minimum.y + ui(31.0f)
|
||||||
};
|
};
|
||||||
draw_toolbar_spinner(draw, center, ui(7.0f), text_color);
|
draw_toolbar_spinner(draw, center, ui(8.5f), text_color);
|
||||||
} else {
|
} else {
|
||||||
draw->AddText(g_regular_font, icon_font_size, {icon_x, minimum.y + ui(19.0f)}, text_color, icon);
|
draw->AddText(g_regular_font, icon_font_size, {icon_x, minimum.y + ui(21.0f)}, text_color, icon);
|
||||||
}
|
}
|
||||||
if (dropdown)
|
if (dropdown)
|
||||||
draw->AddText({icon_x + icon_size.x + ui(7.0f), minimum.y + ui(21.0f)}, text_color, ICON_TB_CARET_DOWN);
|
draw->AddText({icon_x + icon_size.x + ui(7.0f), minimum.y + ui(24.0f)}, text_color, ICON_TB_CARET_DOWN);
|
||||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) {
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort)) {
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
ImGui::TextUnformatted(tooltip);
|
ImGui::TextUnformatted(tooltip);
|
||||||
@@ -3109,7 +3109,7 @@ void draw_pull_options() {
|
|||||||
bool toolbar_selector(const char* id, const char* label, const std::string& value,
|
bool toolbar_selector(const char* id, const char* label, const std::string& value,
|
||||||
float logical_width, bool trailing_arrow = false) {
|
float logical_width, bool trailing_arrow = false) {
|
||||||
ImGui::PushID(id);
|
ImGui::PushID(id);
|
||||||
const bool clicked = ImGui::InvisibleButton("##selector", {ui(logical_width), ui(46.0f)});
|
const bool clicked = ImGui::InvisibleButton("##selector", {ui(logical_width), ui(54.0f)});
|
||||||
const ImVec2 minimum = ImGui::GetItemRectMin();
|
const ImVec2 minimum = ImGui::GetItemRectMin();
|
||||||
const ImVec2 maximum = ImGui::GetItemRectMax();
|
const ImVec2 maximum = ImGui::GetItemRectMax();
|
||||||
ImDrawList* draw = ImGui::GetWindowDrawList();
|
ImDrawList* draw = ImGui::GetWindowDrawList();
|
||||||
@@ -3117,7 +3117,7 @@ bool toolbar_selector(const char* id, const char* label, const std::string& valu
|
|||||||
if (hovered) draw->AddRectFilled(minimum, maximum, IM_COL32(62, 66, 75, 200));
|
if (hovered) draw->AddRectFilled(minimum, maximum, IM_COL32(62, 66, 75, 200));
|
||||||
const float label_font_size = ImGui::GetFontSize() * 0.78f;
|
const float label_font_size = ImGui::GetFontSize() * 0.78f;
|
||||||
draw->AddText(g_regular_font, label_font_size,
|
draw->AddText(g_regular_font, label_font_size,
|
||||||
{minimum.x + ui(8), minimum.y + ui(4.0f)}, IM_COL32(166, 172, 182, 255), label);
|
{minimum.x + ui(8), minimum.y + ui(5.0f)}, IM_COL32(166, 172, 182, 255), label);
|
||||||
const float value_width = maximum.x - minimum.x - ui(34.0f);
|
const float value_width = maximum.x - minimum.x - ui(34.0f);
|
||||||
std::string displayed = value;
|
std::string displayed = value;
|
||||||
if (ImGui::CalcTextSize(displayed.c_str()).x > value_width) {
|
if (ImGui::CalcTextSize(displayed.c_str()).x > value_width) {
|
||||||
@@ -3132,8 +3132,8 @@ bool toolbar_selector(const char* id, const char* label, const std::string& valu
|
|||||||
}
|
}
|
||||||
displayed += ellipsis;
|
displayed += ellipsis;
|
||||||
}
|
}
|
||||||
draw->AddText({minimum.x + ui(8), minimum.y + ui(25.0f)}, IM_COL32(226, 229, 233, 255), displayed.c_str());
|
draw->AddText({minimum.x + ui(8), minimum.y + ui(30.0f)}, IM_COL32(226, 229, 233, 255), displayed.c_str());
|
||||||
draw->AddText({maximum.x - ui(18), minimum.y + ui(25.0f)}, IM_COL32(160, 165, 174, 255),
|
draw->AddText({maximum.x - ui(18), minimum.y + ui(30.0f)}, IM_COL32(160, 165, 174, 255),
|
||||||
trailing_arrow ? ICON_TB_ANGLE_RIGHT : ICON_TB_CARET_DOWN);
|
trailing_arrow ? ICON_TB_ANGLE_RIGHT : ICON_TB_CARET_DOWN);
|
||||||
if (displayed != value && ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort))
|
if (displayed != value && ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort))
|
||||||
ImGui::SetTooltip("%s", value.c_str());
|
ImGui::SetTooltip("%s", value.c_str());
|
||||||
@@ -4115,7 +4115,7 @@ void draw_app() {
|
|||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {ImGui::GetStyle().ItemSpacing.x, 0.0f});
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, {ImGui::GetStyle().ItemSpacing.x, 0.0f});
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(46 / 255.0f, 50 / 255.0f, 59 / 255.0f, 1.0f));
|
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(46 / 255.0f, 50 / 255.0f, 59 / 255.0f, 1.0f));
|
||||||
ImGui::BeginChild("repo_toolbar", {-1, ui(50)}, ImGuiChildFlags_None,
|
ImGui::BeginChild("repo_toolbar", {-1, ui(58)}, ImGuiChildFlags_None,
|
||||||
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
||||||
ImGui::SetCursorPos({ui(5), ui(2)});
|
ImGui::SetCursorPos({ui(5), ui(2)});
|
||||||
ImGui::PushFont(g_bold_font, 0.0f);
|
ImGui::PushFont(g_bold_font, 0.0f);
|
||||||
@@ -4179,7 +4179,7 @@ void draw_app() {
|
|||||||
const float action_group_width = ui(418.0f);
|
const float action_group_width = ui(418.0f);
|
||||||
const float centered_x = (ImGui::GetWindowWidth() - action_group_width) * 0.5f;
|
const float centered_x = (ImGui::GetWindowWidth() - action_group_width) * 0.5f;
|
||||||
const bool toolbar_busy = g_running_toolbar_action != ToolbarActionRequest::none;
|
const bool toolbar_busy = g_running_toolbar_action != ToolbarActionRequest::none;
|
||||||
ImGui::SetCursorPos({std::max(selectors_right + ui(10.0f), centered_x), ui(2.0f)});
|
ImGui::SetCursorPos({std::max(selectors_right + ui(10.0f), centered_x), ui(1.0f)});
|
||||||
|
|
||||||
if (toolbar_action("undo", "Undo", ICON_TB_ROTATE_LEFT, repo().undo_action.tooltip.c_str(),
|
if (toolbar_action("undo", "Undo", ICON_TB_ROTATE_LEFT, repo().undo_action.tooltip.c_str(),
|
||||||
repo().undo_action.available, false, 54))
|
repo().undo_action.available, false, 54))
|
||||||
|
|||||||
Reference in New Issue
Block a user