//--------------------------------------------------------------------------- void tTVPLayerManager::RemoveModeFrom(tTJSNI_BaseLayer *layer) { // remove modal state from given layer bool do_notify = false; try { std::vector<tTJSNI_BaseLayer*>::iterator i; for(i = ModalLayerVector.begin(); i < ModalLayerVector.end();) { if(layer == *i) { if(!do_notify) { do_notify = true; SaveEnabledWork(); } if(layer->Owner) layer->Owner->Release(); SetFocusTo(layer->GetNextFocusable(), true); i = ModalLayerVector.erase(i); } else { i++; } } } catch(...) { if(do_notify) NotifyNodeEnabledState(); throw; } if(do_notify) NotifyNodeEnabledState(); }
//--------------------------------------------------------------------------- void tTVPLayerManager::RemoveTreeModalState(tTJSNI_BaseLayer *root) { // remove modal state from given tree bool do_notify = false; try { std::vector<tTJSNI_BaseLayer*>::iterator i; for(i = ModalLayerVector.begin(); i < ModalLayerVector.end();) { if((*i)->IsAncestorOrSelf(root)) { if(!do_notify) { do_notify = true; SaveEnabledWork(); } if((*i)->Owner) (*i)->Owner->Release(); SetFocusTo(root->GetNextFocusable(), true); i = ModalLayerVector.erase(i); } else { i++; } } } catch(...) { if(do_notify) NotifyNodeEnabledState(); throw; } if(do_notify) NotifyNodeEnabledState(); }
//--------------------------------------------------------------------------- void tTVPLayerManager::SetModeTo(tTJSNI_BaseLayer *layer) { // (primary only) set mode to layer if(!layer) return; SaveEnabledWork(); try { tTJSNI_BaseLayer *current = GetCurrentModalLayer(); if(current && layer->IsAncestorOrSelf(current)) TVPThrowExceptionMessage(TVPCannotSetModeToDisabledOrModal); // cannot set mode to parent layer if(!layer->Visible) layer->Visible = true; if(!layer->GetParentVisible() || !layer->Enabled) TVPThrowExceptionMessage(TVPCannotSetModeToDisabledOrModal); // cannot set mode to parent layer if(layer == current) TVPThrowExceptionMessage(TVPCannotSetModeToDisabledOrModal); // cannot set mode to already modal layer SetFocusTo(layer->SearchFirstFocusable(), true); if(layer->Owner) layer->Owner->AddRef(); ModalLayerVector.push_back(layer); } catch(...) { NotifyNodeEnabledState(); throw; } NotifyNodeEnabledState(); }
//--------------------------------------------------------------------------- bool tTVPLayerManager::BlurTree(tTJSNI_BaseLayer *root) { // (primary only) remove focus from "root" RemoveTreeModalState(root); LeaveMouseFromTree(root); if(!FocusedLayer) return false; if(!FocusedLayer->IsAncestorOrSelf(root)) return false; // root is not ancestor of current focused layer tTJSNI_BaseLayer *next = root->GetNextFocusable(); if(next != FocusedLayer) SetFocusTo(next, true); // focus to root's next focusable layer else SetFocusTo(NULL, true); return true; }
//--------------------------------------------------------------------------- tTJSNI_BaseLayer *tTVPLayerManager::FocusNext() { // focus to next layer tTJSNI_BaseLayer *l; if(!FocusedLayer) l = SearchFirstFocusable(false);// search first focusable layer else l = FocusedLayer->GetNextFocusable(); if(l) SetFocusTo(l, true); return l; }
//--------------------------------------------------------------------------- tTJSNI_BaseLayer *tTVPLayerManager::FocusPrev() { // focus to previous layer tTJSNI_BaseLayer *l; if(!FocusedLayer) l = SearchFirstFocusable(false);// search first focusable layer else l = FocusedLayer->GetPrevFocusable(); if(l) SetFocusTo(l, false); return l; }
//--------------------------------------------------------------------------- void tTVPLayerManager::DetachPrimary() { // detach primary layer from the manager if(Primary) { SetFocusTo(NULL); ReleaseCapture(); ForceMouseLeave(); NotifyPart(Primary); Primary = NULL; } }