Example #1
0
//static
void LLScreenClipRect::updateScissorRegion()
{
	if (sClipRectStack.empty()) return;

	// finish any deferred calls in the old clipping region
	gGL.flush();

	LLRect rect = sClipRectStack.top();
	stop_glerror();
	S32 x,y,w,h;
	x = llfloor(rect.mLeft * LLUI::sGLScaleFactor.mV[VX]);
	y = llfloor(rect.mBottom * LLUI::sGLScaleFactor.mV[VY]);
	w = llmax(0, llceil(rect.getWidth() * LLUI::sGLScaleFactor.mV[VX])) + 1;
	h = llmax(0, llceil(rect.getHeight() * LLUI::sGLScaleFactor.mV[VY])) + 1;
	glScissor( x,y,w,h );
	stop_glerror();
}
BOOL setup_hud_matrices(const LLRect& screen_region)
{
	LLVOAvatar* my_avatarp = gAgent.getAvatarObject();
	if (my_avatarp && my_avatarp->hasHUDAttachment())
	{
		F32 zoom_level = gAgent.mHUDCurZoom;
		LLBBox hud_bbox = my_avatarp->getHUDBBox();

		// set up transform to keep HUD objects in front of camera
		glMatrixMode(GL_PROJECTION);
		F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
		glh::matrix4f proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
		proj.element(2,2) = -0.01f;

		F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();

		glh::matrix4f mat;
		F32 scale_x = (F32)gViewerWindow->getWindowWidth() / (F32)screen_region.getWidth();
		F32 scale_y = (F32)gViewerWindow->getWindowHeight() / (F32)screen_region.getHeight();
		mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
		mat.set_translate(
			glh::vec3f(clamp_rescale((F32)screen_region.getCenterX(), 0.f, (F32)gViewerWindow->getWindowWidth(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
						clamp_rescale((F32)screen_region.getCenterY(), 0.f, (F32)gViewerWindow->getWindowHeight(), 0.5f * scale_y, -0.5f * scale_y),
						0.f));
		proj *= mat;

		glLoadMatrixf(proj.m);
		glh_set_current_projection(proj);

		glMatrixMode(GL_MODELVIEW);
		glh::matrix4f model((GLfloat*) OGL_TO_CFR_ROTATION);
		
		mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level));
		mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f));

		model *= mat;
		glLoadMatrixf(model.m);
		glh_set_current_modelview(model);

		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
Example #3
0
void LLFloaterHtmlFind::show( void* url_string )
{
	if ( sInstance )
	{
		sInstance->setVisibleAndFrontmost();
		return;
	};

	LLFloaterHtmlFind* self = new LLFloaterHtmlFind;

	// create floater from its XML definition
	gUICtrlFactory->buildFloater( self, "floater_html_find.xml" );

	// reposition floater from saved settings
	LLRect rect = gSavedSettings.getRect( "HtmlFindRect" );
	self->reshape( rect.getWidth(), rect.getHeight(), FALSE );
	self->setRect( rect );
}
	void object::test<8>()
	{	
		//
		// test the set() method
		//
		
		LLRect rect;
		
		rect.set(10, 90, 70, 10);
		ensure_equals("set() rectf left", rect.mLeft, 10);
		ensure_equals("set() rectf top", rect.mTop, 90);
		ensure_equals("set() rectf right", rect.mRight, 70);
		ensure_equals("set() rectf bottom", rect.mBottom, 10);
		ensure_equals("set() rectf width", rect.getWidth(), 60);
		ensure_equals("set() rectf height", rect.getHeight(), 80);
		ensure_equals("set() rectf centerx", rect.getCenterX(), 40);
		ensure_equals("set() rectf centery", rect.getCenterY(), 50);
	}
