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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc

Issue 3053036: [GTK] Remove reference to obsolete constant. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/autocomplete/autocomplete_popup_view_gtk.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // to support painting a border that isn't 1 pixel thick. There is no point 561 // to support painting a border that isn't 1 pixel thick. There is no point
562 // in writing that code now, and explode if that day ever comes. 562 // in writing that code now, and explode if that day ever comes.
563 COMPILE_ASSERT(kBorderThickness == 1, border_1px_implied); 563 COMPILE_ASSERT(kBorderThickness == 1, border_1px_implied);
564 // Draw the 1px border around the entire window. 564 // Draw the 1px border around the entire window.
565 gdk_draw_rectangle(drawable, gc, FALSE, 565 gdk_draw_rectangle(drawable, gc, FALSE,
566 0, 0, 566 0, 0,
567 window_rect.width() - 1, window_rect.height() - 1); 567 window_rect.width() - 1, window_rect.height() - 1);
568 568
569 pango_layout_set_height(layout_, kHeightPerResult * PANGO_SCALE); 569 pango_layout_set_height(layout_, kHeightPerResult * PANGO_SCALE);
570 570
571 // An offset to align text in gtk mode. The hard coded constants in this file
572 // are all created for the chrome-theme. In an effort to make this look good
573 // on the majority of gtk themes, we shrink the popup by one pixel on each
574 // side and push it downwards a bit so there's space between the drawn
575 // location bar and the popup so we don't touch it (contrast with
576 // chrome-theme where that's exactly what we want). Because of that, we need
577 // to shift the content inside the popup by one pixel.
578 int gtk_offset = 0;
579 if (theme_provider_->UseGtkTheme())
580 gtk_offset = kGtkHorizontalOffset;
581
582 for (size_t i = 0; i < result.size(); ++i) { 571 for (size_t i = 0; i < result.size(); ++i) {
583 gfx::Rect line_rect = GetRectForLine(i, window_rect.width()); 572 gfx::Rect line_rect = GetRectForLine(i, window_rect.width());
584 // Only repaint and layout damaged lines. 573 // Only repaint and layout damaged lines.
585 if (!line_rect.Intersects(damage_rect)) 574 if (!line_rect.Intersects(damage_rect))
586 continue; 575 continue;
587 576
588 const AutocompleteMatch& match = result.match_at(i); 577 const AutocompleteMatch& match = result.match_at(i);
589 bool is_selected = (model_->selected_line() == i); 578 bool is_selected = (model_->selected_line() == i);
590 bool is_hovered = (model_->hovered_line() == i); 579 bool is_hovered = (model_->hovered_line() == i);
591 if (is_selected || is_hovered) { 580 if (is_selected || is_hovered) {
592 gdk_gc_set_rgb_fg_color(gc, is_selected ? &selected_background_color_ : 581 gdk_gc_set_rgb_fg_color(gc, is_selected ? &selected_background_color_ :
593 &hovered_background_color_); 582 &hovered_background_color_);
594 // This entry is selected or hovered, fill a rect with the color. 583 // This entry is selected or hovered, fill a rect with the color.
595 gdk_draw_rectangle(drawable, gc, TRUE, 584 gdk_draw_rectangle(drawable, gc, TRUE,
596 line_rect.x(), line_rect.y(), 585 line_rect.x(), line_rect.y(),
597 line_rect.width(), line_rect.height()); 586 line_rect.width(), line_rect.height());
598 } 587 }
599 588
600 int icon_start_x = ltr ? (kIconLeftPadding - gtk_offset) : 589 int icon_start_x = ltr ? (kIconLeftPadding) :
Peter Kasting 2010/08/03 01:08:56 Nit: Extra parens
601 (line_rect.width() - kIconLeftPadding - kIconWidth + gtk_offset); 590 (line_rect.width() - kIconLeftPadding - kIconWidth);
602 // Draw the icon for this result. 591 // Draw the icon for this result.
603 DrawFullPixbuf(drawable, gc, 592 DrawFullPixbuf(drawable, gc,
604 IconForMatch(match, is_selected), 593 IconForMatch(match, is_selected),
605 icon_start_x, line_rect.y() + kIconTopPadding); 594 icon_start_x, line_rect.y() + kIconTopPadding);
606 595
607 // Draw the results text vertically centered in the results space. 596 // Draw the results text vertically centered in the results space.
608 // First draw the contents / url, but don't let it take up the whole width 597 // First draw the contents / url, but don't let it take up the whole width
609 // if there is also a description to be shown. 598 // if there is also a description to be shown.
610 bool has_description = !match.description.empty(); 599 bool has_description = !match.description.empty();
611 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding); 600 int text_width = window_rect.width() - (kIconAreaWidth + kRightPadding);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 (text_width - actual_content_width + gtk_offset - 642 (text_width - actual_content_width + gtk_offset -
654 (actual_description_width / PANGO_SCALE)), 643 (actual_description_width / PANGO_SCALE)),
655 content_y, layout_); 644 content_y, layout_);
656 } 645 }
657 } 646 }
658 647
659 g_object_unref(gc); 648 g_object_unref(gc);
660 649
661 return TRUE; 650 return TRUE;
662 } 651 }
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