diff options
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/chrome.gyp | 3 | ||||
-rw-r--r-- | chrome/views/SConscript | 4 | ||||
-rw-r--r-- | chrome/views/controls/button/custom_button.cc | 17 | ||||
-rw-r--r-- | chrome/views/controls/button/text_button.cc | 13 | ||||
-rw-r--r-- | chrome/views/widget/root_view.cc | 13 | ||||
-rw-r--r-- | chrome/views/widget/root_view.h | 4 | ||||
-rw-r--r-- | chrome/views/widget/root_view_gtk.cc | 16 | ||||
-rw-r--r-- | chrome/views/widget/root_view_win.cc | 7 | ||||
-rw-r--r-- | chrome/views/widget/widget_gtk.cc | 8 | ||||
-rw-r--r-- | skia/ext/platform_canvas_linux.h | 4 |
11 files changed, 37 insertions, 56 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 43b620e..f938005 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -24,7 +24,6 @@ #include "chrome/browser/tab_contents/web_contents.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/resource_bundle.h" -#include "chrome/views/controls/button/text_button.h" #include "grit/theme_resources.h" namespace { @@ -156,9 +155,6 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser) if (parsed_command_line.HasSwitch(switches::kViewsGtk)) { experimental_widget_.reset(new views::WidgetGtk()); experimental_widget_->Init(gfx::Rect(), false); - experimental_widget_->SetContentsView( - new views::TextButton(NULL, L"Button")); - gtk_box_pack_start(GTK_BOX(vbox_), experimental_widget_->GetNativeView(), false, false, 2); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 7f05e37..a0e7fe8 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2457,6 +2457,8 @@ 'views/accessibility/accessible_wrapper.cc', 'views/accessibility/view_accessibility.cc', 'views/accessibility/view_accessibility_wrapper.cc', + 'views/controls/button/button.cc', + 'views/controls/button/custom_button.cc', 'views/controls/scrollbar/bitmap_scroll_bar.cc', 'views/controls/button/image_button.cc', 'views/controls/button/button_dropdown.cc', @@ -2479,6 +2481,7 @@ 'views/controls/single_split_view.cc', 'views/controls/tabbed_pane.cc', 'views/controls/table/table_view.cc', + 'views/controls/button/text_button.cc', 'views/controls/text_field.cc', 'views/controls/tree/tree_view.cc', 'views/widget/accelerator_handler.cc', diff --git a/chrome/views/SConscript b/chrome/views/SConscript index 626a420..81325aa 100644 --- a/chrome/views/SConscript +++ b/chrome/views/SConscript @@ -50,8 +50,6 @@ input_files = ChromeFileList([ 'controls/scrollbar/bitmap_scroll_bar.h', 'border.cc', 'border.h', - 'controls/button/custom_button.cc', - 'controls/button/custom_button.h', 'controls/button/image_button.cc', 'controls/button/image_button.h', 'controls/button/button_dropdown.cc', @@ -218,6 +216,7 @@ if env.Bit('linux'): 'accelerator.cc', 'accessibility/accessible_wrapper.cc', 'accessibility/view_accessibility.cc', + 'controls/button/button.cc', 'controls/scrollbar/bitmap_scroll_bar.cc', 'controls/button/image_button.cc', 'controls/button/button_dropdown.cc', @@ -240,6 +239,7 @@ if env.Bit('linux'): 'controls/single_split_view.cc', 'controls/tabbed_pane.cc', 'controls/table/table_view.cc', + 'controls/button/text_button.cc', 'controls/text_field.cc', 'controls/tree/tree_view.cc', 'widget/accelerator_handler.cc', diff --git a/chrome/views/controls/button/custom_button.cc b/chrome/views/controls/button/custom_button.cc index a01c0ab..04e0a50 100644 --- a/chrome/views/controls/button/custom_button.cc +++ b/chrome/views/controls/button/custom_button.cc @@ -4,17 +4,12 @@ #include "chrome/views/controls/button/custom_button.h" -#include "base/keyboard_codes.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/gfx/chrome_canvas.h" -#include "chrome/common/throb_animation.h" - -// TODO(erg): Write drag'n'drop for Linux. -#if defined(OS_WIN) #include "base/base_drag_source.h" #include "chrome/browser/drag_utils.h" +#include "chrome/common/drag_drop_types.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/os_exchange_data.h" -#endif +#include "chrome/common/throb_animation.h" namespace views { @@ -171,10 +166,10 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { // Space sets button state to pushed. Enter clicks the button. This matches // the Windows native behavior of buttons, where Space clicks the button // on KeyRelease and Enter clicks the button on KeyPressed. - if (e.GetCharacter() == base::VKEY_SPACE) { + if (e.GetCharacter() == VK_SPACE) { SetState(BS_PUSHED); return true; - } else if (e.GetCharacter() == base::VKEY_RETURN) { + } else if (e.GetCharacter() == VK_RETURN) { SetState(BS_NORMAL); NotifyClick(0); return true; @@ -185,7 +180,7 @@ bool CustomButton::OnKeyPressed(const KeyEvent& e) { bool CustomButton::OnKeyReleased(const KeyEvent& e) { if (state_ != BS_DISABLED) { - if (e.GetCharacter() == base::VKEY_SPACE) { + if (e.GetCharacter() == VK_SPACE) { SetState(BS_NORMAL); NotifyClick(0); return true; diff --git a/chrome/views/controls/button/text_button.cc b/chrome/views/controls/button/text_button.cc index a273d20..c5f1ae6 100644 --- a/chrome/views/controls/button/text_button.cc +++ b/chrome/views/controls/button/text_button.cc @@ -8,15 +8,12 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/throb_animation.h" +#include "chrome/common/win_util.h" #include "chrome/views/controls/button/button.h" #include "chrome/views/event.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" -#if defined(OS_WIN) -#include "chrome/common/win_util.h" -#endif - namespace views { // Padding between the icon and text. @@ -157,11 +154,11 @@ void TextButtonBorder::GetInsets(gfx::Insets* insets) const { TextButton::TextButton(ButtonListener* listener, const std::wstring& text) : CustomButton(listener), - alignment_(ALIGN_LEFT), font_(ResourceBundle::GetSharedInstance().GetFont( ResourceBundle::BaseFont)), color_(kEnabledColor), - max_width_(0) { + max_width_(0), + alignment_(ALIGN_LEFT) { SetText(text); set_border(new TextButtonBorder); SetAnimationDuration(kHoverAnimationDurationMs); @@ -247,16 +244,12 @@ void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) { text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); if (for_drag) { -#if defined(OS_WIN) - // TODO(erg): Either port DrawStringWithHalo to linux or find an - // alternative here. canvas->DrawStringWithHalo(text_, font_, color_, kHighlightColor, text_bounds.x(), text_bounds.y(), text_bounds.width(), text_bounds.height(), l10n_util::DefaultCanvasTextAlignment()); -#endif } else { // Draw bevel highlight canvas->DrawStringInt(text_, diff --git a/chrome/views/widget/root_view.cc b/chrome/views/widget/root_view.cc index 5e6bcc8..672a210 100644 --- a/chrome/views/widget/root_view.cc +++ b/chrome/views/widget/root_view.cc @@ -150,9 +150,13 @@ void RootView::ProcessPaint(ChromeCanvas* canvas) { ScopedProcessingPaint processing_paint(&is_processing_paint_); #endif +#if defined(OS_WIN) // Clip the invalid rect to our bounds. If a view is in a scrollview // it could be a lot larger - invalid_rect_ = GetScheduledPaintRectConstrainedToSize(); + invalid_rect_ = gfx::Rect(GetScheduledPaintRectConstrainedToSize()); +#else + NOTIMPLEMENTED(); +#endif if (invalid_rect_.IsEmpty()) return; @@ -206,13 +210,6 @@ const gfx::Rect& RootView::GetScheduledPaintRect() { return invalid_rect_; } -gfx::Rect RootView::GetScheduledPaintRectConstrainedToSize() { - if (invalid_rect_.IsEmpty()) - return invalid_rect_; - - return invalid_rect_.Intersect(GetLocalBounds(true)); -} - ///////////////////////////////////////////////////////////////////////////// // // RootView - tree diff --git a/chrome/views/widget/root_view.h b/chrome/views/widget/root_view.h index 0c9f59a..f7ad674 100644 --- a/chrome/views/widget/root_view.h +++ b/chrome/views/widget/root_view.h @@ -82,8 +82,10 @@ class RootView : public View, // Invoked by the Widget to discover what rectangle should be painted. const gfx::Rect& GetScheduledPaintRect(); +#if defined(OS_WIN) // Returns the region scheduled to paint clipped to the RootViews bounds. - gfx::Rect GetScheduledPaintRectConstrainedToSize(); + RECT GetScheduledPaintRectConstrainedToSize(); +#endif // Tree functions diff --git a/chrome/views/widget/root_view_gtk.cc b/chrome/views/widget/root_view_gtk.cc index 115b37d..1c7fe9c 100644 --- a/chrome/views/widget/root_view_gtk.cc +++ b/chrome/views/widget/root_view_gtk.cc @@ -10,22 +10,24 @@ namespace views { +// TODO(port): Port GetScheduledPaintRectConstrainedToSize() to not use RECT. + void RootView::UpdateCursor(const MouseEvent& e) { NOTIMPLEMENTED(); } +// TODO(port): Port OnPaint() to not use HWNDs in its public interface. void RootView::OnPaint(GdkEventExpose* event) { ChromeCanvasPaint canvas(event); + canvas.FillRectInt(SK_ColorRED, 5, 5, 10, 10); + canvas.FillRectInt(SK_ColorGREEN, 25, 5, 10, 10); + canvas.FillRectInt(SK_ColorBLUE, 45, 5, 10, 10); if (!canvas.isEmpty()) { - SchedulePaint(gfx::Rect(canvas.rectangle()), false); - if (NeedsPainting(false)) { + // const PAINTSTRUCT& ps = canvas.paintStruct(); + // SchedulePaint(gfx::Rect(ps.rcPaint), false); + if (NeedsPainting(false)) ProcessPaint(&canvas); - - canvas.FillRectInt(SK_ColorRED, 5, 5, 10, 10); - canvas.FillRectInt(SK_ColorGREEN, 25, 5, 10, 10); - canvas.FillRectInt(SK_ColorBLUE, 45, 5, 10, 10); - } } } diff --git a/chrome/views/widget/root_view_win.cc b/chrome/views/widget/root_view_win.cc index 4aa95ed7..b4641b4 100644 --- a/chrome/views/widget/root_view_win.cc +++ b/chrome/views/widget/root_view_win.cc @@ -37,15 +37,14 @@ void RootView::UpdateCursor(const MouseEvent& e) { } void RootView::OnPaint(HWND hwnd) { - gfx::Rect original_dirty_region = GetScheduledPaintRectConstrainedToSize(); - if (!original_dirty_region.empty()) { + RECT original_dirty_region = GetScheduledPaintRectConstrainedToSize(); + if (!IsRectEmpty(&original_dirty_region)) { // Invoke InvalidateRect so that the dirty region of the window includes the // region we need to paint. If we didn't do this and the region didn't // include the dirty region, ProcessPaint would incorrectly mark everything // as clean. This can happen if a WM_PAINT is generated by the system before // the InvokeLater schedule by RootView is processed. - RECT win_version = original_dirty_region.ToRECT(); - InvalidateRect(hwnd, &win_version, FALSE); + InvalidateRect(hwnd, &original_dirty_region, FALSE); } ChromeCanvasPaint canvas(hwnd); if (!canvas.isEmpty()) { diff --git a/chrome/views/widget/widget_gtk.cc b/chrome/views/widget/widget_gtk.cc index a2a7b35..83d7766 100644 --- a/chrome/views/widget/widget_gtk.cc +++ b/chrome/views/widget/widget_gtk.cc @@ -87,11 +87,7 @@ void WidgetGtk::SetContentsView(View* view) { root_view_->RemoveAllChildViews(true); root_view_->AddChildView(view); - // TODO(erg): Terrible hack to work around lack of real sizing mechanics for - // now. - root_view_->SetBounds(0, 0, 100, 100); - root_view_->Layout(); - root_view_->SchedulePaint(); + // TODO(erg): More windowy stuff here. NOTIMPLEMENTED(); } @@ -147,7 +143,9 @@ bool WidgetGtk::GetAccelerator(int cmd_id, Accelerator* accelerator) { return false; } + gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { + // Do something here with a chrome canvas? root_view_->OnPaint(event); return true; } diff --git a/skia/ext/platform_canvas_linux.h b/skia/ext/platform_canvas_linux.h index 818b70c..63ffd62 100644 --- a/skia/ext/platform_canvas_linux.h +++ b/skia/ext/platform_canvas_linux.h @@ -108,10 +108,6 @@ class CanvasPaintT : public T { return rectangle_.width == 0 || rectangle_.height == 0; } - const GdkRectangle& rectangle() const { - return rectangle_; - } - private: void init(bool opaque) { gdk_window_begin_paint_rect(window_, &rectangle_); |