void LLScrollingPanelList::removePanel( U32 panel_index )
{
    if ( mPanelList.empty() || panel_index >= mPanelList.size() )
    {
        LL_WARNS() << "Panel index " << panel_index << " is out of range!" << LL_ENDL;
        return;
    }
    else
    {
        removeChild( mPanelList.at(panel_index) );
        mPanelList.erase( mPanelList.begin() + panel_index );
    }

    const S32 GAP_BETWEEN_PANELS = 6;

    // Resize this view
    S32 total_height = 0;
    S32 max_width = 0;
    S32 cur_gap = 0;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        total_height += childp->getRect().getHeight() + cur_gap;
        max_width = llmax( max_width, childp->getRect().getWidth() );
        cur_gap = GAP_BETWEEN_PANELS;
    }
    LLRect rc = getRect();
    rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height);
    setRect(rc);

    notifySizeChanged(rc.getHeight());

    // Reposition each of the child views
    S32 cur_y = total_height;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        cur_y -= childp->getRect().getHeight();
        childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
        cur_y -= GAP_BETWEEN_PANELS;
    }
}
void LLDebugView::init()
{
	LLRect r;
	LLRect rect = getLocalRect();

	// Rectangle to draw debug data in (full height, 3/4 width)
	r.set(10, rect.getHeight() - 100, ((rect.getWidth()*3)/4), 100);
	LLConsole::Params cp;
	cp.name("debug console");
	cp.max_lines(20);
	cp.rect(r);
	cp.font(LLFontGL::getFontMonospace());
	cp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_LEFT);
	cp.visible(false);
	mDebugConsolep = LLUICtrlFactory::create<LLConsole>(cp);
	addChild(mDebugConsolep);

	r.set(150 - 25, rect.getHeight() - 50, rect.getWidth()/2 - 25, rect.getHeight() - 450);

	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
  									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
	
	mFastTimerView = dynamic_cast<LLFastTimerView*>(LLFloaterReg::getInstance("fast_timers"));

	gSceneView = new LLSceneView(r);
	gSceneView->setFollowsTop();
	gSceneView->setFollowsLeft();
	gSceneView->setVisible(FALSE);
	addChild(gSceneView);
	gSceneView->setRect(rect);
	
	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
	LLMemoryView::Params mp;
	mp.name("memory");
	mp.rect(r);
	mp.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
	mp.visible(false);
	mMemoryView = LLUICtrlFactory::create<LLMemoryView>(mp);
	addChild(mMemoryView);

	r.set(150, rect.getHeight() - 50, 820, 100);
	LLTextureView::Params tvp;
	tvp.name("gTextureView");
	tvp.rect(r);
	tvp.follows.flags(FOLLOWS_TOP|FOLLOWS_LEFT);
	tvp.visible(false);
	gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp);
	addChild(gTextureView);
	//gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);
}
Example #7
0
void LLFloaterEditUI::refreshCore()
{
	LLView* view = LLView::sEditingUIView;

	LLRect r = view->getRect();
	F32 width = (F32)r.getWidth();
	F32 height = (F32)r.getHeight();
	mWidthSpin->set(width);
	mHeightSpin->set(height);

	LLButton* buttonp = dynamic_cast<LLButton*>(view);
	if (buttonp)
	{
		refreshButton(view);
	}
	else
	{
		refreshView(view);
	}
}
void	LLAccordionCtrlTab::updateLayout	( const LLRect& child_rect )
{
	LLView*	child = getAccordionView();
	if(!mContainerPanel)
		return;

	S32 panel_top = child_rect.getHeight();
	S32 panel_width = child_rect.getWidth();

	static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
	if(mScrollbar->getVisible() != false)
	{
		panel_top+=mScrollbar->getDocPos();
		panel_width-=scrollbar_size;
	}

	//set sizes for first panels and dragbars
	LLRect panel_rect = child->getRect();
	ctrlSetLeftTopAndSize(mContainerPanel,child_rect.mLeft,panel_top,panel_width,panel_rect.getHeight());
}
Example #9
0
void LLFlatListView::clear()
{
	// do not use LLView::deleteAllChildren to avoid removing nonvisible items. drag-n-drop for ex.
	for (pairs_iterator_t it = mItemPairs.begin(); it != mItemPairs.end(); ++it)
	{
		mItemsPanel->removeChild((*it)->first);
		(*it)->first->die();
		delete *it;
	}
	mItemPairs.clear();
	mSelectedItemPairs.clear();

	// also set items panel height to zero. Reshape it to allow reshaping of non-item children
	LLRect rc = mItemsPanel->getRect();
	rc.mBottom = rc.mTop;
	mItemsPanel->reshape(rc.getWidth(), rc.getHeight());
	mItemsPanel->setRect(rc);

	setNoItemsCommentVisible(true);
	notifyParentItemsRectChanged();
}
Example #10
0
void LLOverlayBar::layoutButtons()
{
	LLView* state_buttons_panel = getChildView("state_management_buttons_container");

	if (state_buttons_panel->getVisible())
	{
		U32 button_count = 0;
		const child_list_t& view_list = *(state_buttons_panel->getChildList());
		BOOST_FOREACH(LLView* viewp, view_list)
		{
			if(!viewp->getEnabled())
				continue;
			++button_count;
		}
		const S32 MAX_BAR_WIDTH = 600;
		S32 bar_width = llclamp(state_buttons_panel->getRect().getWidth(), 0, MAX_BAR_WIDTH);

		// calculate button widths
		const S32 MAX_BUTTON_WIDTH = 150;

		static LLCachedControl<S32> status_bar_pad("StatusBarPad",10);
		S32 segment_width = llclamp(lltrunc((F32)(bar_width) / (F32)button_count), 0, MAX_BUTTON_WIDTH);
		S32 btn_width = segment_width - status_bar_pad;

		// Evenly space all buttons, starting from left
		S32 left = 0;
		S32 bottom = 1;

		BOOST_REVERSE_FOREACH(LLView* viewp, view_list)
		{
			if(!viewp->getEnabled())
				continue;
			LLRect r = viewp->getRect();
			//if(dynamic_cast<LLButton*>(viewp))
			//	new_width = llclamp(new_width,0,MAX_BUTTON_WIDTH);
			r.setOriginAndSize(left, bottom, btn_width, r.getHeight());
			viewp->setRect(r);
			left += segment_width;
		}
	}
void LLScreenChannelBase::updatePositionAndSize(LLRect rect)
{
	LLRect this_rect = getRect();

	this_rect.mTop = rect.mTop;
	switch(mChannelAlignment)
	{
	case CA_LEFT :
		break;
	case CA_CENTRE :
		this_rect.setCenterAndSize( (rect.getWidth()) / 2, rect.getHeight() / 2, this_rect.getWidth(), this_rect.getHeight());
		break;
	case CA_RIGHT :
		this_rect.setLeftTopAndSize(rect.mRight - this_rect.getWidth(),
			this_rect.mTop,
			this_rect.getWidth(),
			this_rect.getHeight());
	}
	setRect(this_rect);
	redrawToasts();
	
}
void LLAccordionCtrlTab::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */)
{
	LLRect headerRect;

	headerRect.setLeftTopAndSize(
		0,height,width,HEADER_HEIGHT);
	mHeader->setRect(headerRect);
	mHeader->reshape(headerRect.getWidth(), headerRect.getHeight());

	if(!mDisplayChildren)
		return;

	LLRect childRect;

	childRect.setLeftTopAndSize(
		getPaddingLeft(),
		height - getHeaderHeight() - getPaddingTop(),
		width - getPaddingLeft() - getPaddingRight(), 
		height - getHeaderHeight() - getPaddingTop() - getPaddingBottom() );

	adjustContainerPanel(childRect);
}
Example #13
0
void LLPanelClassifiedInfo::stretchSnapshot()
{
	// *NOTE dzaporozhan
	// Could be moved to LLTextureCtrl

	LLViewerFetchedTexture* texture = mSnapshotCtrl->getTexture();

	if(!texture)
	{
		return;
	}

	if(0 == texture->getOriginalWidth() || 0 == texture->getOriginalHeight())
	{
		// looks like texture is not loaded yet
		return;
	}

	LLRect rc = mSnapshotRect;
	// *HACK dzaporozhan
	// LLTextureCtrl uses BTN_HEIGHT_SMALL as bottom for texture which causes
	// drawn texture to be smaller than expected. (see LLTextureCtrl::draw())
	// Lets increase texture height to force texture look as expected.
	rc.mBottom -= BTN_HEIGHT_SMALL;

	F32 t_width = texture->getFullWidth();
	F32 t_height = texture->getFullHeight();

	F32 ratio = llmin<F32>( (rc.getWidth() / t_width), (rc.getHeight() / t_height) );

	t_width *= ratio;
	t_height *= ratio;

	rc.setCenterAndSize(rc.getCenterX(), rc.getCenterY(), llfloor(t_width), llfloor(t_height));
	mSnapshotCtrl->setShape(rc);

	mSnapshotStreched = true;
}
Example #14
0
//-----------------------------------------------------------------------------
// postBuild()
//-----------------------------------------------------------------------------
BOOL LLFloaterAnimPreview::postBuild()
{
	if (!LLFloaterNameDesc::postBuild())
	{
		return FALSE;
	}

	getChild<LLUICtrl>("name_form")->setCommitCallback(boost::bind(&LLFloaterAnimPreview::onCommitName, this));

	childSetAction("reload_btn", onBtnReload, this);
	childSetAction("ok_btn", onBtnOK, this);
	setDefaultBtn();
	
	if (sUseDummy) 
	{ 
		LLRect rect = getRect(); 
		translate(0, PREVIEW_TEXTURE_HEIGHT-30); 
		reshape(rect.getWidth(), rect.getHeight() + PREVIEW_TEXTURE_HEIGHT-30); 

		mPreviewRect.set(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT, getRect().getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); 
		mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f); 
	} 
	
	mPlayButton = getChild<LLButton>( "play_btn");
	mPlayButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnPlay, this));
//	mPlayButton->setVisible(true);

	mPauseButton = getChild<LLButton>( "pause_btn");
	mPauseButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnPause, this));
