private static SafeControlHandle GetHandle(SurfaceHandler handler, bool scrollable, int width, int height, out Libui.uiAreaHandler outHandler) { outHandler = new Libui.uiAreaHandler { Draw = (nativeHandler, surface, args) => { DrawEventArgs e = new DrawEventArgs(args); handler.Draw(surfaceCache[surface], ref e); }, MouseEvent = (nativeHandler, surface, args) => { MouseEventArgs e = new MouseEventArgs(args); handler.MouseEvent(surfaceCache[surface], ref e); }, MouseCrossed = (nativeHandler, surface, left) => { handler.MouseCrossed(surfaceCache[surface], left); }, DragBroken = (nativeHandler, surface) => handler.DragBroken(surfaceCache[surface]), KeyEvent = (nativeHandler, surface, args) => { KeyEventArgs e = new KeyEventArgs(args); return(handler.KeyEvent(surfaceCache[surface], ref e)); } }; return(!scrollable ? new SafeControlHandle(Libui.Call <Libui.uiNewArea>()(outHandler)) : new SafeControlHandle(Libui.Call <Libui.uiNewScrollingArea>()(outHandler, width, height))); }
/// <summary> /// Initializes a new instance of the <see cref="ScrollableSurface"/> class with the specified <see cref="SurfaceHandler"/>, width, and height. /// </summary> /// <param name="handler">The specified event handler.</param> /// <param name="width">The width of the <see cref="ScrollableSurface"/>.</param> /// <param name="height">The height of the <see cref="ScrollableSurface"/>.</param> public ScrollableSurface(SurfaceHandler handler, int width, int height) : base(handler, true, width, height) { }
internal SurfaceBase(SurfaceHandler handler, bool scrollable, int width, int height, bool cacheable = true) : base(GetHandle(handler, scrollable, width, height, out Libui.uiAreaHandler outHandler), cacheable) { handlerCache.Add(this, outHandler); surfaceCache.Add(Handle, this); }
/// <summary> /// Initializes a new instance of the <see cref="Surface"/> class with the specified <see cref="SurfaceHandler"/>. /// </summary> /// <param name="handler">The specified event handler.</param> public Surface(SurfaceHandler handler) : base(handler, false, 0, 0) { }