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

Unified Diff: chrome/browser/views/star_toggle.cc

Issue 543215: Added Star button to compact navigation mode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/star_toggle.h ('k') | chrome/browser/views/toolbar_star_toggle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/star_toggle.cc
===================================================================
--- chrome/browser/views/star_toggle.cc (revision 38044)
+++ chrome/browser/views/star_toggle.cc (working copy)
@@ -1,81 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/views/star_toggle.h"
-
-#include "app/gfx/canvas.h"
-#include "app/resource_bundle.h"
-#include "base/keyboard_codes.h"
-#include "chrome/app/chrome_dll_resource.h"
-#include "grit/theme_resources.h"
-
-StarToggle::StarToggle(Delegate* delegate)
- : delegate_(delegate),
- state_(false),
- change_state_immediately_(false) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- state_off_ = rb.GetBitmapNamed(IDR_CONTENT_STAR_OFF);
- state_on_ = rb.GetBitmapNamed(IDR_CONTENT_STAR_ON);
- SetFocusable(true);
-}
-
-StarToggle::~StarToggle() {
-}
-
-void StarToggle::SetState(bool s) {
- if (s != state_) {
- state_ = s;
- SchedulePaint();
- }
-}
-
-bool StarToggle::GetState() const {
- return state_;
-}
-
-void StarToggle::Paint(gfx::Canvas* canvas) {
- PaintFocusBorder(canvas);
- canvas->DrawBitmapInt(state_ ? *state_on_ : *state_off_,
- (width() - state_off_->width()) / 2,
- (height() - state_off_->height()) / 2);
-}
-
-gfx::Size StarToggle::GetPreferredSize() {
- return gfx::Size(state_off_->width(), state_off_->height());
-}
-
-bool StarToggle::OnMouseDragged(const views::MouseEvent& e) {
- return e.IsLeftMouseButton();
-}
-
-bool StarToggle::OnMousePressed(const views::MouseEvent& e) {
- if (e.IsLeftMouseButton() && HitTest(e.location())) {
- RequestFocus();
- return true;
- }
- return false;
-}
-
-void StarToggle::OnMouseReleased(const views::MouseEvent& e,
- bool canceled) {
- if (e.IsLeftMouseButton() && HitTest(e.location()))
- SwitchState();
-}
-
-bool StarToggle::OnKeyPressed(const views::KeyEvent& e) {
- if ((e.GetKeyCode() == base::VKEY_SPACE) ||
- (e.GetKeyCode() == base::VKEY_RETURN)) {
- SwitchState();
- return true;
- }
- return false;
-}
-
-void StarToggle::SwitchState() {
- const bool new_state = !state_;
- if (change_state_immediately_)
- state_ = new_state;
- SchedulePaint();
- delegate_->StarStateChanged(new_state);
-}
« no previous file with comments | « chrome/browser/views/star_toggle.h ('k') | chrome/browser/views/toolbar_star_toggle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698