//	mPauseButton->setVisible(false);
	
	mStopButton = getChild<LLButton>( "stop_btn");
	mStopButton->setClickedCallback(boost::bind(&LLFloaterAnimPreview::onBtnStop, this));

	loadBVH();

	return TRUE;
}
void LLToastScriptQuestion::createButtons()
{
	LLNotificationFormPtr form = mNotification->getForm();
	int num_elements = form->getNumElements();
	int buttons_width = 0;

	for (int i = 0; i < num_elements; ++i)
	{
		LLSD form_element = form->getElement(i);
		if ("button" == form_element["type"].asString())
		{
			LLButton::Params p;
			const LLFontGL* font = LLFontGL::getFontSansSerif();
			p.name(form_element["name"].asString());
			p.label(form_element["text"].asString());
			p.layout("topleft");
			p.font(font);
			p.rect.height(BUTTON_HEIGHT);
			p.click_callback.function(boost::bind(&LLToastScriptQuestion::onButtonClicked, this, form_element["name"].asString()));
			p.rect.left = LEFT_PAD;
			p.rect.width = font->getWidth(form_element["text"].asString());
			p.auto_resize = true;
			p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
			p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));
			p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor"));

			LLButton* button = LLUICtrlFactory::create<LLButton>(p);
			button->autoResize();
			getChild<LLPanel>("buttons_panel")->addChild(button);

			LLRect rect = button->getRect();
			rect.setLeftTopAndSize(buttons_width, rect.mTop, rect.getWidth(), rect.getHeight());
			button->setRect(rect);

			buttons_width += rect.getWidth() + LEFT_PAD;
		}
	}
}
Example #16
0
void LLScreenChannelBase::updatePositionAndSize(LLRect old_world_rect, LLRect new_world_rect)
{
	/*
	take sidetray into account - screenchannel should not overlap sidetray
	*/
	S32 world_rect_padding = 0;
	static LLCachedControl<bool> SidebarCameraMovement(gSavedSettings,"SidebarCameraMovement");
	if (SidebarCameraMovement == FALSE
		&& LLSideTray::instanceCreated	())
	{
		LLSideTray*	side_bar = LLSideTray::getInstance();

		if (side_bar->getVisible() && !side_bar->getCollapsed())
			world_rect_padding += side_bar->getRect().getWidth();
	}


	S32 top_delta = old_world_rect.mTop - new_world_rect.mTop;
	LLRect this_rect = getRect();

	this_rect.mTop -= top_delta;
	switch(mChannelAlignment)
	{
	case CA_LEFT :
		break;
	case CA_CENTRE :
		this_rect.setCenterAndSize( (new_world_rect.getWidth() - world_rect_padding) / 2, new_world_rect.getHeight() / 2, this_rect.getWidth(), this_rect.getHeight());
		break;
	case CA_RIGHT :
		this_rect.setLeftTopAndSize(new_world_rect.mRight - world_rect_padding - this_rect.getWidth(),
			this_rect.mTop,
			this_rect.getWidth(),
			this_rect.getHeight());
	}
	setRect(this_rect);
	redrawToasts();
	
}
void LLIMToastNotifyPanel::reshape(S32 width, S32 height, BOOL called_from_parent /* = TRUE */)
{
	S32 text_height = mTextBox->getTextBoundingRect().getHeight();
	S32 widget_height = mTextBox->getRect().getHeight();
	S32 delta = text_height - widget_height;
	LLRect rc = getRect();

	rc.setLeftTopAndSize(rc.mLeft, rc.mTop, width, height + delta);
	height = rc.getHeight();
	width = rc.getWidth();

	bool is_width_changed = width != getRect().getWidth();

	LLToastPanel::reshape(width, height, called_from_parent);

	// Notification height required to display the text message depends on
	// the width of the text box thus if panel width is changed the text box
	// width is also changed then reshape() is called to adjust proper height.
	if (is_width_changed)
	{
		reshape(width, height, called_from_parent);
	}
}
bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model)
{
	if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment())
	{
		F32 zoom_level = gAgentCamera.mHUDCurZoom;
		LLBBox hud_bbox = gAgentAvatarp->getHUDBBox();
		
		F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f);
		proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth);
		proj.element(2,2) = -0.01f;
		
		F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect();
		
		glh::matrix4f mat;
		F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth();
		F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight();
		mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f));
		mat.set_translate(
			glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio),
					   clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y),
					   0.f));
		proj *= mat;
		
		glh::matrix4f tmp_model((GLfloat*) OGL_TO_CFR_ROTATION);
		
		mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level));
		mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f));
		
		tmp_model *= mat;
		model = tmp_model;		
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
S32 LLScrollingPanelList::addPanel( LLScrollingPanel* panel )
{
    addChildInBack( panel );
    mPanelList.push_front( panel );

    // Resize this view
    S32 total_height = 0;
    S32 max_width = 0;
    S32 cur_gap = 0;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        total_height += childp->getRect().getHeight() + cur_gap;
        max_width = llmax( max_width, childp->getRect().getWidth() );
        cur_gap = GAP_BETWEEN_PANELS;
    }
    LLRect rc = getRect();
    rc.setLeftTopAndSize(rc.mLeft, rc.mTop, max_width, total_height);
    setRect(rc);

    notifySizeChanged(rc.getHeight());

    // Reposition each of the child views
    S32 cur_y = total_height;
    for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin();
            iter != mPanelList.end(); ++iter)
    {
        LLScrollingPanel *childp = *iter;
        cur_y -= childp->getRect().getHeight();
        childp->translate( -childp->getRect().mLeft, cur_y - childp->getRect().mBottom);
        cur_y -= GAP_BETWEEN_PANELS;
    }

    return total_height;
}
Example #20
0
// static
void LLFloaterGesture::show()
{
	if (sInstance)
	{
		sInstance->open();		/*Flawfinder: ignore*/
		return;
	}

	LLFloaterGesture *self = new LLFloaterGesture();

	// Builds and adds to gFloaterView
	LLUICtrlFactory::getInstance()->buildFloater(self, "floater_gesture.xml");

	// Fix up rectangle
	LLRect rect = gSavedSettings.getRect("FloaterGestureRect2");
	self->reshape(rect.getWidth(), rect.getHeight());
	self->setRect(rect);

	self->buildGestureList();

	self->childSetFocus("gesture_list");

	LLCtrlListInterface *list = self->childGetListInterface("gesture_list");
	if (list)
	{
		const BOOL ascending = TRUE;
		list->sortByColumn(std::string("name"), ascending);
		list->selectFirstItem();
	}
	
	self->mSelectedID = LLUUID::null;

	// Update button labels
	onCommitList(NULL, self);
	self->open();	/*Flawfinder: ignore*/
}
Example #21
0
void LLOverlayBar::layoutButtons()
{
	LLView* state_buttons_panel = getChildView("state_buttons");

	if (state_buttons_panel->getVisible())
	{
		LLViewQuery query;
		LLWidgetTypeFilter<LLButton> widget_filter;
		query.addPreFilter(LLEnabledFilter::getInstance());
		query.addPreFilter(&widget_filter);

		child_list_t button_list = query(state_buttons_panel);

		const S32 MAX_BAR_WIDTH = 600;
		S32 bar_width = llclamp(state_buttons_panel->getRect().getWidth(), 0, MAX_BAR_WIDTH);

		// calculate button widths
		const S32 MAX_BUTTON_WIDTH = 150;
		S32 segment_width = llclamp(lltrunc((F32)(bar_width) / (F32)button_list.size()), 0, MAX_BUTTON_WIDTH);
		S32 btn_width = segment_width - gSavedSettings.getS32("StatusBarPad");

		// Evenly space all buttons, starting from left
		S32 left = 0;
		S32 bottom = 1;

		for (child_list_reverse_iter_t child_iter = button_list.rbegin();
			child_iter != button_list.rend(); ++child_iter)
		{
			LLView *view = *child_iter;
			LLRect r = view->getRect();
			r.setOriginAndSize(left, bottom, btn_width, r.getHeight());
			view->setRect(r);
			left += segment_width;
		}
	}
}
// Default constructor
LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
									 const LLRect& rect,
									 const std::string& title,
									 const LLUUID& item_id, 
									 const LLUUID& object_id,
									 const LLUUID& asset_id,
									 BOOL show_keep_discard,
									 LLPointer<LLViewerInventoryItem> inv_item) :
	LLPreview(name, rect, title, item_id, object_id, TRUE,
			  PREVIEW_MIN_WIDTH,
			  PREVIEW_MIN_HEIGHT,
			  inv_item),
	mAssetID( asset_id ),
	mNotecardItemID(item_id),
	mObjectID(object_id)
{
	LLRect curRect = rect;

	if (show_keep_discard)
	{
		LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard_keep_discard.xml");
		childSetAction("Keep",onKeepBtn,this);
		childSetAction("Discard",onDiscardBtn,this);
	}
	else
	{
		LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml");
		// <edit>
		childSetAction("Get Items", onClickGetItems, this);
		// </edit>

		if( mAssetID.isNull() )
		{
			const LLInventoryItem* item = getItem();
			if( item )
			{
				mAssetID = item->getAssetUUID();
			}
		}
	}	
	if (hasChild("Save", true))
		childSetAction("Save",onClickSave,this);

	// only assert shape if not hosted in a multifloater
	if (!getHost())
	{
		reshape(curRect.getWidth(), curRect.getHeight(), TRUE);
		setRect(curRect);
	}
			
	if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock"))
		ctrl->setVisible(false);
	
	if (hasChild("desc", true))
	{
		childSetCommitCallback("desc", LLPreview::onText, this);
		if (const LLInventoryItem* item = getItem())
			childSetText("desc", item->getDescription());
		childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
	}

	setTitle(title);
	
	LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");

	if (editor)
	{
		editor->setWordWrap(TRUE);
		editor->setSourceID(item_id);
		editor->setHandleEditKeysDirectly(TRUE);
	}

	initMenu();

	gAgentCamera.changeCameraToDefault();
}
Example #23
0
//---------------------------------------------------------------------------
// Public methods
//---------------------------------------------------------------------------
LLPanelLogin::LLPanelLogin(const LLRect &rect,
						 BOOL show_server,
						 void (*callback)(S32 option, void* user_data),
						 void *cb_data)
