maneac / go-ultralight

Unofficial Golang bindings for the C++ Ultralight UI library
https://ultralig.ht
MIT License
32 stars 1 forks source link

Inspector View #4

Open Gurkengewuerz opened 4 years ago

Gurkengewuerz commented 4 years ago

Hey, i was trying to create a PR for the inspector view but my problem is, as far as I understand the Ultralight API, that I cannot replace a view or create an overlay with a view using the C API. Do you have any ideas? My idea would be to replace a pointer, but with ulOverlayGetView there is only one structure copy.

Current approach:

func (view *View) GetInspectorView() *View {
    return &View{
        v: C.ulViewCreateInspectorView(view.v),
    }
}

From the browser Example:

void Tab::ToggleInspector() {
  if (!inspector_overlay_) {
    inspector_overlay_ = Overlay::Create(ui_->window_, *view()->inspector(), 0, 0);
  } else {
    if (inspector_overlay_->is_hidden())
      inspector_overlay_->Show();
    else
      inspector_overlay_->Hide();
  }

  // Force resize to update layout
  Resize(container_width_, container_height_);
}

If there isn't any approach i already created an issue for the CAPI. https://github.com/ultralight-ux/Ultralight/issues/252

maneac commented 4 years ago

Hi,

Your understanding is correct. Unfortunately, as it is not currently possible to create an overlay from a view using the CAPI, there is no way to display the inspector view.

For this reason, I have omitted the creation of inspector views from this wrapper for the time being, aiming to add in the functionality when it becomes available.

Gurkengewuerz commented 4 years ago

Alright. Lets hope @adamjs will implement this to the CAPI. 👍