summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 02:35:12 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 02:35:12 +0000
commitafa097fea45bb2a21a0a9c11af7a8942db045ef0 (patch)
treec2c86eca9fa9546a084bb0865910ec38c8b95f66 /chrome/browser/views
parent007a0acb82560269c7921960e2fd8077ed1eb527 (diff)
downloadchromium_src-afa097fea45bb2a21a0a9c11af7a8942db045ef0.zip
chromium_src-afa097fea45bb2a21a0a9c11af7a8942db045ef0.tar.gz
chromium_src-afa097fea45bb2a21a0a9c11af7a8942db045ef0.tar.bz2
Two changes to extension app icons:
1) When one of the mini tabs is an app (nano) tab, we now increase the margin between the mini tabs and the regular tabs by a few pixels. This is because with the large icons for nano tabs, it looks a little squished against the regular tabs in the tabstrip. 2) When dragging a nano tab within the tab strip, the background "handle" would grow to be as large as a regular tab (while dragging) due to the fact that UpdateData (that DraggedTabView calls) was not transferring the app tab bit to the new Tab. BUG=None TEST=Visual inspection. Review URL: http://codereview.chromium.org/1700016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc11
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc7
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc31
-rw-r--r--chrome/browser/views/tabs/tab_strip.h14
4 files changed, 50 insertions, 13 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 262154f..1fda3b3 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -23,7 +23,6 @@
#include "chrome/browser/views/tabs/native_view_photobooth.h"
#include "chrome/browser/views/tabs/tab.h"
#include "chrome/browser/views/tabs/tab_strip.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/notification_service.h"
#include "gfx/canvas.h"
#include "grit/theme_resources.h"
@@ -42,7 +41,7 @@
#include <gdk/gdkkeysyms.h>
#endif
-static const int kHorizontalMoveThreshold = 16; // pixels
+static const int kHorizontalMoveThreshold = 16; // Pixels.
namespace {
@@ -338,7 +337,7 @@ DraggedTabController::~DraggedTabController() {
// bounds, it won't be able to clean up properly since its cleanup routine
// uses GetIndexForDraggedContents, which will be invalid.
view_.reset(NULL);
- SetDraggedContents(NULL); // This removes our observer.
+ SetDraggedContents(NULL); // This removes our observer.
}
void DraggedTabController::CaptureDragInfo(const gfx::Point& mouse_offset) {
@@ -766,11 +765,13 @@ void DraggedTabController::Attach(TabStrip* attached_tabstrip,
// TabStrip.
int tab_count = attached_tabstrip_->GetTabCount();
int mini_tab_count = attached_tabstrip_->GetMiniTabCount();
+ int nano_tab_count = attached_tabstrip_->GetNanoTabCount();
if (!tab)
++tab_count;
double unselected_width, selected_width = 0;
attached_tabstrip_->GetDesiredTabWidths(tab_count, mini_tab_count,
- &unselected_width, &selected_width);
+ nano_tab_count, &unselected_width,
+ &selected_width);
EnsureDraggedView();
int dragged_tab_width =
mini_ ? Tab::GetMiniWidth() : static_cast<int>(selected_width);
@@ -809,7 +810,7 @@ void DraggedTabController::Attach(TabStrip* attached_tabstrip,
tab = GetTabMatchingDraggedContents(attached_tabstrip_);
}
- DCHECK(tab); // We should now have a tab.
+ DCHECK(tab); // We should now have a tab.
tab->SetVisible(false);
// Move the corresponding window to the front.
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index f089393..9f22248 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -323,6 +323,7 @@ void TabRenderer::UpdateData(TabContents* contents,
else
data_.favicon = contents->GetFavIcon();
data_.phantom = phantom;
+ data_.app = contents->is_app();
// Sets the accessible name for the tab.
SetAccessibleName(UTF16ToWide(data_.title));
@@ -978,9 +979,9 @@ void TabRenderer::LoadTabImages() {
tab_active.l_width = tab_active.image_l->width();
tab_active.r_width = tab_active.image_r->width();
- // This is high much taller *visually* the regular tab is compared to the
- // nano tabs. The images are the same height, this is really just the
- // difference in whitespace above the tab image.
+ // The regular tab is high much taller *visually* than the nano tabs.
+ // The images are the same height, this is really just the difference
+ // in whitespace above the tab image (regular vs nano).
const int kMiniTabDiffHeight = 14;
tab_active_nano.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_NANO_LEFT);
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index f5a8756..4d61d99 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -238,6 +238,9 @@ class TabStrip::RemoveTabDelegate
// static
const int TabStrip::mini_to_non_mini_gap_ = 3;
+// static
+const int TabStrip::extra_gap_for_nano_ = 10;
+
TabStrip::TabStrip(TabStripModel* model)
: model_(model),
resize_layout_factory_(this),
@@ -1087,9 +1090,11 @@ void TabStrip::GetCurrentTabWidths(double* unselected_width,
void TabStrip::GetDesiredTabWidths(int tab_count,
int mini_tab_count,
+ int nano_tab_count,
double* unselected_width,
double* selected_width) const {
DCHECK(tab_count >= 0 && mini_tab_count >= 0 && mini_tab_count <= tab_count);
+ DCHECK(nano_tab_count >= 0 && nano_tab_count <= tab_count);
const double min_unselected_width = Tab::GetMinimumUnselectedSize().width();
const double min_selected_width = Tab::GetMinimumSelectedSize().width();
@@ -1128,6 +1133,9 @@ void TabStrip::GetDesiredTabWidths(int tab_count,
}
// Account for gap between the last mini-tab and first non-mini-tab.
available_width -= mini_to_non_mini_gap_;
+ // And add some extra space if you have nano tabs in the mix.
+ if (nano_tab_count > 0)
+ available_width -= extra_gap_for_nano_;
}
// Calculate the desired tab widths by dividing the available space into equal
@@ -1187,7 +1195,8 @@ void TabStrip::ResizeLayoutTabs() {
}
Tab* first_tab = GetTabAtTabDataIndex(mini_tab_count);
double unselected, selected;
- GetDesiredTabWidths(GetTabCount(), mini_tab_count, &unselected, &selected);
+ GetDesiredTabWidths(GetTabCount(), mini_tab_count, GetNanoTabCount(),
+ &unselected, &selected);
int w = Round(first_tab->IsSelected() ? selected : selected);
// We only want to run the animation if we're not already at the desired
@@ -1396,17 +1405,20 @@ void TabStrip::GenerateIdealBounds() {
int tab_count = GetTabCount();
int non_closing_tab_count = 0;
int mini_tab_count = 0;
+ int nano_tab_count = 0;
for (int i = 0; i < tab_count; ++i) {
if (!tab_data_[i].tab->closing()) {
++non_closing_tab_count;
if (tab_data_[i].tab->mini())
mini_tab_count++;
+ if (tab_data_[i].tab->app())
+ nano_tab_count++;
}
}
double unselected, selected;
- GetDesiredTabWidths(non_closing_tab_count, mini_tab_count, &unselected,
- &selected);
+ GetDesiredTabWidths(non_closing_tab_count, mini_tab_count, nano_tab_count,
+ &unselected, &selected);
current_unselected_width_ = unselected;
current_selected_width_ = selected;
@@ -1426,6 +1438,8 @@ void TabStrip::GenerateIdealBounds() {
if (last_was_mini) {
// Give a bigger gap between mini and non-mini tabs.
tab_x += mini_to_non_mini_gap_;
+ if (nano_tab_count > 0)
+ tab_x += extra_gap_for_nano_;
}
if (tab->IsSelected())
tab_width = selected;
@@ -1680,6 +1694,17 @@ int TabStrip::GetMiniTabCount() const {
return mini_count;
}
+int TabStrip::GetNanoTabCount() const {
+ int nano_count = 0;
+ for (size_t i = 0; i < tab_data_.size(); ++i) {
+ if (tab_data_[i].tab->app())
+ nano_count++;
+ else
+ return nano_count;
+ }
+ return nano_count;
+}
+
int TabStrip::GetAvailableWidthForTabs(Tab* last_tab) const {
return last_tab->x() + last_tab->width();
}
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 2af7f93..95ccfdb 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
#define CHROME_BROWSER_VIEWS_TABS_TAB_STRIP_H_
+#include <vector>
+
#include "app/animation_container.h"
#include "base/message_loop.h"
#include "base/ref_counted.h"
@@ -186,6 +188,10 @@ class TabStrip : public BaseTabStrip,
// Horizontal gap between mini and non-mini-tabs.
static const int mini_to_non_mini_gap_;
+ // Extra horizontal gap (on top of mini_to_non_mini_gap_) when one of the
+ // mini tabs is a nano tab.
+ static const int extra_gap_for_nano_;
+
private:
class RemoveTabDelegate;
@@ -280,6 +286,9 @@ class TabStrip : public BaseTabStrip,
// Returns the number of mini-tabs.
int GetMiniTabCount() const;
+ // Returns the number of nano-tabs.
+ int GetNanoTabCount() const;
+
// -- Tab Resize Layout -----------------------------------------------------
// Returns the exact (unrounded) current width of each tab.
@@ -290,10 +299,11 @@ class TabStrip : public BaseTabStrip,
// desired strip width and number of tabs. If
// |width_of_tabs_for_mouse_close_| is nonnegative we use that value in
// calculating the desired strip width; otherwise we use the current width.
- // |mini_tab_count| gives the number of mini-tabs, and |tab_count| the
- // number of mini and non-mini-tabs.
+ // |mini_tab_count| gives the number of mini-tabs, |nano_tab_count| the
+ // number of mini-tabs and |tab_count| the number of mini and non-mini-tabs.
void GetDesiredTabWidths(int tab_count,
int mini_tab_count,
+ int nano_tab_count,
double* unselected_width,
double* selected_width) const;