Skip to content

Commit

Permalink
Merge pull request #18 from jeremytieman/warnings-fix
Browse files Browse the repository at this point in the history
Fixed various warnings
  • Loading branch information
gallickgunner authored May 29, 2020
2 parents 200f08f + 4ae9d01 commit f463e29
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions FileBrowser/ImGuiFileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace imgui_addons
float list_item_height = GImGui->FontSize + style.ItemSpacing.y;

ImVec2 pw_content_size = ImGui::GetWindowSize() - style.WindowPadding * 2.0;
ImVec2 sw_size = ImVec2(ImGui::CalcTextSize("Random").x + 140, style.WindowPadding.y * 2.0 + frame_height);
ImVec2 sw_size = ImVec2(ImGui::CalcTextSize("Random").x + 140, style.WindowPadding.y * 2.0f + frame_height);
ImVec2 sw_content_size = sw_size - style.WindowPadding * 2.0;
ImVec2 nw_size = ImVec2(pw_content_size.x - style.ItemSpacing.x - sw_size.x, sw_size.y);

Expand Down Expand Up @@ -318,22 +318,22 @@ namespace imgui_addons
float list_item_height = ImGui::CalcTextSize("").y + style.ItemSpacing.y;
float input_bar_ypos = pw_size.y - ImGui::GetFrameHeightWithSpacing() * 2.5f - style.WindowPadding.y;
float window_height = input_bar_ypos - ImGui::GetCursorPosY() - style.ItemSpacing.y;
float window_content_height = window_height - style.WindowPadding.y * 2.0;
float window_content_height = window_height - style.WindowPadding.y * 2.0f;
float min_content_size = pw_size.x - style.WindowPadding.x * 4.0f;

if(window_content_height <= 0.0f)
return show_error;

//Reinitialize the limit on number of selectables in one column based on height
col_items_limit = std::max(1.0f, window_content_height/list_item_height);
int num_cols = std::max(1.0f, std::ceil(static_cast<float>(filtered_dirs.size() + filtered_files.size()) / col_items_limit));
col_items_limit = static_cast<int>(std::max(1.0f, window_content_height/list_item_height));
int num_cols = static_cast<int>(std::max(1.0f, std::ceil(static_cast<float>(filtered_dirs.size() + filtered_files.size()) / col_items_limit)));

//Limitation by ImGUI in 1.75. If columns are greater than 64 readjust the limit on items per column and recalculate number of columns
if(num_cols > 64)
{
int exceed_items_amount = (num_cols - 64) * col_items_limit;
col_items_limit += std::ceil(exceed_items_amount/64.0);
num_cols = std::max(1.0f, std::ceil(static_cast<float>(filtered_dirs.size() + filtered_files.size()) / col_items_limit));
col_items_limit += static_cast<int>(std::ceil(exceed_items_amount/64.0));
num_cols = static_cast<int>(std::max(1.0f, std::ceil(static_cast<float>(filtered_dirs.size() + filtered_files.size()) / col_items_limit)));
}

float content_width = num_cols * col_width;
Expand Down Expand Up @@ -381,7 +381,7 @@ namespace imgui_addons
items++;
if(ImGui::Selectable(filtered_files[i]->name.c_str(), selected_idx == i && !is_dir, ImGuiSelectableFlags_AllowDoubleClick))
{
int len = filtered_files[i]->name.length();
//int len = filtered_files[i]->name.length();
selected_idx = i;
is_dir = false;

Expand Down Expand Up @@ -505,7 +505,7 @@ namespace imgui_addons
float buttons_xpos;

if (dialog_mode == DialogMode::SELECT)
buttons_xpos = pw_size.x - opensave_btn_width - (2.0 * selcan_btn_width) - ( 2.0 * style.ItemSpacing.x) - style.WindowPadding.x;
buttons_xpos = pw_size.x - opensave_btn_width - (2.0f * selcan_btn_width) - ( 2.0f * style.ItemSpacing.x) - style.WindowPadding.x;
else
buttons_xpos = pw_size.x - opensave_btn_width - selcan_btn_width - style.ItemSpacing.x - style.WindowPadding.x;

Expand Down Expand Up @@ -897,7 +897,7 @@ namespace imgui_addons
ImGui::TextWrapped("%s", error_msg.c_str());

ImGui::Separator();
ImGui::SetCursorPosX(window_size.x/2.0 - getButtonSize("OK").x/2.0);
ImGui::SetCursorPosX(window_size.x/2.0f - getButtonSize("OK").x/2.0f);
if (ImGui::Button("OK", getButtonSize("OK")))
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
Expand All @@ -919,7 +919,7 @@ namespace imgui_addons
ImGui::Separator();

float buttons_width = getButtonSize("Yes").x + getButtonSize("No").x + ImGui::GetStyle().ItemSpacing.x;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetWindowWidth()/2.0 - buttons_width/2.0 - ImGui::GetStyle().WindowPadding.x);
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetWindowWidth()/2.0f - buttons_width/2.0f - ImGui::GetStyle().WindowPadding.x);

if (ImGui::Button("Yes", getButtonSize("Yes")))
{
Expand All @@ -945,7 +945,7 @@ namespace imgui_addons
{
ImGuiStyle& style = ImGui::GetStyle();
std::string text = "Selected file either doesn't exist or is not supported. Please select a file with the following extensions...";
ImVec2 text_size = ImGui::CalcTextSize(text.c_str(), nullptr, true, 350 - style.WindowPadding.x * 2.0);
ImVec2 text_size = ImGui::CalcTextSize(text.c_str(), nullptr, true, 350 - style.WindowPadding.x * 2.0f);
ImVec2 button_size = getButtonSize("OK");

float frame_height = ImGui::GetFrameHeightWithSpacing();
Expand All @@ -963,7 +963,7 @@ namespace imgui_addons
ImGui::BulletText("%s", valid_exts[i].c_str());
ImGui::EndChild();

ImGui::SetCursorPosX(window_size.x/2.0 - button_size.x/2.0);
ImGui::SetCursorPosX(window_size.x/2.0f - button_size.x/2.0f);
if (ImGui::Button("OK", button_size))
ImGui::CloseCurrentPopup();
ImGui::EndPopup();
Expand Down Expand Up @@ -1052,7 +1052,7 @@ namespace imgui_addons
if(ext == "*.*")
return true;
}
int idx = selected_fn.find_last_of('.');
size_t idx = selected_fn.find_last_of('.');
std::string file_ext = idx == std::string::npos ? "" : selected_fn.substr(idx, selected_fn.length() - idx);
return (std::find(valid_exts.begin(), valid_exts.end(), file_ext) != valid_exts.end());
}
Expand Down

0 comments on commit f463e29

Please sign in to comment.