//static void LLFloaterReg::toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD& key) { // // Floaters controlled by the toolbar behave a bit differently from others. // Namely they have 3-4 states as defined in the design wiki page here: // https://wiki.lindenlab.com/wiki/FUI_Button_states // // The basic idea is this: // * If the target floater is minimized, this button press will un-minimize it. // * Else if the target floater is closed open it. // * Else if the target floater does not have focus, give it focus. // * Also, if it is not on top, bring it forward when focus is given. // * Else the target floater is open, close it. // std::string name = sdname.asString(); LLFloater* instance = getInstance(name, key); if (!instance) { lldebugs << "Unable to get instance of floater '" << name << "'" << llendl; } else if (instance->isMinimized()) { instance->setMinimized(FALSE); instance->setVisibleAndFrontmost(); } else if (!instance->isShown()) { // [RLVa:KB] - Checked: 2011-12-17 (RLVa-1.4.5a) | Added: RLVa-1.4.5a // [See LLFloaterReg::showInstance()] if ( ((!sBlockShowFloaters) || (sAlwaysShowableList.find(name) != sAlwaysShowableList.end())) && (mValidateSignal(name, key)) ) { instance->openFloater(key); instance->setVisibleAndFrontmost(); } // [/RLVa:KB] // instance->openFloater(key); // instance->setVisibleAndFrontmost(); } // [SL:KB] - Patch: Chat-NearbyChatBar | Checked: 2011-11-23 (Catznip-3.2.0b) | Modified: Catznip-3.2.0b else { // Give focus to, or close, the host rather than the floater when hosted LLFloater* floaterp = (!instance->getHost()) ? instance : instance->getHost(); if (!floaterp->isFrontmost() || !floaterp->hasFocus()) floaterp->setVisibleAndFrontmost(); else floaterp->closeFloater(); } // [/SL:KB] // else if (!instance->isFrontmost()) // { // instance->setVisibleAndFrontmost(); // } // else // { // instance->closeFloater(); // } }
//static // returns true if the instance is visible when completed bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (LLFloater::isShown(instance)) { // When toggling *visibility*, close the host instead of the floater when hosted if (instance->getHost()) instance->getHost()->closeFloater(); else instance->closeFloater(); return false; } else { return showInstance(name, key, TRUE) ? true : false; } }
//static LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; const std::string& xui_file = sBuildMap[name].mFile; if (build_func) { const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; int index = list.size(); res = build_func(key); bool success = res->buildFromFile(xui_file, NULL); if (!success) { llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe res->mKey = key; res->setInstanceName(name); res->applySavedVariables(); // Can't apply rect and dock state until setting instance name if (res->mAutoTile && !res->getHost() && index > 0) { const LLRect& cur_rect = res->getRect(); LLRect next_rect = getFloaterRect(groupname); next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, cur_rect.getWidth(), cur_rect.getHeight()); res->setRect(next_rect); res->setRectControl(LLStringUtil::null); // don't save rect of tiled floaters gFloaterView->adjustToFitScreen(res, true); } else { gFloaterView->adjustToFitScreen(res, false); } list.push_back(res); } } if (!res) { llwarns << "Floater type: '" << name << "' not registered." << llendl; } } return res; }
void FSFloaterIMContainer::onOpen(const LLSD& key) { LLMultiFloater::onOpen(key); // If we're using multitabs, and we open up for the first time // Add localchat by default if it's not already on the screen somewhere else. -AO // But only if it hasnt been already so we can reopen it to the same tab -KC // Improved handling to leave most of the work to the LL tear-off code -Zi LLFloater* floater = FSFloaterNearbyChat::getInstance(); if (! LLFloater::isVisible(floater) && (floater->getHost() != this)) { if (gSavedSettings.getBOOL("ChatHistoryTornOff")) { // first set the tear-off host to this floater floater->setHost(this); // clear the tear-off host right after, the "last host used" will still stick floater->setHost(NULL); // reparent to floater view gFloaterView->addChild(floater); } else { LLMultiFloater::showFloater(floater); } } /* if (key.isDefined()) { LLIMFloater* im_floater = LLIMFloater::findInstance(key.asUUID()); if (im_floater) { im_floater->openFloater(); } } */ }
//static void LLFloaterReg::toggleInstanceOrBringToFront(const LLSD& sdname, const LLSD& key) { // // Floaters controlled by the toolbar behave a bit differently from others. // Namely they have 3-4 states as defined in the design wiki page here: // https://wiki.lindenlab.com/wiki/FUI_Button_states // // The basic idea is this: // * If the target floater is minimized, this button press will un-minimize it. // * Else if the target floater is closed open it. // * Else if the target floater does not have focus, give it focus. // * Also, if it is not on top, bring it forward when focus is given. // * Else the target floater is open, close it. // std::string name = sdname.asString(); LLFloater* instance = getInstance(name, key); if (!instance) { LL_DEBUGS() << "Unable to get instance of floater '" << name << "'" << LL_ENDL; return; } // If hosted, we need to take that into account LLFloater* host = instance->getHost(); if (host) { //FS:LO from above: * Else if the target floater does not have focus, give it focus. * Also, if it is not on top, bring it forward when focus is given. //if (host->isMinimized() || !host->isShown() || !host->isFrontmost()) if (host->isMinimized() || !host->isShown() || (!host->hasFocus() || !host->isFrontmost())) { host->setMinimized(FALSE); instance->openFloater(key); instance->setVisibleAndFrontmost(true, key); } else if (!instance->getVisible()) { instance->openFloater(key); instance->setVisibleAndFrontmost(true, key); instance->setFocus(TRUE); } else { instance->closeHostedFloater(); } } else { if (instance->isMinimized()) { instance->setMinimized(FALSE); instance->setVisibleAndFrontmost(true, key); } else if (!instance->isShown()) { instance->openFloater(key); instance->setVisibleAndFrontmost(true, key); } //FS:LO from above: * Else if the target floater does not have focus, give it focus. * Also, if it is not on top, bring it forward when focus is given. //else if (!instance->isFrontmost()) else if (!instance->hasFocus() || !instance->isFrontmost()) { instance->setVisibleAndFrontmost(true, key); } else { instance->closeHostedFloater(); } } }
//static LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; const std::string& xui_file = sBuildMap[name].mFile; if (build_func) { const std::string& groupname = sGroupMap[name]; if (!groupname.empty()) { instance_list_t& list = sInstanceMap[groupname]; int index = list.size(); res = build_func(key); bool success = res->buildFromFile(xui_file, NULL); if (!success) { llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe res->mKey = key; res->setInstanceName(name); // AO: Mark certain floaters (sidebar tab floaters) as needing to be pseudo-hidden on minimization. // At the moment we flag this pseudo hiding with the presence of a dummy control in floater_side_bar_tab.xml // and the name of the floater window. This should be refactored into a floater attribute. llinfos << "trying to restore variables for name: " << name << llendl; std::string pat = "side_bar_tab"; size_t found = name.find(pat); if (found!=std::string::npos) { if (!res->hasChild("showMinimized")) res->setHideOnMinimize(true); } res->applySavedVariables(); // Can't apply rect and dock state until setting instance name if (res->mAutoTile && !res->getHost() && index > 0) { const LLRect& cur_rect = res->getRect(); LLRect next_rect = getFloaterRect(groupname); next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, cur_rect.getWidth(), cur_rect.getHeight()); res->setRect(next_rect); res->setRectControl(LLStringUtil::null); // don't save rect of tiled floaters gFloaterView->adjustToFitScreen(res, true); } else { gFloaterView->adjustToFitScreen(res, false); } list.push_back(res); } } if (!res) { llwarns << "Floater type: '" << name << "' not registered." << llendl; } } return res; }