From 034aa113cfb462ca75c9d2bbf345c49d567b10d1 Mon Sep 17 00:00:00 2001
From: 2youyouo2 <501251991@qq.com>
Date: Wed, 3 Aug 2016 14:11:15 +0800
Subject: [PATCH 1/5] fixed mac templates
---
.../frameworks/runtime-src/proj.ios_mac/mac/Info.plist | 5 +++++
.../frameworks/runtime-src/proj.ios_mac/mac/Info.plist | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist
index aa22263424..ada75113cd 100755
--- a/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist
+++ b/native/templates/js-template-binary/frameworks/runtime-src/proj.ios_mac/mac/Info.plist
@@ -32,5 +32,10 @@
MainMenu
NSPrincipalClass
NSApplication
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+
diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist
index aa22263424..ada75113cd 100755
--- a/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist
+++ b/native/templates/js-template-link/frameworks/runtime-src/proj.ios_mac/mac/Info.plist
@@ -32,5 +32,10 @@
MainMenu
NSPrincipalClass
NSApplication
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+
From 190e15d52c746f4258a5fdbc049f156c7388d93b Mon Sep 17 00:00:00 2001
From: zilongshanren
Date: Thu, 4 Aug 2016 15:10:31 +0800
Subject: [PATCH 2/5] fix editbox password alignment
---
.../ui/UIEditBox/Mac/CCUIPasswordTextField.h | 2 +-
.../ui/UIEditBox/Mac/CCUIPasswordTextField.m | 93 +++++++++++++++++--
2 files changed, 86 insertions(+), 9 deletions(-)
diff --git a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h
index 04f6bb6c92..032cf70b85 100644
--- a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h
+++ b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.h
@@ -26,7 +26,7 @@
#import
#include "ui/UIEditBox/Mac/CCUITextInput.h"
-@interface CCUIPasswordTextField : NSSecureTextField
+@interface CCUIPasswordTextField : NSTextField
{
NSMutableDictionary* _placeholderAttributes;
}
diff --git a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m
index 4885a8f7ea..a01cc41f37 100644
--- a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m
+++ b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m
@@ -1,19 +1,19 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 zilongshanren
-
+
http://www.cocos2d-x.org
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -26,6 +26,78 @@
#import "ui/UIEditBox/Mac/CCUIPasswordTextField.h"
#include "ui/UIEditBox/Mac/CCUITextFieldFormatter.h"
+@interface RSVerticallyCenteredSecureTextFieldCell : NSSecureTextFieldCell
+{
+ BOOL mIsEditingOrSelecting;
+}
+
+@end
+
+@implementation RSVerticallyCenteredSecureTextFieldCell
+
+- (NSRect)drawingRectForBounds:(NSRect)theRect
+{
+ // Get the parent's idea of where we should draw
+ NSRect newRect = [super drawingRectForBounds:theRect];
+
+ // When the text field is being
+ // edited or selected, we have to turn off the magic because it screws up
+ // the configuration of the field editor. We sneak around this by
+ // intercepting selectWithFrame and editWithFrame and sneaking a
+ // reduced, centered rect in at the last minute.
+ if (mIsEditingOrSelecting == NO)
+ {
+ // Get our ideal size for current text
+ NSSize textSize = [self cellSizeForBounds:theRect];
+
+ // Center that in the proposed rect
+ float heightDelta = newRect.size.height - textSize.height;
+ if (heightDelta > 0)
+ {
+ newRect.size.height -= heightDelta;
+ newRect.origin.y += (heightDelta / 2);
+ }
+ }
+
+ return newRect;
+}
+
+- (void)selectWithFrame:(NSRect)aRect
+ inView:(NSView *)controlView
+ editor:(NSText *)textObj
+ delegate:(id)anObject
+ start:(long)selStart
+ length:(long)selLength
+{
+ aRect = [self drawingRectForBounds:aRect];
+ mIsEditingOrSelecting = YES;
+ [super selectWithFrame:aRect
+ inView:controlView
+ editor:textObj
+ delegate:anObject
+ start:selStart
+ length:selLength];
+ mIsEditingOrSelecting = NO;
+}
+
+- (void)editWithFrame:(NSRect)aRect
+ inView:(NSView *)controlView
+ editor:(NSText *)textObj
+ delegate:(id)anObject
+ event:(NSEvent *)theEvent
+{
+ aRect = [self drawingRectForBounds:aRect];
+ mIsEditingOrSelecting = YES;
+ [super editWithFrame:aRect
+ inView:controlView
+ editor:textObj
+ delegate:anObject
+ event:theEvent];
+ mIsEditingOrSelecting = NO;
+}
+
+@end
+
@interface CCUIPasswordTextField()
@property (nonatomic, retain) NSMutableDictionary *placeholderAttributes;
@@ -46,14 +118,19 @@
[NSColor grayColor], NSForegroundColorAttributeName,
nil];
}
-
+
return self;
}
++(void)load
+{
+ [self setCellClass:[RSVerticallyCenteredSecureTextFieldCell class]];
+}
+
- (void)dealloc
{
self.placeholderAttributes = nil;
-
+
[super dealloc];
}
@@ -81,9 +158,9 @@
{
NSAttributedString *as = [[NSAttributedString alloc] initWithString:text
attributes:self.placeholderAttributes];
-
+
[[self cell] setPlaceholderAttributedString:as];
-
+
[as release];
}
From 190a94fbcca09b08ac6df5e447959056f606270c Mon Sep 17 00:00:00 2001
From: zilongshanren
Date: Thu, 4 Aug 2016 15:52:13 +0800
Subject: [PATCH 3/5] modify the line truncate mode
---
native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m | 2 ++
1 file changed, 2 insertions(+)
diff --git a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m
index a01cc41f37..8d04eb3d73 100644
--- a/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m
+++ b/native/cocos/ui/UIEditBox/Mac/CCUIPasswordTextField.m
@@ -117,6 +117,8 @@
font, NSFontAttributeName,
[NSColor grayColor], NSForegroundColorAttributeName,
nil];
+ [self setLineBreakMode:NSLineBreakByTruncatingTail];
+
}
return self;
From 7dc1869a4177015493fe83e710f0d6a6c49a4fa1 Mon Sep 17 00:00:00 2001
From: 2youyou2 <501251991@qq.com>
Date: Tue, 9 Aug 2016 15:54:40 +0800
Subject: [PATCH 4/5] fixed graphics crash on windows
---
native/cocos/editor-support/creator/CCGraphicsNode.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp
index bb32357d2a..7ca4356dd5 100644
--- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp
+++ b/native/cocos/editor-support/creator/CCGraphicsNode.cpp
@@ -846,7 +846,7 @@ void GraphicsNode::flattenPaths()
{
if (_curPath && _curPath->points.size() <= 1) {
_nPath --;
- _curPath = _paths[_nPath - 1];
+ _curPath = _nPath > 0 ? _paths[_nPath - 1] : nullptr;
}
for (int i = _pathOffset; i < _nPath; i++) {
From 5172ec698db96529f67039b2312ede7380263920 Mon Sep 17 00:00:00 2001
From: 2youyou2 <501251991@qq.com>
Date: Tue, 9 Aug 2016 15:59:19 +0800
Subject: [PATCH 5/5] tab to 4 spaces
---
native/cocos/editor-support/creator/CCGraphicsNode.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/native/cocos/editor-support/creator/CCGraphicsNode.cpp b/native/cocos/editor-support/creator/CCGraphicsNode.cpp
index 7ca4356dd5..3647390519 100644
--- a/native/cocos/editor-support/creator/CCGraphicsNode.cpp
+++ b/native/cocos/editor-support/creator/CCGraphicsNode.cpp
@@ -846,7 +846,7 @@ void GraphicsNode::flattenPaths()
{
if (_curPath && _curPath->points.size() <= 1) {
_nPath --;
- _curPath = _nPath > 0 ? _paths[_nPath - 1] : nullptr;
+ _curPath = _nPath > 0 ? _paths[_nPath - 1] : nullptr;
}
for (int i = _pathOffset; i < _nPath; i++) {