OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/gtk/find_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/find_bar_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // label for failure searches. | 54 // label for failure searches. |
55 const GdkColor& kEntryTextColor = ui::kGdkBlack; | 55 const GdkColor& kEntryTextColor = ui::kGdkBlack; |
56 | 56 |
57 // Used as the color of the background of the entry box and the background of | 57 // Used as the color of the background of the entry box and the background of |
58 // the find label for successful searches. | 58 // the find label for successful searches. |
59 const GdkColor& kEntryBackgroundColor = ui::kGdkWhite; | 59 const GdkColor& kEntryBackgroundColor = ui::kGdkWhite; |
60 const GdkColor kFindFailureBackgroundColor = GDK_COLOR_RGB(255, 102, 102); | 60 const GdkColor kFindFailureBackgroundColor = GDK_COLOR_RGB(255, 102, 102); |
61 const GdkColor kFindSuccessTextColor = GDK_COLOR_RGB(178, 178, 178); | 61 const GdkColor kFindSuccessTextColor = GDK_COLOR_RGB(178, 178, 178); |
62 | 62 |
63 // Padding around the container. | 63 // Padding around the container. |
64 const int kBarPaddingTopBottom = 4; | 64 const int kBarPaddingTop = 2; |
| 65 const int kBarPaddingBottom = 3; |
65 const int kEntryPaddingLeft = 6; | 66 const int kEntryPaddingLeft = 6; |
66 const int kCloseButtonPaddingLeft = 3; | 67 const int kCloseButtonPadding = 3; |
67 const int kBarPaddingRight = 4; | 68 const int kBarPaddingRight = 4; |
68 | 69 |
69 // The height of the findbar dialog, as dictated by the size of the background | 70 // The height of the findbar dialog, as dictated by the size of the background |
70 // images. | 71 // images. |
71 const int kFindBarHeight = 32; | 72 const int kFindBarHeight = 32; |
72 | 73 |
73 // The default width of the findbar dialog. It may get smaller if the window | 74 // The default width of the findbar dialog. It may get smaller if the window |
74 // is narrow. | 75 // is narrow. |
75 const int kFindBarWidth = 303; | 76 const int kFindBarWidth = 303; |
76 | 77 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 223 |
223 void FindBarGtk::InitWidgets() { | 224 void FindBarGtk::InitWidgets() { |
224 // The find bar is basically an hbox with a gtkentry (text box) followed by 3 | 225 // The find bar is basically an hbox with a gtkentry (text box) followed by 3 |
225 // buttons (previous result, next result, close). We wrap the hbox in a gtk | 226 // buttons (previous result, next result, close). We wrap the hbox in a gtk |
226 // alignment and a gtk event box to get the padding and light blue | 227 // alignment and a gtk event box to get the padding and light blue |
227 // background. We put that event box in a fixed in order to control its | 228 // background. We put that event box in a fixed in order to control its |
228 // lateral position. We put that fixed in a SlideAnimatorGtk in order to get | 229 // lateral position. We put that fixed in a SlideAnimatorGtk in order to get |
229 // the slide effect. | 230 // the slide effect. |
230 GtkWidget* hbox = gtk_hbox_new(false, 0); | 231 GtkWidget* hbox = gtk_hbox_new(false, 0); |
231 container_ = gtk_util::CreateGtkBorderBin(hbox, NULL, | 232 container_ = gtk_util::CreateGtkBorderBin(hbox, NULL, |
232 kBarPaddingTopBottom, kBarPaddingTopBottom, | 233 kBarPaddingTop, kBarPaddingBottom, |
233 kEntryPaddingLeft, kBarPaddingRight); | 234 kEntryPaddingLeft, kBarPaddingRight); |
234 gtk_widget_set_size_request(container_, kFindBarWidth, -1); | 235 gtk_widget_set_size_request(container_, kFindBarWidth, kFindBarHeight); |
235 ViewIDUtil::SetID(container_, VIEW_ID_FIND_IN_PAGE); | 236 ViewIDUtil::SetID(container_, VIEW_ID_FIND_IN_PAGE); |
236 gtk_widget_set_app_paintable(container_, TRUE); | 237 gtk_widget_set_app_paintable(container_, TRUE); |
237 | 238 |
238 slide_widget_.reset(new SlideAnimatorGtk(container_, | 239 slide_widget_.reset(new SlideAnimatorGtk(container_, |
239 SlideAnimatorGtk::DOWN, | 240 SlideAnimatorGtk::DOWN, |
240 0, false, true, NULL)); | 241 0, false, true, NULL)); |
241 | 242 |
242 close_button_.reset(CustomDrawButton::CloseButton(theme_service_)); | 243 GtkWidget* close_alignment = gtk_alignment_new(0, 0.6, 1, 0); |
243 gtk_util::CenterWidgetInHBox(hbox, close_button_->widget(), true, | 244 close_button_.reset(new CustomDrawButton( |
244 kCloseButtonPaddingLeft); | 245 theme_service_, IDR_TAB_CLOSE, |
| 246 IDR_TAB_CLOSE_P, IDR_TAB_CLOSE_H, IDR_TAB_CLOSE, |
| 247 GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU)); |
| 248 gtk_container_add(GTK_CONTAINER(close_alignment), close_button_->widget()); |
| 249 gtk_box_pack_end(GTK_BOX(hbox), close_alignment, FALSE, FALSE, |
| 250 kCloseButtonPadding); |
245 g_signal_connect(close_button_->widget(), "clicked", | 251 g_signal_connect(close_button_->widget(), "clicked", |
246 G_CALLBACK(OnClickedThunk), this); | 252 G_CALLBACK(OnClickedThunk), this); |
247 gtk_widget_set_tooltip_text(close_button_->widget(), | 253 gtk_widget_set_tooltip_text(close_button_->widget(), |
248 l10n_util::GetStringUTF8(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP).c_str()); | 254 l10n_util::GetStringUTF8(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP).c_str()); |
249 | 255 |
250 find_next_button_.reset(new CustomDrawButton(theme_service_, | 256 find_next_button_.reset(new CustomDrawButton(theme_service_, |
251 IDR_FINDINPAGE_NEXT, IDR_FINDINPAGE_NEXT_H, IDR_FINDINPAGE_NEXT_H, | 257 IDR_FINDINPAGE_NEXT, IDR_FINDINPAGE_NEXT_H, IDR_FINDINPAGE_NEXT_H, |
252 IDR_FINDINPAGE_NEXT_D, GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU)); | 258 IDR_FINDINPAGE_NEXT_D, GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU)); |
253 g_signal_connect(find_next_button_->widget(), "clicked", | 259 g_signal_connect(find_next_button_->widget(), "clicked", |
254 G_CALLBACK(OnClickedThunk), this); | 260 G_CALLBACK(OnClickedThunk), this); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 2, 2, 3, 0); | 536 2, 2, 3, 0); |
531 | 537 |
532 // We need this event box to be invisible because we're only going to draw | 538 // We need this event box to be invisible because we're only going to draw |
533 // on the background (but we can't take it out of the heiarchy entirely | 539 // on the background (but we can't take it out of the heiarchy entirely |
534 // because we also need it to take up space). | 540 // because we also need it to take up space). |
535 gtk_event_box_set_visible_window(GTK_EVENT_BOX(border_bin_), FALSE); | 541 gtk_event_box_set_visible_window(GTK_EVENT_BOX(border_bin_), FALSE); |
536 gtk_widget_set_app_paintable(border_bin_, FALSE); | 542 gtk_widget_set_app_paintable(border_bin_, FALSE); |
537 | 543 |
538 gtk_misc_set_alignment(GTK_MISC(match_count_label_), 0.5, 1.0); | 544 gtk_misc_set_alignment(GTK_MISC(match_count_label_), 0.5, 1.0); |
539 | 545 |
| 546 // This is necessary to make the close button dark enough. |
540 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 547 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
541 close_button_->SetBackground( | 548 close_button_->SetBackground( |
542 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), | 549 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT), |
543 rb.GetImageNamed(IDR_CLOSE_BAR).AsBitmap(), | 550 rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap(), |
544 rb.GetImageNamed(IDR_CLOSE_BAR_MASK).AsBitmap()); | 551 rb.GetImageNamed(IDR_TAB_CLOSE).AsBitmap()); |
545 } | 552 } |
546 | 553 |
547 UpdateMatchLabelAppearance(match_label_failure_); | 554 UpdateMatchLabelAppearance(match_label_failure_); |
548 } | 555 } |
549 | 556 |
550 bool FindBarGtk::GetFindBarWindowInfo(gfx::Point* position, | 557 bool FindBarGtk::GetFindBarWindowInfo(gfx::Point* position, |
551 bool* fully_visible) { | 558 bool* fully_visible) { |
552 if (position) | 559 if (position) |
553 *position = GetPosition(); | 560 *position = GetPosition(); |
554 | 561 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 return FALSE; // Continue propagation. | 1017 return FALSE; // Continue propagation. |
1011 } | 1018 } |
1012 | 1019 |
1013 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { | 1020 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { |
1014 g_signal_handlers_disconnect_by_func( | 1021 g_signal_handlers_disconnect_by_func( |
1015 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), | 1022 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), |
1016 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); | 1023 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); |
1017 | 1024 |
1018 return FALSE; // Continue propagation. | 1025 return FALSE; // Continue propagation. |
1019 } | 1026 } |
OLD | NEW |