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

Unified Diff: ash/common/system/chromeos/ime_menu/ime_list_view.cc

Issue 2624193002: Scroll to make the selected IME visible. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/chromeos/ime_menu/ime_list_view.cc
diff --git a/ash/common/system/chromeos/ime_menu/ime_list_view.cc b/ash/common/system/chromeos/ime_menu/ime_list_view.cc
index cf2b34a25d2d1ad022714ecc4ad2d684573f38bc..b0c659178cd6647cd3f39c891eafd8d9d2e429d2 100644
--- a/ash/common/system/chromeos/ime_menu/ime_list_view.cc
+++ b/ash/common/system/chromeos/ime_menu/ime_list_view.cc
@@ -262,7 +262,8 @@ ImeListView::ImeListView(SystemTrayItem* owner,
SingleImeBehavior single_ime_behavior)
: TrayDetailsView(owner),
last_item_selected_with_keyboard_(false),
- should_focus_ime_after_selection_with_keyboard_(false) {
+ should_focus_ime_after_selection_with_keyboard_(false),
+ current_ime_view_(nullptr) {
SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
IMEInfoList list;
delegate->GetAvailableIMEList(&list);
@@ -307,8 +308,11 @@ void ImeListView::Update(const IMEInfoList& list,
SchedulePaint();
if (should_focus_ime_after_selection_with_keyboard_ &&
- last_item_selected_with_keyboard_)
+ last_item_selected_with_keyboard_) {
FocusCurrentImeIfNeeded();
+ } else if (current_ime_view_) {
+ scroll_content()->ScrollRectToVisible(current_ime_view_->bounds());
+ }
}
void ImeListView::ResetImeListView() {
@@ -316,10 +320,12 @@ void ImeListView::ResetImeListView() {
Reset();
material_keyboard_status_view_ = nullptr;
keyboard_status_ = nullptr;
+ current_ime_view_ = nullptr;
}
void ImeListView::CloseImeListView() {
last_selected_item_id_.clear();
+ current_ime_view_ = nullptr;
last_item_selected_with_keyboard_ = false;
GetWidget()->Close();
}
@@ -359,6 +365,9 @@ void ImeListView::AppendImeListAndProperties(
scroll_content()->AddChildView(ime_view);
ime_map_[ime_view] = list[i].id;
+ if (list[i].selected)
+ current_ime_view_ = ime_view;
+
// In material design, the property items will be added after the current
// selected IME item.
if (list[i].selected && !property_list.empty()) {
@@ -446,6 +455,16 @@ void ImeListView::HandleButtonPressed(views::Button* sender,
}
}
+void ImeListView::VisibilityChanged(View* starting_from, bool is_visible) {
+ if (!is_visible || (should_focus_ime_after_selection_with_keyboard_ &&
+ last_item_selected_with_keyboard_) ||
+ !current_ime_view_) {
+ return;
+ }
+
+ scroll_content()->ScrollRectToVisible(current_ime_view_->bounds());
+}
+
void ImeListView::FocusCurrentImeIfNeeded() {
views::FocusManager* manager = GetFocusManager();
if (!manager || manager->GetFocusedView() || last_selected_item_id_.empty())
« 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