diff --git a/Application/src/commons/common/gui/IMGUIBase.cpp b/Application/src/commons/common/gui/IMGUIBase.cpp index c2221fada385979ca87ba6a7a9f02459bdee8388..d0eb29dcf3d7acb90d10b1a0f27ea03c16494761 100644 --- a/Application/src/commons/common/gui/IMGUIBase.cpp +++ b/Application/src/commons/common/gui/IMGUIBase.cpp @@ -422,7 +422,7 @@ void clear_cache() { file::Path path("fonts/Quicksand-"); if (!path.add_extension("ttf").exists()) - U_EXCEPTION("Cannot find file '%S'", &path.str()); + Except("Cannot find file '%S'", &path.str()); auto io = ImGui::GetIO(); //io.FontAllowUserScaling = true; @@ -449,8 +449,11 @@ void clear_cache() { auto full = path.str() + suffix + ".ttf"; auto ptr = io.Fonts->AddFontFromFileTTF(full.c_str(), base_scale * im_font_scale, &config); - if(!ptr) - U_EXCEPTION("Cannot load font '%S' with index %d.", &path.str(), config.FontNo); + if (!ptr) { + Warning("Cannot load font '%S' with index %d.", &path.str(), config.FontNo); + ptr = io.Fonts->AddFontDefault(); + im_font_scale = max(1, dpi_scale) * 0.5; + } ptr->FontSize = base_scale * im_font_scale; return ptr; diff --git a/Application/src/commons/common/gui/types/Layout.h b/Application/src/commons/common/gui/types/Layout.h index 32062cf687897c25424bfd7f4d3aa1203fd73549..b8a265bd3b5cd764e022f743b6efdd62b986931c 100644 --- a/Application/src/commons/common/gui/types/Layout.h +++ b/Application/src/commons/common/gui/types/Layout.h @@ -22,7 +22,7 @@ namespace gui { bool operator<(derived_ptr<Base> other) const { return get() < other.get(); } operator bool() const { return get() != nullptr; } - Base* operator ->() { return get(); } + Base* operator ->() const { return get(); } template<typename T> operator derived_ptr<T> () { diff --git a/Application/src/commons/common/gui/types/ScrollableList.h b/Application/src/commons/common/gui/types/ScrollableList.h index 9e569e53e97d776f12e31c724861c909692b71c6..b13d081c51b567ae0902c5857ac49ee94da6e52c 100644 --- a/Application/src/commons/common/gui/types/ScrollableList.h +++ b/Application/src/commons/common/gui/types/ScrollableList.h @@ -23,9 +23,10 @@ namespace gui { template <typename Q = T> class Item { GETTER(Q, value) + GETTER_SETTER(bool, hovered) public: - Item(T v) : _value(v) {} + Item(T v) : _value(v), _hovered(false) {} }; GETTER(std::vector<Item<T>>, items) @@ -342,7 +343,8 @@ namespace gui { for(auto rect : _rects) { auto idx = rect_to_idx[rect]; auto item = static_cast<const CustomItem*>(&_items[idx].value()); - + _items[idx].set_hovered(rect->hovered()); + if(rect->pressed() || (_stays_toggled && (long)rect_to_idx[rect] == _last_selected_item)) rect->set_fillclr(item->base_color().brightenHSL(0.15f)); else if(rect->hovered()) @@ -353,6 +355,9 @@ namespace gui { } else { for(auto rect : _rects) { + auto idx = rect_to_idx[rect]; + _items[idx].set_hovered(rect->hovered()); + if(rect->pressed() || (_stays_toggled && (long)rect_to_idx[rect] == _last_selected_item)) rect->set_fillclr(_item_color.brighten(0.15f)); else if(rect->hovered())