Commit bca7a2e3 authored by mgiuca's avatar mgiuca Committed by Commit bot

Tab, TabStrip: Added GetClassName override.

This helps with debugging a TabbedPane views hierarchy as you can print
the proper class names of Tabs and TabStrips inside.

Review URL: https://codereview.chromium.org/889453004

Cr-Commit-Position: refs/heads/master@{#313672}
parent c5a78b27
...@@ -34,6 +34,9 @@ const char TabbedPane::kViewClassName[] = "TabbedPane"; ...@@ -34,6 +34,9 @@ const char TabbedPane::kViewClassName[] = "TabbedPane";
// The tab view shown in the tab strip. // The tab view shown in the tab strip.
class Tab : public View { class Tab : public View {
public: public:
// Internal class name.
static const char kViewClassName[];
Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents); Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents);
~Tab() override; ~Tab() override;
...@@ -49,6 +52,7 @@ class Tab : public View { ...@@ -49,6 +52,7 @@ class Tab : public View {
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
gfx::Size GetPreferredSize() const override; gfx::Size GetPreferredSize() const override;
void Layout() override; void Layout() override;
const char* GetClassName() const override;
private: private:
enum TabState { enum TabState {
...@@ -72,12 +76,16 @@ class Tab : public View { ...@@ -72,12 +76,16 @@ class Tab : public View {
// The tab strip shown above the tab contents. // The tab strip shown above the tab contents.
class TabStrip : public View { class TabStrip : public View {
public: public:
// Internal class name.
static const char kViewClassName[];
explicit TabStrip(TabbedPane* tabbed_pane); explicit TabStrip(TabbedPane* tabbed_pane);
~TabStrip() override; ~TabStrip() override;
// Overridden from View: // Overridden from View:
gfx::Size GetPreferredSize() const override; gfx::Size GetPreferredSize() const override;
void Layout() override; void Layout() override;
const char* GetClassName() const override;
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
private: private:
...@@ -86,6 +94,9 @@ class TabStrip : public View { ...@@ -86,6 +94,9 @@ class TabStrip : public View {
DISALLOW_COPY_AND_ASSIGN(TabStrip); DISALLOW_COPY_AND_ASSIGN(TabStrip);
}; };
// static
const char Tab::kViewClassName[] = "Tab";
Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents) Tab::Tab(TabbedPane* tabbed_pane, const base::string16& title, View* contents)
: tabbed_pane_(tabbed_pane), : tabbed_pane_(tabbed_pane),
title_(new Label(title, title_(new Label(title,
...@@ -155,6 +166,10 @@ void Tab::Layout() { ...@@ -155,6 +166,10 @@ void Tab::Layout() {
title_->SetBoundsRect(bounds); title_->SetBoundsRect(bounds);
} }
const char* Tab::GetClassName() const {
return kViewClassName;
}
void Tab::SetState(TabState tab_state) { void Tab::SetState(TabState tab_state) {
if (tab_state == tab_state_) if (tab_state == tab_state_)
return; return;
...@@ -178,6 +193,9 @@ void Tab::SetState(TabState tab_state) { ...@@ -178,6 +193,9 @@ void Tab::SetState(TabState tab_state) {
SchedulePaint(); SchedulePaint();
} }
// static
const char TabStrip::kViewClassName[] = "TabStrip";
TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {} TabStrip::TabStrip(TabbedPane* tabbed_pane) : tabbed_pane_(tabbed_pane) {}
TabStrip::~TabStrip() {} TabStrip::~TabStrip() {}
...@@ -202,6 +220,10 @@ void TabStrip::Layout() { ...@@ -202,6 +220,10 @@ void TabStrip::Layout() {
} }
} }
const char* TabStrip::GetClassName() const {
return kViewClassName;
}
void TabStrip::OnPaint(gfx::Canvas* canvas) { void TabStrip::OnPaint(gfx::Canvas* canvas) {
OnPaintBackground(canvas); OnPaintBackground(canvas);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment