~unity-team/unity/trusty-1066971

« back to all changes in this revision

Viewing changes to unity-shared/OverlayScrollView.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2014-08-06 14:09:30 UTC
  • mto: This revision was merged to the branch mainline in revision 3802.
  • Revision ID: mail@3v1n0.net-20140806140930-knkc0x43ree376r1
PlacesOverlayVScrollBar and VScrollBarOverlayWindow: add support for scaling

Add a new ScrollView class to create ScrollViews with an OverlayScrollbar and with scaling support.
Using them in dash Scopes and Previews.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
 
2
/*
 
3
 * Copyright (C) 2014 Canonical Ltd
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License version 3 as
 
7
 * published by the Free Software Foundation.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
 
18
 */
 
19
 
 
20
#include "OverlayScrollView.h"
 
21
#include "PlacesOverlayVScrollBar.h"
 
22
#include "RawPixel.h"
 
23
 
 
24
namespace unity
 
25
{
 
26
namespace dash
 
27
{
 
28
namespace
 
29
{
 
30
  const RawPixel MOUSE_WHEEL_SCROLL_SIZE = 32_em;
 
31
}
 
32
 
 
33
ScrollView::ScrollView(NUX_FILE_LINE_DECL)
 
34
  : nux::ScrollView(NUX_FILE_LINE_PARAM)
 
35
{
 
36
  auto* scrollbar = new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION);
 
37
  SetVScrollBar(scrollbar);
 
38
 
 
39
  scale.SetGetterFunction([scrollbar] { return scrollbar->scale(); });
 
40
  scale.SetSetterFunction([scrollbar] (double scale) {
 
41
    if (scrollbar->scale() == scale)
 
42
      return false;
 
43
 
 
44
    scrollbar->scale = scale;
 
45
    return true;
 
46
  });
 
47
 
 
48
  m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale);
 
49
 
 
50
  scale.changed.connect([this] (double scale) {
 
51
    m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale);
 
52
  });
 
53
}
 
54
 
 
55
} // dash namespace
 
56
} // unity namespace
 
 
b'\\ No newline at end of file'