summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/aura_desktop/aura_desktop_main.cc27
-rw-r--r--views/events/event_aura.cc16
-rw-r--r--views/widget/native_widget_aura.cc25
-rw-r--r--views/widget/native_widget_aura.h2
4 files changed, 50 insertions, 20 deletions
diff --git a/views/aura_desktop/aura_desktop_main.cc b/views/aura_desktop/aura_desktop_main.cc
index eabf9fe..219f5e5 100644
--- a/views/aura_desktop/aura_desktop_main.cc
+++ b/views/aura_desktop/aura_desktop_main.cc
@@ -27,9 +27,14 @@ class DemoWindowDelegate : public aura::WindowDelegate {
public:
explicit DemoWindowDelegate(SkColor color) : color_(color) {}
+ virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE {
+ return true;
+ }
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode);
}
+ virtual void OnWindowDestroyed() OVERRIDE {
+ }
private:
SkColor color_;
@@ -39,14 +44,32 @@ class DemoWindowDelegate : public aura::WindowDelegate {
class TestView : public views::View {
public:
- TestView() {}
+ TestView() : color_shifting_(false), color_(SK_ColorYELLOW) {}
virtual ~TestView() {}
private:
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) {
- canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height());
+ canvas->FillRectInt(color_, 0, 0, width(), height());
+ }
+ virtual bool OnMousePressed(const views::MouseEvent& event) {
+ color_shifting_ = true;
+ return true;
+ }
+ virtual void OnMouseMoved(const views::MouseEvent& event) {
+ if (color_shifting_) {
+ color_ = SkColorSetRGB((SkColorGetR(color_) + 5) % 255,
+ SkColorGetG(color_),
+ SkColorGetB(color_));
+ SchedulePaint();
+ }
}
+ virtual void OnMouseReleased(const views::MouseEvent& event) {
+ color_shifting_ = false;
+ }
+
+ bool color_shifting_;
+ SkColor color_;
DISALLOW_COPY_AND_ASSIGN(TestView);
};
diff --git a/views/events/event_aura.cc b/views/events/event_aura.cc
index 0a5a882..88ebe5b 100644
--- a/views/events/event_aura.cc
+++ b/views/events/event_aura.cc
@@ -4,6 +4,7 @@
#include "views/events/event.h"
+#include "aura/event.h"
#include "base/logging.h"
namespace views {
@@ -16,13 +17,11 @@ int GetKeyStateFlags() {
}
ui::EventType EventTypeFromNative(NativeEvent native_event) {
- NOTIMPLEMENTED();
- return ui::ET_UNKNOWN;
+ return native_event->type();
}
int EventFlagsFromNative(NativeEvent native_event) {
- NOTIMPLEMENTED();
- return 0;
+ return native_event->flags();
}
}
@@ -51,9 +50,8 @@ void Event::InitWithNativeEvent2(NativeEvent2 native_event_2,
// LocatedEvent, protected:
LocatedEvent::LocatedEvent(NativeEvent native_event)
- : Event(native_event, EventTypeFromNative(native_event),
- EventFlagsFromNative(native_event)),
- location_(0, 0 /* TODO(beng): obtain */) {
+ : Event(native_event, native_event->type(), native_event->flags()),
+ location_(static_cast<aura::LocatedEvent*>(native_event)->location()) {
}
LocatedEvent::LocatedEvent(NativeEvent2 native_event_2,
@@ -68,9 +66,7 @@ LocatedEvent::LocatedEvent(NativeEvent2 native_event_2,
// KeyEvent, public:
KeyEvent::KeyEvent(NativeEvent native_event)
- : Event(native_event,
- EventTypeFromNative(native_event),
- GetKeyStateFlags()),
+ : Event(native_event, native_event->type(), GetKeyStateFlags()),
key_code_(ui::VKEY_UNKNOWN /* TODO: obtain */),
character_(0),
unmodified_character_(0) {
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc
index db48c74..b206504 100644
--- a/views/widget/native_widget_aura.cc
+++ b/views/widget/native_widget_aura.cc
@@ -4,6 +4,7 @@
#include "views/widget/native_widget_aura.h"
+#include "aura/event.h"
#include "aura/window.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/compositor/layer.h"
@@ -103,12 +104,12 @@ ui::Compositor* NativeWidgetAura::GetCompositor() {
}
void NativeWidgetAura::MarkLayerDirty() {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
}
void NativeWidgetAura::CalculateOffsetToAncestorWithLayer(gfx::Point* offset,
View** ancestor) {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
}
void NativeWidgetAura::ViewRemoved(View* view) {
@@ -125,7 +126,7 @@ void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const {
}
TooltipManager* NativeWidgetAura::GetTooltipManager() const {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
return NULL;
}
@@ -149,7 +150,7 @@ void NativeWidgetAura::ReleaseMouseCapture() {
}
bool NativeWidgetAura::HasMouseCapture() const {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
return false;
}
@@ -291,12 +292,12 @@ void NativeWidgetAura::Minimize() {
}
bool NativeWidgetAura::IsMaximized() const {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
return false;
}
bool NativeWidgetAura::IsMinimized() const {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
return false;
}
@@ -333,11 +334,11 @@ void NativeWidgetAura::RunShellDrag(View* view,
}
void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) {
- NOTIMPLEMENTED();
+ window_->SchedulePaintInRect(rect);
}
void NativeWidgetAura::SetCursor(gfx::NativeCursor cursor) {
- NOTIMPLEMENTED();
+ //NOTIMPLEMENTED();
}
void NativeWidgetAura::ClearNativeFocus() {
@@ -361,10 +362,18 @@ void NativeWidgetAura::DispatchKeyEventPostIME(const KeyEvent& key) {
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, aura::WindowDelegate implementation:
+bool NativeWidgetAura::OnMouseEvent(aura::MouseEvent* event) {
+ return delegate_->OnMouseEvent(MouseEvent(event));
+}
+
void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) {
delegate_->OnNativeWidgetPaint(canvas);
}
+void NativeWidgetAura::OnWindowDestroyed() {
+ delete this;
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, public:
diff --git a/views/widget/native_widget_aura.h b/views/widget/native_widget_aura.h
index 9d66a46..9fee3ab 100644
--- a/views/widget/native_widget_aura.h
+++ b/views/widget/native_widget_aura.h
@@ -108,7 +108,9 @@ class NativeWidgetAura : public internal::NativeWidgetPrivate,
virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
// Overridden from aura::WindowDelegate:
+ virtual bool OnMouseEvent(aura::MouseEvent* event) OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual void OnWindowDestroyed() OVERRIDE;
private:
internal::NativeWidgetDelegate* delegate_;