15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/ime/infolist_window.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <string> 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <vector> 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/ime/candidate_window_constants.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/logging.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "grit/ash_strings.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gfx/color_utils.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/native_theme/native_theme.h" 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/background.h" 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/border.h" 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/bubble/bubble_border.h" 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/bubble/bubble_frame_view.h" 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/controls/label.h" 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/layout/box_layout.h" 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/widget/widget.h" 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/wm/core/window_animations.h" 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ash { 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ime { 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace { 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// The width of an info-list. 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const int kInfolistEntryWidth = 200; 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// The milliseconds of the delay to show the infolist window. 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const int kInfolistShowDelayMilliSeconds = 500; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// The milliseconds of the delay to hide the infolist window. 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const int kInfolistHideDelayMilliSeconds = 500; 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// InfolistBorder 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// The BubbleBorder subclass to draw the border and determine its position. 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class InfolistBorder : public views::BubbleBorder { 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) InfolistBorder(); 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~InfolistBorder(); 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // views::BubbleBorder implementation. 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual gfx::Rect GetBounds(const gfx::Rect& anchor_rect, 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Size& contents_size) const OVERRIDE; 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual gfx::Insets GetInsets() const OVERRIDE; 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(InfolistBorder); 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)InfolistBorder::InfolistBorder() 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : views::BubbleBorder(views::BubbleBorder::LEFT_CENTER, 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::BubbleBorder::NO_SHADOW, 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SK_ColorTRANSPARENT) { 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) set_paint_arrow(views::BubbleBorder::PAINT_NONE); 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)InfolistBorder::~InfolistBorder() {} 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::Rect InfolistBorder::GetBounds(const gfx::Rect& anchor_rect, 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Size& contents_size) const { 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect bounds(contents_size); 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bounds.set_x(is_arrow_on_left(arrow()) ? 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) anchor_rect.right() : anchor_rect.x() - contents_size.width()); 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // InfolistBorder modifies the vertical position based on the arrow offset 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // although it doesn't draw the arrow. The arrow offset is the half of 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // |contents_size| by default but can be modified through the off-screen logic 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // in BubbleFrameView. 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bounds.set_y(anchor_rect.y() + contents_size.height() / 2 - 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetArrowOffset(contents_size)); 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return bounds; 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::Insets InfolistBorder::GetInsets() const { 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This has to be specified and return empty insets to place the infolist 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // window without the gap. 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return gfx::Insets(); 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// InfolistRow renderes a row of a infolist. 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class InfolistEntryView : public views::View { 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) InfolistEntryView(const ui::InfolistEntry& entry, 895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::FontList& title_font_list, 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::FontList& description_font_list); 915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~InfolistEntryView(); 925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetEntry(const ui::InfolistEntry& entry); 945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // views::View implementation. 97cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual gfx::Size GetPreferredSize() const OVERRIDE; 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void UpdateBackground(); 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::InfolistEntry entry_; 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The title label. Owned by views hierarchy. 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* title_label_; 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The description label. Owned by views hierarchy. 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* description_label_; 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(InfolistEntryView); 1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)InfolistEntryView::InfolistEntryView(const ui::InfolistEntry& entry, 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::FontList& title_font_list, 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::FontList& description_font_list) 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : entry_(entry) { 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) title_label_ = new views::Label(entry.title, title_font_list); 1195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) title_label_->SetPosition(gfx::Point(0, 0)); 1205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) title_label_->SetBorder(views::Border::CreateEmptyBorder(4, 7, 2, 4)); 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_ = new views::Label(entry.body, description_font_list); 1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_->SetPosition(gfx::Point(0, 0)); 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_->SetMultiLine(true); 1275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_->SizeToFit(kInfolistEntryWidth); 1285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_->SetBorder(views::Border::CreateEmptyBorder(2, 17, 4, 4)); 1295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AddChildView(title_label_); 1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AddChildView(description_label_); 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateBackground(); 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)InfolistEntryView::~InfolistEntryView() {} 1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistEntryView::SetEntry(const ui::InfolistEntry& entry) { 1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (entry_ == entry) 1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entry_ = entry; 1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) title_label_->SetText(entry_.title); 1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_label_->SetText(entry_.body); 1435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateBackground(); 1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 146cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)gfx::Size InfolistEntryView::GetPreferredSize() const { 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return gfx::Size(kInfolistEntryWidth, GetHeightForWidth(kInfolistEntryWidth)); 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistEntryView::UpdateBackground() { 1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (entry_.highlighted) { 1525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) set_background( 1535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetBorder(views::Border::CreateSolidBorder( 1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1, 1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetNativeTheme()->GetSystemColor( 1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::NativeTheme::kColorId_FocusedBorderColor))); 1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) set_background(NULL); 1615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); 1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 1635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SchedulePaint(); 1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// InfolistWindow 1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)InfolistWindow::InfolistWindow(views::View* candidate_window, 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::vector<ui::InfolistEntry>& entries) 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : views::BubbleDelegateView(candidate_window, views::BubbleBorder::NONE), 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) title_font_list_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)), 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) description_font_list_(gfx::Font(kJapaneseFontName, 1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kFontSizeDelta + 11)) { 1755f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) set_can_activate(false); 176f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) set_accept_events(false); 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) set_margins(gfx::Insets()); 1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) set_background( 1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::NativeTheme::kColorId_WindowBackground))); 1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetBorder(views::Border::CreateSolidBorder( 1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1, 1845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetNativeTheme()->GetSystemColor( 1855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::NativeTheme::kColorId_MenuBorderColor))); 1865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* caption_label = new views::Label( 1905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) l10n_util::GetStringUTF16(IDS_ASH_IME_INFOLIST_WINDOW_TITLE)); 1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) caption_label->SetEnabledColor(GetNativeTheme()->GetSystemColor( 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::NativeTheme::kColorId_LabelEnabledColor)); 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) caption_label->SetBorder(views::Border::CreateEmptyBorder(2, 2, 2, 2)); 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) caption_label->set_background(views::Background::CreateSolidBackground( 1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) color_utils::AlphaBlend(SK_ColorBLACK, 1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetNativeTheme()->GetSystemColor( 1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::NativeTheme::kColorId_WindowBackground), 1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 0x10))); 2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AddChildView(caption_label); 2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (size_t i = 0; i < entries.size(); ++i) { 2045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entry_views_.push_back(new InfolistEntryView( 2055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entries[i], title_font_list_, description_font_list_)); 2065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AddChildView(entry_views_.back()); 2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)InfolistWindow::~InfolistWindow() { 2115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::InitWidget() { 2145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Widget* widget = views::BubbleDelegateView::CreateBubble(this); 215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) wm::SetWindowVisibilityAnimationType( 2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) widget->GetNativeView(), 217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // BubbleFrameView will be initialized through CreateBubble. 2205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetBubbleFrameView()->SetBubbleBorder( 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<views::BubbleBorder>(new InfolistBorder())); 2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SizeToContents(); 2235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::Relayout(const std::vector<ui::InfolistEntry>& entries) { 2265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t i = 0; 2275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (; i < entries.size(); ++i) { 2285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (i < entry_views_.size()) { 2295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entry_views_[i]->SetEntry(entries[i]); 2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { 2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) InfolistEntryView* new_entry = new InfolistEntryView( 2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entries[i], title_font_list_, description_font_list_); 2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AddChildView(new_entry); 2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entry_views_.push_back(new_entry); 2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (i < entry_views_.size()) { 2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (; i < entry_views_.size(); ++i) 2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) delete entry_views_[i]; 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) entry_views_.resize(entries.size()); 2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Layout(); 2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetBubbleFrameView()->bubble_border()->set_arrow_offset(0); 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SizeToContents(); 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::ShowWithDelay() { 2505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_hide_timer_.Start( 2515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FROM_HERE, 2525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::TimeDelta::FromMilliseconds(kInfolistShowDelayMilliSeconds), 2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetWidget(), 2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) &views::Widget::Show); 2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::HideWithDelay() { 2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_hide_timer_.Start( 2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FROM_HERE, 2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::TimeDelta::FromMilliseconds(kInfolistHideDelayMilliSeconds), 2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetWidget(), 2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) &views::Widget::Close); 2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::ShowImmediately() { 2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_hide_timer_.Stop(); 2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetWidget()->Show(); 2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::HideImmediately() { 2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_hide_timer_.Stop(); 2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetWidget()->Close(); 2735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InfolistWindow::WindowClosing() { 2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_hide_timer_.Stop(); 2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ime 2805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ash 281