Пример #1
0
void ModifyContainerSplitRatio(double Offset, int Degrees)
{
    if(!FocusedApplication)
        return;

    ax_window *Window = FocusedApplication->Focus;
    if(!Window)
        return;

    ax_display *Display = AXLibWindowDisplay(Window);
    space_info *SpaceInfo = &WindowTree[Display->Space->Identifier];

    tree_node *Root = SpaceInfo->RootNode;
    if(!Root || IsLeafNode(Root) || Root->WindowID != 0)
        return;

    tree_node *Node = GetTreeNodeFromWindowIDOrLinkNode(Root, Window->ID);
    if(Node)
    {
        ax_window *ClosestWindow = NULL;
        if(FindClosestWindow(Degrees, &ClosestWindow, false))
        {
            tree_node *Target = GetTreeNodeFromWindowIDOrLinkNode(Root, ClosestWindow->ID);
            tree_node *Ancestor = FindLowestCommonAncestor(Node, Target);

            if(Ancestor)
            {
                if(!(Node == Ancestor->LeftChild || IsLeftChildInSubTree(Ancestor->LeftChild, Node)))
                    Offset = -Offset;

                double NewSplitRatio = Ancestor->SplitRatio + Offset;
                SetContainerSplitRatio(NewSplitRatio, Node, Ancestor, Display, true);
            }
        }
    }
}
Пример #2
0
void SemanticDictionary::ComputeDependencyPath(SemanticInstance *instance,
        int p, int a,
        string *relation_path,
        string *pos_path) const {
    const vector<int>& heads = instance->GetHeads();
    vector<string> relations_up;
    vector<string> relations_down;
    vector<string> pos_up;
    vector<string> pos_down;

    int ancestor = FindLowestCommonAncestor(heads, p, a);
    int h = p;
    while (ancestor != h) {
        relations_up.push_back(instance->GetDependencyRelation(h));
        pos_up.push_back(instance->GetPosTag(h));
        h = heads[h];
    }
    h = a;
    while (ancestor != h) {
        relations_down.push_back(instance->GetDependencyRelation(h));
        pos_down.push_back(instance->GetPosTag(h));
        h = heads[h];
    }

    relation_path->clear();
    pos_path->clear();
    for (int i = 0; i < relations_up.size(); ++i) {
        *relation_path += relations_up[i] + "^";
        *pos_path += pos_up[i] + "^";
    }
    *pos_path += instance->GetPosTag(ancestor);
    for (int i = relations_down.size()-1; i >= 0; --i) {
        *relation_path += relations_down[i] + "!";
        *pos_path += pos_down[i] + "!";
    }
}