]> git.sesse.net Git - casparcg/blobdiff - core/diagnostics/osd_graph.cpp
Merge branch '2.1.0' of https://github.com/CasparCG/Server into 2.1.0
[casparcg] / core / diagnostics / osd_graph.cpp
index f9b49c2731282ad92cdc210d52f0b507291b41da..fefc74403b3a2c20e8d469e8080e99a10656dbab 100644 (file)
@@ -74,7 +74,7 @@ sf::Font& get_default_font()
        {
                sf::Font font;
                if (!font.loadFromFile("LiberationSans-Regular.ttf"))
-                       CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("LiberationSans-Regular.ttf not found"));
+                       CASPAR_THROW_EXCEPTION(file_not_found() << msg_info("LiberationSans-Regular.ttf not found"));
                return font;
        }();
 
@@ -207,13 +207,22 @@ private:
 
                if (calculate_view_)
                {
+                       int content_height              = static_cast<int>(RENDERING_HEIGHT * drawables_.size());
+                       int window_height               = static_cast<int>(window_->getSize().y);
+                       int not_visible                 = std::max(0, content_height - window_height);
+                       int min_scroll_position = -not_visible;
+                       int max_scroll_position = 0;
+
+                       scroll_position_ = std::min(max_scroll_position, std::max(min_scroll_position, scroll_position_));
                        view_.setViewport(sf::FloatRect(0, 0, 1.0, 1.0));
-                       view_.setSize(RENDERING_WIDTH, window_->getSize().y);
-                       view_.setCenter(RENDERING_WIDTH / 2, window_->getSize().y / 2 - scroll_position_);
+                       view_.setSize(RENDERING_WIDTH, window_height);
+                       view_.setCenter(RENDERING_WIDTH / 2, window_height / 2 - scroll_position_);
                        window_->setView(view_);
+
                        calculate_view_ = false;
                }
 
+               CASPAR_LOG_CALL(trace) << "osd_graph::tick()";
                window_->draw(*this);
 
                static const auto THRESHOLD = 1;