]> khamidou — GitHub mirrors - electron.git/commitdiff
Style fixes
authorCheng Zhao <zcbenz@gmail.com>
Thu, 23 Jul 2015 02:07:58 +0000 (10:07 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 23 Jul 2015 02:07:58 +0000 (10:07 +0800)
* Use under_score for variable names in C++
* Use const& when possible
* Line length <= 80

atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_mac.mm

index 49a41cf51a932a315ad77548bef2bb203111b336..c4e6b06af06f291867cf51e5b9fc8757d0461d26 100644 (file)
@@ -249,8 +249,8 @@ bool Window::IsFullscreen() {
   return window_->IsFullscreen();
 }
 
-void Window::SetAspectRatio(double aspectRatio, gfx::Size extraSize) {
-  window_->SetAspectRatio(aspectRatio, extraSize);
+void Window::SetAspectRatio(double aspect_ratio, const gfx::Size& extraSize) {
+  window_->SetAspectRatio(aspect_ratio, extraSize);
 }
 
 void Window::SetBounds(const gfx::Rect& bounds) {
index e0345bc2e3bf28b5735a1e083915b63e3374c1c0..f807ab135f28c2191bb53f8f6821ac4bbe601ccf 100644 (file)
@@ -95,7 +95,7 @@ class Window : public mate::TrackableObject<Window>,
   bool IsMinimized();
   void SetFullScreen(bool fullscreen);
   bool IsFullscreen();
-  void SetAspectRatio(double aspectRatio, gfx::Size extraSize);
+  void SetAspectRatio(double aspect_ratio, const gfx::Size& extraSize);
   void SetBounds(const gfx::Rect& bounds);
   gfx::Rect GetBounds();
   void SetSize(int width, int height);
index 56999af945c5b2253810dc786a17be04abc348fa..c03ab1ac24a42fc17cea78fb84860ca70be0ee9c 100644 (file)
@@ -85,6 +85,7 @@ NativeWindow::NativeWindow(
       node_integration_(true),
       has_dialog_attached_(false),
       zoom_factor_(1.0),
+      aspect_ratio_(0.0),
       inspectable_web_contents_(inspectable_web_contents),
       weak_factory_(this) {
   inspectable_web_contents->GetView()->SetDelegate(this);
@@ -195,20 +196,6 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
     Show();
 }
 
-double NativeWindow::GetAspectRatio() {
-  return aspectRatio_;
-}
-
-gfx::Size NativeWindow::GetAspectRatioExtraSize() {
-  return aspectRatioExtraSize_;
-}
-
-void NativeWindow::SetAspectRatio(double aspectRatio,
-                                  const gfx::Size& extraSize) {
-  aspectRatio_ = aspectRatio;
-  aspectRatioExtraSize_ = extraSize;
-}
-
 void NativeWindow::SetSize(const gfx::Size& size) {
   SetBounds(gfx::Rect(GetPosition(), size));
 }
@@ -260,6 +247,20 @@ bool NativeWindow::IsMenuBarVisible() {
   return true;
 }
 
+double NativeWindow::GetAspectRatio() {
+  return aspect_ratio_;
+}
+
+gfx::Size NativeWindow::GetAspectRatioExtraSize() {
+  return aspect_ratio_extraSize_;
+}
+
+void NativeWindow::SetAspectRatio(double aspect_ratio,
+                                  const gfx::Size& extra_size) {
+  aspect_ratio_ = aspect_ratio;
+  aspect_ratio_extraSize_ = extra_size;
+}
+
 bool NativeWindow::HasModalDialog() {
   return has_dialog_attached_;
 }
index cc0bd7b8f5a20e46c911f1074f04f2f89bcb0fab..b9c2486b791bfc81d03173cc4c42a760f2217d64 100644 (file)
@@ -107,9 +107,6 @@ class NativeWindow : public content::WebContentsObserver,
   virtual bool IsMinimized() = 0;
   virtual void SetFullScreen(bool fullscreen) = 0;
   virtual bool IsFullscreen() const = 0;
-  double GetAspectRatio();
-  virtual gfx::Size GetAspectRatioExtraSize();
-  virtual void SetAspectRatio(double aspectRatio, const gfx::Size& extraSize);
   virtual void SetBounds(const gfx::Rect& bounds) = 0;
   virtual gfx::Rect GetBounds() = 0;
   virtual void SetSize(const gfx::Size& size);
@@ -166,6 +163,11 @@ class NativeWindow : public content::WebContentsObserver,
   virtual void SetMenuBarVisibility(bool visible);
   virtual bool IsMenuBarVisible();
 
+  // Set the aspect ratio when resizing window.
+  double GetAspectRatio();
+  gfx::Size GetAspectRatioExtraSize();
+  void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size);
+
   base::WeakPtr<NativeWindow> GetWeakPtr() {
     return weak_factory_.GetWeakPtr();
   }
@@ -290,8 +292,8 @@ class NativeWindow : public content::WebContentsObserver,
 
   // Used to maintain the aspect ratio of a view which is inside of the
   // content view.
-  double aspectRatio_ = 0.0;
-  gfx::Size aspectRatioExtraSize_;
+  double aspect_ratio_;
+  gfx::Size aspect_ratio_extraSize_;
 
   // The page this window is viewing.
   brightray::InspectableWebContents* inspectable_web_contents_;
index b69785045a8bbb396d9d607fafcdf03f019baa90..d5f12bde13dd618f3ad25dcbc12bebd69434f019 100644 (file)
@@ -95,27 +95,38 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
   shell_->NotifyWindowBlur();
 }
 
-- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize {
+- (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize {
   NSSize newSize = frameSize;
   double aspectRatio = shell_->GetAspectRatio();
 
   if (aspectRatio > 0.0) {
-    gfx::Size windowFrameSize = shell_->GetSize();
-    gfx::Size contentViewSize = shell_->GetContentSize();
-    gfx::Size aspectRatioExtraSize = shell_->GetAspectRatioExtraSize();
-    double extraWidthPlusFrame = windowFrameSize.width() - contentViewSize.width() + aspectRatioExtraSize.width();
-    double extraHeightPlusFrame = windowFrameSize.height() - contentViewSize.height() + aspectRatioExtraSize.height();
-
-    newSize.width = roundf(((frameSize.height - extraHeightPlusFrame) * aspectRatio) + extraWidthPlusFrame);
-
-    // If the new width is less than the frame size use it as the primary constraint. This ensures that the value returned
-    // by this method will never be larger than the users requested window size.
+    gfx::Size windowSize = shell_->GetSize();
+    gfx::Size contentSize = shell_->GetContentSize();
+    gfx::Size extraSize = shell_->GetAspectRatioExtraSize();
+
+    double extraWidthPlusFrame =
+        windowSize.width() - contentSize.width() + extraSize.width();
+    double extraHeightPlusFrame =
+        windowSize.height() - contentSize.height() + extraSize.height();
+
+    newSize.width =
+        roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio +
+               extraWidthPlusFrame);
+
+    // If the new width is less than the frame size use it as the primary
+    // constraint. This ensures that the value returned by this method will
+    // never be larger than the users requested window size.
     if (newSize.width <= frameSize.width) {
-        newSize.height = roundf(((newSize.width - extraWidthPlusFrame) / aspectRatio) + extraHeightPlusFrame);
-    }
-    else {
-        newSize.height = roundf(((frameSize.width - extraWidthPlusFrame) / aspectRatio) + extraHeightPlusFrame);
-        newSize.width = roundf(((newSize.height - extraHeightPlusFrame) * aspectRatio) + extraWidthPlusFrame);
+      newSize.height =
+          roundf((newSize.width - extraWidthPlusFrame) / aspectRatio +
+                 extraHeightPlusFrame);
+    } else {
+      newSize.height =
+          roundf((frameSize.width - extraWidthPlusFrame) / aspectRatio +
+                 extraHeightPlusFrame);
+      newSize.width =
+          roundf((newSize.height - extraHeightPlusFrame) * aspectRatio +
+                 extraWidthPlusFrame);
     }
   }