コード例 #1
0
fltk::Widget *EditorUI::ObjectView::List::child (const fltk::Menu *, const int *indexes, int level)
{
    MdlObject *obj = root_obj();
    if (!obj) return 0;
    for (;;) {
        int i = *indexes++;
        if (i < 0 || i >= obj->childs.size()) return 0;
        MdlObject *ch = obj->childs[i];// Widget* widget = group->child(i);
        if (!level--) {
            obj = ch;
            break;
        }
        if (ch->childs.empty()) return 0;
        obj = ch;
    }

    // init widget
    item.label(obj->name.c_str());
    item.w(0);
    item.user_data(obj);

    // set selection
    if (obj->isSelected) {
        item.set_flag(fltk::SELECTED);
    } else item.clear_flag(fltk::SELECTED);

    // set open/closed state
    if (obj->isOpen && obj->childs.size()) {
        item.set_flag(fltk::VALUE);
    } else item.clear_flag(fltk::VALUE);

    return &item;
}
コード例 #2
0
int EditorUI::ObjectView::List::children (const fltk::Menu *, const int *indexes, int level) {
    MdlObject *obj = root_obj();
    if (!obj) return -1;
    while (level--) {
        int i = *indexes++;
        //if (i < 0 || i >= group->children()) return -1;
        MdlObject *ch = obj->childs[i];
        if (ch->childs.empty()) return -1;
        obj = ch;
    }
    return obj->childs.size();
}
コード例 #3
0
ファイル: WebrtcTelemetry.cpp プロジェクト: MekliCZ/positron
bool
WebrtcTelemetry::GetWebrtcStats(JSContext *cx, JS::MutableHandle<JS::Value> ret)
{
  JS::Rooted<JSObject*> root_obj(cx, JS_NewPlainObject(cx));
  if (!root_obj)
    return false;
  ret.setObject(*root_obj);

  JS::Rooted<JSObject*> ice_obj(cx, JS_NewPlainObject(cx));
  if (!ice_obj)
    return false;
  JS_DefineProperty(cx, root_obj, "IceCandidatesStats", ice_obj,
                    JSPROP_ENUMERATE);

  if (!AddIceInfo(cx, ice_obj, false))
    return false;
  if (!AddIceInfo(cx, ice_obj, true))
    return false;

  return true;
}