Paint state transition for overlay 9 patch scrollbars
[chromium-blink-merge.git] / ui / app_list / views / folder_header_view.h
blobfa1498edb062546a079d14c1c8045b78436e8995
1 // Copyright (c) 2013 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.
5 #ifndef UI_APP_LIST_VIEWS_FOLDER_HEADER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_FOLDER_HEADER_VIEW_H_
8 #include <string>
10 #include "ui/app_list/app_list_export.h"
11 #include "ui/app_list/app_list_item_observer.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/textfield/textfield_controller.h"
14 #include "ui/views/view.h"
16 namespace views {
17 class ImageButton;
18 } // namespace views
20 namespace app_list {
22 class AppListFolderItem;
23 class AppListFolderView;
24 class FolderHeaderViewDelegate;
26 namespace test {
27 class FolderHeaderViewTest;
30 // FolderHeaderView contains a back button and an editable folder name field.
31 class APP_LIST_EXPORT FolderHeaderView : public views::View,
32 public views::TextfieldController,
33 public views::ButtonListener,
34 public AppListItemObserver {
35 public:
36 explicit FolderHeaderView(FolderHeaderViewDelegate* delegate);
37 virtual ~FolderHeaderView();
39 void SetFolderItem(AppListFolderItem* folder_item);
40 void UpdateFolderNameVisibility(bool visible);
41 void OnFolderItemRemoved();
43 // Overridden from views::View:
44 virtual gfx::Size GetPreferredSize() const OVERRIDE;
46 private:
47 class FolderNameView;
48 friend class test::FolderHeaderViewTest;
50 // Updates UI.
51 void Update();
53 // Updates the accessible name of the folder name control.
54 void UpdateFolderNameAccessibleName();
56 // Gets and sets the folder name for test.
57 const base::string16& GetFolderNameForTest();
58 void SetFolderNameForTest(const base::string16& name);
60 // Returns true if folder name is enabled, only for testing use.
61 bool IsFolderNameEnabledForTest() const;
63 // views::View overrides:
64 virtual void Layout() OVERRIDE;
65 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
66 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
68 // views::TextfieldController overrides:
69 virtual void ContentsChanged(views::Textfield* sender,
70 const base::string16& new_contents) OVERRIDE;
72 // views::ButtonListener overrides:
73 virtual void ButtonPressed(views::Button* sender,
74 const ui::Event& event) OVERRIDE;
76 // AppListItemObserver overrides:
77 virtual void ItemIconChanged() OVERRIDE;
78 virtual void ItemNameChanged() OVERRIDE;
79 virtual void ItemHighlightedChanged() OVERRIDE;
80 virtual void ItemIsInstallingChanged() OVERRIDE;
81 virtual void ItemPercentDownloadedChanged() OVERRIDE;
83 AppListFolderItem* folder_item_; // Not owned.
85 views::ImageButton* back_button_; // Owned by views hierarchy.
86 FolderNameView* folder_name_view_; // Owned by views hierarchy.
88 const base::string16 folder_name_placeholder_text_;
90 FolderHeaderViewDelegate* delegate_;
92 bool folder_name_visible_;
94 DISALLOW_COPY_AND_ASSIGN(FolderHeaderView);
97 } // namespace app_list
99 #endif // UI_APP_LIST_VIEWS_FOLDER_HEADER_VIEW_H_