Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc

Issue 2254453002: Sets the max height of ImeMenuTray. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Defines const int max_items. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_list_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/system/chromeos/ime_menu/ime_menu_tray.h" 5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 9 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" 11 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h"
12 #include "ash/common/system/tray/fixed_sized_scroll_view.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/system/tray/system_tray_notifier.h" 14 #include "ash/common/system/tray/system_tray_notifier.h"
14 #include "ash/common/system/tray/tray_constants.h" 15 #include "ash/common/system/tray/tray_constants.h"
15 #include "ash/common/system/tray/tray_popup_header_button.h" 16 #include "ash/common/system/tray/tray_popup_header_button.h"
16 #include "ash/common/system/tray/tray_utils.h" 17 #include "ash/common/system/tray/tray_utils.h"
17 #include "ash/common/wm_lookup.h" 18 #include "ash/common/wm_lookup.h"
18 #include "ash/common/wm_root_window_controller.h" 19 #include "ash/common/wm_root_window_controller.h"
19 #include "ash/common/wm_shell.h" 20 #include "ash/common/wm_shell.h"
20 #include "ash/common/wm_window.h" 21 #include "ash/common/wm_window.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "grit/ash_resources.h" 23 #include "grit/ash_resources.h"
23 #include "grit/ash_strings.h" 24 #include "grit/ash_strings.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/views/controls/label.h" 26 #include "ui/views/controls/label.h"
26 #include "ui/views/layout/box_layout.h" 27 #include "ui/views/layout/box_layout.h"
27 28
28 namespace ash { 29 namespace ash {
29 30
30 namespace { 31 namespace {
31 32
33 // Returns the max height of ImeListView.
34 int GetImeListViewMaxHeight() {
35 const int max_items = 7;
36 return GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT) * max_items;
37 }
38
32 class ImeMenuLabel : public views::Label { 39 class ImeMenuLabel : public views::Label {
33 public: 40 public:
34 ImeMenuLabel() {} 41 ImeMenuLabel() {}
35 ~ImeMenuLabel() override {} 42 ~ImeMenuLabel() override {}
36 43
37 // views:Label: 44 // views:Label:
38 gfx::Size GetPreferredSize() const override { 45 gfx::Size GetPreferredSize() const override {
39 return gfx::Size(kTrayImeIconSize, kTrayImeIconSize); 46 return gfx::Size(kTrayImeIconSize, kTrayImeIconSize);
40 } 47 }
41 int GetHeightForWidth(int width) const override { return kTrayImeIconSize; } 48 int GetHeightForWidth(int width) const override { return kTrayImeIconSize; }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 kTrayPopupMinWidth, kTrayPopupMaxWidth); 260 kTrayPopupMinWidth, kTrayPopupMaxWidth);
254 init_params.first_item_has_no_margin = true; 261 init_params.first_item_has_no_margin = true;
255 init_params.can_activate = true; 262 init_params.can_activate = true;
256 init_params.close_on_deactivate = true; 263 init_params.close_on_deactivate = true;
257 264
258 views::TrayBubbleView* bubble_view = 265 views::TrayBubbleView* bubble_view =
259 views::TrayBubbleView::Create(tray_container(), this, &init_params); 266 views::TrayBubbleView::Create(tray_container(), this, &init_params);
260 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0)); 267 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0));
261 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 268 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
262 269
270 ImeListView* ime_list_view =
271 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME);
272 if (ime_list_view->scroll_content()->height() > GetImeListViewMaxHeight()) {
273 ime_list_view->scroller()->SetFixedSize(
274 gfx::Size(kTrayPopupMaxWidth, GetImeListViewMaxHeight()));
275 }
263 // Adds IME list to the bubble. 276 // Adds IME list to the bubble.
264 bubble_view->AddChildView( 277 bubble_view->AddChildView(ime_list_view);
265 new ImeListView(nullptr, false, ImeListView::SHOW_SINGLE_IME));
266 278
267 // Adds IME buttons to the bubble if needed. 279 // Adds IME buttons to the bubble if needed.
268 LoginStatus login = 280 LoginStatus login =
269 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); 281 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus();
270 if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED && 282 if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED &&
271 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) 283 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen())
272 bubble_view->AddChildView(new ImeButtonsView(false, false, false, true)); 284 bubble_view->AddChildView(new ImeButtonsView(false, false, false, true));
273 285
274 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); 286 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view));
275 SetDrawBackgroundAsActive(true); 287 SetDrawBackgroundAsActive(true);
276 } 288 }
277 289
278 void ImeMenuTray::HideImeMenuBubble() { 290 void ImeMenuTray::HideImeMenuBubble() {
279 bubble_.reset(); 291 bubble_.reset();
280 SetDrawBackgroundAsActive(false); 292 SetDrawBackgroundAsActive(false);
281 } 293 }
282 294
283 } // namespace ash 295 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/ime_menu/ime_list_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698