• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_
7 #pragma once
8 
9 #include "views/view.h"
10 
11 class DropdownBarHost;
12 
13 ////////////////////////////////////////////////////////////////////////////////
14 //
15 // The DropdownBarView is an abstract view to draw the UI controls of the
16 // DropdownBarHost.
17 //
18 ////////////////////////////////////////////////////////////////////////////////
19 class DropdownBarView : public views::View {
20  public:
DropdownBarView(DropdownBarHost * host)21   explicit DropdownBarView(DropdownBarHost* host)
22       : host_(host),
23         animation_offset_(0) {
24   }
~DropdownBarView()25   virtual ~DropdownBarView() {}
26 
27   // Claims focus for the text field and selects its contents.
28   virtual void SetFocusAndSelection(bool select_all) = 0;
29 
30   // Updates the view to let it know where the host is clipping the
31   // dropdown widget (while animating the opening or closing of the widget).
set_animation_offset(int offset)32   void set_animation_offset(int offset) { animation_offset_ = offset; }
33 
34   // Returns the offset used while animating.
animation_offset()35   int animation_offset() const { return animation_offset_; }
36 
37  protected:
38   // Returns the DropdownBarHost that manages this view.
host()39   DropdownBarHost* host() const { return host_; }
40 
41  private:
42   // The dropdown bar host that controls this view.
43   DropdownBarHost* host_;
44 
45   // While animating, the host clips the widget and draws only the bottom
46   // part of it. The view needs to know the pixel offset at which we are drawing
47   // the widget so that we can draw the curved edges that attach to the toolbar
48   // in the right location.
49   int animation_offset_;
50 
51   DISALLOW_COPY_AND_ASSIGN(DropdownBarView);
52 };
53 
54 #endif  // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_VIEW_H_
55