summaryrefslogtreecommitdiffstats
path: root/mojo/examples/window_manager/debug_panel.h
blob: 181de764a97735d2f455426eaff0eb69a43435ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_
#define MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_

#include <string>

#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/layout/layout_manager.h"
#include "ui/views/widget/widget_delegate.h"

namespace views {
class Label;
class RadioButton;
}

namespace mojo {

class Node;

namespace examples {

namespace {
const SkColor kColors[] = { SK_ColorYELLOW,
                            SK_ColorRED,
                            SK_ColorGREEN,
                            SK_ColorMAGENTA };
}

// A panel of controls intended to demonstrate the functionality of the window
// manager.
class DebugPanel : public views::LayoutManager, public views::ButtonListener {
 public:
  class Delegate {
   public:
    virtual void CloseTopWindow() = 0;
    virtual void RequestNavigate(
        uint32 source_node_id, Target target,
        NavigationDetailsPtr nav_details) = 0;
   protected:
    virtual ~Delegate(){}
  };

  DebugPanel(Delegate* delegate, Node* node);
  virtual ~DebugPanel();

  Target navigation_target() const;

 private:
  // LayoutManager overrides:
  virtual gfx::Size GetPreferredSize(const views::View* view) const OVERRIDE;
  virtual void Layout(views::View* host) OVERRIDE;
  virtual void ButtonPressed(views::Button* sender,
                             const ui::Event& event) OVERRIDE;

  void Navigate(const std::string& url);

  Delegate* delegate_;
  Node* node_;

  views::Label* navigation_target_label_;
  views::RadioButton* navigation_target_new_;
  views::RadioButton* navigation_target_source_;
  views::RadioButton* navigation_target_default_;

  size_t next_color_;
  views::Button* colored_square_;
  views::Button* close_last_;
  views::Button* cross_app_;

  DISALLOW_COPY_AND_ASSIGN(DebugPanel);
};

}  // examples
}  // mojo

#endif  //  MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_