OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/ime/tray_ime.h" | 5 #include "ash/system/ime/tray_ime.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_details_view.h" |
13 #include "ash/system/tray/tray_item_more.h" | 14 #include "ash/system/tray/tray_item_more.h" |
14 #include "ash/system/tray/tray_item_view.h" | 15 #include "ash/system/tray/tray_item_view.h" |
15 #include "ash/system/tray/tray_views.h" | 16 #include "ash/system/tray/tray_views.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
18 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
19 #include "grit/ui_resources.h" | 20 #include "grit/ui_resources.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
(...skipping 24 matching lines...) Expand all Loading... |
47 | 48 |
48 void UpdateLabel(const IMEInfo& info) { | 49 void UpdateLabel(const IMEInfo& info) { |
49 SetLabel(info.name); | 50 SetLabel(info.name); |
50 SetAccessibleName(info.name); | 51 SetAccessibleName(info.name); |
51 } | 52 } |
52 | 53 |
53 private: | 54 private: |
54 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); | 55 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); |
55 }; | 56 }; |
56 | 57 |
57 class IMEDetailedView : public views::View, | 58 class IMEDetailedView : public TrayDetailsView, |
58 public ViewClickListener { | 59 public ViewClickListener { |
59 public: | 60 public: |
60 IMEDetailedView(SystemTrayItem* owner, user::LoginStatus login) | 61 IMEDetailedView(SystemTrayItem* owner, user::LoginStatus login) |
61 : login_(login), | 62 : login_(login) { |
62 header_(NULL) { | |
63 SetLayoutManager(new views::BoxLayout( | |
64 views::BoxLayout::kVertical, 0, 0, 0)); | |
65 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | |
66 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 63 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
67 IMEInfoList list; | 64 IMEInfoList list; |
68 delegate->GetAvailableIMEList(&list); | 65 delegate->GetAvailableIMEList(&list); |
69 IMEPropertyInfoList property_list; | 66 IMEPropertyInfoList property_list; |
70 delegate->GetCurrentIMEProperties(&property_list); | 67 delegate->GetCurrentIMEProperties(&property_list); |
71 Update(list, property_list); | 68 Update(list, property_list); |
72 } | 69 } |
73 | 70 |
74 virtual ~IMEDetailedView() {} | 71 virtual ~IMEDetailedView() {} |
75 | 72 |
76 void Update(const IMEInfoList& list, | 73 void Update(const IMEInfoList& list, |
77 const IMEPropertyInfoList& property_list) { | 74 const IMEPropertyInfoList& property_list) { |
78 RemoveAllChildViews(true); | 75 Reset(); |
79 | |
80 header_ = NULL; | |
81 | 76 |
82 AppendIMEList(list); | 77 AppendIMEList(list); |
83 if (!property_list.empty()) | 78 if (!property_list.empty()) |
84 AppendIMEProperties(property_list); | 79 AppendIMEProperties(property_list); |
85 if (login_ != user::LOGGED_IN_NONE && login_ != user::LOGGED_IN_LOCKED) | 80 if (login_ != user::LOGGED_IN_NONE && login_ != user::LOGGED_IN_LOCKED) |
86 AppendSettings(); | 81 AppendSettings(); |
87 AppendHeaderEntry(); | 82 AppendHeaderEntry(); |
88 | 83 |
89 Layout(); | 84 Layout(); |
90 SchedulePaint(); | 85 SchedulePaint(); |
91 } | 86 } |
92 | 87 |
93 private: | 88 private: |
94 void AppendHeaderEntry() { | 89 void AppendHeaderEntry() { |
95 header_ = new SpecialPopupRow(); | 90 CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this); |
96 header_->SetTextLabel(IDS_ASH_STATUS_TRAY_IME, this); | |
97 AddChildView(header_); | |
98 } | 91 } |
99 | 92 |
100 void AppendIMEList(const IMEInfoList& list) { | 93 void AppendIMEList(const IMEInfoList& list) { |
101 ime_map_.clear(); | 94 ime_map_.clear(); |
102 views::View* imes = new views::View; | 95 CreateScrollableList(); |
103 imes->SetLayoutManager(new views::BoxLayout( | |
104 views::BoxLayout::kVertical, 0, 0, 1)); | |
105 for (size_t i = 0; i < list.size(); i++) { | 96 for (size_t i = 0; i < list.size(); i++) { |
106 HoverHighlightView* container = new HoverHighlightView(this); | 97 HoverHighlightView* container = new HoverHighlightView(this); |
107 container->set_fixed_height(kTrayPopupItemHeight); | 98 container->set_fixed_height(kTrayPopupItemHeight); |
108 container->AddLabel(list[i].name, | 99 container->AddLabel(list[i].name, |
109 list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL); | 100 list[i].selected ? gfx::Font::BOLD : gfx::Font::NORMAL); |
110 imes->AddChildView(container); | 101 scroll_content()->AddChildView(container); |
111 ime_map_[container] = list[i].id; | 102 ime_map_[container] = list[i].id; |
112 } | 103 } |
113 imes->set_border(views::Border::CreateSolidSidedBorder(1, 0, 1, 0, | |
114 kBorderLightColor)); | |
115 AddChildView(imes); | |
116 } | 104 } |
117 | 105 |
118 void AppendIMEProperties(const IMEPropertyInfoList& property_list) { | 106 void AppendIMEProperties(const IMEPropertyInfoList& property_list) { |
119 property_map_.clear(); | 107 property_map_.clear(); |
120 views::View* properties = new views::View; | 108 views::View* properties = new views::View; |
121 properties->SetLayoutManager(new views::BoxLayout( | 109 properties->SetLayoutManager(new views::BoxLayout( |
122 views::BoxLayout::kVertical, 0, 0, 1)); | 110 views::BoxLayout::kVertical, 0, 0, 1)); |
123 for (size_t i = 0; i < property_list.size(); i++) { | 111 for (size_t i = 0; i < property_list.size(); i++) { |
124 HoverHighlightView* container = new HoverHighlightView(this); | 112 HoverHighlightView* container = new HoverHighlightView(this); |
125 container->set_fixed_height(kTrayPopupItemHeight); | 113 container->set_fixed_height(kTrayPopupItemHeight); |
(...skipping 14 matching lines...) Expand all Loading... |
140 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). | 128 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). |
141 GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS), | 129 GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS), |
142 gfx::Font::NORMAL); | 130 gfx::Font::NORMAL); |
143 AddChildView(container); | 131 AddChildView(container); |
144 settings_ = container; | 132 settings_ = container; |
145 } | 133 } |
146 | 134 |
147 // Overridden from ViewClickListener. | 135 // Overridden from ViewClickListener. |
148 virtual void ClickedOn(views::View* sender) OVERRIDE { | 136 virtual void ClickedOn(views::View* sender) OVERRIDE { |
149 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 137 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
150 if (sender == header_->content()) { | 138 if (sender == footer()->content()) { |
151 Shell::GetInstance()->tray()->ShowDefaultView(); | 139 Shell::GetInstance()->tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
152 } else if (sender == settings_) { | 140 } else if (sender == settings_) { |
153 delegate->ShowIMESettings(); | 141 delegate->ShowIMESettings(); |
154 } else { | 142 } else { |
155 std::map<views::View*, std::string>::const_iterator ime_find; | 143 std::map<views::View*, std::string>::const_iterator ime_find; |
156 ime_find = ime_map_.find(sender); | 144 ime_find = ime_map_.find(sender); |
157 if (ime_find != ime_map_.end()) { | 145 if (ime_find != ime_map_.end()) { |
158 std::string ime_id = ime_find->second; | 146 std::string ime_id = ime_find->second; |
159 delegate->SwitchIME(ime_id); | 147 delegate->SwitchIME(ime_id); |
160 GetWidget()->Close(); | 148 GetWidget()->Close(); |
161 } else { | 149 } else { |
162 std::map<views::View*, std::string>::const_iterator prop_find; | 150 std::map<views::View*, std::string>::const_iterator prop_find; |
163 prop_find = property_map_.find(sender); | 151 prop_find = property_map_.find(sender); |
164 if (prop_find != property_map_.end()) { | 152 if (prop_find != property_map_.end()) { |
165 const std::string key = prop_find->second; | 153 const std::string key = prop_find->second; |
166 delegate->ActivateIMEProperty(key); | 154 delegate->ActivateIMEProperty(key); |
167 GetWidget()->Close(); | 155 GetWidget()->Close(); |
168 } | 156 } |
169 } | 157 } |
170 } | 158 } |
171 } | 159 } |
172 | 160 |
173 user::LoginStatus login_; | 161 user::LoginStatus login_; |
174 | 162 |
175 std::map<views::View*, std::string> ime_map_; | 163 std::map<views::View*, std::string> ime_map_; |
176 std::map<views::View*, std::string> property_map_; | 164 std::map<views::View*, std::string> property_map_; |
177 SpecialPopupRow* header_; | |
178 views::View* settings_; | 165 views::View* settings_; |
179 | 166 |
180 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); | 167 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); |
181 }; | 168 }; |
182 | 169 |
183 } // namespace tray | 170 } // namespace tray |
184 | 171 |
185 TrayIME::TrayIME() | 172 TrayIME::TrayIME() |
186 : tray_label_(NULL), | 173 : tray_label_(NULL), |
187 default_(NULL), | 174 default_(NULL), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 UpdateTrayLabel(current, list.size()); | 241 UpdateTrayLabel(current, list.size()); |
255 | 242 |
256 if (default_) | 243 if (default_) |
257 default_->UpdateLabel(current); | 244 default_->UpdateLabel(current); |
258 if (detailed_) | 245 if (detailed_) |
259 detailed_->Update(list, property_list); | 246 detailed_->Update(list, property_list); |
260 } | 247 } |
261 | 248 |
262 } // namespace internal | 249 } // namespace internal |
263 } // namespace ash | 250 } // namespace ash |
OLD | NEW |