Skip to content
Jean-Philippe Bruyère edited this page Oct 26, 2021 · 4 revisions

Interface is the base class for building crow application. It is thread safe allowing application to run multiple interfaces in different threads.

The Interface contains :

  • rendering and layouting queues and logic.
  • helpers to load IML interfaces files directely bound to this interface
  • global static constants and variables of CROW
  • Keyboard and Mouse logic

namespace: Crow

Inheritance Hierarchy

  • Interface

Syntax

public class Interface : ILayoutable, ICommandHost

Constructors

prototype description
Interface (int width, int height, IntPtr glfwWindowHandle) Create a new Crow Interface by providing an existing valid GLFW window handle. UI thread will not be started, and the main surface will not be initialized. This is used to give crow support to existing glfw application by providing a custom suface creation, and a custom update thread.
Interface (int width=800, int height=600, bool startUIThread=true, bool createSurface=true) Create a standard Crow interface.

Properties

name description
ActiveWidget Widget is focused and button is down or another perif action is occuring , it can not lose focus while Active
Alt __
ArrangeChildren __
ClientRectangle __
Clipboard __
CrowAssemblyNames Each time this array is set, the resolved Assemblies will be added to the CrowAssemblies list, see 'AddCrowAssembly' for details.
Ctrl __
DragAndDropInProgress __
DropTarget __
FocusedWidget Widget has the keyboard or mouse focus
HostContainer __
HoverWidget Pointer is over the widget
LayoutingTries __
LogicalParent __
MouseCursor __
MousePosition __
Parent __
RegisteredLayoutings __
RequiredLayoutings __
Running __
Shift __
SolidBackground __
SurfacePointer __
Theme __
WindowHandle Native GLFW window handle bound to this interface.
WindowTitle __
ZoomFactor __

Methods

prototype description
void AddCrowAssembly(Assembly a) Add Assembly that may contains CROW ui ressources like custom widget classes, IML, images, ... Styling fond in those assemblies are automatically loaded on addition; This assembly will be searched for embedded ressource resolution, extension methods, and custom widgets. For those assemblies to be added by simple name, see 'CrowAssemblyNames'.
Widget AddWidget(Widget g) Add widget to the Graphic tree of this interface and register it for layouting
void ChildrenLayoutingConstraints(ILayoutable layoutable, ref LayoutingType layoutType) __
void ClearDragImage() __
void ClearInterface() Remove all Graphic objects from top container
Rectangle ContextCoordinates(Rectangle r) __
void CreateDragImage(Surface img, Rectangle bounds, bool followMouse=true) __
Widget CreateInstance(string path) Create an instance of a Widget linked to this interface but not added to the GraphicTree
T CreateInstance< T >(string path) __
Instantiator CreateITorFromIMLFragment(string imlFragment) Create an instantiator bound to this interface from the IML fragment
void CreateMainSurface(ref Rectangle r) ??
Surface CreateSurface(ref Rectangle r) __
Surface CreateSurface(int width, int height) __
Surface CreateSurface(IntPtr existingSurfaceHandle) __
Surface CreateSurfaceForData(IntPtr data, int width, int height) __
void DeleteWidget(Widget g) Set visible state of widget to false and delete if from the graphic tree
void Dispose() __
void EnqueueForRepaint(Widget g) Enqueue Graphic object for Repaint, DrawingQueue is locked because GraphObj's property Set methods could trigger an update from another thread Once in that queue, that means that the layouting of obj and childs have succeed, the next step when dequeued will be clipping registration
Widget FindByName(string nameToFind) Search a Graphic object in the tree named 'nameToFind'
void ForceMousePosition() Ask OS to force the mouse position to the actual coordinate of Interface.MousePosition
Rectangle GetClientRectangleForChild(ILayoutable child) __
Instantiator GetInstantiator(string path) Fetch instantiator from cache or create it.
ItemTemplate GetItemTemplate(string path) Item templates are derived from instantiator, this function try to fetch the requested one in the cache or create it. They have additional properties for recursivity and custom display per item type
Rectangle getSlot() __
Stream GetStreamFromPath(string path) __
Type GetWidgetTypeFromName(string typeName) search for graphic object type in crow assembly, if not found, search for type independently of namespace in all the loaded assemblies
void Init() load styling, init default tooltips and context menus, load main.crow resource if exists.
void InterfaceThread() __
bool IsDown(MouseButton button) __
bool IsKeyDown(Key key) __
Widget Load(string path) Create an instance of a Widget and add it to the GraphicTree of this Interface
T Load< T >(string path) __
void LoaderInvoker(object instance) Main Cairo context
Widget LoadIMLFragment(string imlFragment) Add the content of the IML fragment to the graphic tree of this interface
T LoadIMLFragment< T >(string imlFragment) __
void LoadStyle(string stylePath) __
void LoadStyle(Stream stream, string resId) __
void NotifyValueChanged(string MemberName, object _value) __
void NotifyValueChanged(object _value, [CallerMemberName] string caller=null) __
bool OnKeyDown(KeyEventArgs e) __
bool OnKeyPress(char c) __
bool OnKeyUp(KeyEventArgs e) __
bool OnMouseButtonDown(MouseButton button) Forward the mouse down event from the host to the hover widget in the crow interface
bool OnMouseButtonUp(MouseButton button) Forward the mouse up event from the host to the crow interface
bool OnMouseMove(int x, int y) Processes mouse move events from the root container, this function should be called by the host on mouse move event to forward events to crow interfaces
bool OnMouseWheelChanged(float delta) Forward the mouse wheel event from the host to the crow interface
bool PointIsIn(ref Point m) __
void ProcessResize(Rectangle bounds) Resize the interface. This function should be called by the host when window resize event occurs.
void PutOnTop(Widget g, bool isOverlay=false) Put widget on top of other root widgets
void Quit() __
void RegisterClip(Rectangle r) __
void RegisterForLayouting(LayoutingType layoutType) __
void RemoveCrowAssembly(Assembly a) Remove Assembly from the CrowAssembly list. See 'AddCrowAssembly' for details.
void RemoveWidget(Widget g) Set visible state of widget to false and remove if from the graphic tree
void Run() call Init() then enter the running loop performing ProcessEvents until running==false.
Rectangle ScreenCoordinates(Rectangle r) __
MethodInfo SearchExtMethod(Type t, string methodName) __
void SetWindowIcon(string path) Set the main GLFW window icon.
void ShowContextMenu(Widget go) __
void Terminate() __
void Update(Context ctx=null) Main Update loop, executed in this interface thread, protected by the UpdateMutex Steps:
void UpdateFrame() __
bool UpdateLayout(LayoutingType layoutType) __

Events

name description
EndDragOperation __
Initialized Each control need a ref to the root interface containing it, if not set in Widget.currentInterface, the ref of this one will be stored in Widget.currentInterface
KeyDown __
KeyUp __
StartDragOperation __
ValueChanged __
Clone this wiki locally