~eliasnaur/gio#428: 
Windows Platform View

Creating this todo after I was suggested from the mailing list: https://lists.sr.ht/~eliasnaur/gio/%3CCAEYLQcqLcsN7KdTUjoD7ZwdL0uLuEALqVB78enuz4iGcG-UkqQ%40mail.gmail.com%3E

There is few things should be done before seeing a working platform view. Currently GIO needs to be able to: -Parent a native window -Move native window relative to a placeholder image inside I can't figure out how to do this. https://gist.githubusercontent.com/hanswered/e0bc6bdd00db344683f36219c29ab8f6/raw/de802d8fabb72cbcbc68c8817167ea13ba0b2220/gistfile1.txt Other required functions are already available.

Later: -Overlay GIO on top of native window and vice versa. Transparency effects are undocumented but there might be an alternative way that I haven't yet explored https://docs.microsoft.com/en-us/archive/msdn-magazine/2014/june/windows-with-c-high-performance-window-layering-using-the-windows-composition-engine Optional: -An example of a native window with best practices of aquiring a handle (using os mutexes/ipc/something else?) -Starting and managing native window processes "UI friendly way".

Status
REPORTED
Submitter
~hanswer
Assigned to
No-one
Submitted
5 months ago
Updated
4 months ago
Labels
No labels applied.

~inkeliz 5 months ago*

I'm working to use WebView inside Gio. The only thing you need is the HWND from app.ViewEvent, and use it as parent. That works fine for most cases. It have some limitations: that is not aware of gio-layouts (clips, offsets, ...) and it's always "on-top" of Gio.

I guess, we need some paint.LinkedView (using paint. because it will insert the window inside the clip.RRect). The LinkedView should accept one interface, that interface is responsible to show the content at specific position and size. That is also related to https://lists.sr.ht/~eliasnaur/gio/%3Cfe3835f7-b4d4-4db9-81fb-dfd8ab06f2ed%40www.fastmail.com%3E

EDIT: For Android, seems that Gio must use LayoutFrame, to allow add new Views ( see https://todo.sr.ht/~eliasnaur/gio/427 ).

~hanswer 5 months ago

~inkeliz I already Parented a SDL window using app.ViewEvent shown on my mailing list. This way external window can only be moved in a predefined values. I expect the external window move to a specific placeholder image inside gio. I'm having a hard time figuring out how clip, offsets(relative to window) and dimension(of a placeholder image) can be calculated inside a widget. My guess we expose clip offsets in gtx.Constrains?

~whereswaldon 5 months ago

Gio's design deliberately prevents widgets from being able to look up their own absolute coordinates. Allowing this would require a lot of complexity given Gio's capability to perform arbitrary affine transformations. I think that an approach relying on absolute positioning, though appealing because it is easy, is probably a dead end. The model that I think we'd prefer is as ~inkeliz describes above. Imagine a paint operation that works just like paint.ImageOp, but paints from a surface presented by your native view. Then Gio's normal operations can be used to position the native view and gather input for it.

~eliasnaur 5 months ago

Imagine a paint operation that works just like paint.ImageOp, but paints from a surface presented by your native view. Then Gio's normal operations can be used to position the native view and gather input for it.

Or even a paint.WidgetOp{Handle: <Windows hwnd>} where Gio makes sure to position it according to Gio ops. Input handling would then be handled automatically by the OS.

~hanswer 5 months ago*

Was able to somehow use GIO offsets move window accurately just by having only one imageOP in (r *renderer) drawOps(). And then my idea was to write i.handle and recieve handle in drawOps(). Code below causes out of range panic.

(op *ClipOp) Decode(data []byte). const ops.TypeView ops.OpType = 208
// data := ops.Write1(&o.Internal, ops.TypeImageLen, i.handle) // data[0] = byte(ops.TypeView) }
func (i ViewOp) Add(o *op.Ops) {

I have no idea if this write1 usage is correct.

type ViewOp struct { handle interface{} area image.Point }

func NewViewOp(src interface{}, area image.Point) ViewOp { return ViewOp{handle: src, area: area} }

func (i ViewOp) Add(o *op.Ops) {

  data := ops.Write1(&o.Internal, ops.TypeImageLen, i.handle)
  data[0] = byte(ops.TypeView)
}

func (i ViewOp) Size() image.Point { return i.area }

~hanswer 4 months ago*

POC is complete now. There is probably some code reviews needed.

-At this stage can I directly make a pull request on github?

-For the linkedView widget do I have move the code to gio/x repository?

~psydvl 4 months ago

~hanswer, for format text you should use Markdown (click to open)
  1. to create newline instead of keep text on previous line, use double space in the end of previous line
  2. to format inline code use `
    Like:
    I love `map[int]struct{}`
    
    Will produce:
    I love map[int]struct{}
  3. to format code block use triple ```
    Like:
    ``` go
    // This is main fucntion
    func main() {
        fmt.Println("Hello, world!")
    }
    ```
    
    Will produce
    // This is main fucntion
    func main() {
        fmt.Println("Hello, world!")
    }
    
    Instead of what we see now
  4. Also, preview button very useful, but you also can use any online markdown editor, like https://markdownlivepreview.com/

~hanswer 4 months ago

~psydvl have formatted code now but the strikethrough ~~ isn't working.

~eliasnaur 4 months ago

Please do post your work as a PR or patch to the mailing list so we have something concrete to discuss.

Register here or Log in to comment, or comment via email.