:	LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE),		// not bordered
	mLogoImage(),
	mCallback(callback),
	mCallbackData(cb_data),
	mHtmlAvailable( TRUE )
{
	setFocusRoot(TRUE);

	setBackgroundVisible(FALSE);
	setBackgroundOpaque(TRUE);

	// instance management
	if (LLPanelLogin::sInstance)
	{
		llwarns << "Duplicate instance of login view deleted" << llendl;
		delete LLPanelLogin::sInstance;

		// Don't leave bad pointer in gFocusMgr
		gFocusMgr.setDefaultKeyboardFocus(NULL);
	}

	LLPanelLogin::sInstance = this;

	// add to front so we are the bottom-most child
	gViewerWindow->getRootView()->addChildAtEnd(this);

	// Logo
	mLogoImage = LLUI::getUIImage("startup_logo.j2c");

	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml");
	
#if USE_VIEWER_AUTH
	//leave room for the login menu bar
	setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0)); 
#endif
	reshape(rect.getWidth(), rect.getHeight());

#if !USE_VIEWER_AUTH
	childSetPrevalidate("first_name_edit", LLLineEditor::prevalidatePrintableNoSpace);
	childSetPrevalidate("last_name_edit", LLLineEditor::prevalidatePrintableNoSpace);

	childSetCommitCallback("password_edit", mungePassword);
	childSetKeystrokeCallback("password_edit", onPassKey, this);
	childSetUserData("password_edit", this);

	// change z sort of clickable text to be behind buttons
	sendChildToBack(getChildView("channel_text"));
	sendChildToBack(getChildView("forgot_password_text"));

	LLLineEditor* edit = getChild<LLLineEditor>("password_edit");
	if (edit) edit->setDrawAsterixes(TRUE);

	LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
	combo->setAllowTextEntry(TRUE, 128, FALSE);

	// The XML file loads the combo with the following labels:
	// 0 - "My Home"
	// 1 - "My Last Location"
	// 2 - "<Type region name>"

	BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
	std::string sim_string = LLURLSimString::sInstance.mSimString;
	if (!sim_string.empty())
	{
		// Replace "<Type region name>" with this region name
		combo->remove(2);
		combo->add( sim_string );
		combo->setTextEntry(sim_string);
		combo->setCurrentByIndex( 2 );
	}
	else if (login_last)
	{
		combo->setCurrentByIndex( 1 );
	}
	else
	{
		combo->setCurrentByIndex( 0 );
	}


	LLComboBox* server_choice_combo = sInstance->getChild<LLComboBox>("server_combo");
	server_choice_combo->setCommitCallback(onSelectServer);
	//server_choice_combo->setFocusLostCallback(onServerComboLostFocus);

	childSetAction("connect_btn", onClickConnect, this);
	childSetAction("grid_btn", onClickGrid, this);

	setDefaultBtn("connect_btn");

	// childSetAction("quit_btn", onClickQuit, this);

	std::string imp_channel = gSavedSettings.getString("VersionChannelName");
	std::string imp_version = llformat("%d.%d.%d %s",
		ViewerVersion::getImpMajorVersion(),
		ViewerVersion::getImpMinorVersion(),
		ViewerVersion::getImpPatchVersion(),
		ViewerVersion::getImpTestVersion().c_str() );

	std::string ll_channel = ViewerVersion::getLLViewerName();
	std::string ll_version = llformat("%d.%d.%d (%d)",
		ViewerVersion::getLLMajorVersion(),
		ViewerVersion::getLLMinorVersion(),
		ViewerVersion::getLLPatchVersion(),
		ViewerVersion::getLLBuildVersion() );

	LLTextBox* channel_text = getChild<LLTextBox>("channel_text");
	channel_text->setTextArg("[CHANNEL]", imp_channel);
	channel_text->setTextArg("[VERSION]", imp_version);
	channel_text->setTextArg("[ALT_CHANNEL]", ll_channel);
	channel_text->setTextArg("[ALT_VERSION]", ll_version);
	channel_text->setClickedCallback(onClickVersion);
	channel_text->setCallbackUserData(this);
	
	LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text");
	forgot_password_text->setClickedCallback(onClickForgotPassword);

	LLTextBox* create_new_account_text = getChild<LLTextBox>("create_new_account_text");
	create_new_account_text->setClickedCallback(onClickNewAccount);
#endif    
	
	// get the web browser control
	LLWebBrowserCtrl* web_browser = getChild<LLWebBrowserCtrl>("login_html");
	// Need to handle login secondlife:///app/ URLs
	web_browser->setTrusted( true );

	// observe browser events
	web_browser->addObserver( this );

	// don't make it a tab stop until SL-27594 is fixed
	web_browser->setTabStop(FALSE);
	web_browser->navigateToLocalPage( "loading", "loading.html" );

	// make links open in external browser
	web_browser->setOpenInExternalBrowser( true );

	// force the size to be correct (XML doesn't seem to be sufficient to do this) (with some padding so the other login screen doesn't show through)
	LLRect htmlRect = getRect();
