diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-07-12 00:24:13 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-07-12 00:24:13 +0200 |
| commit | 6e24926ab09be838048c4fa65623e8c286e5fd65 (patch) | |
| tree | bec3784e3e0648f602ca4a962465cd68faa9b428 /unity-shared | |
| parent | 2f4a81a0dabf9771a33ea68efc0e9f5a084f7228 (diff) | |
OverlayScrollView: a simple class to create nux scroll views that use our Overlay Scrollbars
(bzr r3830.6.14)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | unity-shared/OverlayScrollView.cpp | 45 | ||||
| -rw-r--r-- | unity-shared/OverlayScrollView.h | 43 |
3 files changed, 89 insertions, 0 deletions
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index b56c77990..ed39e5809 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -44,6 +44,7 @@ set (UNITY_SHARED_SOURCES LineSeparator.cpp MenuManager.cpp OverlayRenderer.cpp + OverlayScrollView.cpp OverlayWindowButtons.cpp PanelStyle.cpp PlacesVScrollBar.cpp diff --git a/unity-shared/OverlayScrollView.cpp b/unity-shared/OverlayScrollView.cpp new file mode 100644 index 000000000..857e3d9df --- /dev/null +++ b/unity-shared/OverlayScrollView.cpp @@ -0,0 +1,45 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2014 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> + */ + +#include "OverlayScrollView.h" +#include "PlacesOverlayVScrollBar.h" + +namespace unity +{ +namespace dash +{ + +ScrollView::ScrollView(NUX_FILE_LINE_DECL) + : nux::ScrollView(NUX_FILE_LINE_PARAM) +{ + auto* scrollbar = new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION); + SetVScrollBar(scrollbar); + + scale.SetGetterFunction([scrollbar] { return scrollbar->scale(); }); + scale.SetSetterFunction([scrollbar] (double scale) { + if (scrollbar->scale() == scale) + return false; + + scrollbar->scale = scale; + return true; + }); +} + +} // dash namespace +} // unity namespace \ No newline at end of file diff --git a/unity-shared/OverlayScrollView.h b/unity-shared/OverlayScrollView.h new file mode 100644 index 000000000..1cabd05a8 --- /dev/null +++ b/unity-shared/OverlayScrollView.h @@ -0,0 +1,43 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2014 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> + */ + +#ifndef _UNITY_SCROLL_VIEW_H_ +#define _UNITY_SCROLL_VIEW_H_ + +#include <Nux/Nux.h> + +namespace unity +{ +namespace dash +{ + +class ScrollView : public nux::ScrollView +{ +public: + ScrollView(NUX_FILE_LINE_PROTO); + + nux::RWProperty<double> scale; + + using nux::ScrollView::SetVScrollBar; +}; + +} // dash namespace +} // unity namespace + +#endif // _UNITY_SCROLL_VIEW_H_ |
