private static SafeControlHandle GetHandle(SurfaceHandler handler, bool scrollable, int width, int height, out LibuiEx.AreaHandler outHandler) { outHandler = new LibuiEx.AreaHandler { Draw = (nativeHandler, surface, args) => handler.Draw(surfaceCache[surface], ref args), MouseEvent = (nativeHandler, surface, args) => handler.MouseEvent(surfaceCache[surface], ref args), MouseCrossed = (nativeHandler, surface, left) => handler.MouseCrossed(surfaceCache[surface], left), DragBroken = (nativeHandler, surface) => handler.DragBroken(surfaceCache[surface]), KeyEvent = (nativeHandler, surface, args) => handler.KeyEvent(surfaceCache[surface], ref args) }; return(!scrollable ? new SafeControlHandle(LibuiEx.NewArea(outHandler)) : new SafeControlHandle(LibuiEx.NewScrollingArea(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 LibuiEx.AreaHandler outHandler), cacheable) { handlerCache.Add(this, outHandler); surfaceCache.Add(Handle, this); }