#if USE_VIEWER_AUTH
	htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY(), getRect().getWidth() + 6, getRect().getHeight());
#else
	htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY() + 40, getRect().getWidth() + 6, getRect().getHeight() - 78 );
#endif
	web_browser->setRect( htmlRect );
	web_browser->reshape( htmlRect.getWidth(), htmlRect.getHeight(), TRUE );
	reshape( getRect().getWidth(), getRect().getHeight(), 1 );

	// kick off a request to grab the url manually
	gResponsePtr = LLIamHereLogin::build( this );
	std::string login_page = gSavedSettings.getString("LoginPage");
	if (login_page.empty())
	{
		login_page = getString( "real_url" );
	}
	LLHTTPClient::head( login_page, gResponsePtr );

#if !USE_VIEWER_AUTH
	// Initialize visibility (and don't force visibility - use prefs)
	refreshLocation( false );
#endif

	LLFirstUse::useLoginScreen();
}
Example #24
0
void LLFloaterBuyLandUI::updateCovenantInfo()
{
	LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion();
	if(!region) return;

	U8 sim_access = region->getSimAccess();
	std::string rating = LLViewerRegion::accessToString(sim_access);
	
	LLTextBox* region_name = getChild<LLTextBox>("region_name_text");
	if (region_name)
	{
		std::string region_name_txt = region->getName() + " ("+rating +")";
		region_name->setText(region_name_txt);

		LLIconCtrl* rating_icon = getChild<LLIconCtrl>("rating_icon");
		LLRect rect = rating_icon->getRect();
		S32 region_name_width = llmin(region_name->getRect().getWidth(), region_name->getTextBoundingRect().getWidth());
		S32 icon_left_pad = region_name->getRect().mLeft + region_name_width + ICON_PAD;
		region_name->setToolTip(region_name->getText());
		rating_icon->setRect(rect.setOriginAndSize(icon_left_pad, rect.mBottom, rect.getWidth(), rect.getHeight()));

		switch(sim_access)
		{
		case SIM_ACCESS_PG:
			rating_icon->setValue(getString("icon_PG"));
			break;

		case SIM_ACCESS_ADULT:
			rating_icon->setValue(getString("icon_R"));
			break;

		default:
			rating_icon->setValue(getString("icon_M"));
		}
	}

	LLTextBox* region_type = getChild<LLTextBox>("region_type_text");
	if (region_type)
	{
		region_type->setText(region->getLocalizedSimProductName());
		region_type->setToolTip(region->getLocalizedSimProductName());
	}
	
	LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause");
	if (resellable_clause)
	{
		if (region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL)
		{
			resellable_clause->setText(getString("can_not_resell"));
		}
		else
		{
			resellable_clause->setText(getString("can_resell"));
		}
	}
	
	LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause");
	if (changeable_clause)
	{
		if (region->getRegionFlags() & REGION_FLAGS_ALLOW_PARCEL_CHANGES)
		{
			changeable_clause->setText(getString("can_change"));
		}
		else
		{
			changeable_clause->setText(getString("can_not_change"));
		}
	}

	LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant");
	if(check)
	{
		check->set(false);
		check->setEnabled(true);
		check->setCommitCallback(onChangeAgreeCovenant, this);
	}

	LLTextBox* box = getChild<LLTextBox>("covenant_text");
	if(box)
	{
		box->setVisible(FALSE);
	}
	
	// send EstateCovenantInfo message
	LLMessageSystem *msg = gMessageSystem;
	msg->newMessage("EstateCovenantRequest");
	msg->nextBlockFast(_PREHASH_AgentData);
	msg->addUUIDFast(_PREHASH_AgentID,	gAgent.getID());
	msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
	msg->sendReliable(region->getHost());
}
Example #25
0
void LLPreviewTexture::draw()
{
	updateDimensions();

	LLPreview::draw();

	if (!isMinimized())
	{
		LLGLSUIDefault gls_ui;
		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
		
		const LLRect& border = mClientRect;
		LLRect interior = mClientRect;
		interior.stretch( -PREVIEW_BORDER_WIDTH );

		// ...border
		gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f));
		gl_rect_2d_checkerboard( interior );

		if ( mImage.notNull() )
		{
			// Draw the texture
			glColor3f( 1.f, 1.f, 1.f );
			gl_draw_scaled_image(interior.mLeft,
								interior.mBottom,
								interior.getWidth(),
								interior.getHeight(),
								mImage);

			// Pump the texture priority
			F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA  : (F32)(interior.getWidth() * interior.getHeight() );
			mImage->addTextureStats( pixel_area );
			if(pixel_area > 0.f)
			{
				//boost the previewed image priority to the highest to make it to get loaded first.
				mImage->setAdditionalDecodePriority(1.0f) ;
			}


			std::string assetid(mImageID.asString());
			if (mIsCopyable) childSetText("uuid", assetid);

			if (uploaderkey.isNull()&&(mImage->mDecodedComment.find("a")!=mImage->mDecodedComment.end()))
			{
				uploaderkey = LLUUID(mImage->mDecodedComment["a"]);
				childSetText("uploader", mImage->mDecodedComment["a"]);
				gCacheName->get(uploaderkey, FALSE, callbackLoadAvatarName);
			}
			if (color.empty()&&(mImage->mDecodedComment.find("c")!=mImage->mDecodedComment.end()))
			{
				color = mImage->mDecodedComment["c"];
			}
			if (time.empty()&&(mImage->mDecodedComment.find("z")!=mImage->mDecodedComment.end()))
			{
				time=mImage->mDecodedComment["z"];
				std::string year = time.substr(0,4);
				std::string month = time.substr(4,2);
				std::string day = time.substr(6,2);
				std::string hour = time.substr(8,2);
				std::string minute = time.substr(10,2);
				std::string second = time.substr(12,2);

				time = llformat("%s/%s/%s - %s:%s:%s",year.c_str(),month.c_str(),day.c_str(),hour.c_str(),minute.c_str(),second.c_str());

				childSetText("uploadtime", time);
			}

			// Don't bother decoding more than we can display, unless
			// we're loading the full image.
			if (!mLoadingFullImage)
			{
				S32 int_width = interior.getWidth();
				S32 int_height = interior.getHeight();
				mImage->setKnownDrawSize(int_width, int_height);
			}
			else
			{
				// Don't use this feature
				mImage->setKnownDrawSize(0, 0);
			}

			if( mLoadingFullImage )
			{
				// *TODO: Translate
				LLFontGL::getFontSansSerif()->renderUTF8(std::string("Receiving:"), 0,
					interior.mLeft + 4, 
					interior.mBottom + 4,
					LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM,
					LLFontGL::DROP_SHADOW);
				
				F32 data_progress = mImage->mDownloadProgress;
				
				// Draw the progress bar.
				const S32 BAR_HEIGHT = 12;
				const S32 BAR_LEFT_PAD = 80;
				S32 left = interior.mLeft + 4 + BAR_LEFT_PAD;
				S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2;
				S32 top = interior.mBottom + 4 + BAR_HEIGHT;
				S32 right = left + bar_width;
				S32 bottom = top - BAR_HEIGHT;

				LLColor4 background_color(0.f, 0.f, 0.f, 0.75f);
				LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f);
				LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f);

				gl_rect_2d(left, top, right, bottom, background_color);

				if (data_progress > 0.0f)
				{
					// Downloaded bytes
					right = left + llfloor(data_progress * (F32)bar_width);
					if (right > left)
					{
						gl_rect_2d(left, top, right, bottom, downloaded_color);
					}
				}
			}
			else
			if( !mSavedFileTimer.hasExpired() )
			{
				// *TODO: Translate
				LLFontGL::getFontSansSerif()->renderUTF8(std::string("File Saved"), 0,
					interior.mLeft + 4,
					interior.mBottom + 4,
					LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM,
					LLFontGL::DROP_SHADOW);
			}
		}
	} 
}
Example #26
0
//---------------------------------------------------------------------------
// Public methods
//---------------------------------------------------------------------------
LLPanelLogin::LLPanelLogin(const LLRect &rect,
						 void (*callback)(S32 option, void* user_data),
						 void *cb_data)
