Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/app_list/views/folder_header_view.h" | 5 #include "ui/app_list/views/folder_header_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| 11 #include "ui/app_list/app_list_folder_item.h" | 11 #include "ui/app_list/app_list_folder_item.h" |
| 12 #include "ui/app_list/views/app_list_folder_view.h" | 12 #include "ui/app_list/views/app_list_folder_view.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 #include "ui/resources/grit/ui_resources.h" | 15 #include "ui/resources/grit/ui_resources.h" |
| 16 #include "ui/strings/grit/ui_strings.h" | 16 #include "ui/strings/grit/ui_strings.h" |
| 17 #include "ui/views/border.h" | 17 #include "ui/views/border.h" |
| 18 #include "ui/views/controls/button/image_button.h" | 18 #include "ui/views/controls/button/image_button.h" |
| 19 #include "ui/views/controls/textfield/textfield.h" | 19 #include "ui/views/controls/textfield/textfield.h" |
| 20 #include "ui/views/painter.h" | 20 #include "ui/views/painter.h" |
| 21 | 21 |
| 22 namespace app_list { | 22 namespace app_list { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const int kPreferredWidth = 360; | 26 const int kPreferredWidth = 360; |
| 27 const int kPreferredHeight = 48; | 27 const int kPreferredHeight = 48; |
| 28 const int kIconDimension = 24; | 28 const int kIconDimension = 24; |
| 29 const int kPadding = 14; | 29 const int kPadding = 14; |
| 30 const int kBottomSeparatorWidth = 380; | 30 const int kBottomSeparatorPadding = 9; |
| 31 const int kBottomSeparatorHeight = 1; | 31 const int kBottomSeparatorHeight = 1; |
| 32 const int kMaxFolderNameWidth = 300; | 32 const int kMaxFolderNameWidth = 300; |
| 33 | 33 |
| 34 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); | 34 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 class FolderHeaderView::FolderNameView : public views::Textfield { | 38 class FolderHeaderView::FolderNameView : public views::Textfield { |
| 39 public: | 39 public: |
| 40 FolderNameView() { | 40 FolderNameView() { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 } | 185 } |
| 186 | 186 |
| 187 void FolderHeaderView::OnPaint(gfx::Canvas* canvas) { | 187 void FolderHeaderView::OnPaint(gfx::Canvas* canvas) { |
| 188 views::View::OnPaint(canvas); | 188 views::View::OnPaint(canvas); |
| 189 | 189 |
| 190 gfx::Rect rect(GetContentsBounds()); | 190 gfx::Rect rect(GetContentsBounds()); |
| 191 if (rect.IsEmpty() || !folder_name_visible_) | 191 if (rect.IsEmpty() || !folder_name_visible_) |
| 192 return; | 192 return; |
| 193 | 193 |
| 194 // Draw bottom separator line. | 194 // Draw bottom separator line. |
| 195 rect.set_x((rect.width() - kBottomSeparatorWidth) / 2 + rect.x()); | 195 rect.set_x(kBottomSeparatorPadding); |
| 196 rect.set_y(rect.y() + rect.height() - kBottomSeparatorHeight); | 196 rect.set_y(rect.y() + rect.height() - kBottomSeparatorHeight); |
| 197 rect.set_width(kBottomSeparatorWidth); | 197 rect.set_width(rect.width() - kBottomSeparatorPadding * 2); |
|
calamity
2014/09/19 09:56:17
Use Rect::Inset().
Matt Giuca
2014/09/19 09:58:22
Done.
| |
| 198 rect.set_height(kBottomSeparatorHeight); | 198 rect.set_height(kBottomSeparatorHeight); |
| 199 canvas->FillRect(rect, kTopSeparatorColor); | 199 canvas->FillRect(rect, kTopSeparatorColor); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void FolderHeaderView::ContentsChanged(views::Textfield* sender, | 202 void FolderHeaderView::ContentsChanged(views::Textfield* sender, |
| 203 const base::string16& new_contents) { | 203 const base::string16& new_contents) { |
| 204 // Temporarily remove from observer to ignore data change caused by us. | 204 // Temporarily remove from observer to ignore data change caused by us. |
| 205 if (!folder_item_) | 205 if (!folder_item_) |
| 206 return; | 206 return; |
| 207 | 207 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 221 void FolderHeaderView::ButtonPressed(views::Button* sender, | 221 void FolderHeaderView::ButtonPressed(views::Button* sender, |
| 222 const ui::Event& event) { | 222 const ui::Event& event) { |
| 223 delegate_->NavigateBack(folder_item_, event); | 223 delegate_->NavigateBack(folder_item_, event); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void FolderHeaderView::ItemNameChanged() { | 226 void FolderHeaderView::ItemNameChanged() { |
| 227 Update(); | 227 Update(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace app_list | 230 } // namespace app_list |
| OLD | NEW |