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

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

Issue 2826543002: Chrome OS: truncate text in virtual keyboard tray item (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | 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/system/ime_menu/ime_menu_tray.h" 5 #include "ash/system/ime_menu/ime_menu_tray.h"
6 6
7 #include "ash/accessibility_delegate.h" 7 #include "ash/accessibility_delegate.h"
8 #include "ash/ash_constants.h" 8 #include "ash/ash_constants.h"
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/resources/grit/ash_resources.h" 10 #include "ash/resources/grit/ash_resources.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 // Returns true if the current input context type is password. 93 // Returns true if the current input context type is password.
94 bool IsInPasswordInputContext() { 94 bool IsInPasswordInputContext() {
95 return ui::IMEBridge::Get()->GetCurrentInputContext().type == 95 return ui::IMEBridge::Get()->GetCurrentInputContext().type ==
96 ui::TEXT_INPUT_TYPE_PASSWORD; 96 ui::TEXT_INPUT_TYPE_PASSWORD;
97 } 97 }
98 98
99 class ImeMenuLabel : public views::Label { 99 class ImeMenuLabel : public views::Label {
100 public: 100 public:
101 ImeMenuLabel() {} 101 ImeMenuLabel() {
102 // Sometimes the label will be more than 2 characters, e.g. INTL and EXTD.
103 // This border makes sure we only leave room for ~2 and the others are
104 // truncated.
105 SetBorder(views::CreateEmptyBorder(gfx::Insets(0, 6)));
106 }
102 ~ImeMenuLabel() override {} 107 ~ImeMenuLabel() override {}
103 108
104 // views:Label: 109 // views:Label:
105 gfx::Size GetPreferredSize() const override { 110 gfx::Size GetPreferredSize() const override {
106 return gfx::Size(kTrayItemSize, kTrayItemSize); 111 return gfx::Size(kTrayItemSize, kTrayItemSize);
107 } 112 }
108 int GetHeightForWidth(int width) const override { return kTrayItemSize; } 113 int GetHeightForWidth(int width) const override { return kTrayItemSize; }
109 114
110 private: 115 private:
111 DISALLOW_COPY_AND_ASSIGN(ImeMenuLabel); 116 DISALLOW_COPY_AND_ASSIGN(ImeMenuLabel);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) 279 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf)
275 : TrayBackgroundView(wm_shelf, true), 280 : TrayBackgroundView(wm_shelf, true),
276 label_(new ImeMenuLabel()), 281 label_(new ImeMenuLabel()),
277 show_keyboard_(false), 282 show_keyboard_(false),
278 force_show_keyboard_(false), 283 force_show_keyboard_(false),
279 should_block_shelf_auto_hide_(false), 284 should_block_shelf_auto_hide_(false),
280 keyboard_suppressed_(false), 285 keyboard_suppressed_(false),
281 show_bubble_after_keyboard_hidden_(false) { 286 show_bubble_after_keyboard_hidden_(false) {
282 SetInkDropMode(InkDropMode::ON); 287 SetInkDropMode(InkDropMode::ON);
283 SetupLabelForTray(label_); 288 SetupLabelForTray(label_);
289 label_->SetElideBehavior(gfx::TRUNCATE);
284 tray_container()->AddChildView(label_); 290 tray_container()->AddChildView(label_);
285 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); 291 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier();
286 tray_notifier->AddIMEObserver(this); 292 tray_notifier->AddIMEObserver(this);
287 tray_notifier->AddVirtualKeyboardObserver(this); 293 tray_notifier->AddVirtualKeyboardObserver(this);
288 } 294 }
289 295
290 ImeMenuTray::~ImeMenuTray() { 296 ImeMenuTray::~ImeMenuTray() {
291 if (bubble_) 297 if (bubble_)
292 bubble_->bubble_view()->reset_delegate(); 298 bubble_->bubble_view()->reset_delegate();
293 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); 299 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier();
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 Shell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 547 Shell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
542 548
543 // Updates the tray label based on the current input method. 549 // Updates the tray label based on the current input method.
544 if (current_ime_.third_party) 550 if (current_ime_.third_party)
545 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 551 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
546 else 552 else
547 label_->SetText(current_ime_.short_name); 553 label_->SetText(current_ime_.short_name);
548 } 554 }
549 555
550 } // namespace ash 556 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698