:	LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE),		// not bordered
	mLogoImage(),
	mCallback(callback),
	mCallbackData(cb_data),
	mHtmlAvailable( TRUE )
{
	setFocusRoot(TRUE);

	setBackgroundVisible(FALSE);
	setBackgroundOpaque(TRUE);

	// instance management
	if (LLPanelLogin::sInstance)
	{
		llwarns << "Duplicate instance of login view deleted" << llendl;
		delete LLPanelLogin::sInstance;

		// Don't leave bad pointer in gFocusMgr
		gFocusMgr.setDefaultKeyboardFocus(NULL);
	}

	LLPanelLogin::sInstance = this;

	// add to front so we are the bottom-most child
	gViewerWindow->getRootView()->addChildAtEnd(this);

	// Logo
	mLogoImage = LLUI::getUIImage("startup_logo.j2c");

	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml");
	
#if USE_VIEWER_AUTH
	//leave room for the login menu bar
	setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0)); 
#endif
	reshape(rect.getWidth(), rect.getHeight());

#if !USE_VIEWER_AUTH
	LLComboBox* name_combo = sInstance->getChild<LLComboBox>("name_combo");
	name_combo->setCommitCallback(onSelectLoginEntry);
	name_combo->setFocusLostCallback(onLoginComboLostFocus);
	name_combo->setPrevalidate(LLLineEditor::prevalidatePrintableNotPipe);
	name_combo->setSuppressTentative(true);
	name_combo->setSuppressAutoComplete(true);

	childSetCommitCallback("remember_name_check", onNameCheckChanged);
	childSetCommitCallback("password_edit", mungePassword);
	childSetKeystrokeCallback("password_edit", onPassKey, this);
	childSetUserData("password_edit", this);

	// change z sort of clickable text to be behind buttons
	sendChildToBack(getChildView("channel_text"));
	sendChildToBack(getChildView("forgot_password_text"));

	LLLineEditor* edit = getChild<LLLineEditor>("password_edit");
	if (edit) edit->setDrawAsterixes(TRUE);

	//OGPX : This keeps the uris in a history file 
	//OGPX TODO: should this be inside an OGP only check?
	LLComboBox* regioncombo = getChild<LLComboBox>("regionuri_edit"); 
	regioncombo->setAllowTextEntry(TRUE, 256, FALSE);
	std::string  current_regionuri = gSavedSettings.getString("CmdLineRegionURI");

	// iterate on uri list adding to combobox (couldn't figure out how to add them all in one call)
	// ... and also append the command line value we might have gotten to the URLHistory
	LLSD regionuri_history = LLURLHistory::getURLHistory("regionuri");
	LLSD::array_iterator iter_history = regionuri_history.beginArray();
	LLSD::array_iterator iter_end = regionuri_history.endArray();
	for (; iter_history != iter_end; ++iter_history)
	{
		regioncombo->addSimpleElement((*iter_history).asString());
	}

	if ( LLURLHistory::appendToURLCollection("regionuri",current_regionuri)) 
	{
		// since we are in login, another read of urlhistory file is going to happen 
		// so we need to persist the new value we just added (or maybe we should do it in startup.cpp?)

		// since URL history only populated on create of sInstance, add to combo list directly
		regioncombo->addSimpleElement(current_regionuri);
	}
	
	// select which is displayed if we have a current URL.
	regioncombo->setSelectedByValue(LLSD(current_regionuri),TRUE);

	//llinfos << " url history: " << LLSDOStreamer<LLSDXMLFormatter>(LLURLHistory::getURLHistory("regionuri")) << llendl;

	LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
	combo->setAllowTextEntry(TRUE, 128, FALSE);

	// The XML file loads the combo with the following labels:
	// 0 - "My Home"
	// 1 - "My Last Location"
	// 2 - "<Type region name>"

	BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
	std::string sim_string = LLURLSimString::sInstance.mSimString;
	if (!sim_string.empty())
	{
		// Replace "<Type region name>" with this region name
		combo->remove(2);
		combo->add( sim_string );
		combo->setTextEntry(sim_string);
		combo->setCurrentByIndex( 2 );
	}
	else if (login_last)
	{
		combo->setCurrentByIndex( 1 );
	}
	else
	{
		combo->setCurrentByIndex( 0 );
	}

	combo->setCommitCallback( &set_start_location );

	childSetAction("connect_btn", onClickConnect, this);

	setDefaultBtn("connect_btn");

	// childSetAction("quit_btn", onClickQuit, this);
	childSetAction("grids_btn", onClickGrids, this);
	childSetCommitCallback("grids_combo", onSelectGrid, this);

	std::string channel = LL_CHANNEL;

	std::string version = llformat("%d.%d.%d (%d)",
		LL_VERSION_MAJOR,
		LL_VERSION_MINOR,
		LL_VERSION_PATCH,
		LL_VIEWER_BUILD );
	LLTextBox* channel_text = getChild<LLTextBox>("channel_text");
	channel_text->setTextArg("[CHANNEL]", channel); // though not displayed
	channel_text->setTextArg("[VERSION]", version);
	channel_text->setClickedCallback(onClickVersion);
	channel_text->setCallbackUserData(this);
	
	LLTextBox* forgot_password_text = getChild<LLTextBox>("forgot_password_text");
	forgot_password_text->setClickedCallback(onClickForgotPassword);

	LLTextBox* create_new_account_text = getChild<LLTextBox>("create_new_account_text");
	create_new_account_text->setClickedCallback(onClickNewAccount);
#endif    
	
	// get the web browser control
	LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("login_html");
	web_browser->addObserver(this);

	// Need to handle login secondlife:///app/ URLs
	web_browser->setTrusted( true );

	// don't make it a tab stop until SL-27594 is fixed
	web_browser->setTabStop(FALSE);
	// web_browser->navigateToLocalPage( "loading", "loading.html" );

	// make links open in external browser
	web_browser->setOpenInExternalBrowser( true );

	// force the size to be correct (XML doesn't seem to be sufficient to do this) (with some padding so the other login screen doesn't show through)
	LLRect htmlRect = getRect();
#if USE_VIEWER_AUTH
	htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY(), getRect().getWidth() + 6, getRect().getHeight());
