Merge branch 'master' of github.com:buggins/dlangui

This commit is contained in:
Vadim Lopatin 2015-11-19 08:52:04 +03:00
commit a6486ddb50
1 changed files with 17 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import derelict.cocoa;
import dlangui.core.logger; import dlangui.core.logger;
import dlangui.core.types; import dlangui.core.types;
import dlangui.core.events; import dlangui.core.events;
import dlangui.graphics.drawbuf;
import std.uuid; import std.uuid;
import core.stdc.stdlib; import core.stdc.stdlib;
import std.string; import std.string;
@ -16,6 +17,8 @@ void main(string[] args)
Log.setLogLevel(LogLevel.Trace); Log.setLogLevel(LogLevel.Trace);
DerelictCocoa.load(); DerelictCocoa.load();
static if (true) { static if (true) {
auto pool = new NSAutoreleasePool; auto pool = new NSAutoreleasePool;
NSString appName = NSProcessInfo.processInfo().processName(); NSString appName = NSProcessInfo.processInfo().processName();
@ -107,13 +110,13 @@ class IWindowListenerLogger : IWindowListener {
Log.d("onMouseClick"); Log.d("onMouseClick");
} }
override void recomputeDirtyAreas() { override void recomputeDirtyAreas() {
Log.d("recomputeDirtyAreas"); //Log.d("recomputeDirtyAreas");
} }
override void onResized(int width, int height) { override void onResized(int width, int height) {
Log.d("onResized"); Log.d("onResized");
} }
override void onAnimate(double dt, double time) { override void onAnimate(double dt, double time) {
Log.d("onAnimate"); //Log.d("onAnimate");
} }
override Rect getDirtyRectangle() { override Rect getDirtyRectangle() {
return Rect(0, 0, 100, 100); return Rect(0, 0, 100, 100);
@ -150,6 +153,8 @@ private:
NSData _imageData; NSData _imageData;
NSString _logFormatStr; NSString _logFormatStr;
ColorDrawBuf _drawBuf;
DPlugCustomView _view = null; DPlugCustomView _view = null;
bool _terminated = false; bool _terminated = false;
@ -184,7 +189,9 @@ public:
NSWindow window = NSWindow.alloc(); NSWindow window = NSWindow.alloc();
window.initWithContentRect(NSMakeRect(100, 100, width, height), window.initWithContentRect(NSMakeRect(100, 100, width, height),
NSBorderlessWindowMask, NSBackingStoreBuffered, NO); NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask,
NSBackingStoreBuffered,
NO);
window.makeKeyAndOrderFront(); window.makeKeyAndOrderFront();
parentView = window.contentView(); parentView = window.contentView();
@ -409,10 +416,11 @@ private:
// wfb.pitch = byteStride(_width); // wfb.pitch = byteStride(_width);
// wfb.pixels = cast(RGBA*)_buffer; // wfb.pixels = cast(RGBA*)_buffer;
// _listener.onDraw(wfb, WindowPixelFormat.ARGB8); // _listener.onDraw(wfb, WindowPixelFormat.ARGB8);
_drawBuf.fill(0x8090B0);
_drawBuf.fillRect(Rect(20, 20, 120, 120), 0xFFBBBB);
size_t sizeNeeded = byteStride(_width) * _height; size_t sizeNeeded = byteStride(_width) * _height;
_imageData = NSData.dataWithBytesNoCopy(_buffer, sizeNeeded, false); _imageData = NSData.dataWithBytesNoCopy(cast(ubyte*)_drawBuf.scanLine(0), sizeNeeded, false);
CIImage image = CIImage.imageWithBitmapData(_imageData, CIImage image = CIImage.imageWithBitmapData(_imageData,
byteStride(_width), byteStride(_width),
@ -440,6 +448,10 @@ private:
_buffer = cast(ubyte*) malloc(sizeNeeded); _buffer = cast(ubyte*) malloc(sizeNeeded);
_width = newWidth; _width = newWidth;
_height = newHeight; _height = newHeight;
if (_drawBuf is null)
_drawBuf = new ColorDrawBuf(_width, _height);
else if (_drawBuf.width != _width || _drawBuf.height != _height)
_drawBuf.resize(_width, _height);
_listener.onResized(_width, _height); _listener.onResized(_width, _height);
return true; return true;
} }