grkek / iu Goto Github PK
View Code? Open in Web Editor NEWUI framework based on the Fusion/libui.cr library, with elements from watzon/cru.
License: MIT License
UI framework based on the Fusion/libui.cr library, with elements from watzon/cru.
License: MIT License
A class inherits Iu::Components::Area and implements on_*
callback, will crash program when its instance access instance variables:
class MyArea < Iu::Components::Area
def initialize(width = nil, height = width)
@blah = "blah"
super(width, height)
end
def on_draw(params : UI::AreaDrawParams)
puts @blah
end
def on_mouse_event(mouse_event : UI::AreaMouseEvent);end
def on_mouse_crossed(left : Bool);end
def on_drag_broken;end
def on_key_event(key_event : UI::AreaKeyEvent);end
end
I'm not familiar with Crystal. I think the reason is that the callback function passed to the libui C library forms a closure. The Iu shard wraps libui, a new member "data" is added to the AreaHandler structure to store pointers to an area objects. This allows libui to call back the on_*
method implemented by the MyArea class, I'm not sure if this is the scenario described in Crystal document. After testing, this bug can be solved in this way:
@@on_mouse_event_cb = Proc(UI::AreaHandler*, UI::Area*, UI::AreaMouseEvent*, Nil).new { |h, a, e|
# h.value.data.as(Area*).value.on_mouse_event(e.value).as(Nil)
::Box(Area).unbox(h.value.data).on_mouse_event(e.value).as(Nil)
}
# @handler.data = self.as(Void*)
@handler.data = ::Box.box(self)
Could a standalone image example be added to demonstrate the view-image functionality?
I know it is possible because ruby libui does it. Would be nice to have copy/paste-able code
in crystal as-is to just modify it a little bit for already existing images.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.