Пример #1
0
void LLSideTrayListener::getTabs(const LLSD& event) const
{
    LLSD reply;

    LLSideTray* tray = mGetter();
    LLSD::Integer ord(0);
    for (LLSideTray::child_list_const_iter_t chi(tray->beginChild()), chend(tray->endChild());
         chi != chend; ++chi, ++ord)
    {
        LLView* child = *chi;
        // How much info is important? Toss in as much as seems reasonable for
        // each tab. But to me, at least for the moment, the most important
        // item is the tab name.
        LLSD info;
        // I like the idea of returning a map keyed by tab name. But as
        // compared to an array of maps, that loses sequence information.
        // Address that by indicating the original order in each map entry.
        info["ord"] = ord;
        info["visible"] = bool(child->getVisible());
        info["enabled"] = bool(child->getEnabled());
        info["available"] = child->isAvailable();
        reply[child->getName()] = info;
    }

    sendReply(reply, event);
}
Пример #2
0
bool LLPanel::childIsEnabled(const std::string& id) const
{
	LLView* child = findChild<LLView>(id);
	if (child)
	{
		return (bool)child->getEnabled();
	}
	return false;
}
BOOL LLViewerTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
{
	for (child_list_const_iter_t child_iter = getChildList()->begin();
			child_iter != getChildList()->end(); ++child_iter)
	{
		LLView *viewp = *child_iter;
		S32 local_x = x - viewp->getRect().mLeft;
		S32 local_y = y - viewp->getRect().mBottom;
		if( viewp->pointInView(local_x, local_y) 
			&& viewp->getVisible() 
			&& viewp->getEnabled()
			&& viewp->handleToolTip(local_x, local_y, msg, sticky_rect_screen ) )
		{
			return TRUE;
		}
	}

	if( mSegments.empty() )
	{
		return TRUE;
	}

	const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
	if( cur_segment )
	{
		BOOL has_tool_tip = FALSE;
		if( cur_segment->getStyle()->getIsEmbeddedItem() )
		{
			LLWString wtip;
			has_tool_tip = getEmbeddedItemToolTipAtPos(cur_segment->getStart(), wtip);
			msg = wstring_to_utf8str(wtip);
		}
		else
		{
			has_tool_tip = cur_segment->getToolTip( msg );
		}
		if( has_tool_tip )
		{
			// Just use a slop area around the cursor
			// Convert rect local to screen coordinates
			S32 SLOP = 8;
			localPointToScreen( 
				x - SLOP, y - SLOP, 
				&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
			sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
			sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
		}
	}
	return TRUE;
}
void PieMenu::draw()
{
	// save the current OpenGL drawing matrix so we can freely modify it
	gGL.pushMatrix();

	// save the widget's rectangle for later use
	LLRect r = getRect();

	// initialize pie scale factor for popup effect
	F32 factor = getScaleFactor();

#if PIE_DRAW_BOUNDING_BOX
	// draw a bounding box around the menu for debugging purposes
	gl_rect_2d(0, r.getHeight(), r.getWidth(), 0, LLColor4::white, FALSE);
#endif

	// set up pie menu colors
	LLColor4 lineColor = LLUIColorTable::instance().getColor("PieMenuLineColor");
	LLColor4 selectedColor = LLUIColorTable::instance().getColor("PieMenuSelectedColor");
	LLColor4 textColor = LLUIColorTable::instance().getColor("PieMenuTextColor");
	LLColor4 bgColor = LLUIColorTable::instance().getColor("PieMenuBgColor");
	LLColor4 borderColor = bgColor % 0.3f;

	// if the user wants their own colors, apply them here
	static LLCachedControl<bool> sOverridePieColors(gSavedSettings, "OverridePieColors", false);
	if (sOverridePieColors)
	{
		static LLCachedControl<F32> sPieMenuOpacity(gSavedSettings, "PieMenuOpacity");
		static LLCachedControl<F32> sPieMenuFade(gSavedSettings, "PieMenuFade");
		bgColor = LLUIColorTable::instance().getColor("PieMenuBgColorOverride") % sPieMenuOpacity;
		borderColor = bgColor % (1.f - sPieMenuFade);
		selectedColor = LLUIColorTable::instance().getColor("PieMenuSelectedColorOverride");
	}

	// on first click, make the menu fade out to indicate "borderless" operation
	if (mFirstClick)
	{
		borderColor %= 0.f;
	}

	// move origin point to the center of our rectangle
	gGL.translatef(r.getWidth() / 2, r.getHeight() / 2, 0);

	// draw the general pie background
	gl_washer_2d(PIE_OUTER_SIZE * factor, PIE_INNER_SIZE, 32, bgColor, borderColor);

	// set up an item list iterator to point at the beginning of the item list
	slice_list_t::iterator cur_item_iter;
	cur_item_iter = mSlices->begin();

	// clear current slice pointer
	mSlice = NULL;
	// current slice number is 0
	S32 num = 0;
	bool wasAutohide = false;
	do
	{
		// standard item text color
		LLColor4 itemColor = textColor;

		// clear the label and set up the starting angle to draw in
		std::string label("");
		F32 segmentStart = F_PI / 4.f * (F32)num - F_PI / 8.f;

		// iterate through the list of slices
		if (cur_item_iter != mSlices->end())
		{
			// get current slice item
			LLView* item = (*cur_item_iter);

			// check if this is a submenu or a normal click slice
			PieSlice* currentSlice = dynamic_cast<PieSlice*>(item);
			PieMenu* currentSubmenu = dynamic_cast<PieMenu*>(item);
			// advance internally to the next slice item
			cur_item_iter++;

			// in case it is regular click slice
			if (currentSlice)
			{
				// get the slice label and tell the slice to check if it's supposed to be visible
				label = currentSlice->getLabel();
				currentSlice->updateVisible();
				// disable it if it's not visible, pie slices never really disappear
				BOOL slice_visible = currentSlice->getVisible();
				currentSlice->setEnabled(slice_visible);
				if (!slice_visible)
				{
				//	LL_DEBUGS() << label << " is not visible" << LL_ENDL;
					label = "";
				}

				// if the current slice is the start of an autohide chain, clear out previous chains
				if (currentSlice->getStartAutohide())
				{
					wasAutohide = false;
				}

				// check if the current slice is part of an autohide chain
				if (currentSlice->getAutohide())
				{
					// if the previous item already won the autohide, skip this item
					if (wasAutohide)
					{
						continue;
					}

					// look at the next item in the pie
					LLView* lookAhead = (*cur_item_iter);
					// check if this is a normal click slice
					PieSlice* lookSlice = dynamic_cast<PieSlice*>(lookAhead);
					if (lookSlice)
					{
						// if the next item is part of the current autohide chain as well ...
						if (lookSlice->getAutohide() && !lookSlice->getStartAutohide())
						{
							// ... it's visible and it's enabled, skip the current one.
							// the first visible and enabled item in autohide chains wins
							// this is useful for Sit/Stand toggles
							lookSlice->updateEnabled();
							lookSlice->updateVisible();
							if (lookSlice->getVisible() && lookSlice->getEnabled())
							{
								continue;
							}

							// this item won the autohide contest
							wasAutohide = true;
						}
					}
				}
				else
				{
					// reset autohide chain
					wasAutohide = false;
				}

				// check if the slice is currently enabled
				currentSlice->updateEnabled();
				if (!currentSlice->getEnabled())
				{
					LL_DEBUGS() << label << " is disabled" << LL_ENDL;
					// fade the item color alpha to mark the item as disabled
					itemColor %= 0.3f;
				}
			}
			// if it's a submenu just get the label
			else if (currentSubmenu)
			{
				label = currentSubmenu->getLabel();
			}

			// if it's a slice or submenu, the mouse pointer is over the same segment as our counter and the item is enabled
			if ((currentSlice || currentSubmenu) && (mCurrentSegment == num) && item->getEnabled())
			{
				// memorize the currently highlighted slice for later
				mSlice = item;
				// if we highlighted a different slice than before, we must play a sound
				if (mOldSlice != mSlice)
				{
					// get the appropriate UI sound and play it
					char soundNum = '0' + num;
					std::string soundName = "UISndPieMenuSliceHighlight";
					soundName += soundNum;

					make_ui_sound(soundName.c_str());
					// remember which slice we highlighted last, so we only play the sound once
					mOldSlice = mSlice;
				}

				// draw the currently highlighted pie slice
				gl_washer_segment_2d(PIE_OUTER_SIZE * factor, PIE_INNER_SIZE, segmentStart + 0.02f, segmentStart + F_PI / 4.f - 0.02f, 4, selectedColor, borderColor);
			}
		}
		// draw the divider line for this slice
		gl_washer_segment_2d(PIE_OUTER_SIZE * factor, PIE_INNER_SIZE, segmentStart - 0.02f, segmentStart + 0.02f, 4, lineColor, borderColor);

		// draw the slice labels around the center
		mFont->renderUTF8(label,
							0,
							PIE_X[num],
							PIE_Y[num],
							itemColor,
							LLFontGL::HCENTER,
							LLFontGL::VCENTER,
							LLFontGL::NORMAL,
							LLFontGL::DROP_SHADOW_SOFT);
		// next slice
		num++;
	}
	while (num < 8);	// do this until the menu is full

	// draw inner and outer circle, outer only if it was not the first click
	if (!mFirstClick)
	{
		gl_washer_2d(PIE_OUTER_SIZE * factor, PIE_OUTER_SIZE * factor - 2.f, 32, lineColor, borderColor);
	}
	gl_washer_2d(PIE_INNER_SIZE + 1, PIE_INNER_SIZE - 1, 16, borderColor, lineColor);

	// restore OpenGL drawing matrix
	gGL.popMatrix();

	// give control back to the UI library
	LLView::draw();
}
Пример #5
0
void LLOverlayBar::draw()
{
	// retrieve rounded rect image
	LLUUID image_id;
	image_id.set(gViewerArt.getString("rounded_square.tga"));
	LLViewerImage* imagep = gImageList.getImage(image_id, MIPMAP_FALSE, TRUE);

	if (imagep)
	{
		LLGLSTexture texture_enabled;
		LLViewerImage::bindTexture(imagep);

		const S32 PAD = gSavedSettings.getS32("StatusBarPad");

		// draw rounded rect tabs behind all children
		LLRect r;
		// focus highlights
		LLColor4 color = gColors.getColor("FloaterFocusBorderColor");
		glColor4fv(color.mV);
		if(gFocusMgr.childHasKeyboardFocus(gBottomPanel))
		{
			for (child_list_const_iter_t child_iter = getChildList()->begin();
				child_iter != getChildList()->end(); ++child_iter)
			{
				LLView *view = *child_iter;
				if(view->getEnabled() && view->getVisible())
				{
					r = view->getRect();
					gl_segmented_rect_2d_tex(r.mLeft - PAD/3 - 1, 
											r.mTop + 3, 
											r.mRight + PAD/3 + 1,
											r.mBottom, 
											imagep->getWidth(), 
											imagep->getHeight(), 
											16, 
											ROUNDED_RECT_TOP);
				}
			}
		}

		// main tabs
		for (child_list_const_iter_t child_iter = getChildList()->begin();
			child_iter != getChildList()->end(); ++child_iter)
		{
			LLView *view = *child_iter;
			if(view->getEnabled() && view->getVisible())
			{
				r = view->getRect();
				// draw a nice little pseudo-3D outline
				color = gColors.getColor("DefaultShadowDark");
				glColor4fv(color.mV);
				gl_segmented_rect_2d_tex(r.mLeft - PAD/3 + 1, r.mTop + 2, r.mRight + PAD/3, r.mBottom, 
										 imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
				color = gColors.getColor("DefaultHighlightLight");
				glColor4fv(color.mV);
				gl_segmented_rect_2d_tex(r.mLeft - PAD/3, r.mTop + 2, r.mRight + PAD/3 - 3, r.mBottom, 
										 imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
				// here's the main background.  Note that it overhangs on the bottom so as to hide the
				// focus highlight on the bottom panel, thus producing the illusion that the focus highlight
				// continues around the tabs
				color = gColors.getColor("FocusBackgroundColor");
				glColor4fv(color.mV);
				gl_segmented_rect_2d_tex(r.mLeft - PAD/3 + 1, r.mTop + 1, r.mRight + PAD/3 - 1, r.mBottom - 1, 
										 imagep->getWidth(), imagep->getHeight(), 16, ROUNDED_RECT_TOP);
			}
		}
	}

	// draw children on top
	LLPanel::draw();
}