summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-20 22:23:48 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-20 22:23:48 +0000
commitcc3d2d551dbc6620072f8e6e193200698a2c9786 (patch)
tree086516f3172319c556a997e9f8cf2aa4813d8375 /chrome
parent85883a10c1b7641c4e94575443ce66d825dab583 (diff)
downloadchromium_src-cc3d2d551dbc6620072f8e6e193200698a2c9786.zip
chromium_src-cc3d2d551dbc6620072f8e6e193200698a2c9786.tar.gz
chromium_src-cc3d2d551dbc6620072f8e6e193200698a2c9786.tar.bz2
Roll back this change until I can understand why it's having adverse effects.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14067 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc84
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h9
2 files changed, 40 insertions, 53 deletions
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index 0a76d2b..15866a3 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -18,15 +18,14 @@
#include "grit/theme_resources.h"
#include "skia/include/SkShader.h"
-static const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0);
+// The stroke color around the popup border.
+static const SkColor kEdgeColor = SkColorSetRGB(183, 195, 219);
static const int kPopupTransparency = 235;
static const int kHoverRowAlpha = 0x40;
class AutocompleteResultView : public views::View {
public:
- AutocompleteResultView(AutocompleteResultViewModel* model,
- int model_index,
- const ChromeFont& font);
+ AutocompleteResultView(AutocompleteResultViewModel* model, int model_index);
virtual ~AutocompleteResultView();
// Overridden from views::View:
@@ -47,7 +46,9 @@ class AutocompleteResultView : public views::View {
void PaintAsMoreRow(ChromeCanvas* canvas);
// Get colors for row backgrounds and text for different row states.
- SkColor GetBackgroundColor() const;
+ SkColor GetHighlightRowColor() const;
+ SkColor GetHighlightTextColor() const;
+ SkColor GetHoverRowColor() const;
SkColor GetTextColor() const;
// This row's model and model index.
@@ -57,31 +58,26 @@ class AutocompleteResultView : public views::View {
// True if the mouse is over this row.
bool hot_;
- // The font used to derive fonts for rendering the text in this row.
- ChromeFont font_;
-
DISALLOW_COPY_AND_ASSIGN(AutocompleteResultView);
};
AutocompleteResultView::AutocompleteResultView(
AutocompleteResultViewModel* model,
- int model_index,
- const ChromeFont& font)
+ int model_index)
: model_(model),
model_index_(model_index),
- hot_(false),
- font_(font) {
+ hot_(false) {
}
AutocompleteResultView::~AutocompleteResultView() {
}
void AutocompleteResultView::Paint(ChromeCanvas* canvas) {
- canvas->FillRectInt(GetBackgroundColor(), 0, 0, width(), height());
-
- const AutocompleteMatch& match = model_->GetMatchAtIndex(model_index_);
- canvas->DrawStringInt(match.contents, font_, GetTextColor(), 0, 0, width(),
- height());
+ // Paint the row background if any.
+ if (model_->IsSelectedIndex(model_index_))
+ canvas->FillRectInt(GetHighlightRowColor(), 0, 0, width(), height());
+ else if (hot_)
+ canvas->FillRectInt(GetHoverRowColor(), 0, 0, width(), height());
}
gfx::Size AutocompleteResultView::GetPreferredSize() {
@@ -147,20 +143,21 @@ void AutocompleteResultView::PaintAsMoreRow(ChromeCanvas* canvas) {
}
-SkColor AutocompleteResultView::GetBackgroundColor() const {
- if (model_->IsSelectedIndex(model_index_))
- return color_utils::GetSysSkColor(COLOR_HIGHLIGHT);
- if (hot_) {
- COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
- return SkColorSetARGB(kHoverRowAlpha, GetRValue(color), GetGValue(color),
- GetBValue(color));
- }
- return kTransparentColor;
+SkColor AutocompleteResultView::GetHighlightRowColor() const {
+ return color_utils::GetSysSkColor(COLOR_HIGHLIGHT);
+}
+
+SkColor AutocompleteResultView::GetHighlightTextColor() const {
+ return color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT);
+}
+
+SkColor AutocompleteResultView::GetHoverRowColor() const {
+ COLORREF color = GetSysColor(COLOR_HIGHLIGHT);
+ return SkColorSetARGB(kHoverRowAlpha, GetRValue(color), GetGValue(color),
+ GetBValue(color));
}
SkColor AutocompleteResultView::GetTextColor() const {
- if (model_->IsSelectedIndex(model_index_))
- return color_utils::GetSysSkColor(COLOR_HIGHLIGHTTEXT);
return color_utils::GetSysSkColor(COLOR_WINDOWTEXT);
}
@@ -274,30 +271,27 @@ AutocompletePopupContentsView::AutocompletePopupContentsView(
: popup_(new AutocompletePopupWin(this)),
model_(new AutocompletePopupModel(this, edit_model, profile)),
edit_view_(edit_view),
- popup_positioner_(popup_positioner),
- edit_font_(font) {
+ popup_positioner_(popup_positioner) {
set_border(new PopupBorder);
}
void AutocompletePopupContentsView::SetAutocompleteResult(
const AutocompleteResult& result) {
RemoveAllChildViews(true);
- for (size_t i = 0; i < result.size(); ++i)
- AddChildView(new AutocompleteResultView(this, i, edit_font_));
- // Update the popup's size by calling Show. This will cause us to be laid out
- // again at the new size.
- popup_->Show();
+ for (size_t i = 0; i < result.size(); ++i) {
+ AutocompleteMatch match = result.match_at(i);
+ AutocompleteResultView* result = new AutocompleteResultView(this, i);
+ AddChildView(result);
+ }
+ Layout();
}
gfx::Rect AutocompletePopupContentsView::GetPopupBounds() const {
gfx::Insets insets;
border()->GetInsets(&insets);
gfx::Rect contents_bounds = popup_positioner_->GetPopupBounds();
- int child_count = GetChildViewCount();
- int height = 0;
- for (int i = 0; i < child_count; ++i)
- height += GetChildViewAt(i)->GetPreferredSize().height();
- contents_bounds.set_height(height);
+ contents_bounds.set_height(100); // TODO(beng): size to contents (once we
+ // have contents!)
contents_bounds.Inset(-insets.left(), -insets.top(), -insets.right(),
-insets.bottom());
return contents_bounds;
@@ -349,9 +343,9 @@ bool AutocompletePopupContentsView::IsSelectedIndex(size_t index) {
return index == model_->selected_line();
}
-const AutocompleteMatch& AutocompletePopupContentsView::GetMatchAtIndex(
+AutocompleteMatch::Type AutocompletePopupContentsView::GetResultTypeAtIndex(
size_t index) {
- return model_->result().match_at(index);
+ return model_->result().match_at(index).type;
}
void AutocompletePopupContentsView::OpenIndex(
@@ -396,12 +390,10 @@ void AutocompletePopupContentsView::PaintChildren(ChromeCanvas* canvas) {
true);
contents_canvas.FillRectInt(color_utils::GetSysSkColor(COLOR_WINDOW), 0, 0,
contents_rect.width(), contents_rect.height());
- View::PaintChildren(&contents_canvas);
// We want the contents background to be slightly transparent so we can see
- // the blurry glass effect on DWM systems behind. We do this _after_ we paint
- // the children since they paint text, and GDI will reset this alpha data if
- // we paint text after this call.
+ // the blurry glass effect on DWM systems behind.
MakeCanvasTransparent(&contents_canvas);
+ View::PaintChildren(&contents_canvas);
// Now paint the contents of the contents canvas into the actual canvas.
SkPaint paint;
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
index 9afeb0d..30a4306 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
@@ -8,7 +8,6 @@
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
-#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/view.h"
class AutocompleteEditModel;
@@ -33,7 +32,7 @@ class AutocompleteResultViewModel {
virtual bool IsSelectedIndex(size_t index) = 0;
// Returns the type of match that the row corresponds to.
- virtual const AutocompleteMatch& GetMatchAtIndex(size_t index) = 0;
+ virtual AutocompleteMatch::Type GetResultTypeAtIndex(size_t index) = 0;
// Called when the line at the specified index should be opened with the
// provided disposition.
@@ -75,7 +74,7 @@ class AutocompletePopupContentsView : public views::View,
// Overridden from AutocompleteResultViewModel:
virtual bool IsSelectedIndex(size_t index);
- virtual const AutocompleteMatch& GetMatchAtIndex(size_t index);
+ virtual AutocompleteMatch::Type GetResultTypeAtIndex(size_t index);
virtual void OpenIndex(size_t index, WindowOpenDisposition disposition);
virtual void SetHoveredLine(size_t index);
virtual void SetSelectedLine(size_t index, bool revert_to_default);
@@ -107,10 +106,6 @@ class AutocompletePopupContentsView : public views::View,
// An object that tells the popup how to position itself.
AutocompletePopupPositioner* popup_positioner_;
- // The font used by the edit that created us. This is used by the result
- // views to synthesize a suitable display font.
- ChromeFont edit_font_;
-
DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView);
};