#else
	htmlRect.setCenterAndSize( getRect().getCenterX() - 2, getRect().getCenterY() + 40, getRect().getWidth() + 6, getRect().getHeight() - 78 );
#endif
	web_browser->setRect( htmlRect );
	web_browser->reshape( htmlRect.getWidth(), htmlRect.getHeight(), TRUE );
	reshape( getRect().getWidth(), getRect().getHeight(), 1 );

	updateGridCombo();

	childSetVisible("create_new_account_text",
		!gHippoGridManager->getConnectedGrid()->getRegisterUrl().empty());
	childSetVisible("forgot_password_text",
		!gHippoGridManager->getConnectedGrid()->getPasswordUrl().empty());
		
	loadLoginPage();

#if !USE_VIEWER_AUTH
	// Initialize visibility (and don't force visibility - use prefs)
	refreshLocation( false );
#endif

}
void LLPreviewTexture::draw()
{
	updateDimensions();
	
	LLPreview::draw();

	if (!isMinimized())
	{
		LLGLSUIDefault gls_ui;
		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
		
		const LLRect& border = mClientRect;
		LLRect interior = mClientRect;
		interior.stretch( -PREVIEW_BORDER_WIDTH );

		// ...border
		gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f));
		gl_rect_2d_checkerboard( interior );

		if ( mImage.notNull() )
		{
			// Automatically bring up SaveAs dialog if we opened this to save the texture.
			if (mPreviewToSave)
			{
				mPreviewToSave = FALSE;
				saveAs();
			}
			// Draw the texture
			gGL.diffuseColor3f( 1.f, 1.f, 1.f );
			gl_draw_scaled_image(interior.mLeft,
								interior.mBottom,
								interior.getWidth(),
								interior.getHeight(),
								mImage);

			// Pump the texture priority
			F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA  : (F32)(interior.getWidth() * interior.getHeight() );
			mImage->addTextureStats( pixel_area );

			// Don't bother decoding more than we can display, unless
			// we're loading the full image.
			if (!mLoadingFullImage)
			{
				S32 int_width = interior.getWidth();
				S32 int_height = interior.getHeight();
				mImage->setKnownDrawSize(int_width, int_height);
			}
			else
			{
				// Don't use this feature
				mImage->setKnownDrawSize(0, 0);
			}

			if( mLoadingFullImage )
			{
				LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("Receiving"), 0,
					interior.mLeft + 4, 
					interior.mBottom + 4,
					LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM,
					LLFontGL::NORMAL,
					LLFontGL::DROP_SHADOW);
				
				F32 data_progress = mImage->getDownloadProgress() ;
				
				// Draw the progress bar.
				const S32 BAR_HEIGHT = 12;
				const S32 BAR_LEFT_PAD = 80;
				S32 left = interior.mLeft + 4 + BAR_LEFT_PAD;
				S32 bar_width = getRect().getWidth() - left - RESIZE_HANDLE_WIDTH - 2;
				S32 top = interior.mBottom + 4 + BAR_HEIGHT;
				S32 right = left + bar_width;
				S32 bottom = top - BAR_HEIGHT;

				LLColor4 background_color(0.f, 0.f, 0.f, 0.75f);
				LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f);
				LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f);

				gl_rect_2d(left, top, right, bottom, background_color);

				if (data_progress > 0.0f)
				{
					// Downloaded bytes
					right = left + llfloor(data_progress * (F32)bar_width);
					if (right > left)
					{
						gl_rect_2d(left, top, right, bottom, downloaded_color);
					}
				}
			}
			else
			if( !mSavedFileTimer.hasExpired() )
			{
				LLFontGL::getFontSansSerif()->renderUTF8(LLTrans::getString("FileSaved"), 0,
					interior.mLeft + 4,
					interior.mBottom + 4,
					LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM,
					LLFontGL::NORMAL,
					LLFontGL::DROP_SHADOW);
			}
		}
	} 

}
Example #28
0
// static
void LLFloaterPay::processPayPriceReply(LLMessageSystem* msg, void **userdata)
{
	LLFloaterPay* self = (LLFloaterPay*)userdata;
	if (self)
	{
		S32 price;
		LLUUID target;

		msg->getUUIDFast(_PREHASH_ObjectData,_PREHASH_ObjectID,target);
		if (target != self->mTargetUUID)
		{
			// This is a message for a different object's pay info
			return;
		}

		msg->getS32Fast(_PREHASH_ObjectData,_PREHASH_DefaultPayPrice,price);
		
		if (PAY_PRICE_HIDE == price)
		{
			self->childSetVisible("amount", FALSE);
			self->childSetVisible("pay btn", FALSE);
			self->childSetVisible("amount text", FALSE);
		}
		else if (PAY_PRICE_DEFAULT == price)
		{			
			self->childSetVisible("amount", TRUE);
			self->childSetVisible("pay btn", TRUE);
			self->childSetVisible("amount text", TRUE);
		}
		else
		{
			// PAY_PRICE_HIDE and PAY_PRICE_DEFAULT are negative values
			// So we take the absolute value here after we have checked for those cases
			
			self->childSetVisible("amount", TRUE);
			self->childSetVisible("pay btn", TRUE);
			self->childSetEnabled("pay btn", TRUE);
			self->childSetVisible("amount text", TRUE);

			self->childSetText("amount", llformat("%d", llabs(price)));
		}

		S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_ButtonData);
		S32 i = 0;
		if (num_blocks > MAX_PAY_BUTTONS) num_blocks = MAX_PAY_BUTTONS;

		S32 max_pay_amount = 0;
		S32 padding_required = 0;

		for (i=0;i<num_blocks;++i)
		{
			S32 pay_button;
			msg->getS32Fast(_PREHASH_ButtonData,_PREHASH_PayButton,pay_button,i);
			if (pay_button > 0)
			{
				std::string button_str = "L$";
				button_str += LLResMgr::getInstance()->getMonetaryString( pay_button );

				self->mQuickPayButton[i]->setLabelSelected(button_str);
				self->mQuickPayButton[i]->setLabelUnselected(button_str);
				self->mQuickPayButton[i]->setVisible(TRUE);
				self->mQuickPayInfo[i]->mAmount = pay_button;
				self->childSetVisible("fastpay text",TRUE);

				if ( pay_button > max_pay_amount )
				{
					max_pay_amount = pay_button;
				}
			}
			else
			{
				self->mQuickPayButton[i]->setVisible(FALSE);
			}
		}

		// build a string containing the maximum value and calc nerw button width from it.
		std::string balance_str = "L$";
		balance_str += LLResMgr::getInstance()->getMonetaryString( max_pay_amount );
		const LLFontGL* font = LLFontGL::getFontSansSerif();
		S32 new_button_width = font->getWidth( std::string(balance_str));
		new_button_width += ( 12 + 12 );	// padding

		// dialong is sized for 2 digit pay amounts - larger pay values need to be scaled
		const S32 threshold = 100000;
		if ( max_pay_amount >= threshold )
		{
			S32 num_digits_threshold = (S32)log10((double)threshold) + 1;
			S32 num_digits_max = (S32)log10((double)max_pay_amount) + 1;
				
			// calculate the extra width required by 2 buttons with max amount and some commas
			padding_required = ( num_digits_max - num_digits_threshold + ( num_digits_max / 3 ) ) * font->getWidth( std::string("0") );
		};

		// change in button width
		S32 button_delta = new_button_width - FASTPAY_BUTTON_WIDTH;
		if ( button_delta < 0 ) 
			button_delta = 0;

		// now we know the maximum amount, we can resize all the buttons to be 
		for (i=0;i<num_blocks;++i)
		{
			LLRect r;
			r = self->mQuickPayButton[i]->getRect();

			// RHS button colum needs to move further because LHS changed too
			if ( i % 2 )
			{
				r.setCenterAndSize( r.getCenterX() + ( button_delta * 3 ) / 2 , 
					r.getCenterY(), 
						r.getWidth() + button_delta, 
							r.getHeight() ); 
			}
			else
			{
				r.setCenterAndSize( r.getCenterX() + button_delta / 2, 
					r.getCenterY(), 
						r.getWidth() + button_delta, 
						r.getHeight() ); 
			}
			self->mQuickPayButton[i]->setRect( r );
		}

		for (i=num_blocks;i<MAX_PAY_BUTTONS;++i)
		{
			self->mQuickPayButton[i]->setVisible(FALSE);
		}

		self->reshape( self->getRect().getWidth() + padding_required, self->getRect().getHeight(), FALSE );
	}
	msg->setHandlerFunc("PayPriceReply",NULL,NULL);
}
// rect is in document coordinates, constraint is in display coordinates relative to content window rect
void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& constraint)
{
	if (!mScrolledView)
	{
		llwarns << "LLScrollContainer::scrollToShowRect with no view!" << llendl;
		return;
	}

	LLRect content_window_rect = getContentWindowRect();
	// get document rect
	LLRect scrolled_rect = mScrolledView->getRect();

	// shrink target rect to fit within constraint region, biasing towards top left
	LLRect rect_to_constrain = rect;
	rect_to_constrain.mBottom = llmax(rect_to_constrain.mBottom, rect_to_constrain.mTop - constraint.getHeight());
	rect_to_constrain.mRight = llmin(rect_to_constrain.mRight, rect_to_constrain.mLeft + constraint.getWidth());

	// calculate allowable positions for scroller window in document coordinates
	LLRect allowable_scroll_rect(rect_to_constrain.mRight - constraint.mRight,
								rect_to_constrain.mBottom - constraint.mBottom,
								rect_to_constrain.mLeft - constraint.mLeft,
								rect_to_constrain.mTop - constraint.mTop);

	// translate from allowable region for lower left corner to upper left corner
	allowable_scroll_rect.translate(0, content_window_rect.getHeight());

	S32 vert_pos = llclamp(mScrollbar[VERTICAL]->getDocPos(), 
					mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mTop, // min vertical scroll
					mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mBottom); // max vertical scroll	

	mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() );
	mScrollbar[VERTICAL]->setPageSize( content_window_rect.getHeight() );
	mScrollbar[VERTICAL]->setDocPos( vert_pos );

	S32 horizontal_pos = llclamp(mScrollbar[HORIZONTAL]->getDocPos(), 
								allowable_scroll_rect.mLeft,
								allowable_scroll_rect.mRight);

	mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() );
	mScrollbar[HORIZONTAL]->setPageSize( content_window_rect.getWidth() );
	mScrollbar[HORIZONTAL]->setDocPos( horizontal_pos );

	// propagate scroll to document
	updateScroll();

	// In case we are in accordion tab notify parent to show selected rectangle
	LLRect screen_rc;
	localRectToScreen(rect_to_constrain, &screen_rc);
	notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue()));
}
Example #30
0
void LLTracker::drawMarker(const LLVector3d& pos_global, const LLColor4& color)
{
	// get position
	LLVector3 pos_local = gAgent.getPosAgentFromGlobal(pos_global);

	// check in frustum
	LLCoordGL screen;
	S32 x = 0;
	S32 y = 0;
	const BOOL CLAMP = TRUE;

	if (LLViewerCamera::getInstance()->projectPosAgentToScreen(pos_local, screen, CLAMP)
		|| LLViewerCamera::getInstance()->projectPosAgentToScreenEdge(pos_local, screen) )
	{
		gHUDView->screenPointToLocal(screen.mX, screen.mY, &x, &y);

		// the center of the rendered position of the arrow obeys 
		// the following rules:
		// (1) it lies on an ellipse centered on the target position 
		// (2) it lies on the line between the target and the window center
		// (3) right now the radii of the ellipse are fixed, but eventually
		//     they will be a function of the target text
		// 
		// from those rules we can compute the position of the 
		// lower left corner of the image
		LLRect rect = gHUDView->getRect();
		S32 x_center = lltrunc(0.5f * (F32)rect.getWidth());
		S32 y_center = lltrunc(0.5f * (F32)rect.getHeight());
		x = x - x_center;	// x and y relative to center
		y = y - y_center;
		F32 dist = sqrt((F32)(x*x + y*y));
		S32 half_arrow_size = lltrunc(0.5f * HUD_ARROW_SIZE);
		if (dist > 0.f)
		{
			const F32 ARROW_ELLIPSE_RADIUS_X = 2 * HUD_ARROW_SIZE;
			const F32 ARROW_ELLIPSE_RADIUS_Y = HUD_ARROW_SIZE;

			// compute where the arrow should be
			F32 x_target = (F32)(x + x_center) - (ARROW_ELLIPSE_RADIUS_X * ((F32)x / dist) );	
			F32 y_target = (F32)(y + y_center) - (ARROW_ELLIPSE_RADIUS_Y * ((F32)y / dist) );

			// keep the arrow within the window
			F32 x_clamped = llclamp( x_target, (F32)half_arrow_size, (F32)(rect.getWidth() - half_arrow_size));
			F32 y_clamped = llclamp( y_target, (F32)half_arrow_size, (F32)(rect.getHeight() - half_arrow_size));

			F32 slope = (F32)(y) / (F32)(x);
			F32 window_ratio = (F32)(rect.getHeight() - HUD_ARROW_SIZE) / (F32)(rect.getWidth() - HUD_ARROW_SIZE);

			// if the arrow has been clamped on one axis
			// then we need to compute the other axis
			if (llabs(slope) > window_ratio)
			{  
				if (y_clamped != (F32)y_target)
				{
					// clamp by y 
					x_clamped = (y_clamped - (F32)y_center) / slope + (F32)x_center;
				}
			}
			else if (x_clamped != (F32)x_target)
			{
				// clamp by x
				y_clamped = (x_clamped - (F32)x_center) * slope + (F32)y_center;
			}
			mHUDArrowCenterX = lltrunc(x_clamped);
			mHUDArrowCenterY = lltrunc(y_clamped);
		}
		else
		{
			// recycle the old values
			x = mHUDArrowCenterX - x_center;
			y = mHUDArrowCenterY - y_center;
		}

		F32 angle = atan2( (F32)y, (F32)x );

		gl_draw_scaled_rotated_image(mHUDArrowCenterX - half_arrow_size, 
									 mHUDArrowCenterY - half_arrow_size, 
									 HUD_ARROW_SIZE, HUD_ARROW_SIZE, 
									 RAD_TO_DEG * angle, 
									 LLWorldMapView::sTrackArrowImage->getImage(), 
									 color);
	}
}