🔧 Implement feedback
This commit is contained in:
parent
b4bb00843b
commit
6191e6e787
5 changed files with 10 additions and 16 deletions
|
@ -15,8 +15,4 @@ NativeBrowserView::NativeBrowserView(
|
||||||
|
|
||||||
NativeBrowserView::~NativeBrowserView() {}
|
NativeBrowserView::~NativeBrowserView() {}
|
||||||
|
|
||||||
void NativeBrowserView::UpdateDraggableRegions(
|
|
||||||
std::vector<gfx::Rect> system_drag_exclude_areas) {
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -42,7 +42,7 @@ class NativeBrowserView {
|
||||||
|
|
||||||
// Called when the window needs to update its draggable region.
|
// Called when the window needs to update its draggable region.
|
||||||
virtual void UpdateDraggableRegions(
|
virtual void UpdateDraggableRegions(
|
||||||
std::vector<gfx::Rect> system_drag_exclude_areas);
|
const std::vector<gfx::Rect>& system_drag_exclude_areas) {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit NativeBrowserView(
|
explicit NativeBrowserView(
|
||||||
|
|
|
@ -22,7 +22,7 @@ class NativeBrowserViewMac : public NativeBrowserView {
|
||||||
void SetAutoResizeFlags(uint8_t flags) override;
|
void SetAutoResizeFlags(uint8_t flags) override;
|
||||||
void SetBounds(const gfx::Rect& bounds) override;
|
void SetBounds(const gfx::Rect& bounds) override;
|
||||||
void SetBackgroundColor(SkColor color) override;
|
void SetBackgroundColor(SkColor color) override;
|
||||||
void UpdateDraggableRegions(std::vector<gfx::Rect> system_drag_exclude_areas) override;
|
void UpdateDraggableRegions(const std::vector<gfx::Rect>& system_drag_exclude_areas) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeBrowserViewMac);
|
DISALLOW_COPY_AND_ASSIGN(NativeBrowserViewMac);
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include "skia/ext/skia_utils_mac.h"
|
#include "skia/ext/skia_utils_mac.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
|
|
||||||
using base::scoped_nsobject;
|
|
||||||
|
|
||||||
// Match view::Views behavior where the view sticks to the top-left origin.
|
// Match view::Views behavior where the view sticks to the top-left origin.
|
||||||
const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||||
NSViewMaxXMargin | NSViewMinYMargin;
|
NSViewMaxXMargin | NSViewMinYMargin;
|
||||||
|
@ -54,18 +52,17 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSPoint currentLocation;
|
NSPoint currentLocation = [NSEvent mouseLocation];
|
||||||
NSPoint newOrigin;
|
NSPoint newOrigin;
|
||||||
|
|
||||||
NSRect screenFrame = [[NSScreen mainScreen] frame];
|
NSRect screenFrame = [[NSScreen mainScreen] frame];
|
||||||
NSRect windowFrame = [self.window frame];
|
NSRect windowFrame = [self.window frame];
|
||||||
|
|
||||||
currentLocation = [NSEvent mouseLocation];
|
|
||||||
newOrigin.x = currentLocation.x - self.initialLocation.x;
|
newOrigin.x = currentLocation.x - self.initialLocation.x;
|
||||||
newOrigin.y = currentLocation.y - self.initialLocation.y;
|
newOrigin.y = currentLocation.y - self.initialLocation.y;
|
||||||
|
|
||||||
// Don't let window get dragged up under the menu bar
|
// Don't let window get dragged up under the menu bar
|
||||||
if( (newOrigin.y + windowFrame.size.height) > (screenFrame.origin.y + screenFrame.size.height) ){
|
if ((newOrigin.y + windowFrame.size.height) > (screenFrame.origin.y + screenFrame.size.height)) {
|
||||||
newOrigin.y = screenFrame.origin.y + (screenFrame.size.height - windowFrame.size.height);
|
newOrigin.y = screenFrame.origin.y + (screenFrame.size.height - windowFrame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +72,13 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||||
|
|
||||||
// Debugging tips:
|
// Debugging tips:
|
||||||
// Uncomment the following four lines to color DragRegionView bright red
|
// Uncomment the following four lines to color DragRegionView bright red
|
||||||
|
// #ifdef DEBUG_DRAG_REGIONS
|
||||||
// - (void)drawRect:(NSRect)aRect
|
// - (void)drawRect:(NSRect)aRect
|
||||||
// {
|
// {
|
||||||
// [[NSColor redColor] set];
|
// [[NSColor redColor] set];
|
||||||
// NSRectFill([self bounds]);
|
// NSRectFill([self bounds]);
|
||||||
// }
|
// }
|
||||||
|
// #endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -94,11 +93,13 @@ const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||||
|
|
||||||
// Debugging tips:
|
// Debugging tips:
|
||||||
// Uncomment the following four lines to color ExcludeDragRegionView bright red
|
// Uncomment the following four lines to color ExcludeDragRegionView bright red
|
||||||
|
// #ifdef DEBUG_DRAG_REGIONS
|
||||||
// - (void)drawRect:(NSRect)aRect
|
// - (void)drawRect:(NSRect)aRect
|
||||||
// {
|
// {
|
||||||
// [[NSColor greenColor] set];
|
// [[NSColor greenColor] set];
|
||||||
// NSRectFill([self bounds]);
|
// NSRectFill([self bounds]);
|
||||||
// }
|
// }
|
||||||
|
// #endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
std::vector<gfx::Rect> system_drag_exclude_areas) {
|
const std::vector<gfx::Rect>& system_drag_exclude_areas) {
|
||||||
NSView* webView = GetInspectableWebContentsView()->GetNativeView();
|
NSView* webView = GetInspectableWebContentsView()->GetNativeView();
|
||||||
|
|
||||||
NSInteger superViewHeight = NSHeight([webView.superview bounds]);
|
NSInteger superViewHeight = NSHeight([webView.superview bounds]);
|
||||||
|
@ -178,8 +179,7 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||||
webViewHeight)];
|
webViewHeight)];
|
||||||
|
|
||||||
// Then, on top of that, add "exclusion zones"
|
// Then, on top of that, add "exclusion zones"
|
||||||
for (std::vector<gfx::Rect>::const_iterator iter =
|
for (auto iter = system_drag_exclude_areas.begin();
|
||||||
system_drag_exclude_areas.begin();
|
|
||||||
iter != system_drag_exclude_areas.end();
|
iter != system_drag_exclude_areas.end();
|
||||||
++iter) {
|
++iter) {
|
||||||
base::scoped_nsobject<NSView> controlRegion(
|
base::scoped_nsobject<NSView> controlRegion(
|
||||||
|
|
|
@ -1767,8 +1767,6 @@ void NativeWindowMac::UpdateDraggableRegionViews(
|
||||||
std::vector<gfx::Rect> system_drag_exclude_areas =
|
std::vector<gfx::Rect> system_drag_exclude_areas =
|
||||||
CalculateNonDraggableRegions(regions, webViewWidth, webViewHeight);
|
CalculateNonDraggableRegions(regions, webViewWidth, webViewHeight);
|
||||||
|
|
||||||
// Call down to a BrowserView, if it exists, and inform it about the
|
|
||||||
// draggable areas
|
|
||||||
if (browser_view_) {
|
if (browser_view_) {
|
||||||
browser_view_->UpdateDraggableRegions(system_drag_exclude_areas);
|
browser_view_->UpdateDraggableRegions(system_drag_exclude_areas);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue