Commit a997e131 authored by Bryan O'Sullivan's avatar Bryan O'Sullivan
Browse files

Merge with SVN viewer-2.0.0-3 branch

parents cab31b57 bbf49746
......@@ -87,7 +87,8 @@
#include "lldefs.h"
#include "llerror.h"
#include "llextendedstatus.h"
#include "llfasttimer.h"
// Don't do this, adds 15K lines of header code to every library file.
//#include "llfasttimer.h"
#include "llfile.h"
#include "llformat.h"
......
......@@ -38,7 +38,7 @@
#include "apr_time.h"
#include <time.h>
#include <locale>
#include <locale.h>
#include <string>
#include <iomanip>
#include <sstream>
......@@ -100,33 +100,28 @@ std::string LLDate::toHTTPDateString (std::string fmt) const
{
LLFastTimer ft1(FT_DATE_FORMAT);
std::ostringstream stream;
time_t locSeconds = (time_t) mSecondsSinceEpoch;
struct tm * gmt = gmtime (&locSeconds);
stream.imbue (std::locale(LLStringUtil::getLocale().c_str()));
toHTTPDateStream (stream, gmt, fmt);
return stream.str();
return toHTTPDateString(gmt, fmt);
}
std::string LLDate::toHTTPDateString (tm * gmt, std::string fmt)
{
LLFastTimer ft1(FT_DATE_FORMAT);
std::ostringstream stream;
stream.imbue (std::locale(LLStringUtil::getLocale().c_str()));
toHTTPDateStream (stream, gmt, fmt);
return stream.str();
}
void LLDate::toHTTPDateStream(std::ostream& s, tm * gmt, std::string fmt)
{
LLFastTimer ft1(FT_DATE_FORMAT);
// avoid calling setlocale() unnecessarily - it's expensive.
static std::string prev_locale = "";
std::string this_locale = LLStringUtil::getLocale();
if (this_locale != prev_locale)
{
setlocale(LC_TIME, this_locale.c_str());
prev_locale = this_locale;
}
const char * pBeg = fmt.c_str();
const char * pEnd = pBeg + fmt.length();
const std::time_put<char>& tp = std::use_facet<std::time_put<char> >(s.getloc());
tp.put (s, s, s.fill(), gmt, pBeg, pEnd);
// use strftime() as it appears to be faster than std::time_put
char buffer[128];
strftime(buffer, 128, fmt.c_str(), gmt);
return std::string(buffer);
}
void LLDate::toStream(std::ostream& s) const
......
......@@ -86,7 +86,6 @@ class LLDate
void toStream(std::ostream&) const;
std::string toHTTPDateString (std::string fmt) const;
static std::string toHTTPDateString (tm * gmt, std::string fmt);
static void toHTTPDateStream(std::ostream&, tm *, std::string);
/**
* @brief Set the date from an ISO-8601 string.
*
......
......@@ -36,7 +36,6 @@
#include <string>
#include <locale>
#include <iomanip>
#include <boost/regex.hpp>
#include "llsd.h"
#include "llfasttimer.h"
......@@ -232,7 +231,6 @@ class LLStringUtilBase
typedef std::map<LLFormatMapString, LLFormatMapString> format_map_t;
static void getTokens(const std::basic_string<T>& instr, std::vector<std::basic_string<T> >& tokens, const std::basic_string<T>& delims);
static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens);
static void formatNumber(std::basic_string<T>& numStr, std::basic_string<T> decimals);
static bool formatDatetime(std::basic_string<T>& replacement, std::basic_string<T> token, std::basic_string<T> param, S32 secFromEpoch);
static S32 format(std::basic_string<T>& s, const format_map_t& substitutions);
......@@ -347,6 +345,8 @@ class LLStringUtilBase
static void testHarness();
#endif
private:
static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens);
};
template<class T> std::basic_string<T> LLStringUtilBase<T>::null;
......
......@@ -59,8 +59,11 @@ class LLCoordGL : public LLCoord
{}
LLCoordGL(S32 x, S32 y) : LLCoord(x, y)
{}
bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordGL& other) const { return !(*this == other); }
};
//bool operator ==(const LLCoordGL& a, const LLCoordGL& b);
// Window coords include things like window borders,
// menu regions, etc.
......@@ -71,6 +74,8 @@ class LLCoordWindow : public LLCoord
{}
LLCoordWindow(S32 x, S32 y) : LLCoord(x, y)
{}
bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordWindow& other) const { return !(*this == other); }
};
......@@ -82,6 +87,8 @@ class LLCoordScreen : public LLCoord
{}
LLCoordScreen(S32 x, S32 y) : LLCoord(x, y)
{}
bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordScreen& other) const { return !(*this == other); }
};
class LLCoordFont : public LLCoord
......@@ -96,6 +103,8 @@ class LLCoordFont : public LLCoord
void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; }
void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; }
bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordFont& other) const { return !(*this == other); }
};
......
......@@ -32,7 +32,7 @@
#ifndef LL_LLPLUGINCLASSMEDIA_H
#define LL_LLPLUGINCLASSMEDIA_H
#include "llgl.h"
#include "llgltypes.h"
#include "llpluginprocessparent.h"
#include "llrect.h"
#include "llpluginclassmediaowner.h"
......
......@@ -32,7 +32,6 @@
#ifndef LL_LLPLUGINCLASSMEDIAOWNER_H
#define LL_LLPLUGINCLASSMEDIAOWNER_H
#include "llgl.h"
#include "llpluginprocessparent.h"
#include "llrect.h"
#include <queue>
......
......@@ -50,6 +50,7 @@ set(llui_SOURCE_FILES
lllayoutstack.cpp
lllineeditor.cpp
lllistctrl.cpp
lllocalcliprect.cpp
llmenugl.cpp
llmodaldialog.cpp
llmultifloater.cpp
......@@ -85,6 +86,7 @@ set(llui_SOURCE_FILES
lltexteditor.cpp
lltextparser.cpp
lltransutil.cpp
lltooltip.cpp
llui.cpp
lluicolortable.cpp
lluictrl.cpp
......@@ -133,6 +135,7 @@ set(llui_HEADER_FILES
lllazyvalue.h
lllineeditor.h
lllistctrl.h
lllocalcliprect.h
llmenugl.h
llmodaldialog.h
llmultifloater.h
......@@ -167,6 +170,7 @@ set(llui_HEADER_FILES
lltextbox.h
lltexteditor.h
lltextparser.h
lltooltip.h
lltransutil.h
lluicolortable.h
lluiconstants.h
......
......@@ -514,6 +514,7 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask)
// virtual
void LLButton::draw()
{
F32 alpha = getDrawContext().mAlpha;
bool flash = FALSE;
static LLUICachedControl<F32> button_flash_rate("ButtonFlashRate", 0);
static LLUICachedControl<S32> button_flash_count("ButtonFlashCount", 0);
......@@ -535,7 +536,7 @@ void LLButton::draw()
// Unselected image assignments
S32 local_mouse_x;
S32 local_mouse_y;
LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
bool enabled = isInEnabledChain();
......@@ -662,7 +663,7 @@ void LLButton::draw()
if (hasFocus())
{
F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
drawBorder(imagep, gFocusMgr.getFocusColor(), llround(lerp(1.f, 3.f, lerp_amt)));
drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, llround(lerp(1.f, 3.f, lerp_amt)));
}
if (use_glow_effect)
......@@ -685,21 +686,21 @@ void LLButton::draw()
LLColor4 disabled_color = mFadeWhenDisabled ? mDisabledImageColor.get() % 0.5f : mDisabledImageColor.get();
if ( mScaleImage)
{
imagep->draw(getLocalRect(), enabled ? mImageColor.get() : disabled_color );
imagep->draw(getLocalRect(), (enabled ? mImageColor.get() : disabled_color) % alpha );
if (mCurGlowStrength > 0.01f)
{
gGL.setSceneBlendType(glow_type);
imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % mCurGlowStrength);
imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % (mCurGlowStrength * alpha));
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
}
else
{
imagep->draw(0, 0, enabled ? mImageColor.get() : disabled_color );
imagep->draw(0, 0, (enabled ? mImageColor.get() : disabled_color) % alpha );
if (mCurGlowStrength > 0.01f)
{
gGL.setSceneBlendType(glow_type);
imagep->drawSolid(0, 0, glow_color % mCurGlowStrength);
imagep->drawSolid(0, 0, glow_color % (mCurGlowStrength * alpha));
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
}
......@@ -709,7 +710,7 @@ void LLButton::draw()
// no image
lldebugs << "No image for button " << getName() << llendl;
// draw it in pink so we can find it
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1, FALSE);
gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1 % alpha, FALSE);
}
// let overlay image and text play well together
......@@ -744,6 +745,7 @@ void LLButton::draw()
{
overlay_color.mV[VALPHA] = 0.5f;
}
overlay_color.mV[VALPHA] *= alpha;
switch(mImageOverlayAlignment)
{
......@@ -815,7 +817,7 @@ void LLButton::draw()
// Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode.
// Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars.
mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset),
label_color,
label_color % alpha,
mHAlign, LLFontGL::BOTTOM,
LLFontGL::NORMAL,
mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW,
......@@ -956,17 +958,6 @@ void LLButton::setColor(const LLColor4& color)
setImageColor(color);
}
void LLButton::setAlpha(F32 alpha)
{
LLColor4 temp = mImageColor.get();
temp.setAlpha(alpha);
mImageColor.set(temp);
temp = mDisabledImageColor.get();
temp.setAlpha(alpha * 0.5f);
mDisabledImageColor.set(temp);
}
void LLButton::setImageDisabled(LLPointer<LLUIImage> image)
{
mImageDisabled = image;
......
......@@ -191,7 +191,6 @@ class LLButton
void setImageColor(const std::string& color_control);
void setImageColor(const LLColor4& c);
/*virtual*/ void setColor(const LLColor4& c);
/*virtual*/ void setAlpha(F32 alpha);
void setImages(const std::string &image_name, const std::string &selected_name);
......
......@@ -55,6 +55,7 @@
#include "lllineeditor.h"
#include "v2math.h"
#include "lluictrlfactory.h"
#include "lltooltip.h"
// Globals
S32 LLCOMBOBOX_HEIGHT = 0;
......@@ -77,6 +78,7 @@ LLComboBox::ItemParams::ItemParams()
LLComboBox::Params::Params()
: allow_text_entry("allow_text_entry", false),
allow_new_values("allow_new_values", false),
show_text_as_tentative("show_text_as_tentative", true),
max_chars("max_chars", 20),
list_position("list_position", BELOW),
......@@ -96,6 +98,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
mTextEntryTentative(p.show_text_as_tentative),
mHasAutocompletedText(false),
mAllowTextEntry(p.allow_text_entry),
mAllowNewValues(p.allow_new_values),
mMaxChars(p.max_chars),
mPrearrangeCallback(p.prearrange_callback()),
mTextEntryCallback(p.text_entry_callback()),
......@@ -620,7 +623,15 @@ void LLComboBox::hideList()
if (mList->getVisible())
{
// assert selection in list
mList->selectNthItem(mLastSelectedIndex);
if(mAllowNewValues)
{
// mLastSelectedIndex = -1 means that we entered a new value, don't select
// any of existing items in this case.
if(mLastSelectedIndex >= 0)
mList->selectNthItem(mLastSelectedIndex);
}
else
mList->selectNthItem(mLastSelectedIndex);
mButton->setToggleState(FALSE);
mList->setVisible(FALSE);
......@@ -704,7 +715,7 @@ void LLComboBox::onItemSelected(const LLSD& data)
}
}
BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen)
{
std::string tool_tip;
......@@ -713,25 +724,17 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_re
return TRUE;
}
if (LLUI::sShowXUINames)
tool_tip = getToolTip();
if (tool_tip.empty())
{
tool_tip = getShowNamesToolTip();
}
else
{
tool_tip = getToolTip();
if (tool_tip.empty())
{
tool_tip = getSelectedItemLabel();
}
tool_tip = getSelectedItemLabel();
}
if( !tool_tip.empty() )
{
msg = tool_tip;
// Convert rect local to screen coordinates
*sticky_rect_screen = calcScreenRect();
LLToolTipMgr::instance().show(LLToolTipParams()
.message(tool_tip)
.sticky_rect(calcScreenRect()));
}
return TRUE;
}
......
......@@ -78,7 +78,8 @@ class LLComboBox
: public LLInitParam::Block<Params, LLUICtrl::Params>
{
Optional<bool> allow_text_entry,
show_text_as_tentative;
show_text_as_tentative,
allow_new_values;
Optional<S32> max_chars;
Optional<commit_callback_t> prearrange_callback,
text_entry_callback,
......@@ -112,7 +113,7 @@ class LLComboBox
// LLView interface
virtual void onFocusLost();
virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect);
virtual BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect);
virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleUnicodeCharHere(llwchar uni_char);
......@@ -224,6 +225,7 @@ class LLComboBox
private:
BOOL mAllowTextEntry;
BOOL mAllowNewValues;
S32 mMaxChars;
BOOL mTextEntryTentative;
commit_callback_t mPrearrangeCallback;
......
......@@ -34,10 +34,14 @@
#include "lldockablefloater.h"
//static
LLDockableFloater* LLDockableFloater::instance = NULL;
LLDockableFloater::LLDockableFloater(LLDockControl* dockControl,
const LLSD& key, const Params& params) :
LLFloater(key, params), mDockControl(dockControl)
{
resetInstance();
}
LLDockableFloater::~LLDockableFloater()
......@@ -51,23 +55,66 @@ BOOL LLDockableFloater::postBuild()
return LLView::postBuild();
}
void LLDockableFloater::resetInstance()
{
if (instance != this)
{
if (instance != NULL && instance->isDocked())
{
//closeFloater() is not virtual
if (instance->canClose())
{
instance->closeFloater();
}
else
{
instance->setVisible(FALSE);
}
}
instance = this;
}
}
void LLDockableFloater::setVisible(BOOL visible)
{
if(visible && isDocked())
{
resetInstance();
}
LLFloater::setVisible(visible);
}
void LLDockableFloater::setDocked(bool docked, bool pop_on_undock)
{
if (docked)
if (mDockControl.get() != NULL)
{
mDockControl.get()->on();
if (docked)
{
resetInstance();
mDockControl.get()->on();
}
else
{
mDockControl.get()->off();
}
}
else
if (!docked && pop_on_undock)
{
mDockControl.get()->off();
// visually pop up a little bit to emphasize the undocking
translate(0, UNDOCK_LEAP_HEIGHT);
}
LLFloater::setDocked(docked, pop_on_undock);
}
void LLDockableFloater::draw()
{
mDockControl.get()->repositionDockable();
mDockControl.get()->drawToungue();
if (mDockControl.get() != NULL)
{
mDockControl.get()->repositionDockable();
mDockControl.get()->drawToungue();
}
LLFloater::draw();
}
......
......@@ -43,6 +43,7 @@
*/
class LLDockableFloater : public LLFloater
{
static const U32 UNDOCK_LEAP_HEIGHT = 12;
public:
LOG_CLASS(LLDockableFloater);
LLDockableFloater(LLDockControl* dockControl, const LLSD& key, const Params& params = getDefaultParams());
......@@ -51,6 +52,14 @@ class LLDockableFloater : public LLFloater
/* virtula */BOOL postBuild();
/* virtual */void setDocked(bool docked, bool pop_on_undock = true);
/* virtual */void draw();
/*virtual*/ void setVisible(BOOL visible);
private:
/**
* Provides unique of dockable floater.
* If dockable floater already exists it should be closed.
*/
void resetInstance();
protected:
void setDockControl(LLDockControl* dockControl);
......@@ -60,6 +69,7 @@ class LLDockableFloater : public LLFloater
private:
std::auto_ptr<LLDockControl> mDockControl;
LLUIImagePtr mDockTongue;
static LLDockableFloater* instance;
};
#endif /* LL_DOCKABLEFLOATER_H */
......@@ -44,6 +44,7 @@ LLFilterEditor::LLFilterEditor(const LLFilterEditor::Params& p)
line_editor_p.rect(getLocalRect());
line_editor_p.follows.flags(FOLLOWS_ALL);
line_editor_p.text_pad_right(getRect().getHeight());
line_editor_p.revert_on_esc(false);
line_editor_p.keystroke_callback(boost::bind(&LLUICtrl::onCommit, this));
mFilterEditor = LLUICtrlFactory::create<LLLineEditor>(line_editor_p);
......
......@@ -218,9 +218,6 @@ LLFloater::Params::Params()
close_callback("close_callback"),
can_dock("can_dock", false)
{
name = "floater";
// defaults that differ from LLPanel:
background_visible = true;
visible = false;
}
......@@ -241,41 +238,39 @@ void LLFloater::initClass()
}
}
// defaults for floater param block pulled from widgets/floater.xml
static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater");
LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
: LLPanel(),
mDragHandle(NULL),
mTitle(p.title),
mShortTitle(p.short_title),
mSingleInstance(p.single_instance),
mKey(key),
mAutoTile(p.auto_tile),
mCanTearOff(p.can_tear_off),
mCanMinimize(p.can_minimize),
mCanClose(p.can_close),
mDragOnLeft(p.can_drag_on_left),
mResizable(p.can_resize),
mMinWidth(p.min_width),
mMinHeight(p.min_height),
mMinimized(FALSE),
mForeground(FALSE),
mFirstLook(TRUE),
mEditing(FALSE),
mButtonScale(1.0f),
mAutoFocus(TRUE), // automatically take focus when opened
mCanDock(false),
mDocked(false),
mHasBeenDraggedWhileMinimized(FALSE),
mPreviousMinimizedBottom(0),
mPreviousMinimizedLeft(0),
mNotificationContext(NULL)
{
static LLUIColor default_background_color = LLUIColorTable::instance().getColor("FloaterDefaultBackgroundColor");
static LLUIColor focus_background_color = LLUIColorTable::instance().getColor("FloaterFocusBackgroundColor");
: LLPanel(),
mDragHandle(NULL),
mTitle(p.title),
mShortTitle(p.short_title),
mSingleInstance(p.single_instance),
mKey(key),
mAutoTile(p.auto_tile),
mCanTearOff(p.can_tear_off),
mCanMinimize(p.can_minimize),
mCanClose(p.can_close),
mDragOnLeft(p.can_drag_on_left),
mResizable(p.can_resize),
mMinWidth(p.min_width),
mMinHeight(p.min_height),
mMinimized(FALSE),
mForeground(FALSE),
mFirstLook(TRUE),
mEditing(FALSE),
mButtonScale(1.0f),
mAutoFocus(TRUE), // automatically take focus when opened
mCanDock(false),
mDocked(false),
mHasBeenDraggedWhileMinimized(FALSE),
mPreviousMinimizedBottom(0),
mPreviousMinimizedLeft(0),
mNotificationContext(NULL)
{
mHandle.bind(this);
mNotificationContext = new LLFloaterNotificationContext(getHandle());
mBgColorAlpha = default_background_color;
mBgColorOpaque = focus_background_color;
// Clicks stop here.
setMouseOpaque(TRUE);
......@@ -779,11 +774,6 @@ void LLFloater::applyRectControl()
void LLFloater::applyTitle()
{
if (gNoRender)
{
return;
}