diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-16 23:25:13 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-16 23:25:13 +0000 |
commit | 48c8fa63122510b2c51c6608a93b30e94192e679 (patch) | |
tree | dc22b80b2f4103d865cbfe47c6f4dc52c8595985 /chrome/views | |
parent | 9ea0ea99d3a1140a17712a286414d387eddbe8ac (diff) | |
download | chromium_src-48c8fa63122510b2c51c6608a93b30e94192e679.zip chromium_src-48c8fa63122510b2c51c6608a93b30e94192e679.tar.gz chromium_src-48c8fa63122510b2c51c6608a93b30e94192e679.tar.bz2 |
Rework the Button API to be saner in preparation for NativeControl rejiggering.BaseButton->Button, CustomButtonButton->ImageButtonToggleButton->ToggleImageButtonRemoving SetListener (buttons take listener through ctor)Tidy up source files. No functionality changes, just naming and organization.Look at the button classes first, then everything else.
Review URL: http://codereview.chromium.org/46096
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/base_button.h | 185 | ||||
-rw-r--r-- | chrome/views/bitmap_scroll_bar.cc | 49 | ||||
-rw-r--r-- | chrome/views/bitmap_scroll_bar.h | 18 | ||||
-rw-r--r-- | chrome/views/button.cc | 198 | ||||
-rw-r--r-- | chrome/views/button.h | 143 | ||||
-rw-r--r-- | chrome/views/button_dropdown.cc | 17 | ||||
-rw-r--r-- | chrome/views/button_dropdown.h | 6 | ||||
-rw-r--r-- | chrome/views/custom_button.cc (renamed from chrome/views/base_button.cc) | 215 | ||||
-rw-r--r-- | chrome/views/custom_button.h | 94 | ||||
-rw-r--r-- | chrome/views/custom_frame_view.cc | 62 | ||||
-rw-r--r-- | chrome/views/custom_frame_view.h | 18 | ||||
-rw-r--r-- | chrome/views/image_button.cc | 157 | ||||
-rw-r--r-- | chrome/views/image_button.h | 101 | ||||
-rw-r--r-- | chrome/views/menu_button.cc | 11 | ||||
-rw-r--r-- | chrome/views/menu_button.h | 3 | ||||
-rw-r--r-- | chrome/views/text_button.cc | 76 | ||||
-rw-r--r-- | chrome/views/text_button.h | 62 | ||||
-rw-r--r-- | chrome/views/views.vcproj | 24 |
18 files changed, 674 insertions, 765 deletions
diff --git a/chrome/views/base_button.h b/chrome/views/base_button.h deleted file mode 100644 index 7d6c66a..0000000 --- a/chrome/views/base_button.h +++ /dev/null @@ -1,185 +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. - -#ifndef CHROME_VIEWS_BASE_BUTTON_H__ -#define CHROME_VIEWS_BASE_BUTTON_H__ - -#include "chrome/common/animation.h" -#include "chrome/views/event.h" -#include "chrome/views/view.h" - -class ThrobAnimation; - -namespace views { - -class MouseEvent; - -//////////////////////////////////////////////////////////////////////////////// -// -// BaseButton -// -// A base button class that shares common button functionality between various -// specializations. -// -//////////////////////////////////////////////////////////////////////////////// -class BaseButton : public View, - public AnimationDelegate { - public: - // Possible states - typedef enum ButtonState { BS_NORMAL = 0, - BS_HOT = 1, - BS_PUSHED = 2, - BS_DISABLED = 3}; - static const int kButtonStateCount = 4; - - virtual ~BaseButton(); - - // Set / test whether the MenuButton is enabled. - virtual void SetEnabled(bool f); - virtual bool IsEnabled() const; - - // Set / test whether the button is hot-tracked. - void SetHotTracked(bool f); - bool IsHotTracked() const; - - // Set how long the hover animation will last for. - void SetAnimationDuration(int duration); - - // Starts throbbing. See HoverAnimation for a description of cycles_til_stop. - void StartThrobbing(int cycles_til_stop); - - // Returns whether the button is pushed. - bool IsPushed() const; - - virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); - void SetTooltipText(const std::wstring& tooltip); - - // Overridden from View to take into account the enabled state. - virtual bool IsFocusable() const; - virtual bool AcceleratorPressed(const Accelerator& accelerator); - - // Overridden from AnimationDelegate to advance the hover state. - virtual void AnimationProgressed(const Animation* animation); - - // Returns a string containing the mnemonic, or the keyboard shortcut. - bool GetAccessibleKeyboardShortcut(std::wstring* shortcut); - - // Returns a brief, identifying string, containing a unique, readable name. - bool GetAccessibleName(std::wstring* name); - - // Assigns a keyboard shortcut string description. - void SetAccessibleKeyboardShortcut(const std::wstring& shortcut); - - // Assigns an accessible string name. - void SetAccessibleName(const std::wstring& name); - - // - // These methods are overriden to implement a simple push button - // behavior - virtual bool OnMousePressed(const MouseEvent& e); - virtual bool OnMouseDragged(const MouseEvent& e); - virtual void OnMouseReleased(const MouseEvent& e, bool canceled); - virtual void OnMouseMoved(const MouseEvent& e); - virtual void OnMouseEntered(const MouseEvent& e); - virtual void OnMouseExited(const MouseEvent& e); - virtual bool OnKeyPressed(const KeyEvent& e); - virtual bool OnKeyReleased(const KeyEvent& e); - // Overriden to reset state then invoke super's implementation. - virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); - - class ButtonListener { - public: - // - // This is invoked once the button is released use BaseButton::GetTag() - // to find out which button has been pressed. - // - virtual void ButtonPressed(BaseButton* sender) = 0; - }; - - // - // The the listener, the object that receives a notification when this - // button is pressed. tag is any int value to uniquely identify this - // button. - virtual void SetListener(ButtonListener *l, int tag); - - // - // Return the button tag as set by SetListener() - virtual int GetTag(); - - // - // Cause the button to notify the listener that a click occured. - virtual void NotifyClick(int mouse_event_flags); - - // Valid when the listener is notified. Contains the event flags from the - // mouse event, or 0 if not invoked from a mouse event. - int mouse_event_flags() { return mouse_event_flags_; } - - // - // Get the state. - // - int GetState() const { - return state_; - } - - // - // Set the state. If the state is different, causes the button - // to be repainted - // - virtual void SetState(ButtonState new_state); - - - virtual void Paint(ChromeCanvas* canvas); - - // Variant of paint that allows you to specify whether the paint is for a - // drag operation. This may be used during drag and drop to get a - // representation of this button suitable for drag and drop. - virtual void Paint(ChromeCanvas* canvas, bool for_drag); - - protected: - BaseButton(); - - // Returns true if the event is one that can trigger notifying the listener. - // This implementation returns true if the left mouse button is down. - virtual bool IsTriggerableEvent(const MouseEvent& e); - - virtual void OnDragDone(); - - // Overriden to reset the state to normal (as long as we're not disabled). - // This ensures we don't get stuck in a down state if on click our ancestor - // is removed. - virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); - - // tooltip text storage - std::wstring tooltip_text_; - - // storage of strings needed for accessibility - std::wstring accessible_shortcut_; - std::wstring accessible_name_; - - // The button state (defined in implementation) - int state_; - - // Hover animation. - scoped_ptr<ThrobAnimation> hover_animation_; - - private: - // The current listener - ButtonListener* listener_; - - // tag storage - int tag_; - - // See description in mouse_event_flags(). - int mouse_event_flags_; - - // Should we animate when the state changes? Defaults to true, but false while - // throbbing. - bool animate_on_state_change_; - - DISALLOW_COPY_AND_ASSIGN(BaseButton); -}; - -} // namespace views - -#endif // CHROME_VIEWS_BASE_BUTTON_H__ diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc index 98ad4ad..32080a6 100644 --- a/chrome/views/bitmap_scroll_bar.cc +++ b/chrome/views/bitmap_scroll_bar.cc @@ -33,11 +33,12 @@ static const int kScrollThumbDragOutSnap = 100; // down on the button. // /////////////////////////////////////////////////////////////////////////////// -class AutorepeatButton : public Button { +class AutorepeatButton : public ImageButton { public: - AutorepeatButton() - : repeater_(NewCallback<AutorepeatButton>(this, - &AutorepeatButton::NotifyClick)) { + AutorepeatButton(ButtonListener* listener) + : ImageButton(listener), + repeater_(NewCallback<AutorepeatButton>(this, + &AutorepeatButton::NotifyClick)) { } virtual ~AutorepeatButton() {} @@ -55,7 +56,7 @@ class AutorepeatButton : public Button { private: void NotifyClick() { - BaseButton::NotifyClick(0); + Button::NotifyClick(0); } // The repeat controller that we use to repeatedly click the button when the @@ -79,7 +80,7 @@ class BitmapScrollBarThumb : public View { : scroll_bar_(scroll_bar), drag_start_position_(-1), mouse_offset_(-1), - state_(BaseButton::BS_NORMAL) { + state_(CustomButton::BS_NORMAL) { } virtual ~BitmapScrollBarThumb() { } @@ -154,17 +155,17 @@ class BitmapScrollBarThumb : public View { } virtual void OnMouseEntered(const MouseEvent& event) { - SetState(BaseButton::BS_HOT); + SetState(CustomButton::BS_HOT); } virtual void OnMouseExited(const MouseEvent& event) { - SetState(BaseButton::BS_NORMAL); + SetState(CustomButton::BS_NORMAL); } virtual bool OnMousePressed(const MouseEvent& event) { mouse_offset_ = scroll_bar_->IsHorizontal() ? event.x() : event.y(); drag_start_position_ = GetPosition(); - SetState(BaseButton::BS_PUSHED); + SetState(CustomButton::BS_PUSHED); return true; } @@ -197,7 +198,7 @@ class BitmapScrollBarThumb : public View { virtual void OnMouseReleased(const MouseEvent& event, bool canceled) { - SetState(BaseButton::BS_HOT); + SetState(CustomButton::BS_HOT); View::OnMouseReleased(event, canceled); } @@ -222,11 +223,11 @@ class BitmapScrollBarThumb : public View { // transparently over the background bitmap. SkBitmap* grippy_bitmap() const { return scroll_bar_->images_[BitmapScrollBar::THUMB_GRIPPY] - [BaseButton::BS_NORMAL]; + [CustomButton::BS_NORMAL]; } // Update our state and schedule a repaint when the mouse moves over us. - void SetState(BaseButton::ButtonState state) { + void SetState(CustomButton::ButtonState state) { state_ = state; SchedulePaint(); } @@ -241,7 +242,7 @@ class BitmapScrollBarThumb : public View { int mouse_offset_; // The current state of the thumb button. - BaseButton::ButtonState state_; + CustomButton::ButtonState state_; DISALLOW_EVIL_CONSTRUCTORS(BitmapScrollBarThumb); }; @@ -254,10 +255,10 @@ class BitmapScrollBarThumb : public View { BitmapScrollBar::BitmapScrollBar(bool horizontal, bool show_scroll_buttons) : contents_size_(0), contents_scroll_offset_(0), - prev_button_(new AutorepeatButton), - next_button_(new AutorepeatButton), + prev_button_(new AutorepeatButton(this)), + next_button_(new AutorepeatButton(this)), thumb_(new BitmapScrollBarThumb(this)), - thumb_track_state_(BaseButton::BS_NORMAL), + thumb_track_state_(CustomButton::BS_NORMAL), last_scroll_amount_(SCROLL_NONE), repeater_(NewCallback<BitmapScrollBar>(this, &BitmapScrollBar::TrackClicked)), @@ -268,8 +269,6 @@ BitmapScrollBar::BitmapScrollBar(bool horizontal, bool show_scroll_buttons) prev_button_->SetVisible(false); next_button_->SetVisible(false); } - prev_button_->SetListener(this, -1); - next_button_->SetListener(this, -1); AddChildView(prev_button_); AddChildView(next_button_); @@ -299,10 +298,10 @@ gfx::Rect BitmapScrollBar::GetTrackBounds() const { } void BitmapScrollBar::SetImage(ScrollBarPart part, - BaseButton::ButtonState state, + CustomButton::ButtonState state, SkBitmap* bitmap) { DCHECK(part < PART_COUNT); - DCHECK(state < BaseButton::kButtonStateCount); + DCHECK(state < CustomButton::BS_COUNT); switch (part) { case PREV_BUTTON: prev_button_->SetImage(state, bitmap); @@ -443,7 +442,7 @@ void BitmapScrollBar::Layout() { bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) { if (event.IsOnlyLeftMouseButton()) { - SetThumbTrackState(BaseButton::BS_PUSHED); + SetThumbTrackState(CustomButton::BS_PUSHED); gfx::Rect thumb_bounds = thumb_->bounds(); if (IsHorizontal()) { if (event.x() < thumb_bounds.x()) { @@ -465,7 +464,7 @@ bool BitmapScrollBar::OnMousePressed(const MouseEvent& event) { } void BitmapScrollBar::OnMouseReleased(const MouseEvent& event, bool canceled) { - SetThumbTrackState(BaseButton::BS_NORMAL); + SetThumbTrackState(CustomButton::BS_NORMAL); repeater_.Stop(); View::OnMouseReleased(event, canceled); } @@ -624,9 +623,9 @@ void BitmapScrollBar::ExecuteCommand(int id) { } /////////////////////////////////////////////////////////////////////////////// -// BitmapScrollBar, BaseButton::ButtonListener implementation: +// BitmapScrollBar, ButtonListener implementation: -void BitmapScrollBar::ButtonPressed(BaseButton* sender) { +void BitmapScrollBar::ButtonPressed(Button* sender) { if (sender == prev_button_) { ScrollByAmount(SCROLL_PREV_LINE); } else if (sender == next_button_) { @@ -696,7 +695,7 @@ int BitmapScrollBar::CalculateContentsOffset(int thumb_position, return (thumb_position * contents_size_) / GetTrackSize(); } -void BitmapScrollBar::SetThumbTrackState(BaseButton::ButtonState state) { +void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { thumb_track_state_ = state; SchedulePaint(); } diff --git a/chrome/views/bitmap_scroll_bar.h b/chrome/views/bitmap_scroll_bar.h index 453c55f..53e9e72 100644 --- a/chrome/views/bitmap_scroll_bar.h +++ b/chrome/views/bitmap_scroll_bar.h @@ -5,7 +5,7 @@ #ifndef CHROME_VIEWS_BITMAP_SCROLL_BAR_H__ #define CHROME_VIEWS_BITMAP_SCROLL_BAR_H__ -#include "chrome/views/button.h" +#include "chrome/views/image_button.h" #include "chrome/views/menu.h" #include "chrome/views/repeat_controller.h" #include "chrome/views/scroll_bar.h" @@ -33,7 +33,7 @@ class BitmapScrollBarThumb; // /////////////////////////////////////////////////////////////////////////////// class BitmapScrollBar : public ScrollBar, - public BaseButton::ButtonListener, + public ButtonListener, public ContextMenuController, public Menu::Delegate { public: @@ -66,7 +66,7 @@ class BitmapScrollBar : public ScrollBar, // Sets the bitmap to be rendered for the specified part and state. void SetImage(ScrollBarPart part, - BaseButton::ButtonState state, + CustomButton::ButtonState state, SkBitmap* bitmap); // An enumeration of different amounts of incremental scroll, representing @@ -103,7 +103,7 @@ class BitmapScrollBar : public ScrollBar, virtual bool OnKeyPressed(const KeyEvent& event); // BaseButton::ButtonListener overrides: - virtual void ButtonPressed(BaseButton* sender); + virtual void ButtonPressed(Button* sender); // ScrollBar overrides: virtual void Update(int viewport_size, @@ -146,11 +146,11 @@ class BitmapScrollBar : public ScrollBar, // Called when the state of the thumb track changes (e.g. by the user // pressing the mouse button down in it). - void SetThumbTrackState(BaseButton::ButtonState state); + void SetThumbTrackState(CustomButton::ButtonState state); // The thumb needs to be able to access the part images. friend BitmapScrollBarThumb; - SkBitmap* images_[PART_COUNT][BaseButton::kButtonStateCount]; + SkBitmap* images_[PART_COUNT][CustomButton::BS_COUNT]; // The size of the scrolled contents, in pixels. int contents_size_; @@ -159,13 +159,13 @@ class BitmapScrollBar : public ScrollBar, int contents_scroll_offset_; // Up/Down/Left/Right buttons and the Thumb. - Button* prev_button_; - Button* next_button_; + ImageButton* prev_button_; + ImageButton* next_button_; BitmapScrollBarThumb* thumb_; // The state of the scrollbar track. Typically, the track will highlight when // the user presses the mouse on them (during page scrolling). - BaseButton::ButtonState thumb_track_state_; + CustomButton::ButtonState thumb_track_state_; // The last amount of incremental scroll that this scrollbar performed. This // is accessed by the callbacks for the auto-repeat up/down buttons to know diff --git a/chrome/views/button.cc b/chrome/views/button.cc index 0093927..860d8fa 100644 --- a/chrome/views/button.cc +++ b/chrome/views/button.cc @@ -4,198 +4,68 @@ #include "chrome/views/button.h" -#include <atlbase.h> -#include <atlapp.h> - -#include "chrome/app/chrome_dll_resource.h" -#include "chrome/common/gfx/chrome_canvas.h" -#include "chrome/common/l10n_util.h" -#include "chrome/common/throb_animation.h" -#include "chrome/views/event.h" -#include "grit/generated_resources.h" -#include "skia/ext/image_operations.h" - namespace views { -static const int kDefaultWidth = 16; // Default button width if no theme. -static const int kDefaultHeight = 14; // Default button height if no theme. - //////////////////////////////////////////////////////////////////////////////// -// -// Button - constructors, destructors, initialization -// -//////////////////////////////////////////////////////////////////////////////// - -Button::Button() : BaseButton(), - h_alignment_(ALIGN_LEFT), - v_alignment_(ALIGN_TOP) { - // By default, we request that the ChromeCanvas passed to our View::Paint() - // implementation is flipped horizontally so that the button's bitmaps are - // mirrored when the UI directionality is right-to-left. - EnableCanvasFlippingForRTLUI(true); -} +// Button, public: Button::~Button() { } -//////////////////////////////////////////////////////////////////////////////// -// -// Button - properties -// -//////////////////////////////////////////////////////////////////////////////// - -void Button::SetImage(ButtonState aState, SkBitmap* anImage) { - images_[aState] = anImage ? *anImage : SkBitmap(); -} - -void Button::SetImageAlignment(HorizontalAlignment h_align, - VerticalAlignment v_align) { - h_alignment_ = h_align; - v_alignment_ = v_align; - SchedulePaint(); -} - -gfx::Size Button::GetPreferredSize() { - if (!images_[BS_NORMAL].isNull()) - return gfx::Size(images_[BS_NORMAL].width(), images_[BS_NORMAL].height()); - return gfx::Size(kDefaultWidth, kDefaultHeight); -} - -// Set the tooltip text for this button. -void Button::SetTooltipText(const std::wstring& text) { - tooltip_text_ = text; +void Button::SetTooltipText(const std::wstring& tooltip_text) { + tooltip_text_ = tooltip_text; TooltipTextChanged(); } -// Return the tooltip text currently used by this button. -std::wstring Button::GetTooltipText() const { - return tooltip_text_; -} - -//////////////////////////////////////////////////////////////////////////////// -// -// Button - painting -// //////////////////////////////////////////////////////////////////////////////// +// Button, View overrides: -void Button::Paint(ChromeCanvas* canvas) { - View::Paint(canvas); - SkBitmap img = GetImageToPaint(); - - if (!img.isNull()) { - int x = 0, y = 0; - - if (h_alignment_ == ALIGN_CENTER) - x = (width() - img.width()) / 2; - else if (h_alignment_ == ALIGN_RIGHT) - x = width() - img.width(); - - if (v_alignment_ == ALIGN_MIDDLE) - y = (height() - img.height()) / 2; - else if (v_alignment_ == ALIGN_BOTTOM) - y = height() - img.height(); - - canvas->DrawBitmapInt(img, x, y); +bool Button::GetTooltipText(int x, int y, std::wstring* tooltip) { + if (!tooltip_text_.empty()) { + *tooltip = tooltip_text_; + return true; } - PaintFocusBorder(canvas); + return false; } -SkBitmap Button::GetImageToPaint() { - SkBitmap img; - - if (!images_[BS_HOT].isNull() && hover_animation_->IsAnimating()) { - img = skia::ImageOperations::CreateBlendedBitmap(images_[BS_NORMAL], - images_[BS_HOT], hover_animation_->GetCurrentValue()); - } else { - img = images_[GetState()]; +bool Button::GetAccessibleKeyboardShortcut(std::wstring* shortcut) { + if (!accessible_shortcut_.empty()) { + *shortcut = accessible_shortcut_; + return true; } - - return !img.isNull() ? img : images_[BS_NORMAL]; -} - -//////////////////////////////////////////////////////////////////////////////// -// -// Button - accessibility -// -//////////////////////////////////////////////////////////////////////////////// - -bool Button::GetAccessibleDefaultAction(std::wstring* action) { - DCHECK(action); - - action->assign(l10n_util::GetString(IDS_ACCACTION_PRESS)); - return true; -} - -bool Button::GetAccessibleRole(VARIANT* role) { - DCHECK(role); - - role->vt = VT_I4; - role->lVal = ROLE_SYSTEM_PUSHBUTTON; - return true; -} - -bool Button::GetTooltipText(int x, int y, std::wstring* tooltip) { - if (tooltip_text_.empty()) - return false; - - *tooltip = tooltip_text_; - return true; -} - -//////////////////////////////////////////////////////////////////////////////// -// -// ToggleButton -// -//////////////////////////////////////////////////////////////////////////////// -ToggleButton::ToggleButton() : Button(), toggled_(false) { + return false; } -ToggleButton::~ToggleButton() { -} - -void ToggleButton::SetImage(ButtonState state, SkBitmap* image) { - if (toggled_) { - alternate_images_[state] = image ? *image : SkBitmap(); - } else { - images_[state] = image ? *image : SkBitmap(); - if (state_ == state) - SchedulePaint(); +bool Button::GetAccessibleName(std::wstring* name) { + if (!accessible_name_.empty()) { + *name = accessible_name_; + return true; } + return false; } -void ToggleButton::SetToggledImage(ButtonState state, SkBitmap* image) { - if (toggled_) { - images_[state] = image ? *image : SkBitmap(); - if (state_ == state) - SchedulePaint(); - } else { - alternate_images_[state] = image ? *image : SkBitmap(); - } +void Button::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) { + accessible_shortcut_.assign(shortcut); } -bool ToggleButton::GetTooltipText(int x, int y, std::wstring* tooltip) { - if (!toggled_ || toggled_tooltip_text_.empty()) - return Button::GetTooltipText(x, y, tooltip); - - *tooltip = toggled_tooltip_text_; - return true; +void Button::SetAccessibleName(const std::wstring& name) { + accessible_name_.assign(name); } -void ToggleButton::SetToggled(bool toggled) { - if (toggled == toggled_) - return; +//////////////////////////////////////////////////////////////////////////////// +// Button, protected: - for (int i = 0; i < kButtonStateCount; ++i) { - SkBitmap temp = images_[i]; - images_[i] = alternate_images_[i]; - alternate_images_[i] = temp; - } - toggled_ = toggled; - SchedulePaint(); +Button::Button(ButtonListener* listener) + : listener_(listener), + tag_(-1), + mouse_event_flags_(0) { } -void ToggleButton::SetToggledTooltipText(const std::wstring& tooltip) { - toggled_tooltip_text_.assign(tooltip); +void Button::NotifyClick(int mouse_event_flags) { + mouse_event_flags_ = mouse_event_flags; + listener_->ButtonPressed(this); + // NOTE: don't attempt to reset mouse_event_flags_ as the listener may have + // deleted us. } } // namespace views diff --git a/chrome/views/button.h b/chrome/views/button.h index df8c463..a29fb78 100644 --- a/chrome/views/button.h +++ b/chrome/views/button.h @@ -5,125 +5,68 @@ #ifndef CHROME_VIEWS_BUTTON_H_ #define CHROME_VIEWS_BUTTON_H_ -#include "chrome/views/base_button.h" -#include "skia/include/SkBitmap.h" +#include "chrome/views/view.h" namespace views { -//////////////////////////////////////////////////////////////////////////////// -// -// Button -// -// A simple button class -// -//////////////////////////////////////////////////////////////////////////////// -class Button : public BaseButton { - public: - // - // Create a Button - Button(); - virtual ~Button(); - - // - // Set the image the button should use for the provided state. - virtual void SetImage(ButtonState aState, SkBitmap* anImage); - - enum HorizontalAlignment { ALIGN_LEFT = 0, - ALIGN_CENTER, - ALIGN_RIGHT, }; +class Button; - enum VerticalAlignment {ALIGN_TOP = 0, - ALIGN_MIDDLE, - ALIGN_BOTTOM }; - - void SetImageAlignment(HorizontalAlignment h_align, - VerticalAlignment v_align); - - // - // Computes the minimum size given the current theme and graphics - gfx::Size GetPreferredSize(); +// An interface implemented by an object to let it know that a button was +// pressed. +class ButtonListener { + public: + virtual void ButtonPressed(Button* sender) = 0; +}; - // Returns the MSAA default action of the current view. The string returned - // describes the default action that will occur when executing - // IAccessible::DoDefaultAction. - bool GetAccessibleDefaultAction(std::wstring* action); +// A View representing a button. Depending on the specific type, the button +// could be implemented by a native control or custom rendered. +class Button : public View { + public: + virtual ~Button(); - // Returns the MSAA role of the current view. The role is what assistive - // technologies (ATs) use to determine what behavior to expect from a given - // control. - bool GetAccessibleRole(VARIANT* role); + void SetTooltipText(const std::wstring& tooltip_text); - // Set the tooltip text for this button. - void SetTooltipText(const std::wstring& text); + int tag() const { return tag_; } + void set_tag(int tag) { tag_ = tag; } - // Return the tooltip text currently used by this button. - std::wstring GetTooltipText() const; + int mouse_event_flags() const { return mouse_event_flags_; } - // Overridden from View. + // Overridden from View: virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); - protected: + virtual bool GetAccessibleKeyboardShortcut(std::wstring* shortcut); + virtual bool GetAccessibleName(std::wstring* name); + virtual void SetAccessibleKeyboardShortcut(const std::wstring& shortcut); + virtual void SetAccessibleName(const std::wstring& name); - // Overridden to render the button. - virtual void Paint(ChromeCanvas* canvas); - - // Returns the image to paint. This is invoked from paint and returns a value - // from images. - virtual SkBitmap GetImageToPaint(); - - // Images. - SkBitmap images_[kButtonStateCount]; + protected: + // Construct the Button with a Listener. The listener can be NULL, as long as + // the specific button implementation makes sure to not call NotifyClick. This + // can be true of buttons that don't have a listener - e.g. menubuttons where + // there's no default action. + explicit Button(ButtonListener* listener); - // Alignment State. - HorizontalAlignment h_alignment_; - VerticalAlignment v_alignment_; + // Cause the button to notify the listener that a click occurred. + virtual void NotifyClick(int mouse_event_flags); - // The tooltip text or empty string for none. + private: + // The text shown in a tooltip. std::wstring tooltip_text_; - DISALLOW_COPY_AND_ASSIGN(Button); -}; + // Accessibility data. + std::wstring accessible_shortcut_; + std::wstring accessible_name_; -//////////////////////////////////////////////////////////////////////////////// -// -// ToggleButton -// -// A togglable button. It swaps out its graphics when toggled. -// -//////////////////////////////////////////////////////////////////////////////// -class ToggleButton : public Button { - public: - ToggleButton(); - virtual ~ToggleButton(); + // The button's listener. Notified when clicked. + ButtonListener* listener_; - // Overridden from Button. - virtual void SetImage(ButtonState aState, SkBitmap* anImage); - - // Like Button::SetImage(), but to set the graphics used for the - // "has been toggled" state. Must be called for each button state - // before the button is toggled. - void SetToggledImage(ButtonState state, SkBitmap* image); - - virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); + // The id tag associated with this button. Used to disambiguate buttons in + // the ButtonListener implementation. + int tag_; - // Set the tooltip text displayed when the button is toggled. - void SetToggledTooltipText(const std::wstring& tooltip); + // Event flags present when the button was clicked. + int mouse_event_flags_; - // Change the toggled state. - void SetToggled(bool toggled); - - private: - // The parent class's images_ member is used for the current images, - // and this array is used to hold the alternative images. - // We swap between the two when toggling. - SkBitmap alternate_images_[kButtonStateCount]; - - bool toggled_; - - // The parent class's tooltip_text_ is displayed when not toggled, and - // this one is shown when toggled. - std::wstring toggled_tooltip_text_; - - DISALLOW_EVIL_CONSTRUCTORS(ToggleButton); + DISALLOW_COPY_AND_ASSIGN(Button); }; } // namespace views diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc index 6428598..9d30561 100644 --- a/chrome/views/button_dropdown.cc +++ b/chrome/views/button_dropdown.cc @@ -22,11 +22,12 @@ static const int kMenuTimerDelay = 500; // //////////////////////////////////////////////////////////////////////////////// -ButtonDropDown::ButtonDropDown(Menu::Delegate* menu_delegate) - : Button(), - menu_delegate_(menu_delegate), - y_position_on_lbuttondown_(0), - show_menu_factory_(this) { +ButtonDropDown::ButtonDropDown(ButtonListener* listener, + Menu::Delegate* menu_delegate) + : ImageButton(listener), + menu_delegate_(menu_delegate), + y_position_on_lbuttondown_(0), + show_menu_factory_(this) { } ButtonDropDown::~ButtonDropDown() { @@ -52,11 +53,11 @@ bool ButtonDropDown::OnMousePressed(const MouseEvent& e) { kMenuTimerDelay); } - return Button::OnMousePressed(e); + return ImageButton::OnMousePressed(e); } void ButtonDropDown::OnMouseReleased(const MouseEvent& e, bool canceled) { - Button::OnMouseReleased(e, canceled); + ImageButton::OnMouseReleased(e, canceled); if (canceled) return; @@ -77,7 +78,7 @@ void ButtonDropDown::OnMouseReleased(const MouseEvent& e, bool canceled) { } bool ButtonDropDown::OnMouseDragged(const MouseEvent& e) { - bool result = Button::OnMouseDragged(e); + bool result = ImageButton::OnMouseDragged(e); if (!show_menu_factory_.empty()) { // SM_CYDRAG is a pixel value for minimum dragging distance before operation diff --git a/chrome/views/button_dropdown.h b/chrome/views/button_dropdown.h index 380426c..e92204b 100644 --- a/chrome/views/button_dropdown.h +++ b/chrome/views/button_dropdown.h @@ -6,7 +6,7 @@ #define CHROME_VIEWS_BUTTON_DROPDOWN_H__ #include "base/task.h" -#include "chrome/views/button.h" +#include "chrome/views/image_button.h" #include "chrome/views/menu.h" namespace views { @@ -19,9 +19,9 @@ namespace views { // display a menu // //////////////////////////////////////////////////////////////////////////////// -class ButtonDropDown : public Button { +class ButtonDropDown : public ImageButton { public: - explicit ButtonDropDown(Menu::Delegate* menu_delegate); + ButtonDropDown(ButtonListener* listener, Menu::Delegate* menu_delegate); virtual ~ButtonDropDown(); // Returns the MSAA default action of the current view. The string returned diff --git a/chrome/views/base_button.cc b/chrome/views/custom_button.cc index 26b123f..70c8fc7 100644 --- a/chrome/views/base_button.cc +++ b/chrome/views/custom_button.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/views/base_button.h" +#include "chrome/views/custom_button.h" #include "base/base_drag_source.h" #include "chrome/browser/drag_utils.h" @@ -17,43 +17,19 @@ namespace views { static const int kHoverFadeDurationMs = 150; //////////////////////////////////////////////////////////////////////////////// -// -// BaseButton - constructors, destructors, initialization -// -//////////////////////////////////////////////////////////////////////////////// - -BaseButton::BaseButton() - : listener_(NULL), - tag_(-1), - state_(BS_NORMAL), - mouse_event_flags_(0), - animate_on_state_change_(true) { - hover_animation_.reset(new ThrobAnimation(this)); - hover_animation_->SetSlideDuration(kHoverFadeDurationMs); -} - -BaseButton::~BaseButton() { -} - -//////////////////////////////////////////////////////////////////////////////// -// -// BaseButton - properties -// -//////////////////////////////////////////////////////////////////////////////// +// CustomButton, public: -bool BaseButton::IsTriggerableEvent(const MouseEvent& e) { - return e.IsLeftMouseButton(); +CustomButton::~CustomButton() { } -void BaseButton::SetState(BaseButton::ButtonState new_state) { - if (new_state != state_) { +void CustomButton::SetState(ButtonState state) { + if (state != state_) { if (animate_on_state_change_ || !hover_animation_->IsAnimating()) { animate_on_state_change_ = true; - if (state_ == BaseButton::BS_NORMAL && new_state == BaseButton::BS_HOT) { + if (state_ == BS_NORMAL && state == BS_HOT) { // Button is hovered from a normal state, start hover animation. hover_animation_->Show(); - } else if (state_ == BaseButton::BS_HOT && - new_state == BaseButton::BS_NORMAL) { + } else if (state_ == BS_HOT && state == BS_NORMAL) { // Button is returning to a normal state from hover, start hover // fade animation. hover_animation_->Hide(); @@ -62,97 +38,76 @@ void BaseButton::SetState(BaseButton::ButtonState new_state) { } } - state_ = new_state; + state_ = state; SchedulePaint(); } } -void BaseButton::SetEnabled(bool f) { - if (f && state_ == BS_DISABLED) { - SetState(BS_NORMAL); - } else if (!f && state_ != BS_DISABLED) { - SetState(BS_DISABLED); - } -} - -void BaseButton::SetAnimationDuration(int duration) { - hover_animation_->SetSlideDuration(duration); -} - -void BaseButton::StartThrobbing(int cycles_til_stop) { +void CustomButton::StartThrobbing(int cycles_til_stop) { animate_on_state_change_ = false; hover_animation_->StartThrobbing(cycles_til_stop); } -bool BaseButton::IsEnabled() const { - return state_ != BS_DISABLED; +void CustomButton::SetAnimationDuration(int duration) { + hover_animation_->SetSlideDuration(duration); } -void BaseButton::SetHotTracked(bool f) { - if (f && state_ != BS_DISABLED) { - SetState(BS_HOT); - } else if (!f && state_ != BS_DISABLED) { +//////////////////////////////////////////////////////////////////////////////// +// CustomButton, View overrides: + +void CustomButton::SetEnabled(bool enabled) { + if (enabled && state_ == BS_DISABLED) { SetState(BS_NORMAL); + } else if (!enabled && state_ != BS_DISABLED) { + SetState(BS_DISABLED); } } -bool BaseButton::IsHotTracked() const { - return state_ == BS_HOT; +bool CustomButton::IsEnabled() const { + return state_ != BS_DISABLED; } -bool BaseButton::IsPushed() const { - return state_ == BS_PUSHED; +bool CustomButton::IsFocusable() const { + return (state_ != BS_DISABLED) && View::IsFocusable(); } -void BaseButton::SetListener(ButtonListener *l, int tag) { - listener_ = l; - tag_ = tag; -} +//////////////////////////////////////////////////////////////////////////////// +// CustomButton, protected: -int BaseButton::GetTag() { - return tag_; +CustomButton::CustomButton(ButtonListener* listener) + : Button(listener), + state_(BS_NORMAL), + animate_on_state_change_(true) { + hover_animation_.reset(new ThrobAnimation(this)); + hover_animation_->SetSlideDuration(kHoverFadeDurationMs); } -bool BaseButton::IsFocusable() const { - return (state_ != BS_DISABLED) && View::IsFocusable(); +bool CustomButton::IsTriggerableEvent(const MouseEvent& e) { + return e.IsLeftMouseButton(); } //////////////////////////////////////////////////////////////////////////////// -// -// BaseButton - Tooltips -// -//////////////////////////////////////////////////////////////////////////////// +// CustomButton, View overrides (protected): -bool BaseButton::GetTooltipText(int x, int y, std::wstring* tooltip) { - if (!tooltip_text_.empty()) { - *tooltip = tooltip_text_; +bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { + if (enabled_) { + SetState(BS_NORMAL); + NotifyClick(0); return true; } return false; } -void BaseButton::SetTooltipText(const std::wstring& tooltip) { - tooltip_text_.assign(tooltip); - TooltipTextChanged(); -} - -//////////////////////////////////////////////////////////////////////////////// -// -// BaseButton - Events -// -//////////////////////////////////////////////////////////////////////////////// - -bool BaseButton::OnMousePressed(const MouseEvent& e) { +bool CustomButton::OnMousePressed(const MouseEvent& e) { if (state_ != BS_DISABLED) { - if (IsTriggerableEvent(e) && HitTest(e.location())) { + if (IsTriggerableEvent(e) && HitTest(e.location())) SetState(BS_PUSHED); - } RequestFocus(); } return true; } -bool BaseButton::OnMouseDragged(const MouseEvent& e) { +bool CustomButton::OnMouseDragged(const MouseEvent& e) { if (state_ != BS_DISABLED) { if (!HitTest(e.location())) SetState(BS_NORMAL); @@ -164,7 +119,7 @@ bool BaseButton::OnMouseDragged(const MouseEvent& e) { return true; } -void BaseButton::OnMouseReleased(const MouseEvent& e, bool canceled) { +void CustomButton::OnMouseReleased(const MouseEvent& e, bool canceled) { if (InDrag()) { // Starting a drag results in a MouseReleased, we need to ignore it. return; @@ -185,12 +140,12 @@ void BaseButton::OnMouseReleased(const MouseEvent& e, bool canceled) { } } -void BaseButton::OnMouseEntered(const MouseEvent& e) { +void CustomButton::OnMouseEntered(const MouseEvent& e) { if (state_ != BS_DISABLED) SetState(BS_HOT); } -void BaseButton::OnMouseMoved(const MouseEvent& e) { +void CustomButton::OnMouseMoved(const MouseEvent& e) { if (state_ != BS_DISABLED) { if (HitTest(e.location())) { SetState(BS_HOT); @@ -200,21 +155,13 @@ void BaseButton::OnMouseMoved(const MouseEvent& e) { } } -void BaseButton::OnMouseExited(const MouseEvent& e) { +void CustomButton::OnMouseExited(const MouseEvent& e) { // Starting a drag results in a MouseExited, we need to ignore it. if (state_ != BS_DISABLED && !InDrag()) SetState(BS_NORMAL); } -void BaseButton::NotifyClick(int mouse_event_flags) { - mouse_event_flags_ = mouse_event_flags; - if (listener_ != NULL) - listener_->ButtonPressed(this); - // NOTE: don't attempt to reset mouse_event_flags_ as the listener may have - // deleted us. -} - -bool BaseButton::OnKeyPressed(const KeyEvent& e) { +bool CustomButton::OnKeyPressed(const KeyEvent& e) { if (state_ != BS_DISABLED) { // Space sets button state to pushed. Enter clicks the button. This matches // the Windows native behavior of buttons, where Space clicks the button @@ -231,7 +178,7 @@ bool BaseButton::OnKeyPressed(const KeyEvent& e) { return false; } -bool BaseButton::OnKeyReleased(const KeyEvent& e) { +bool CustomButton::OnKeyReleased(const KeyEvent& e) { if (state_ != BS_DISABLED) { if (e.GetCharacter() == VK_SPACE) { SetState(BS_NORMAL); @@ -242,75 +189,51 @@ bool BaseButton::OnKeyReleased(const KeyEvent& e) { return false; } -void BaseButton::ShowContextMenu(int x, int y, bool is_mouse_gesture) { +void CustomButton::OnDragDone() { + SetState(BS_NORMAL); +} + +void CustomButton::ShowContextMenu(int x, int y, bool is_mouse_gesture) { if (GetContextMenuController()) { // We're about to show the context menu. Showing the context menu likely // means we won't get a mouse exited and reset state. Reset it now to be // sure. - if (GetState() != BS_DISABLED) + if (state_ != BS_DISABLED) SetState(BS_NORMAL); View::ShowContextMenu(x, y, is_mouse_gesture); } } -bool BaseButton::AcceleratorPressed(const Accelerator& accelerator) { - if (enabled_) { - SetState(BS_NORMAL); - NotifyClick(0); - return true; - } - return false; -} - -void BaseButton::AnimationProgressed(const Animation* animation) { - SchedulePaint(); -} - -void BaseButton::OnDragDone() { - SetState(BS_NORMAL); -} - -void BaseButton::ViewHierarchyChanged(bool is_add, View *parent, View *child) { +void CustomButton::ViewHierarchyChanged(bool is_add, View *parent, + View *child) { if (!is_add && state_ != BS_DISABLED) SetState(BS_NORMAL); } //////////////////////////////////////////////////////////////////////////////// -// -// BaseButton - Accessibility -// -//////////////////////////////////////////////////////////////////////////////// +// CustomButton, AnimationDelegate implementation: -bool BaseButton::GetAccessibleKeyboardShortcut(std::wstring* shortcut) { - if (!accessible_shortcut_.empty()) { - *shortcut = accessible_shortcut_; - return true; - } - return false; -} - -bool BaseButton::GetAccessibleName(std::wstring* name) { - if (!accessible_name_.empty()) { - *name = accessible_name_; - return true; - } - return false; +void CustomButton::AnimationProgressed(const Animation* animation) { + SchedulePaint(); } -void BaseButton::SetAccessibleKeyboardShortcut(const std::wstring& shortcut) { - accessible_shortcut_.assign(shortcut); -} +//////////////////////////////////////////////////////////////////////////////// +// CustomButton, private: -void BaseButton::SetAccessibleName(const std::wstring& name) { - accessible_name_.assign(name); +void CustomButton::SetHighlighted(bool highlighted) { + if (highlighted && state_ != BS_DISABLED) { + SetState(BS_HOT); + } else if (!highlighted && state_ != BS_DISABLED) { + SetState(BS_NORMAL); + } } -void BaseButton::Paint(ChromeCanvas* canvas) { - View::Paint(canvas); +bool CustomButton::IsHighlighted() const { + return state_ == BS_HOT; } -void BaseButton::Paint(ChromeCanvas* canvas, bool for_drag) { - Paint(canvas); +bool CustomButton::IsPushed() const { + return state_ == BS_PUSHED; } } // namespace views diff --git a/chrome/views/custom_button.h b/chrome/views/custom_button.h new file mode 100644 index 0000000..eeeb22c --- /dev/null +++ b/chrome/views/custom_button.h @@ -0,0 +1,94 @@ +// 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. + +#ifndef CHROME_VIEWS_CUSTOM_BUTTON_H_ +#define CHROME_VIEWS_CUSTOM_BUTTON_H_ + +#include "chrome/common/animation.h" +#include "chrome/views/button.h" + +class ThrobAnimation; + +namespace views { + +// A button with custom rendering. The common base class of IconButton and +// TextButton. +class CustomButton : public Button, + public AnimationDelegate { + public: + virtual ~CustomButton(); + + // Possible states + enum ButtonState { + BS_NORMAL = 0, + BS_HOT, + BS_PUSHED, + BS_DISABLED, + BS_COUNT + }; + + // Get/sets the current display state of the button. + ButtonState state() const { return state_; } + void SetState(ButtonState state); + + // Starts throbbing. See HoverAnimation for a description of cycles_til_stop. + void StartThrobbing(int cycles_til_stop); + + // Set how long the hover animation will last for. + void SetAnimationDuration(int duration); + + // Overridden from View: + virtual void SetEnabled(bool enabled); + virtual bool IsEnabled() const; + virtual bool IsFocusable() const; + + protected: + // Construct the Button with a Listener. See comment for Button's ctor. + explicit CustomButton(ButtonListener* listener); + + // Returns true if the event is one that can trigger notifying the listener. + // This implementation returns true if the left mouse button is down. + virtual bool IsTriggerableEvent(const MouseEvent& e); + + // Overridden from View: + virtual bool AcceleratorPressed(const Accelerator& accelerator); + virtual bool OnMousePressed(const MouseEvent& e); + virtual bool OnMouseDragged(const MouseEvent& e); + virtual void OnMouseReleased(const MouseEvent& e, bool canceled); + virtual void OnMouseEntered(const MouseEvent& e); + virtual void OnMouseMoved(const MouseEvent& e); + virtual void OnMouseExited(const MouseEvent& e); + virtual bool OnKeyPressed(const KeyEvent& e); + virtual bool OnKeyReleased(const KeyEvent& e); + virtual void OnDragDone(); + virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); + virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); + + // Overridden from AnimationDelegate: + virtual void AnimationProgressed(const Animation* animation); + + // The button state (defined in implementation) + ButtonState state_; + + // Hover animation. + scoped_ptr<ThrobAnimation> hover_animation_; + + private: + // Set / test whether the button is highlighted (in the hover state). + void SetHighlighted(bool highlighted); + bool IsHighlighted() const; + + // Returns whether the button is pushed. + bool IsPushed() const; + + // Should we animate when the state changes? Defaults to true, but false while + // throbbing. + bool animate_on_state_change_; + + DISALLOW_COPY_AND_ASSIGN(CustomButton); +}; + +} // namespace views + +#endif // CHROME_VIEWS_CUSTOM_BUTTON_H_ diff --git a/chrome/views/custom_frame_view.cc b/chrome/views/custom_frame_view.cc index d9db4b2..d330be0 100644 --- a/chrome/views/custom_frame_view.cc +++ b/chrome/views/custom_frame_view.cc @@ -219,45 +219,41 @@ const int kCaptionTopSpacing = 1; CustomFrameView::CustomFrameView(Window* frame) : NonClientFrameView(), - close_button_(new Button), - restore_button_(new Button), - maximize_button_(new Button), - minimize_button_(new Button), - system_menu_button_(new Button), + close_button_(new ImageButton(this)), + restore_button_(new ImageButton(this)), + maximize_button_(new ImageButton(this)), + minimize_button_(new ImageButton(this)), + system_menu_button_(new ImageButton(this)), should_show_minmax_buttons_(false), frame_(frame) { InitClass(); WindowResources* resources = active_resources_; // Close button images will be set in LayoutWindowControls(). - close_button_->SetListener(this, -1); AddChildView(close_button_); - restore_button_->SetImage(Button::BS_NORMAL, + restore_button_->SetImage(CustomButton::BS_NORMAL, resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON)); - restore_button_->SetImage(Button::BS_HOT, + restore_button_->SetImage(CustomButton::BS_HOT, resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_H)); - restore_button_->SetImage(Button::BS_PUSHED, + restore_button_->SetImage(CustomButton::BS_PUSHED, resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_P)); - restore_button_->SetListener(this, -1); AddChildView(restore_button_); - maximize_button_->SetImage(Button::BS_NORMAL, + maximize_button_->SetImage(CustomButton::BS_NORMAL, resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON)); - maximize_button_->SetImage(Button::BS_HOT, + maximize_button_->SetImage(CustomButton::BS_HOT, resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_H)); - maximize_button_->SetImage(Button::BS_PUSHED, + maximize_button_->SetImage(CustomButton::BS_PUSHED, resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_P)); - maximize_button_->SetListener(this, -1); AddChildView(maximize_button_); - minimize_button_->SetImage(Button::BS_NORMAL, + minimize_button_->SetImage(CustomButton::BS_NORMAL, resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON)); - minimize_button_->SetImage(Button::BS_HOT, + minimize_button_->SetImage(CustomButton::BS_HOT, resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_H)); - minimize_button_->SetImage(Button::BS_PUSHED, + minimize_button_->SetImage(CustomButton::BS_PUSHED, resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_P)); - minimize_button_->SetListener(this, -1); AddChildView(minimize_button_); should_show_minmax_buttons_ = frame_->GetDelegate()->CanMaximize(); @@ -344,9 +340,9 @@ void CustomFrameView::EnableClose(bool enable) { } void CustomFrameView::ResetWindowControls() { - restore_button_->SetState(Button::BS_NORMAL); - minimize_button_->SetState(Button::BS_NORMAL); - maximize_button_->SetState(Button::BS_NORMAL); + restore_button_->SetState(CustomButton::BS_NORMAL); + minimize_button_->SetState(CustomButton::BS_NORMAL); + maximize_button_->SetState(CustomButton::BS_NORMAL); // The close button isn't affected by this constraint. } @@ -378,9 +374,9 @@ gfx::Size CustomFrameView::GetPreferredSize() { } /////////////////////////////////////////////////////////////////////////////// -// CustomFrameView, BaseButton::ButtonListener implementation: +// CustomFrameView, ButtonListener implementation: -void CustomFrameView::ButtonPressed(BaseButton* sender) { +void CustomFrameView::ButtonPressed(Button* sender) { if (sender == close_button_) frame_->Close(); else if (sender == minimize_button_) @@ -560,7 +556,8 @@ void CustomFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { } void CustomFrameView::LayoutWindowControls() { - close_button_->SetImageAlignment(Button::ALIGN_LEFT, Button::ALIGN_BOTTOM); + close_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, + ImageButton::ALIGN_BOTTOM); // Maximized buttons start at window top so that even if their images aren't // drawn flush with the screen edge, they still obey Fitts' Law. bool is_maximized = frame_->IsMaximized(); @@ -583,24 +580,25 @@ void CustomFrameView::LayoutWindowControls() { // When the window is restored, we show a maximized button; otherwise, we show // a restore button. bool is_restored = !is_maximized && !frame_->IsMinimized(); - views::Button* invisible_button = is_restored ? + views::ImageButton* invisible_button = is_restored ? restore_button_ : maximize_button_; invisible_button->SetVisible(false); - views::Button* visible_button = is_restored ? + views::ImageButton* visible_button = is_restored ? maximize_button_ : restore_button_; FramePartBitmap normal_part, hot_part, pushed_part; if (should_show_minmax_buttons_) { visible_button->SetVisible(true); - visible_button->SetImageAlignment(Button::ALIGN_LEFT, Button::ALIGN_BOTTOM); + visible_button->SetImageAlignment(ImageButton::ALIGN_LEFT, + ImageButton::ALIGN_BOTTOM); gfx::Size visible_button_size = visible_button->GetPreferredSize(); visible_button->SetBounds(close_button_->x() - visible_button_size.width(), caption_y, visible_button_size.width(), visible_button_size.height() + top_extra_height); minimize_button_->SetVisible(true); - minimize_button_->SetImageAlignment(Button::ALIGN_LEFT, - Button::ALIGN_BOTTOM); + minimize_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, + ImageButton::ALIGN_BOTTOM); gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); minimize_button_->SetBounds( visible_button->x() - minimize_button_size.width(), caption_y, @@ -619,11 +617,11 @@ void CustomFrameView::LayoutWindowControls() { pushed_part = FRAME_CLOSE_BUTTON_ICON_SA_P; } - close_button_->SetImage(Button::BS_NORMAL, + close_button_->SetImage(CustomButton::BS_NORMAL, active_resources_->GetPartBitmap(normal_part)); - close_button_->SetImage(Button::BS_HOT, + close_button_->SetImage(CustomButton::BS_HOT, active_resources_->GetPartBitmap(hot_part)); - close_button_->SetImage(Button::BS_PUSHED, + close_button_->SetImage(CustomButton::BS_PUSHED, active_resources_->GetPartBitmap(pushed_part)); } diff --git a/chrome/views/custom_frame_view.h b/chrome/views/custom_frame_view.h index 2a47c73..2edc3f9 100644 --- a/chrome/views/custom_frame_view.h +++ b/chrome/views/custom_frame_view.h @@ -5,7 +5,7 @@ #ifndef CHROME_VIEWS_CUSTOM_FRAME_VIEW_H_ #define CHROME_VIEWS_CUSTOM_FRAME_VIEW_H_ -#include "chrome/views/button.h" +#include "chrome/views/image_button.h" #include "chrome/views/non_client_view.h" #include "chrome/views/window.h" #include "chrome/views/window_resources.h" @@ -29,7 +29,7 @@ namespace views { // //////////////////////////////////////////////////////////////////////////////// class CustomFrameView : public NonClientFrameView, - public BaseButton::ButtonListener { + public ButtonListener { public: explicit CustomFrameView(Window* frame); virtual ~CustomFrameView(); @@ -49,8 +49,8 @@ class CustomFrameView : public NonClientFrameView, virtual void Layout(); virtual gfx::Size GetPreferredSize(); - // BaseButton::ButtonListener implementation: - virtual void ButtonPressed(BaseButton* sender); + // ButtonListener implementation: + virtual void ButtonPressed(Button* sender); private: // Returns the thickness of the border that makes up the window frame edges. @@ -98,11 +98,11 @@ class CustomFrameView : public NonClientFrameView, gfx::Rect title_bounds_; // Window controls. - Button* close_button_; - Button* restore_button_; - Button* maximize_button_; - Button* minimize_button_; - Button* system_menu_button_; // Uses the window icon if visible. + ImageButton* close_button_; + ImageButton* restore_button_; + ImageButton* maximize_button_; + ImageButton* minimize_button_; + ImageButton* system_menu_button_; // Uses the window icon if visible. bool should_show_minmax_buttons_; // The window that owns this view. diff --git a/chrome/views/image_button.cc b/chrome/views/image_button.cc new file mode 100644 index 0000000..e6e370f --- /dev/null +++ b/chrome/views/image_button.cc @@ -0,0 +1,157 @@ +// 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/views/image_button.h" + +#include "chrome/app/chrome_dll_resource.h" +#include "chrome/common/gfx/chrome_canvas.h" +#include "chrome/common/l10n_util.h" +#include "chrome/common/throb_animation.h" +#include "grit/generated_resources.h" +#include "skia/ext/image_operations.h" + +namespace views { + +static const int kDefaultWidth = 16; // Default button width if no theme. +static const int kDefaultHeight = 14; // Default button height if no theme. + +//////////////////////////////////////////////////////////////////////////////// +// ImageButton, public: + +ImageButton::ImageButton(ButtonListener* listener) + : CustomButton(listener), + h_alignment_(ALIGN_LEFT), + v_alignment_(ALIGN_TOP) { + // By default, we request that the ChromeCanvas passed to our View::Paint() + // implementation is flipped horizontally so that the button's bitmaps are + // mirrored when the UI directionality is right-to-left. + EnableCanvasFlippingForRTLUI(true); +} + +ImageButton::~ImageButton() { +} + +void ImageButton::SetImage(ButtonState aState, SkBitmap* anImage) { + images_[aState] = anImage ? *anImage : SkBitmap(); +} + +void ImageButton::SetImageAlignment(HorizontalAlignment h_align, + VerticalAlignment v_align) { + h_alignment_ = h_align; + v_alignment_ = v_align; + SchedulePaint(); +} + +//////////////////////////////////////////////////////////////////////////////// +// ImageButton, View overrides: + +gfx::Size ImageButton::GetPreferredSize() { + if (!images_[BS_NORMAL].isNull()) + return gfx::Size(images_[BS_NORMAL].width(), images_[BS_NORMAL].height()); + return gfx::Size(kDefaultWidth, kDefaultHeight); +} + +void ImageButton::Paint(ChromeCanvas* canvas) { + // Call the base class first to paint any background/borders. + View::Paint(canvas); + + SkBitmap img = GetImageToPaint(); + + if (!img.isNull()) { + int x = 0, y = 0; + + if (h_alignment_ == ALIGN_CENTER) + x = (width() - img.width()) / 2; + else if (h_alignment_ == ALIGN_RIGHT) + x = width() - img.width(); + + if (v_alignment_ == ALIGN_MIDDLE) + y = (height() - img.height()) / 2; + else if (v_alignment_ == ALIGN_BOTTOM) + y = height() - img.height(); + + canvas->DrawBitmapInt(img, x, y); + } + PaintFocusBorder(canvas); +} + +//////////////////////////////////////////////////////////////////////////////// +// ImageButton, protected: + +SkBitmap ImageButton::GetImageToPaint() { + SkBitmap img; + + if (!images_[BS_HOT].isNull() && hover_animation_->IsAnimating()) { + img = skia::ImageOperations::CreateBlendedBitmap(images_[BS_NORMAL], + images_[BS_HOT], hover_animation_->GetCurrentValue()); + } else { + img = images_[state_]; + } + + return !img.isNull() ? img : images_[BS_NORMAL]; +} + +//////////////////////////////////////////////////////////////////////////////// +// ToggleImageButton, public: + +ToggleImageButton::ToggleImageButton(ButtonListener* listener) + : ImageButton(listener), + toggled_(false) { +} + +ToggleImageButton::~ToggleImageButton() { +} + +void ToggleImageButton::SetToggled(bool toggled) { + if (toggled == toggled_) + return; + + for (int i = 0; i < BS_COUNT; ++i) { + SkBitmap temp = images_[i]; + images_[i] = alternate_images_[i]; + alternate_images_[i] = temp; + } + toggled_ = toggled; + SchedulePaint(); +} + +void ToggleImageButton::SetToggledImage(ButtonState state, SkBitmap* image) { + if (toggled_) { + images_[state] = image ? *image : SkBitmap(); + if (state_ == state) + SchedulePaint(); + } else { + alternate_images_[state] = image ? *image : SkBitmap(); + } +} + +void ToggleImageButton::SetToggledTooltipText(const std::wstring& tooltip) { + toggled_tooltip_text_.assign(tooltip); +} + +//////////////////////////////////////////////////////////////////////////////// +// ToggleImageButton, ImageButton overrides: + +void ToggleImageButton::SetImage(ButtonState state, SkBitmap* image) { + if (toggled_) { + alternate_images_[state] = image ? *image : SkBitmap(); + } else { + images_[state] = image ? *image : SkBitmap(); + if (state_ == state) + SchedulePaint(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// ToggleImageButton, View overrides: + +bool ToggleImageButton::GetTooltipText(int x, int y, std::wstring* tooltip) { + if (!toggled_ || toggled_tooltip_text_.empty()) + return Button::GetTooltipText(x, y, tooltip); + + *tooltip = toggled_tooltip_text_; + return true; +} + +} // namespace views diff --git a/chrome/views/image_button.h b/chrome/views/image_button.h new file mode 100644 index 0000000..f39753e --- /dev/null +++ b/chrome/views/image_button.h @@ -0,0 +1,101 @@ +// 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. + +#ifndef CHROME_VIEWS_IMAGE_BUTTON_H_ +#define CHROME_VIEWS_IMAGE_BUTTON_H_ + +#include "chrome/views/custom_button.h" +#include "skia/include/SkBitmap.h" + +namespace views { + +// An image button. +class ImageButton : public CustomButton { + public: + explicit ImageButton(ButtonListener* listener); + virtual ~ImageButton(); + + // Set the image the button should use for the provided state. + virtual void SetImage(ButtonState aState, SkBitmap* anImage); + + enum HorizontalAlignment { ALIGN_LEFT = 0, + ALIGN_CENTER, + ALIGN_RIGHT, }; + + enum VerticalAlignment { ALIGN_TOP = 0, + ALIGN_MIDDLE, + ALIGN_BOTTOM }; + + // Sets how the image is laid out within the button's bounds. + void SetImageAlignment(HorizontalAlignment h_align, + VerticalAlignment v_align); + + // Overridden from View: + virtual gfx::Size GetPreferredSize(); + virtual void Paint(ChromeCanvas* canvas); + + protected: + // Returns the image to paint. This is invoked from paint and returns a value + // from images. + virtual SkBitmap GetImageToPaint(); + + // The images used to render the different states of this button. + SkBitmap images_[BS_COUNT]; + + private: + // Image alignment. + HorizontalAlignment h_alignment_; + VerticalAlignment v_alignment_; + + DISALLOW_COPY_AND_ASSIGN(ImageButton); +}; + +//////////////////////////////////////////////////////////////////////////////// +// +// ToggleImageButton +// +// A toggle-able ImageButton. It swaps out its graphics when toggled. +// +//////////////////////////////////////////////////////////////////////////////// +class ToggleImageButton : public ImageButton { + public: + ToggleImageButton(ButtonListener* listener); + virtual ~ToggleImageButton(); + + // Change the toggled state. + void SetToggled(bool toggled); + + // Like Button::SetImage(), but to set the graphics used for the + // "has been toggled" state. Must be called for each button state + // before the button is toggled. + void SetToggledImage(ButtonState state, SkBitmap* image); + + // Set the tooltip text displayed when the button is toggled. + void SetToggledTooltipText(const std::wstring& tooltip); + + // Overridden from ImageButton: + virtual void SetImage(ButtonState aState, SkBitmap* anImage); + + // Overridden from View: + virtual bool GetTooltipText(int x, int y, std::wstring* tooltip); + + private: + // The parent class's images_ member is used for the current images, + // and this array is used to hold the alternative images. + // We swap between the two when toggling. + SkBitmap alternate_images_[BS_COUNT]; + + // True if the button is currently toggled. + bool toggled_; + + // The parent class's tooltip_text_ is displayed when not toggled, and + // this one is shown when toggled. + std::wstring toggled_tooltip_text_; + + DISALLOW_EVIL_CONSTRUCTORS(ToggleImageButton); +}; + +} // namespace views + +#endif // CHROME_VIEWS_IMAGE_BUTTON_H_ diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc index 09a9318..21cc828 100644 --- a/chrome/views/menu_button.cc +++ b/chrome/views/menu_button.cc @@ -43,10 +43,11 @@ static const int kMenuMarkerPaddingRight = -1; // //////////////////////////////////////////////////////////////////////////////// -MenuButton::MenuButton(const std::wstring& text, +MenuButton::MenuButton(ButtonListener* listener, + const std::wstring& text, ViewMenuDelegate* menu_delegate, bool show_menu_marker) - : TextButton(text), + : TextButton(listener, text), menu_visible_(false), menu_closed_time_(), menu_delegate_(menu_delegate), @@ -55,7 +56,7 @@ MenuButton::MenuButton(const std::wstring& text, kMenuMarker = ResourceBundle::GetSharedInstance() .GetBitmapNamed(IDR_MENU_DROPARROW); } - SetTextAlignment(TextButton::ALIGN_LEFT); + set_alignment(TextButton::ALIGN_LEFT); } MenuButton::~MenuButton() { @@ -180,7 +181,7 @@ bool MenuButton::Activate() { bool MenuButton::OnMousePressed(const MouseEvent& e) { RequestFocus(); - if (GetState() != BS_DISABLED) { + if (state() != BS_DISABLED) { // If we're draggable (GetDragOperations returns a non-zero value), then // don't pop on press, instead wait for release. if (e.IsOnlyLeftMouseButton() && HitTest(e.location()) && @@ -198,7 +199,7 @@ bool MenuButton::OnMousePressed(const MouseEvent& e) { void MenuButton::OnMouseReleased(const MouseEvent& e, bool canceled) { if (GetDragOperations(e.x(), e.y()) != DragDropTypes::DRAG_NONE && - GetState() != BS_DISABLED && !canceled && !InDrag() && + state() != BS_DISABLED && !canceled && !InDrag() && e.IsOnlyLeftMouseButton() && HitTest(e.location())) { Activate(); } else { diff --git a/chrome/views/menu_button.h b/chrome/views/menu_button.h index 185d59f..55fe4e5 100644 --- a/chrome/views/menu_button.h +++ b/chrome/views/menu_button.h @@ -29,7 +29,8 @@ class MenuButton : public TextButton { public: // // Create a Button - MenuButton(const std::wstring& text, + MenuButton(ButtonListener* listener, + const std::wstring& text, ViewMenuDelegate* menu_delegate, bool show_menu_marker); virtual ~MenuButton(); diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc index 5c2e663..f7c0cda 100644 --- a/chrome/views/text_button.cc +++ b/chrome/views/text_button.cc @@ -72,7 +72,7 @@ TextButtonBorder::~TextButtonBorder() { void TextButtonBorder::Paint(const View& view, ChromeCanvas* canvas) const { const TextButton* mb = static_cast<const TextButton*>(&view); - int state = mb->GetState(); + int state = mb->state(); // TextButton takes care of deciding when to call Paint. const MBBImageSet* set = &hot_set_; @@ -151,16 +151,13 @@ void TextButtonBorder::GetInsets(gfx::Insets* insets) const { } //////////////////////////////////////////////////////////////////////////////// -// -// TextButton - Implementation -// -//////////////////////////////////////////////////////////////////////////////// +// TextButton, public: -TextButton::TextButton(const std::wstring& text) - : font_(ResourceBundle::GetSharedInstance().GetFont( +TextButton::TextButton(ButtonListener* listener, const std::wstring& text) + : CustomButton(listener), + font_(ResourceBundle::GetSharedInstance().GetFont( ResourceBundle::BaseFont)), color_(kEnabledColor), - BaseButton(), max_width_(0), alignment_(ALIGN_LEFT) { SetText(text); @@ -171,31 +168,6 @@ TextButton::TextButton(const std::wstring& text) TextButton::~TextButton() { } -gfx::Size TextButton::GetPreferredSize() { - gfx::Insets insets = GetInsets(); - - // Use the max size to set the button boundaries. - gfx::Size prefsize(max_text_size_.width() + icon_.width() + insets.width(), - std::max(max_text_size_.height(), icon_.height()) + - insets.height()); - - if (icon_.width() > 0 && !text_.empty()) - prefsize.Enlarge(kIconTextPadding, 0); - - if (max_width_ > 0) - prefsize.set_width(std::min(max_width_, prefsize.width())); - - return prefsize; -} - -gfx::Size TextButton::GetMinimumSize() { - return max_text_size_; -} - -bool TextButton::OnMousePressed(const MouseEvent& e) { - return true; -} - void TextButton::SetText(const std::wstring& text) { text_ = text; // Update our new current and max text size @@ -213,10 +185,6 @@ void TextButton::ClearMaxTextSize() { max_text_size_ = text_size_; } -void TextButton::Paint(ChromeCanvas* canvas) { - Paint(canvas, false); -} - void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) { if (!for_drag) { PaintBackground(canvas); @@ -313,12 +281,44 @@ void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) { } } +//////////////////////////////////////////////////////////////////////////////// +// TextButton, View overrides: + +gfx::Size TextButton::GetPreferredSize() { + gfx::Insets insets = GetInsets(); + + // Use the max size to set the button boundaries. + gfx::Size prefsize(max_text_size_.width() + icon_.width() + insets.width(), + std::max(max_text_size_.height(), icon_.height()) + + insets.height()); + + if (icon_.width() > 0 && !text_.empty()) + prefsize.Enlarge(kIconTextPadding, 0); + + if (max_width_ > 0) + prefsize.set_width(std::min(max_width_, prefsize.width())); + + return prefsize; +} + +gfx::Size TextButton::GetMinimumSize() { + return max_text_size_; +} + void TextButton::SetEnabled(bool enabled) { if (enabled == IsEnabled()) return; - BaseButton::SetEnabled(enabled); + CustomButton::SetEnabled(enabled); color_ = enabled ? kEnabledColor : kDisabledColor; SchedulePaint(); } +bool TextButton::OnMousePressed(const MouseEvent& e) { + return true; +} + +void TextButton::Paint(ChromeCanvas* canvas) { + Paint(canvas, false); +} + } // namespace views diff --git a/chrome/views/text_button.h b/chrome/views/text_button.h index 0fd8a61..9a4d68f 100644 --- a/chrome/views/text_button.h +++ b/chrome/views/text_button.h @@ -5,17 +5,13 @@ #ifndef CHROME_VIEWS_TEXT_BUTTON_H__ #define CHROME_VIEWS_TEXT_BUTTON_H__ -#include <windows.h> - #include "chrome/common/gfx/chrome_font.h" #include "chrome/views/border.h" -#include "chrome/views/base_button.h" +#include "chrome/views/custom_button.h" #include "skia/include/SkBitmap.h" namespace views { -class MouseEvent; - //////////////////////////////////////////////////////////////////////////////// // // TextButtonBorder @@ -64,77 +60,79 @@ class TextButtonBorder : public Border { // passed to SetText. To reset the cached max size invoke ClearMaxTextSize. // //////////////////////////////////////////////////////////////////////////////// -class TextButton : public BaseButton { -public: - TextButton(const std::wstring& text); +class TextButton : public CustomButton { + public: + TextButton(ButtonListener* listener, const std::wstring& text); virtual ~TextButton(); + // Call SetText once per string in your set of possible values at button + // creation time, so that it can contain the largest of them and avoid + // resizing the button when the text changes. + virtual void SetText(const std::wstring& text); + std::wstring text() const { return text_; } + typedef enum TextAlignment { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT }; - virtual gfx::Size GetPreferredSize(); - virtual gfx::Size GetMinimumSize(); - virtual bool OnMousePressed(const MouseEvent& e); - - // Call SetText once per string in your set of possible values at - // button creation time, so that it can contain the largest of them - // and avoid resizing the button when the text changes. - virtual void SetText(const std::wstring& text); - - void TextButton::SetTextAlignment(TextAlignment alignment) { - alignment_ = alignment; - } - - const std::wstring& GetText() { return text_; } + void set_alignment(TextAlignment alignment) { alignment_ = alignment; } // Sets the icon. void SetIcon(const SkBitmap& icon); - - const SkBitmap& GetIcon() { return icon_; } + SkBitmap icon() const { return icon_; } // TextButton remembers the maximum display size of the text passed to // SetText. This method resets the cached maximum display size to the // current size. void ClearMaxTextSize(); - virtual void Paint(ChromeCanvas* canvas); + void set_max_width(int max_width) { max_width_ = max_width; } + + // Paint the button into the specified canvas. If |for_drag| is true, the + // function paints a drag image representation into the canvas. virtual void Paint(ChromeCanvas* canvas, bool for_drag); - // Sets the enabled state. Setting the enabled state resets the color. + // Overridden from View: + virtual gfx::Size GetPreferredSize(); + virtual gfx::Size GetMinimumSize(); virtual void SetEnabled(bool enabled); - // Sets the max width. The preferred width of the button will never be larger - // then the specified value. A value <= 0 indicates the preferred width - // is not constrained in anyway. - void set_max_width(int max_width) { max_width_ = max_width; } + protected: + virtual bool OnMousePressed(const MouseEvent& e); + virtual void Paint(ChromeCanvas* canvas); private: + // The text string that is displayed in the button. std::wstring text_; + + // The size of the text string. gfx::Size text_size_; // Track the size of the largest text string seen so far, so that // changing text_ will not resize the button boundary. gfx::Size max_text_size_; + // The alignment of the text string within the button. TextAlignment alignment_; + // The font used to paint the text. ChromeFont font_; // Text color. SkColor color_; + // An icon displayed with the text. SkBitmap icon_; - // See setter for details. + // The width of the button will never be larger than this value. A value <= 0 + // indicates the width is not constrained. int max_width_; DISALLOW_EVIL_CONSTRUCTORS(TextButton); }; - } // namespace views #endif // CHROME_VIEWS_TEXT_BUTTON_H__ diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj index 49e1abe..01f8da5 100644 --- a/chrome/views/views.vcproj +++ b/chrome/views/views.vcproj @@ -178,14 +178,6 @@ > </File> <File - RelativePath=".\base_button.cc" - > - </File> - <File - RelativePath=".\base_button.h" - > - </File> - <File RelativePath=".\bitmap_scroll_bar.cc" > </File> @@ -254,6 +246,14 @@ > </File> <File + RelativePath=".\custom_button.cc" + > + </File> + <File + RelativePath=".\custom_button.h" + > + </File> + <File RelativePath=".\custom_frame_view.cc" > </File> @@ -338,6 +338,14 @@ > </File> <File + RelativePath=".\image_button.cc" + > + </File> + <File + RelativePath=".\image_button.h" + > + </File> + <File RelativePath=".\image_view.cc" > </File> |