-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS] Make the default background color black. #36906
Changes from all commits
831744b
18f13a0
d8f3f65
4aaad35
0e94bfe
25ddb12
c2f7828
4b143f2
18ecb7f
4b459f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -159,6 +159,8 @@ void Reset() { | |||||||||||||
| */ | ||||||||||||||
| @interface FlutterViewWrapper : NSView | ||||||||||||||
|
|
||||||||||||||
| - (void)setBackgroundColor:(NSColor*)color; | ||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't pretty, but the cc @chunhtai, do you think there's a better way to do this?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The FlutterViewController should have direct access to FlutterView?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The engine/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm Lines 379 to 380 in e39c4df
but the engine/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm Lines 255 to 257 in e39c4df
I tried calling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant the FlutterViewController should be able to access flutter view directly engine/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h Line 14 in 7d5df81
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason, every time I reference this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably PEBKAC |
||||||||||||||
|
|
||||||||||||||
| @end | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
|
|
@@ -266,6 +268,10 @@ - (instancetype)initWithFlutterView:(FlutterView*)view { | |||||||||||||
| return self; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| - (void)setBackgroundColor:(NSColor*)color { | ||||||||||||||
| [_flutterView setBackgroundColor:color]; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| - (NSArray*)accessibilityChildren { | ||||||||||||||
| return @[ _flutterView ]; | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -376,6 +382,9 @@ - (void)loadView { | |||||||||||||
| } | ||||||||||||||
| flutterView = [[FlutterView alloc] initWithMainContext:mainContext reshapeListener:self]; | ||||||||||||||
| } | ||||||||||||||
| if (_backgroundColor != nil) { | ||||||||||||||
| [flutterView setBackgroundColor:_backgroundColor]; | ||||||||||||||
| } | ||||||||||||||
| FlutterViewWrapper* wrapperView = [[FlutterViewWrapper alloc] initWithFlutterView:flutterView]; | ||||||||||||||
| self.view = wrapperView; | ||||||||||||||
| _flutterView = flutterView; | ||||||||||||||
|
|
@@ -418,6 +427,11 @@ - (void)setMouseTrackingMode:(FlutterMouseTrackingMode)mode { | |||||||||||||
| [self configureTrackingArea]; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| - (void)setBackgroundColor:(NSColor*)color { | ||||||||||||||
| _backgroundColor = color; | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are going to cache it, you will also need to apply the background color during the loadView. |
||||||||||||||
| [_flutterView setBackgroundColor:_backgroundColor]; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| - (void)onPreEngineRestart { | ||||||||||||||
| [self initializeKeyboard]; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,3 +57,9 @@ Picture _createSimplePicture() { | |
| void nativeCallback() { | ||
| signalNativeTest(); | ||
| } | ||
|
|
||
| @pragma('vm:entry-point') | ||
| void backgroundTest() { | ||
| PlatformDispatcher.instance.views.first.render(SceneBuilder().build()); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cbracken we decided the test should look like Picture _createSimplePicture() {
Paint paint = Paint();
paint.color = Color(0xFFFF3A00);
PictureRecorder baseRecorder = PictureRecorder();
Canvas canvas = Canvas(baseRecorder);
canvas.drawRect(Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), paint);
return baseRecorder.endRecording();
}
void main() async {
window.render(SceneBuilder().build());
// 1. should look black
final SceneBuilder builder = SceneBuilder();
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
builder.pushOffset(1.0, 2.0);
builder.pop(); // offset
window.render(builder.build());
// 2. should have a red square
window.render(SceneBuilder().build());
// 3. should be black again.
}but flutter/flutter#113785 is preventing step 3 from producing the correct output. Before we can add a test like the one above, flutter/flutter#113785 has to be fixed. |
||
| signalNativeTest(); // should look black | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.