~brandontschaefer/nux/xim-tests

« back to all changes in this revision

Viewing changes to examples/kinetic_scroll_view.cpp

  • Committer: Brandon Schaefer
  • Date: 2012-10-19 00:23:27 UTC
  • mfrom: (637.2.55 trunk)
  • Revision ID: brandon.schaefer@canonical.com-20121019002327-60e88jn3k8chi7gt
* Merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 - Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License, as
 
6
 * published by the  Free Software Foundation; either version 2.1 or 3.0
 
7
 * of the License.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful, but
 
10
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
12
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
13
 * License for more details.
 
14
 *
 
15
 * You should have received a copy of both the GNU Lesser General Public
 
16
 * License along with this program. If not, see <http://www.gnu.org/licenses/>
 
17
 *
 
18
 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
 
19
 */
 
20
 
 
21
#include <Nux/Nux.h>
 
22
#include <Nux/KineticScrollView.h>
 
23
#include <Nux/HLayout.h>
 
24
#include <Nux/VLayout.h>
 
25
 
 
26
#include "TestButton.h"
 
27
 
 
28
using namespace nux;
 
29
 
 
30
View *CreateKineticScrollView()
 
31
{
 
32
  VLayout *layout = new VLayout (NUX_TRACKER_LOCATION);
 
33
 
 
34
  char buffer[500];
 
35
  for (int i = 0; i < 100; i++)
 
36
  {
 
37
    sprintf(buffer, "TestButton %d", i+1);
 
38
    Button *button = new TestButton(buffer, NUX_TRACKER_LOCATION);
 
39
    button->SetMinimumHeight(50);
 
40
 
 
41
    layout->AddView(button, 1, eLeft, eFull);
 
42
  }
 
43
 
 
44
  KineticScrollView *kinetic_scroll_view = new KineticScrollView(NUX_TRACKER_LOCATION);
 
45
  kinetic_scroll_view->SetLayout(layout);
 
46
  kinetic_scroll_view->SetScrollableDirections(ScrollableDirectionsVertical);
 
47
 
 
48
  return kinetic_scroll_view;
 
49
}
 
50
 
 
51
void UserInterfaceInitialization(NThread* /* thread */, void* /* InitData */)
 
52
{
 
53
 
 
54
  HLayout* mainLayout = new HLayout(NUX_TRACKER_LOCATION);
 
55
  mainLayout->AddView(CreateKineticScrollView(), 1, eCenter, eFull);
 
56
 
 
57
  GetWindowThread()->SetLayout(mainLayout);
 
58
}
 
59
 
 
60
int main()
 
61
{
 
62
  NuxInitialize(0);
 
63
 
 
64
  WindowThread* window_thread = CreateGUIThread(
 
65
      "KineticScrollView Example", 640, 300, 0, &UserInterfaceInitialization, 0);
 
66
 
 
67
  // Start the main loop.
 
68
  window_thread->Run(NULL);
 
69
 
 
70
  delete window_thread;
 
71
  return 0;
 
72
}