[aseprite] 191/250: Make viewport bigger when we load a new font on FontPopup
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:29 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 2a09990b16513bcb2dd19d270cacf8f6a5a7e381
Author: David Capello <davidcapello at gmail.com>
Date: Fri Oct 16 18:51:35 2015 -0300
Make viewport bigger when we load a new font on FontPopup
---
src/app/ui/font_popup.cpp | 8 +++++---
src/ui/listbox.cpp | 34 +++++++++++++++++++---------------
src/ui/listbox.h | 1 +
3 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/src/app/ui/font_popup.cpp b/src/app/ui/font_popup.cpp
index 57557c8..12b7c46 100644
--- a/src/app/ui/font_popup.cpp
+++ b/src/app/ui/font_popup.cpp
@@ -89,7 +89,8 @@ private:
}
void onSelect() override {
- if (!getParent())
+ ListBox* listbox = static_cast<ListBox*>(getParent());
+ if (!listbox)
return;
app::skin::SkinTheme* theme = app::skin::SkinTheme::instance();
@@ -105,8 +106,9 @@ private:
gfx::getb(color),
gfx::geta(color))));
- getParent()->layout();
- invalidate();
+ View* view = View::getView(listbox);
+ view->updateView();
+ listbox->makeChildVisible(this);
}
catch (const std::exception& ex) {
Console::showException(ex);
diff --git a/src/ui/listbox.cpp b/src/ui/listbox.cpp
index bbe53fa..6cbda29 100644
--- a/src/ui/listbox.cpp
+++ b/src/ui/listbox.cpp
@@ -64,22 +64,8 @@ void ListBox::selectChild(Widget* item)
}
if (item) {
- View* view = View::getView(this);
-
item->setSelected(true);
-
- if (view) {
- gfx::Rect vp = view->getViewportBounds();
- gfx::Point scroll = view->getViewScroll();
-
- if (item->getBounds().y < vp.y)
- scroll.y = item->getBounds().y - getBounds().y;
- else if (item->getBounds().y > vp.y + vp.h - item->getBounds().h)
- scroll.y = (item->getBounds().y - getBounds().y
- - vp.h + item->getBounds().h);
-
- view->setViewScroll(scroll);
- }
+ makeChildVisible(item);
}
onChange();
@@ -101,6 +87,24 @@ std::size_t ListBox::getItemsCount() const
return getChildren().size();
}
+void ListBox::makeChildVisible(Widget* child)
+{
+ View* view = View::getView(this);
+ if (!view)
+ return;
+
+ gfx::Point scroll = view->getViewScroll();
+ gfx::Rect vp = view->getViewportBounds();
+
+ if (child->getBounds().y < vp.y)
+ scroll.y = child->getBounds().y - getBounds().y;
+ else if (child->getBounds().y > vp.y + vp.h - child->getBounds().h)
+ scroll.y = (child->getBounds().y - getBounds().y
+ - vp.h + child->getBounds().h);
+
+ view->setViewScroll(scroll);
+}
+
// Setup the scroll to center the selected item in the viewport
void ListBox::centerScroll()
{
diff --git a/src/ui/listbox.h b/src/ui/listbox.h
index 043d90a..3a7ec3d 100644
--- a/src/ui/listbox.h
+++ b/src/ui/listbox.h
@@ -27,6 +27,7 @@ namespace ui {
std::size_t getItemsCount() const;
+ void makeChildVisible(Widget* item);
void centerScroll();
void sortItems();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list