Merge of my DEV-36732 work and all the main line login api work that went on.

master
Palmer 2009-08-06 14:51:11 -07:00
commit b2632c50ef
1019 changed files with 47789 additions and 24698 deletions

View File

@ -44,6 +44,7 @@ Aleric Inglewood
VWR-10001
VWR-10759
VWR-10837
VWR-13996
Ales Beaumont
VWR-9352
Alissa Sabre

View File

@ -192,7 +192,7 @@ endif (DARWIN)
if (LINUX OR DARWIN)
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-non-virtual-dtor")
set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-non-virtual-dtor -Woverloaded-virtual")
if (NOT GCC_DISABLE_FATAL_WARNINGS)
set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
@ -227,7 +227,6 @@ else (STANDALONE)
glib-2.0
gstreamer-0.10
gtk-2.0
llfreetype2
pango-1.0
)
endif (STANDALONE)

View File

@ -76,6 +76,7 @@ class PlatformSetup(object):
build_type = build_types['relwithdebinfo']
standalone = 'OFF'
unattended = 'OFF'
universal = 'OFF'
project_name = 'SecondLife'
distcc = True
cmake_opts = []
@ -414,11 +415,11 @@ class DarwinSetup(UnixSetup):
def os(self):
return 'darwin'
#def arch(self):
# if self.unattended == 'ON':
# return 'universal'
# else:
# return UnixSetup.arch(self)
def arch(self):
if self.universal == 'ON':
return 'universal'
else:
return UnixSetup.arch(self)
def cmake_commandline(self, src_dir, build_dir, opts, simple):
args = dict(
@ -429,12 +430,11 @@ class DarwinSetup(UnixSetup):
word_size=self.word_size,
unattended=self.unattended,
project_name=self.project_name,
universal='',
universal=self.universal,
type=self.build_type.upper(),
)
if self.unattended == 'ON':
#args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386;ppc\''
pass
if self.universal == 'ON':
args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386;ppc\''
#if simple:
# return 'cmake %(opts)s %(dir)r' % args
return ('cmake -G %(generator)r '
@ -673,6 +673,7 @@ Options:
--standalone build standalone, without Linden prebuild libraries
--unattended build unattended, do not invoke any tools requiring
a human response
--universal build a universal binary on Mac OS X (unsupported)
-t | --type=NAME build type ("Debug", "Release", or "RelWithDebInfo")
-m32 | -m64 build architecture (32-bit or 64-bit)
-N | --no-distcc disable use of distcc
@ -718,7 +719,7 @@ def main(arguments):
opts, args = getopt.getopt(
arguments,
'?hNt:p:G:m:',
['help', 'standalone', 'no-distcc', 'unattended', 'type=', 'incredibuild', 'generator=', 'project='])
['help', 'standalone', 'no-distcc', 'unattended', 'universal', 'type=', 'incredibuild', 'generator=', 'project='])
except getopt.GetoptError, err:
print >> sys.stderr, 'Error:', err
print >> sys.stderr, """
@ -735,6 +736,8 @@ For example: develop.py configure -DSERVER:BOOL=OFF"""
setup.standalone = 'ON'
elif o in ('--unattended',):
setup.unattended = 'ON'
elif o in ('--universal',):
setup.universal = 'ON'
elif o in ('-m',):
if a in ('32', '64'):
setup.word_size = int(a)

View File

@ -41,6 +41,7 @@
#include "lldir.h"
#include "llerrorcontrol.h"
#include "llfloater.h"
#include "llfontfreetype.h"
#include "llfontgl.h"
#include "lltrans.h"
#include "llui.h"
@ -51,6 +52,11 @@
// *TODO: switch to using TUT
// *TODO: teach Parabuild about this program, run automatically after full builds
// I believe these must be globals, not stack variables. JC
LLControlGroup gSavedSettings("Global"); // saved at end of session
LLControlGroup gSavedPerAccountSettings("PerAccount"); // saved at end of session
LLControlGroup gWarningSettings("Warnings"); // persists ignored dialogs/warnings
// We can't create LLImageGL objects because we have no window or rendering
// context. Provide enough of an LLUIImage to test the LLUI library without
// an underlying image.
@ -72,6 +78,8 @@ public:
}
};
class LLTexture ;
// We need to supply dummy images
class TestImageProvider : public LLImageProviderInterface
{
@ -92,68 +100,71 @@ public:
LLPointer<LLUIImage> makeImage()
{
LLPointer<LLImageGL> image_gl;
LLPointer<LLUIImage> image = new LLUIImage( std::string(), image_gl);
LLPointer<LLTexture> image_gl;
LLPointer<LLUIImage> image = new TestUIImage(); //LLUIImage( std::string(), image_gl);
mImageList.push_back(image);
return image;
}
public:
// Unclear if we need this, hold on to one copy of each image we make
std::vector<LLPointer<LLUIImage> > mImageList;
};
TestImageProvider gTestImageProvider;
static std::string get_xui_dir()
{
std::string delim = gDirUtilp->getDirDelimiter();
return gDirUtilp->getAppRODataDir() + delim + std::string("skins") + delim + "default" + delim + "xui" + delim;
return gDirUtilp->getSkinBaseDir() + delim + "default" + delim + "xui" + delim;
}
int main(int argc, char** argv)
void init_llui()
{
// Must init LLError for llerrs to actually cause errors.
LLError::initForApplication(".");
// Font lookup needs directory support
gDirUtilp->initAppDirs("SecondLife", "../../../newview");
#if LL_DARWIN
const char* newview_path = "../../../../newview";
#else
const char* newview_path = "../../../newview";
#endif
gDirUtilp->initAppDirs("SecondLife", newview_path);
gDirUtilp->setSkinFolder("default");
// colors are no longer stored in a LLControlGroup file
LLUIColorTable::instance().loadFromSettings();
std::string config_filename = gDirUtilp->getExpandedFilename(
LL_PATH_APP_SETTINGS, "settings.xml");
LLControlGroup config_group("config");
config_group.loadFromFile(config_filename);
std::string color_filename = gDirUtilp->getExpandedFilename(
LL_PATH_DEFAULT_SKIN, "colors.xml");
LLControlGroup color_group("color");
color_group.loadFromFile(color_filename);
LLControlGroup floater_group("floater");
LLControlGroup ignores_group("ignores");
LL_PATH_APP_SETTINGS, "settings.xml");
gSavedSettings.loadFromFile(config_filename);
// See LLAppViewer::init()
LLUI::settings_map_t settings;
settings["config"] = &config_group;
settings["color"] = &color_group;
settings["floater"] = &floater_group;
settings["ignores"] = &ignores_group;
settings["config"] = &gSavedSettings;
settings["ignores"] = &gWarningSettings;
settings["floater"] = &gSavedSettings;
settings["account"] = &gSavedPerAccountSettings;
// Don't use real images as we don't have a GL context
TestImageProvider image_provider;
LLUI::initClass(settings, &image_provider);
LLUI::initClass(settings, &gTestImageProvider);
const bool no_register_widgets = false;
LLWidgetReg::initClass( no_register_widgets );
// Unclear if this is needed
LLUI::setupPaths();
// Otherwise we get translation warnings when setting up floaters
// (tooltips for buttons)
std::set<std::string> default_args;
LLTrans::parseStrings("strings.xml", default_args);
LLTrans::parseLanguageStrings("language_settings.xml");
LLFontManager::initClass();
// Creating widgets apparently requires fonts to be initialized,
// otherwise it crashes.
LLFontGL::initClass(96.f, 1.f, 1.f,
gDirUtilp->getAppRODataDir(),
LLUI::getXUIPaths(),
false ); // don't create gl textures
gDirUtilp->getAppRODataDir(),
LLUI::getXUIPaths(),
false ); // don't create gl textures
LLFloaterView::Params fvparams;
fvparams.name("Floater View");
fvparams.rect( LLRect(0,480,640,0) );
@ -161,7 +172,10 @@ int main(int argc, char** argv)
fvparams.follows.flags(FOLLOWS_ALL);
fvparams.tab_stop(false);
gFloaterView = LLUICtrlFactory::create<LLFloaterView> (fvparams);
}
void export_test_floaters()
{
// Convert all test floaters to new XML format
std::string delim = gDirUtilp->getDirDelimiter();
std::string xui_dir = get_xui_dir() + "en" + delim;
@ -176,21 +190,32 @@ int main(int argc, char** argv)
llinfos << "Converting " << filename << llendl;
// Build a floater and output new attributes
LLXMLNodePtr output_node = new LLXMLNode();
LLFloater* floater = new LLFloater();
LLFloater* floater = new LLFloater(LLSD());
LLUICtrlFactory::getInstance()->buildFloater(floater,
filename,
FALSE, // don't open floater
output_node);
filename,
// FALSE, // don't open floater
output_node);
std::string out_filename = xui_dir + filename;
std::string::size_type extension_pos = out_filename.rfind(".xml");
out_filename.resize(extension_pos);
out_filename += "_new.xml";
llinfos << "Output: " << out_filename << llendl;
LLFILE* floater_file = LLFile::fopen(out_filename.c_str(), "w");
LLXMLNode::writeHeaderToFile(floater_file);
output_node->writeToFile(floater_file);
fclose(floater_file);
}
}
int main(int argc, char** argv)
{
// Must init LLError for llerrs to actually cause errors.
LLError::initForApplication(".");
init_llui();
export_test_floaters();
return 0;
}

View File

@ -42,6 +42,7 @@
#include "llmultisliderctrl.h"
#include "llprogressbar.h"
#include "llradiogroup.h"
#include "llsearcheditor.h"
#include "llscrollcontainer.h"
#include "llscrollingpanellist.h"
#include "llscrolllistctrl.h"
@ -53,7 +54,7 @@
#include "lltextbox.h"
#include "lltexteditor.h"
#include "llflyoutbutton.h"
#include "llsearcheditor.h"
#include "llfiltereditor.h"
#include "lllayoutstack.h"
void LLWidgetReg::initClass(bool register_widgets)
@ -62,45 +63,46 @@ void LLWidgetReg::initClass(bool register_widgets)
// references to the object files.
if (register_widgets)
{
LLDefaultWidgetRegistry::Register<LLButton> button("button");
LLDefaultWidgetRegistry::Register<LLCheckBoxCtrl> check_box("check_box");
LLDefaultWidgetRegistry::Register<LLComboBox> combo_box("combo_box");
LLDefaultWidgetRegistry::Register<LLFlyoutButton> flyout_button("flyout_button");
LLDefaultWidgetRegistry::Register<LLContainerView> container_view("container_view");
LLDefaultWidgetRegistry::Register<LLIconCtrl> icon("icon");
LLDefaultWidgetRegistry::Register<LLLineEditor> line_editor("line_editor");
LLDefaultWidgetRegistry::Register<LLSearchEditor> search_editor("search_editor");
LLDefaultWidgetRegistry::Register<LLMenuItemSeparatorGL> menu_item_separator("menu_item_separator");
LLDefaultWidgetRegistry::Register<LLMenuItemCallGL> menu_item_call_gl("menu_item_call");
LLDefaultWidgetRegistry::Register<LLMenuItemCheckGL> menu_item_check_gl("menu_item_check");
LLDefaultWidgetRegistry::Register<LLMenuGL> menu("menu");
LLDefaultWidgetRegistry::Register<LLMenuBarGL> menu_bar("menu_bar");
LLDefaultWidgetRegistry::Register<LLContextMenu> context_menu("context_menu");
LLDefaultWidgetRegistry::Register<LLMultiSlider> multi_slider_bar("multi_slider_bar");
LLDefaultWidgetRegistry::Register<LLMultiSliderCtrl> multi_slider("multi_slider");
LLDefaultWidgetRegistry::Register<LLPanel> panel("panel", &LLPanel::fromXML);
LLDefaultWidgetRegistry::Register<LLLayoutStack> layout_stack("layout_stack", &LLLayoutStack::fromXML);
LLDefaultWidgetRegistry::Register<LLProgressBar> progress_bar("progress_bar");
LLDefaultWidgetRegistry::Register<LLRadioGroup> radio_group("radio_group");
LLDefaultWidgetRegistry::Register<LLRadioCtrl> radio_item("radio_item");
LLDefaultWidgetRegistry::Register<LLScrollContainer> scroll_container("scroll_container");
LLDefaultWidgetRegistry::Register<LLScrollingPanelList> scrolling_panel_list("scrolling_panel_list");
LLDefaultWidgetRegistry::Register<LLScrollListCtrl> scroll_list("scroll_list");
LLDefaultWidgetRegistry::Register<LLSlider> slider_bar("slider_bar");
LLDefaultWidgetRegistry::Register<LLSliderCtrl> slider("slider");
LLDefaultWidgetRegistry::Register<LLSpinCtrl> spinner("spinner");
LLDefaultWidgetRegistry::Register<LLStatBar> stat_bar("stat_bar");
//LLDefaultWidgetRegistry::Register<LLPlaceHolderPanel> placeholder("placeholder");
LLDefaultWidgetRegistry::Register<LLTabContainer> tab_container("tab_container");
LLDefaultWidgetRegistry::Register<LLTextBox> text("text");
LLDefaultWidgetRegistry::Register<LLTextEditor> simple_text_editor("simple_text_editor");
LLDefaultWidgetRegistry::Register<LLUICtrl> ui_ctrl("ui_ctrl");
LLDefaultWidgetRegistry::Register<LLStatView> stat_view("stat_view");
//LLDefaultWidgetRegistry::Register<LLUICtrlLocate> locate("locate");
//LLDefaultWidgetRegistry::Register<LLUICtrlLocate> pad("pad");
LLDefaultWidgetRegistry::Register<LLViewBorder> view_border("view_border");
LLDefaultChildRegistry::Register<LLButton> button("button");
LLDefaultChildRegistry::Register<LLCheckBoxCtrl> check_box("check_box");
LLDefaultChildRegistry::Register<LLComboBox> combo_box("combo_box");
LLDefaultChildRegistry::Register<LLFilterEditor> filter_editor("filter_editor");
LLDefaultChildRegistry::Register<LLFlyoutButton> flyout_button("flyout_button");
LLDefaultChildRegistry::Register<LLContainerView> container_view("container_view");
LLDefaultChildRegistry::Register<LLIconCtrl> icon("icon");
LLDefaultChildRegistry::Register<LLLineEditor> line_editor("line_editor");
LLDefaultChildRegistry::Register<LLMenuItemSeparatorGL> menu_item_separator("menu_item_separator");
LLDefaultChildRegistry::Register<LLMenuItemCallGL> menu_item_call_gl("menu_item_call");
LLDefaultChildRegistry::Register<LLMenuItemCheckGL> menu_item_check_gl("menu_item_check");
LLDefaultChildRegistry::Register<LLMenuGL> menu("menu");
LLDefaultChildRegistry::Register<LLMenuBarGL> menu_bar("menu_bar");
LLDefaultChildRegistry::Register<LLContextMenu> context_menu("context_menu");
LLDefaultChildRegistry::Register<LLMultiSlider> multi_slider_bar("multi_slider_bar");
LLDefaultChildRegistry::Register<LLMultiSliderCtrl> multi_slider("multi_slider");
LLDefaultChildRegistry::Register<LLPanel> panel("panel", &LLPanel::fromXML);
LLDefaultChildRegistry::Register<LLLayoutStack> layout_stack("layout_stack", &LLLayoutStack::fromXML);
LLDefaultChildRegistry::Register<LLProgressBar> progress_bar("progress_bar");
LLDefaultChildRegistry::Register<LLRadioGroup> radio_group("radio_group");
LLDefaultChildRegistry::Register<LLRadioCtrl> radio_item("radio_item");
LLDefaultChildRegistry::Register<LLSearchEditor> search_editor("search_editor");
LLDefaultChildRegistry::Register<LLScrollContainer> scroll_container("scroll_container");
LLDefaultChildRegistry::Register<LLScrollingPanelList> scrolling_panel_list("scrolling_panel_list");
LLDefaultChildRegistry::Register<LLScrollListCtrl> scroll_list("scroll_list");
LLDefaultChildRegistry::Register<LLSlider> slider_bar("slider_bar");
LLDefaultChildRegistry::Register<LLSliderCtrl> slider("slider");
LLDefaultChildRegistry::Register<LLSpinCtrl> spinner("spinner");
LLDefaultChildRegistry::Register<LLStatBar> stat_bar("stat_bar");
//LLDefaultChildRegistry::Register<LLPlaceHolderPanel> placeholder("placeholder");
LLDefaultChildRegistry::Register<LLTabContainer> tab_container("tab_container");
LLDefaultChildRegistry::Register<LLTextBox> text("text");
LLDefaultChildRegistry::Register<LLTextEditor> simple_text_editor("simple_text_editor");
LLDefaultChildRegistry::Register<LLUICtrl> ui_ctrl("ui_ctrl");
LLDefaultChildRegistry::Register<LLStatView> stat_view("stat_view");
//LLDefaultChildRegistry::Register<LLUICtrlLocate> locate("locate");
//LLDefaultChildRegistry::Register<LLUICtrlLocate> pad("pad");
LLDefaultChildRegistry::Register<LLViewBorder> view_border("view_border");
}
// *HACK: Usually this is registered as a viewer text editor
LLDefaultWidgetRegistry::Register<LLTextEditor> text_editor("text_editor");
LLDefaultChildRegistry::Register<LLTextEditor> text_editor("text_editor");
}

View File

@ -33,7 +33,7 @@
// Register all widgets with the builder registry.
// Useful on Windows where linker discards all references to the
// static LLDefaultWidgetRegistry::Register<> calls.
// static LLDefaultChildRegistry::Register<> calls.
class LLWidgetReg
{
public:

View File

@ -174,7 +174,7 @@ public:
void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot);
virtual BOOL isAnimatable() { return TRUE; }
virtual BOOL isAnimatable() const { return TRUE; }
S32 getJointNum() const { return mJointNum; }
void setJointNum(S32 joint_num) { mJointNum = joint_num; }

View File

@ -50,6 +50,7 @@ const S32 GESTURE_VERSION = 2;
LLMultiGesture::LLMultiGesture()
: mKey(),
mMask(),
mName(),
mTrigger(),
mReplaceText(),
mSteps(),

View File

@ -65,11 +65,13 @@ protected:
const LLMultiGesture& operator=(const LLMultiGesture& rhs);
public:
// name is stored at asset level
// desc is stored at asset level
KEY mKey;
MASK mMask;
// This name can be empty if the inventory item is not around and
// the gesture manager has not yet set the name
std::string mName;
// String, like "/foo" or "hello" that makes it play
std::string mTrigger;

View File

@ -516,9 +516,9 @@ BOOL LLPoseBlender::addMotion(LLMotion* motion)
void LLPoseBlender::blendAndApply()
{
for (blender_list_t::iterator iter = mActiveBlenders.begin();
iter != mActiveBlenders.end(); ++iter)
iter != mActiveBlenders.end(); )
{
LLJointStateBlender* jsbp = *iter;
LLJointStateBlender* jsbp = *iter++;
jsbp->blendJointStates();
}

View File

@ -74,6 +74,7 @@ set(llcommon_SOURCE_FILES
llsdserialize_xml.cpp
llsdutil.cpp
llsecondlifeurls.cpp
llsingleton.cpp
llstat.cpp
llstacktrace.cpp
llstreamtools.cpp

View File

@ -44,19 +44,29 @@ struct AssetEntry : public LLDictionaryEntry
{
AssetEntry(const char *desc_name,
const char *type_name, // 8 character limit!
const char *human_name,
const char *human_name, // for decoding to human readable form; put any and as many printable characters you want in each one
const char *category_name, // used by llinventorymodel when creating new categories
EDragAndDropType dad_type,
bool can_link);
bool can_link, // can you create a link to this type?
bool is_protected) // can the viewer change categories of this type?
:
LLDictionaryEntry(desc_name),
mTypeName(type_name),
mHumanName(human_name),
mCategoryName(category_name),
mDadType(dad_type),
mCanLink(can_link),
mIsProtected(is_protected)
{
llassert(strlen(mTypeName) <= 8);
}
// limited to 8 characters
const char *mTypeName;
// human readable form. Put as many printable characters you want in each one.
// (c.f. llinventory.cpp INVENTORY_TYPE_HUMAN_NAMES).
const char *mHumanName;
const char *mCategoryName;
EDragAndDropType mDadType;
bool mCanLink;
bool mIsProtected;
};
class LLAssetDictionary : public LLSingleton<LLAssetDictionary>,
@ -68,53 +78,50 @@ public:
LLAssetDictionary::LLAssetDictionary()
{
addEntry(LLAssetType::AT_TEXTURE, new AssetEntry("TEXTURE", "texture", "texture", "Textures", DAD_TEXTURE, FALSE));
addEntry(LLAssetType::AT_SOUND, new AssetEntry("SOUND", "sound", "sound", "Sounds", DAD_SOUND, FALSE));
addEntry(LLAssetType::AT_CALLINGCARD, new AssetEntry("CALLINGCARD", "callcard", "calling card", "Calling Cards", DAD_CALLINGCARD, FALSE));
addEntry(LLAssetType::AT_LANDMARK, new AssetEntry("LANDMARK", "landmark", "landmark", "Landmarks", DAD_LANDMARK, FALSE));
addEntry(LLAssetType::AT_SCRIPT, new AssetEntry("SCRIPT", "script", "legacy script", "Scripts", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_CLOTHING, new AssetEntry("CLOTHING", "clothing", "clothing", "Clothing", DAD_CLOTHING, TRUE));
addEntry(LLAssetType::AT_OBJECT, new AssetEntry("OBJECT", "object", "object", "Objects", DAD_OBJECT, TRUE));
addEntry(LLAssetType::AT_NOTECARD, new AssetEntry("NOTECARD", "notecard", "note card", "Notecards", DAD_NOTECARD, FALSE));
addEntry(LLAssetType::AT_CATEGORY, new AssetEntry("CATEGORY", "category", "folder", "New Folder", DAD_CATEGORY, TRUE));
addEntry(LLAssetType::AT_ROOT_CATEGORY, new AssetEntry("ROOT_CATEGORY", "root", "root", "Inventory", DAD_ROOT_CATEGORY, TRUE));
addEntry(LLAssetType::AT_LSL_TEXT, new AssetEntry("LSL_TEXT", "lsltext", "lsl2 script", "Scripts", DAD_SCRIPT, FALSE));
addEntry(LLAssetType::AT_LSL_BYTECODE, new AssetEntry("LSL_BYTECODE", "lslbyte", "lsl bytecode", "Scripts", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_TEXTURE_TGA, new AssetEntry("TEXTURE_TGA", "txtr_tga", "tga texture", "Uncompressed Images", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_BODYPART, new AssetEntry("BODYPART", "bodypart", "body part", "Body Parts", DAD_BODYPART, TRUE));
addEntry(LLAssetType::AT_TRASH, new AssetEntry("TRASH", "trash", "trash", "Trash", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_SNAPSHOT_CATEGORY, new AssetEntry("SNAPSHOT_CATEGORY", "snapshot", "snapshot", "Photo Album", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_LOST_AND_FOUND, new AssetEntry("LOST_AND_FOUND", "lstndfnd", "lost and found", "Lost And Found", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_SOUND_WAV, new AssetEntry("SOUND_WAV", "snd_wav", "sound", "Uncompressed SoundS", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_IMAGE_TGA, new AssetEntry("IMAGE_TGA", "img_tga", "targa image", "Uncompressed Images", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_IMAGE_JPEG, new AssetEntry("IMAGE_JPEG", "jpeg", "jpeg image", "Uncompressed Images", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_ANIMATION, new AssetEntry("ANIMATION", "animatn", "animation", "Animations", DAD_ANIMATION, FALSE));
addEntry(LLAssetType::AT_GESTURE, new AssetEntry("GESTURE", "gesture", "gesture", "Gestures", DAD_GESTURE, FALSE));
addEntry(LLAssetType::AT_SIMSTATE, new AssetEntry("SIMSTATE", "simstate", "simstate", "New Folder", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_FAVORITE, new AssetEntry("FAVORITE", "favorite", "favorite", "favorite", DAD_NONE, FALSE));
// DESCRIPTION TYPE NAME HUMAN NAME CATEGORY NAME DRAG&DROP CAN LINK? PROTECTED?
// |--------------------|-----------|-------------------|-------------------|---------------|-----------|-----------|
addEntry(LLAssetType::AT_TEXTURE, new AssetEntry("TEXTURE", "texture", "texture", "Textures", DAD_TEXTURE, FALSE, TRUE));
addEntry(LLAssetType::AT_SOUND, new AssetEntry("SOUND", "sound", "sound", "Sounds", DAD_SOUND, FALSE, TRUE));
addEntry(LLAssetType::AT_CALLINGCARD, new AssetEntry("CALLINGCARD", "callcard", "calling card", "Calling Cards", DAD_CALLINGCARD, FALSE, TRUE));
addEntry(LLAssetType::AT_LANDMARK, new AssetEntry("LANDMARK", "landmark", "landmark", "Landmarks", DAD_LANDMARK, FALSE, TRUE));
addEntry(LLAssetType::AT_SCRIPT, new AssetEntry("SCRIPT", "script", "legacy script", "Scripts", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_CLOTHING, new AssetEntry("CLOTHING", "clothing", "clothing", "Clothing", DAD_CLOTHING, TRUE, TRUE));
addEntry(LLAssetType::AT_OBJECT, new AssetEntry("OBJECT", "object", "object", "Objects", DAD_OBJECT, TRUE, TRUE));
addEntry(LLAssetType::AT_NOTECARD, new AssetEntry("NOTECARD", "notecard", "note card", "Notecards", DAD_NOTECARD, FALSE, TRUE));
addEntry(LLAssetType::AT_CATEGORY, new AssetEntry("CATEGORY", "category", "folder", "New Folder", DAD_CATEGORY, TRUE, TRUE));
addEntry(LLAssetType::AT_ROOT_CATEGORY, new AssetEntry("ROOT_CATEGORY", "root", "root", "Inventory", DAD_ROOT_CATEGORY, TRUE, TRUE));
addEntry(LLAssetType::AT_LSL_TEXT, new AssetEntry("LSL_TEXT", "lsltext", "lsl2 script", "Scripts", DAD_SCRIPT, FALSE, TRUE));
addEntry(LLAssetType::AT_LSL_BYTECODE, new AssetEntry("LSL_BYTECODE", "lslbyte", "lsl bytecode", "Scripts", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_TEXTURE_TGA, new AssetEntry("TEXTURE_TGA", "txtr_tga", "tga texture", "Uncompressed Images", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_BODYPART, new AssetEntry("BODYPART", "bodypart", "body part", "Body Parts", DAD_BODYPART, TRUE, TRUE));
addEntry(LLAssetType::AT_TRASH, new AssetEntry("TRASH", "trash", "trash", "Trash", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_SNAPSHOT_CATEGORY, new AssetEntry("SNAPSHOT_CATEGORY", "snapshot", "snapshot", "Photo Album", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_LOST_AND_FOUND, new AssetEntry("LOST_AND_FOUND", "lstndfnd", "lost and found", "Lost And Found", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_SOUND_WAV, new AssetEntry("SOUND_WAV", "snd_wav", "sound", "Uncompressed SoundS", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_IMAGE_TGA, new AssetEntry("IMAGE_TGA", "img_tga", "targa image", "Uncompressed Images", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_IMAGE_JPEG, new AssetEntry("IMAGE_JPEG", "jpeg", "jpeg image", "Uncompressed Images", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_ANIMATION, new AssetEntry("ANIMATION", "animatn", "animation", "Animations", DAD_ANIMATION, FALSE, TRUE));
addEntry(LLAssetType::AT_GESTURE, new AssetEntry("GESTURE", "gesture", "gesture", "Gestures", DAD_GESTURE, FALSE, TRUE));
addEntry(LLAssetType::AT_SIMSTATE, new AssetEntry("SIMSTATE", "simstate", "simstate", "New Folder", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_FAVORITE, new AssetEntry("FAVORITE", "favorite", "favorite", "favorite", DAD_NONE, FALSE, TRUE));
addEntry(LLAssetType::AT_LINK, new AssetEntry("LINK", "link", "symbolic link", "New Folder", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_LINK_FOLDER, new AssetEntry("FOLDER_LINK", "link_f", "symbolic folder link", "New Folder", DAD_NONE, FALSE));
addEntry(LLAssetType::AT_LINK, new AssetEntry("LINK", "link", "symbolic link", "Link", DAD_LINK, FALSE, TRUE));
addEntry(LLAssetType::AT_LINK_FOLDER, new AssetEntry("FOLDER_LINK", "link_f", "symbolic folder link", "New Folder", DAD_LINK, FALSE, TRUE));
addEntry(LLAssetType::AT_NONE, new AssetEntry("NONE", "-1", NULL, "New Folder", DAD_NONE, FALSE));
for (S32 ensemble_num = S32(LLAssetType::AT_FOLDER_ENSEMBLE_START);
ensemble_num <= S32(LLAssetType::AT_FOLDER_ENSEMBLE_END);
ensemble_num++)
{
addEntry(LLAssetType::EType(ensemble_num), new AssetEntry("ENSEMBLE", "ensemble", "ensemble", "New Folder", DAD_CATEGORY, TRUE, FALSE));
}
addEntry(LLAssetType::AT_CURRENT_OUTFIT, new AssetEntry("CURRENT", "current", "current outfit", "Current Outfit", DAD_CATEGORY, FALSE, TRUE));
addEntry(LLAssetType::AT_OUTFIT, new AssetEntry("OUTFIT", "outfit", "outfit", "Outfit", DAD_CATEGORY, TRUE, FALSE));
addEntry(LLAssetType::AT_MY_OUTFITS, new AssetEntry("MY_OUTFITS", "my_otfts", "my outfits", "My Outfits", DAD_CATEGORY, FALSE, TRUE));
addEntry(LLAssetType::AT_NONE, new AssetEntry("NONE", "-1", NULL, "New Folder", DAD_NONE, FALSE, FALSE));
};
AssetEntry::AssetEntry(const char *desc_name,
const char *type_name,
const char *human_name,
const char *category_name,
EDragAndDropType dad_type,
bool can_link) :
LLDictionaryEntry(desc_name),
mTypeName(type_name),
mHumanName(human_name),
mCategoryName(category_name),
mDadType(dad_type),
mCanLink(can_link)
{
llassert(strlen(mTypeName) <= 8);
}
// static
LLAssetType::EType LLAssetType::getType(const std::string& desc_name)
{
@ -128,11 +135,11 @@ const std::string &LLAssetType::getDesc(LLAssetType::EType asset_type)
{
const AssetEntry *entry = LLAssetDictionary::getInstance()->lookup(asset_type);
if (entry)
{
{
return entry->mName;
}
else
{
{
static const std::string error_string = "BAD TYPE";
return error_string;
}
@ -154,7 +161,7 @@ const char *LLAssetType::lookup(LLAssetType::EType asset_type)
}
// static
LLAssetType::EType LLAssetType::lookup( const char* name )
LLAssetType::EType LLAssetType::lookup(const char* name)
{
return lookup(ll_safe_string(name));
}
@ -191,7 +198,7 @@ const char *LLAssetType::lookupHumanReadable(LLAssetType::EType asset_type)
}
// static
LLAssetType::EType LLAssetType::lookupHumanReadable( const char* name )
LLAssetType::EType LLAssetType::lookupHumanReadable(const char* name)
{
return lookupHumanReadable(ll_safe_string(name));
}
@ -261,6 +268,21 @@ bool LLAssetType::lookupIsLinkType(EType asset_type)
return false;
}
// static
// Only ensembles and plain folders aren't protected. "Protected" means
// you can't change certain properties such as their type.
bool LLAssetType::lookupIsProtectedCategoryType(EType asset_type)
{
const LLAssetDictionary *dict = LLAssetDictionary::getInstance();
const AssetEntry *entry = dict->lookup(asset_type);
if (entry)
{
return entry->mIsProtected;
}
return true;
}
// static. Generate a good default description
void LLAssetType::generateDescriptionFor(LLAssetType::EType asset_type,
std::string& description)

View File

@ -125,7 +125,7 @@ public:
AT_SIMSTATE = 22,
// Simstate file.
AT_FAVORITE = 23,
// favorite items
@ -135,21 +135,35 @@ public:
AT_LINK_FOLDER = 25,
// Inventory folder link
AT_COUNT = 26,
AT_FOLDER_ENSEMBLE_START = 26,
AT_FOLDER_ENSEMBLE_END = 45,
// This range is reserved for special clothing folder types.
// +************************************************+
// | TO ADD AN ELEMENT TO THIS ENUM: |
// +************************************************+
// | 1. INSERT BEFORE AT_COUNT |
// | 2. INCREMENT AT_COUNT BY 1 |
// | 3. ADD TO LLAssetDictionary in llassettype.cpp |
// +************************************************+
AT_CURRENT_OUTFIT = 46,
// Current outfit
AT_OUTFIT = 47,
// Predefined outfit ("look")
AT_MY_OUTFITS = 48,
// Folder that holds your outfits.
AT_COUNT = 49,
// +*********************************************************+
// | TO ADD AN ELEMENT TO THIS ENUM: |
// +*********************************************************+
// | 1. INSERT BEFORE AT_COUNT |
// | 2. INCREMENT AT_COUNT BY 1 |
// | 3. ADD TO LLAssetDictionary in LLAssetType.cpp |
// | 3. ADD TO DEFAULT_ASSET_FOR_INV in LLInventoryType.cpp |
// +*********************************************************+
AT_NONE = -1
};
// machine transation between type and strings
static EType lookup(const char* name); // safe conversion to std::string, *TODO: deprecate
static EType lookup(const char* name); // safe conversion to std::string, *TODO: deprecate
static EType lookup(const std::string& type_name);
static const char* lookup(EType asset_type);
@ -158,8 +172,6 @@ public:
static EType lookupHumanReadable(const std::string& readable_name);
static const char* lookupHumanReadable(EType asset_type);
static const char* lookupCategoryName(EType asset_type);
// Generate a good default description. You may want to add a verb
// or agent name after this depending on your application.
static void generateDescriptionFor(LLAssetType::EType asset_type,
@ -168,9 +180,13 @@ public:
static EType getType(const std::string& desc_name);
static const std::string& getDesc(EType asset_type);
static EDragAndDropType lookupDragAndDropType(EType asset_type);
static bool lookupCanLink(EType asset_type);
static bool lookupIsLinkType(EType asset_type);
static const char* lookupCategoryName(EType asset_type);
static bool lookupIsProtectedCategoryType(EType asset_type);
/* TODO: Change return types from "const char *" to "const std::string &".
This is fairly straightforward, but requires changing some calls to use .c_str().
e.g.:
@ -180,8 +196,8 @@ public:
private:
// don't instantiate or derive one of these objects
LLAssetType() {}
~LLAssetType() {}
LLAssetType( void ) {}
~LLAssetType( void ) {}
};
#endif // LL_LLASSETTYPE_H

View File

@ -581,6 +581,8 @@ public:
return sorted_range(begin, end);
}
using LLDependenciesBase::describe; // unhide virtual std::string describe(bool full=true) const;
/// Override base-class describe() with actual implementation
virtual std::ostream& describe(std::ostream& out, bool full=true) const
{
@ -597,6 +599,7 @@ public:
return out;
}
/// describe() helper: report a DepNodeEntry
static std::ostream& describe(std::ostream& out, std::string& sep,
const DepNodeMapEntry& entry, bool full)

View File

@ -95,6 +95,10 @@ public:
protected:
void addEntry(Index index, Entry *entry)
{
if (lookup(index))
{
llerrs << "Dictionary entry already added (attempted to add duplicate entry)" << llendl;
}
(*this)[index] = entry;
}
};

View File

@ -21,7 +21,16 @@
#include <vector>
#include <deque>
#include <stdexcept>
#if LL_WINDOWS
#pragma warning (push)
#pragma warning (disable : 4263) // boost::signals2::expired_slot::what() has const mismatch
#pragma warning (disable : 4264)
#endif
#include <boost/signals2.hpp>
#if LL_WINDOWS
#pragma warning (pop)
#endif
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>

View File

@ -116,8 +116,10 @@
#pragma warning( 3 : 4702 ) // "unreachable code" Treat this as level 3, not level 4.
#pragma warning( 3 : 4189 ) // "local variable initialized but not referenced" Treat this as level 3, not level 4.
//#pragma warning( 3 : 4018 ) // "signed/unsigned mismatch" Treat this as level 3, not level 4.
#pragma warning( 3 : 4263 ) // 'function' : member function does not override any base class virtual member function
#pragma warning( 3 : 4264 ) // "'virtual_function' : no override available for virtual member function from base 'class'; function is hidden"
#pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual"
#pragma warning( disable : 4786 ) // silly MS warning deep inside their <map> include file
#pragma warning( 3 : 4266 ) // 'function' : no override available for virtual member function from base 'type'; function is hidden
#pragma warning( disable : 4284 ) // silly MS warning deep inside their <map> include file
#pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
#pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)

View File

@ -162,6 +162,7 @@ namespace
virtual LLSD::Type type() const { return T; }
using LLSD::Impl::assign; // Unhiding base class virtuals...
virtual void assign(LLSD::Impl*& var, DataRef value) {
if (shared())
{
@ -349,6 +350,10 @@ namespace
virtual LLSD::Boolean asBoolean() const { return !mData.empty(); }
virtual bool has(const LLSD::String&) const;
using LLSD::Impl::get; // Unhiding get(LLSD::Integer)
using LLSD::Impl::erase; // Unhiding erase(LLSD::Integer)
using LLSD::Impl::ref; // Unhiding ref(LLSD::Integer)
virtual LLSD get(const LLSD::String&) const;
LLSD& insert(const LLSD::String& k, const LLSD& v);
virtual void erase(const LLSD::String&);
@ -439,6 +444,9 @@ namespace
virtual LLSD::Boolean asBoolean() const { return !mData.empty(); }
using LLSD::Impl::get; // Unhiding get(LLSD::String)
using LLSD::Impl::erase; // Unhiding erase(LLSD::String)
using LLSD::Impl::ref; // Unhiding ref(LLSD::String)
virtual int size() const;
virtual LLSD get(LLSD::Integer) const;
void set(LLSD::Integer, const LLSD&);

View File

@ -0,0 +1,38 @@
/**
* @file llsingleton.cpp
* @author Brad Kittenbrink
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
*
* Copyright (c) 2009-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llsingleton.h"
std::map<std::string, void *> LLSingletonRegistry::sSingletonMap;

View File

@ -33,7 +33,30 @@
#include "llerror.h" // *TODO: eliminate this
#include <typeinfo>
#include <boost/noncopyable.hpp>
#include <boost/any.hpp>
/// @brief A global registry of all singletons to prevent duplicate allocations
/// across shared library boundaries
class LL_COMMON_API LLSingletonRegistry {
private:
typedef std::map<std::string, void *> TypeMap;
static TypeMap sSingletonMap;
public:
template<typename T> static void * & get()
{
std::string name(typeid(T).name());
if(0 == sSingletonMap.count(name))
{
sSingletonMap[name] = NULL;
}
return sSingletonMap[typeid(T).name()];
}
};
// LLSingleton implements the getInstance() method part of the Singleton
// pattern. It can't make the derived class constructors protected, though, so
@ -107,8 +130,16 @@ public:
static SingletonInstanceData& getData()
{
void * & registry = LLSingletonRegistry::get<DERIVED_TYPE>();
static SingletonInstanceData data;
return data;
// *TODO - look into making this threadsafe
if(NULL == registry)
{
registry = &data;
}
return *static_cast<SingletonInstanceData *>(registry);
}
static DERIVED_TYPE* getInstance()
@ -143,7 +174,14 @@ public:
{
return *getInstance();
}
// Has this singleton been created uet?
// Use this to avoid accessing singletons before the can safely be constructed
static bool instanceExists()
{
return getData().mInitState == INITIALIZED;
}
// Has this singleton already been deleted?
// Use this to avoid accessing singletons from a static object's destructor
static bool destroyed()

View File

@ -36,7 +36,7 @@
const S32 LL_VERSION_MAJOR = 1;
const S32 LL_VERSION_MINOR = 29;
const S32 LL_VERSION_PATCH = 0;
const S32 LL_VERSION_BUILD = 120909;
const S32 LL_VERSION_BUILD = 0;
const char * const LL_CHANNEL = "Second Life Server";

View File

@ -54,7 +54,8 @@ enum EDragAndDropType
DAD_BODYPART = 11,
DAD_ANIMATION = 12,
DAD_GESTURE = 13,
DAD_COUNT = 14, // number of types in this enum
DAD_LINK = 14,
DAD_COUNT = 15, // number of types in this enum
};
// Reasons for drags to be denied.

View File

@ -310,6 +310,7 @@ LLInventoryItem::LLInventoryItem(
{
LLStringUtil::replaceNonstandardASCII(mDescription, ' ');
LLStringUtil::replaceChar(mDescription, '|', ' ');
mPermissions.initMasks(inv_type);
}
LLInventoryItem::LLInventoryItem() :
@ -432,6 +433,9 @@ void LLInventoryItem::setDescription(const std::string& d)
void LLInventoryItem::setPermissions(const LLPermissions& perm)
{
mPermissions = perm;
// Override permissions to unrestricted if this is a landmark
mPermissions.initMasks(mInventoryType);
}
void LLInventoryItem::setInventoryType(LLInventoryType::EType inv_type)
@ -503,6 +507,7 @@ BOOL LLInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32
mType = static_cast<LLAssetType::EType>(type);
msg->getS8(block, "InvType", type, block_num);
mInventoryType = static_cast<LLInventoryType::EType>(type);
mPermissions.initMasks(mInventoryType);
msg->getU32Fast(block, _PREHASH_Flags, mFlags, block_num);
@ -693,6 +698,9 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
lldebugs << "Resetting inventory type for " << mUUID << llendl;
mInventoryType = LLInventoryType::defaultForAssetType(mType);
}
mPermissions.initMasks(mInventoryType);
return success;
}
@ -896,6 +904,9 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream)
lldebugs << "Resetting inventory type for " << mUUID << llendl;
mInventoryType = LLInventoryType::defaultForAssetType(mType);
}
mPermissions.initMasks(mInventoryType);
return success;
}
@ -1118,6 +1129,8 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd)
mInventoryType = LLInventoryType::defaultForAssetType(mType);
}
mPermissions.initMasks(mInventoryType);
return true;
fail:
return false;
@ -1624,7 +1637,7 @@ LLSD ll_create_sd_from_inventory_category(LLPointer<LLInventoryCategory> cat)
rv[INV_PARENT_ID_LABEL] = cat->getParentUUID();
rv[INV_NAME_LABEL] = cat->getName();
rv[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(cat->getType());
if(LLAssetType::AT_NONE != cat->getPreferredType())
if(LLAssetType::lookupIsProtectedCategoryType(cat->getPreferredType()))
{
rv[INV_PREFERRED_TYPE_LABEL] =
LLAssetType::lookup(cat->getPreferredType());

View File

@ -44,9 +44,23 @@ static const std::string empty_string;
///----------------------------------------------------------------------------
struct InventoryEntry : public LLDictionaryEntry
{
InventoryEntry(const std::string &name,
const std::string &human_name,
int num_asset_types = 0, ...);
InventoryEntry(const std::string &name, // unlike asset type names, not limited to 8 characters; need not match asset type names
const std::string &human_name, // for decoding to human readable form; put any and as many printable characters you want in each one.
int num_asset_types = 0, ...)
:
LLDictionaryEntry(name),
mHumanName(human_name)
{
va_list argp;
va_start(argp, num_asset_types);
// Read in local textures
for (U8 i=0; i < num_asset_types; i++)
{
LLAssetType::EType t = (LLAssetType::EType)va_arg(argp,int);
mAssetTypes.push_back(t);
}
}
const std::string mHumanName;
typedef std::vector<LLAssetType::EType> asset_vec_t;
asset_vec_t mAssetTypes;
@ -115,25 +129,35 @@ DEFAULT_ASSET_FOR_INV_TYPE[LLAssetType::AT_COUNT] =
LLInventoryType::IT_GESTURE, // AT_GESTURE
LLInventoryType::IT_NONE, // AT_SIMSTATE
LLInventoryType::IT_FAVORITE, // AT_FAVORITE
LLInventoryType::IT_NONE, // AT_LINK
LLInventoryType::IT_NONE, // AT_LINK_FOLDER
};
InventoryEntry::InventoryEntry(const std::string &name,
const std::string &human_name,
int num_asset_types, ...) :
LLDictionaryEntry(name),
mHumanName(human_name)
{
va_list argp;
va_start(argp, num_asset_types);
// Read in local textures
for (U8 i=0; i < num_asset_types; i++)
{
LLAssetType::EType t = (LLAssetType::EType)va_arg(argp,int);
mAssetTypes.push_back(t);
}
}
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_ENSEMBLE
LLInventoryType::IT_CATEGORY, // AT_CURRENT_OUTFIT
LLInventoryType::IT_CATEGORY, // AT_OUTFIT
LLInventoryType::IT_CATEGORY, // AT_MY_OUTFITS
};
// static
const std::string &LLInventoryType::lookup(EType type)
@ -173,6 +197,21 @@ LLInventoryType::EType LLInventoryType::defaultForAssetType(LLAssetType::EType a
}
}
// add any types that we don't want the user to be able to change permissions on.
// static
bool LLInventoryType::cannotRestrictPermissions(LLInventoryType::EType type)
{
switch(type)
{
case IT_CALLINGCARD:
case IT_LANDMARK:
return true;
default:
return false;
}
}
bool inventory_and_asset_types_match(LLInventoryType::EType inventory_type,
LLAssetType::EType asset_type)
{

View File

@ -83,10 +83,13 @@ public:
// return the default inventory for the given asset type.
static EType defaultForAssetType(LLAssetType::EType asset_type);
// true if this type cannot have restricted permissions.
static bool cannotRestrictPermissions(EType type);
private:
// don't instantiate or derive one of these objects
LLInventoryType() {}
~LLInventoryType() {}
LLInventoryType( void );
~LLInventoryType( void );
};
// helper function that returns true if inventory type and asset type

View File

@ -447,8 +447,10 @@ public:
BOOL getAllowFly() const
{ return (mParcelFlags & PF_ALLOW_FLY) ? TRUE : FALSE; }
// Remove permission restrictions for creating landmarks.
// We should eventually remove this flag completely.
BOOL getAllowLandmark() const
{ return (mParcelFlags & PF_ALLOW_LANDMARK) ? TRUE : FALSE; }
{ return TRUE; }
BOOL getAllowGroupScripts() const
{ return (mParcelFlags & PF_ALLOW_GROUP_SCRIPTS) ? TRUE : FALSE; }

View File

@ -83,6 +83,17 @@ void LLPermissions::initMasks(PermissionMask base, PermissionMask owner,
fix();
}
// ! BACKWARDS COMPATIBILITY ! Override masks for inventory types that
// no longer can have restricted permissions. This takes care of previous
// version landmarks that could have had no copy/mod/transfer bits set.
void LLPermissions::initMasks(LLInventoryType::EType type)
{
if (LLInventoryType::cannotRestrictPermissions(type))
{
initMasks(PERM_ALL, PERM_ALL, PERM_ALL, PERM_ALL, PERM_ALL);
}
}
BOOL LLPermissions::getOwnership(LLUUID& owner_id, BOOL& is_group_owned) const
{
if(mOwner.notNull())

View File

@ -38,6 +38,7 @@
#include "lluuid.h"
#include "llxmlnode.h"
#include "reflective.h"
#include "llinventorytype.h"
// prototypes
class LLMessageSystem;
@ -129,6 +130,8 @@ public:
void initMasks(PermissionMask base, PermissionMask owner,
PermissionMask everyone, PermissionMask group,
PermissionMask next);
// adjust permissions based on inventory type.
void initMasks(LLInventoryType::EType type);
//
// ACCESSORS

View File

@ -32,9 +32,6 @@
#ifndef LL_LLPERMISSIONSFLAGS_H
#define LL_LLPERMISSIONSFLAGS_H
// llpermissionsflags.h
// Copyright 2002, Linden Research, Inc.
//
// Flags for various permissions bits.
// Shared between viewer and simulator.

View File

@ -10,6 +10,7 @@ include_directories(
)
set(llmath_SOURCE_FILES
llbbox.cpp
llbboxlocal.cpp
llcamera.cpp
llcoordframe.cpp
@ -39,6 +40,7 @@ set(llmath_HEADER_FILES
camera.h
coordframe.h
llbbox.h
llbboxlocal.h
llcamera.h
llcoord.h

162
indra/llmath/llbbox.cpp Normal file
View File

@ -0,0 +1,162 @@
/**
* @file llbbox.cpp
* @brief General purpose bounding box class (Not axis aligned)
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "linden_common.h"
// self include
#include "llbbox.h"
// library includes
#include "m4math.h"
void LLBBox::addPointLocal(const LLVector3& p)
{
if (mEmpty)
{
mMinLocal = p;
mMaxLocal = p;
mEmpty = FALSE;
}
else
{
mMinLocal.mV[VX] = llmin( p.mV[VX], mMinLocal.mV[VX] );
mMinLocal.mV[VY] = llmin( p.mV[VY], mMinLocal.mV[VY] );
mMinLocal.mV[VZ] = llmin( p.mV[VZ], mMinLocal.mV[VZ] );
mMaxLocal.mV[VX] = llmax( p.mV[VX], mMaxLocal.mV[VX] );
mMaxLocal.mV[VY] = llmax( p.mV[VY], mMaxLocal.mV[VY] );
mMaxLocal.mV[VZ] = llmax( p.mV[VZ], mMaxLocal.mV[VZ] );
}
}
void LLBBox::addPointAgent( LLVector3 p)
{
p -= mPosAgent;
p.rotVec( ~mRotation );
addPointLocal( p );
}
void LLBBox::addBBoxAgent(const LLBBox& b)
{
if (mEmpty)
{
mPosAgent = b.mPosAgent;
mRotation = b.mRotation;
mMinLocal.clearVec();
mMaxLocal.clearVec();
}
LLVector3 vertex[8];
vertex[0].setVec( b.mMinLocal.mV[VX], b.mMinLocal.mV[VY], b.mMinLocal.mV[VZ] );
vertex[1].setVec( b.mMinLocal.mV[VX], b.mMinLocal.mV[VY], b.mMaxLocal.mV[VZ] );
vertex[2].setVec( b.mMinLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMinLocal.mV[VZ] );
vertex[3].setVec( b.mMinLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMaxLocal.mV[VZ] );
vertex[4].setVec( b.mMaxLocal.mV[VX], b.mMinLocal.mV[VY], b.mMinLocal.mV[VZ] );
vertex[5].setVec( b.mMaxLocal.mV[VX], b.mMinLocal.mV[VY], b.mMaxLocal.mV[VZ] );
vertex[6].setVec( b.mMaxLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMinLocal.mV[VZ] );
vertex[7].setVec( b.mMaxLocal.mV[VX], b.mMaxLocal.mV[VY], b.mMaxLocal.mV[VZ] );
LLMatrix4 m( b.mRotation );
m.translate( b.mPosAgent );
m.translate( -mPosAgent );
m.rotate( ~mRotation );
for( S32 i=0; i<8; i++ )
{
addPointLocal( vertex[i] * m );
}
}
void LLBBox::expand( F32 delta )
{
mMinLocal.mV[VX] -= delta;
mMinLocal.mV[VY] -= delta;
mMinLocal.mV[VZ] -= delta;
mMaxLocal.mV[VX] += delta;
mMaxLocal.mV[VY] += delta;
mMaxLocal.mV[VZ] += delta;
}
LLVector3 LLBBox::localToAgent(const LLVector3& v) const
{
LLMatrix4 m( mRotation );
m.translate( mPosAgent );
return v * m;
}
LLVector3 LLBBox::agentToLocal(const LLVector3& v) const
{
LLMatrix4 m;
m.translate( -mPosAgent );
m.rotate( ~mRotation ); // inverse rotation
return v * m;
}
LLVector3 LLBBox::localToAgentBasis(const LLVector3& v) const
{
LLMatrix4 m( mRotation );
return v * m;
}
LLVector3 LLBBox::agentToLocalBasis(const LLVector3& v) const
{
LLMatrix4 m( ~mRotation ); // inverse rotation
return v * m;
}
BOOL LLBBox::containsPointLocal(const LLVector3& p) const
{
if ( (p.mV[VX] < mMinLocal.mV[VX])
||(p.mV[VX] > mMaxLocal.mV[VX])
||(p.mV[VY] < mMinLocal.mV[VY])
||(p.mV[VY] > mMaxLocal.mV[VY])
||(p.mV[VZ] < mMinLocal.mV[VZ])
||(p.mV[VZ] > mMaxLocal.mV[VZ]))
{
return FALSE;
}
return TRUE;
}
BOOL LLBBox::containsPointAgent(const LLVector3& p) const
{
LLVector3 point_local = agentToLocal(p);
return containsPointLocal(point_local);
}
/*
LLBBox operator*(const LLBBox &a, const LLMatrix4 &b)
{
return LLBBox( a.mMin * b, a.mMax * b );
}
*/

103
indra/llmath/llbbox.h Normal file
View File

@ -0,0 +1,103 @@
/**
* @file llbbox.h
* @brief General purpose bounding box class
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LL_BBOX_H
#define LL_BBOX_H
#include "v3math.h"
#include "llquaternion.h"
// Note: "local space" for an LLBBox is defined relative to agent space in terms of
// a translation followed by a rotation. There is no scale term since the LLBBox's min and
// max are not necessarily symetrical and define their own extents.
class LLBBox
{
public:
LLBBox() {mEmpty = TRUE;}
LLBBox( const LLVector3& pos_agent,
const LLQuaternion& rot,
const LLVector3& min_local,
const LLVector3& max_local )
:
mMinLocal( min_local ), mMaxLocal( max_local ), mPosAgent(pos_agent), mRotation( rot), mEmpty( TRUE )
{}
// Default copy constructor is OK.
const LLVector3& getPositionAgent() const { return mPosAgent; }
const LLQuaternion& getRotation() const { return mRotation; }
const LLVector3& getMinLocal() const { return mMinLocal; }
void setMinLocal( const LLVector3& min ) { mMinLocal = min; }
const LLVector3& getMaxLocal() const { return mMaxLocal; }
void setMaxLocal( const LLVector3& max ) { mMaxLocal = max; }
LLVector3 getCenterLocal() const { return (mMaxLocal - mMinLocal) * 0.5f + mMinLocal; }
LLVector3 getCenterAgent() const { return localToAgent( getCenterLocal() ); }
LLVector3 getExtentLocal() const { return mMaxLocal - mMinLocal; }
BOOL containsPointLocal(const LLVector3& p) const;
BOOL containsPointAgent(const LLVector3& p) const;
void addPointAgent(LLVector3 p);
void addBBoxAgent(const LLBBox& b);
void addPointLocal(const LLVector3& p);
void addBBoxLocal(const LLBBox& b) { addPointLocal( b.mMinLocal ); addPointLocal( b.mMaxLocal ); }
void expand( F32 delta );
LLVector3 localToAgent( const LLVector3& v ) const;
LLVector3 agentToLocal( const LLVector3& v ) const;
// Changes rotation but not position
LLVector3 localToAgentBasis(const LLVector3& v) const;
LLVector3 agentToLocalBasis(const LLVector3& v) const;
// friend LLBBox operator*(const LLBBox& a, const LLMatrix4& b);
private:
LLVector3 mMinLocal;
LLVector3 mMaxLocal;
LLVector3 mPosAgent; // Position relative to Agent's Region
LLQuaternion mRotation;
BOOL mEmpty; // Nothing has been added to this bbox yet
};
//LLBBox operator*(const LLBBox &a, const LLMatrix4 &b);
#endif // LL_BBOX_H

View File

@ -53,9 +53,6 @@ public:
LLVector3 getCenter() const { return (mMax - mMin) * 0.5f + mMin; }
LLVector3 getExtent() const { return mMax - mMin; }
BOOL containsPoint(const LLVector3& p) const;
BOOL intersects(const LLBBoxLocal& b) const;
void addPoint(const LLVector3& p);
void addBBox(const LLBBoxLocal& b) { addPoint( b.mMin ); addPoint( b.mMax ); }

View File

@ -65,11 +65,10 @@ public:
};
template <class T>
class LLOctreeTraveler : public LLTreeTraveler<T>
class LLOctreeTraveler
{
public:
virtual void traverse(const LLTreeNode<T>* node);
virtual void visit(const LLTreeNode<T>* state) { }
virtual void traverse(const LLOctreeNode<T>* node);
virtual void visit(const LLOctreeNode<T>* branch) = 0;
};
@ -700,19 +699,16 @@ public:
}
};
//========================
// LLOctreeTraveler
//========================
template <class T>
void LLOctreeTraveler<T>::traverse(const LLTreeNode<T>* tree_node)
void LLOctreeTraveler<T>::traverse(const LLOctreeNode<T>* node)
{
const LLOctreeNode<T>* node = (const LLOctreeNode<T>*) tree_node;
node->accept(this);
for (U32 i = 0; i < node->getChildCount(); i++)
{
traverse(node->getChild(i));
}
}
#endif

View File

@ -71,10 +71,10 @@ public:
void setValue(const LLSD& sd)
{
mLeft = sd[0].asInteger();
mTop = sd[1].asInteger();
mRight = sd[2].asInteger();
mBottom = sd[3].asInteger();
mLeft = (Type)sd[0].asInteger();
mTop = (Type)sd[1].asInteger();
mRight = (Type)sd[2].asInteger();
mBottom = (Type)sd[3].asInteger();
}
LLSD getValue() const

View File

@ -1025,12 +1025,12 @@ LLSD LLAssetStorage::getPendingDetails(LLAssetStorage::ERequestType rt,
{
const request_list_t* requests = getRequestList(rt);
LLSD sd;
sd["requests"] = getPendingDetails(requests, asset_type, detail_prefix);
sd["requests"] = getPendingDetailsImpl(requests, asset_type, detail_prefix);
return sd;
}
// virtual
LLSD LLAssetStorage::getPendingDetails(const LLAssetStorage::request_list_t* requests,
LLSD LLAssetStorage::getPendingDetailsImpl(const LLAssetStorage::request_list_t* requests,
LLAssetType::EType asset_type,
const std::string& detail_prefix) const
{
@ -1113,11 +1113,11 @@ LLSD LLAssetStorage::getPendingRequest(LLAssetStorage::ERequestType rt,
const LLUUID& asset_id) const
{
const request_list_t* requests = getRequestList(rt);
return getPendingRequest(requests, asset_type, asset_id);
return getPendingRequestImpl(requests, asset_type, asset_id);
}
// virtual
LLSD LLAssetStorage::getPendingRequest(const LLAssetStorage::request_list_t* requests,
LLSD LLAssetStorage::getPendingRequestImpl(const LLAssetStorage::request_list_t* requests,
LLAssetType::EType asset_type,
const LLUUID& asset_id) const
{
@ -1136,7 +1136,7 @@ bool LLAssetStorage::deletePendingRequest(LLAssetStorage::ERequestType rt,
const LLUUID& asset_id)
{
request_list_t* requests = getRequestList(rt);
if (deletePendingRequest(requests, asset_type, asset_id))
if (deletePendingRequestImpl(requests, asset_type, asset_id))
{
llinfos << "Asset " << getRequestName(rt) << " request for "
<< asset_id << "." << LLAssetType::lookup(asset_type)
@ -1147,7 +1147,7 @@ bool LLAssetStorage::deletePendingRequest(LLAssetStorage::ERequestType rt,
}
// virtual
bool LLAssetStorage::deletePendingRequest(LLAssetStorage::request_list_t* requests,
bool LLAssetStorage::deletePendingRequestImpl(LLAssetStorage::request_list_t* requests,
LLAssetType::EType asset_type,
const LLUUID& asset_id)
{

View File

@ -306,15 +306,15 @@ public:
void markAssetToxic( const LLUUID& uuid );
protected:
virtual LLSD getPendingDetails(const request_list_t* requests,
virtual LLSD getPendingDetailsImpl(const request_list_t* requests,
LLAssetType::EType asset_type,
const std::string& detail_prefix) const;
virtual LLSD getPendingRequest(const request_list_t* requests,
virtual LLSD getPendingRequestImpl(const request_list_t* requests,
LLAssetType::EType asset_type,
const LLUUID& asset_id) const;
virtual bool deletePendingRequest(request_list_t* requests,
virtual bool deletePendingRequestImpl(request_list_t* requests,
LLAssetType::EType asset_type,
const LLUUID& asset_id);

View File

@ -120,7 +120,7 @@ LLCurl::Responder::~Responder()
}
// virtual
void LLCurl::Responder::error(
void LLCurl::Responder::errorWithContent(
U32 status,
const std::string& reason,
const LLSD&)
@ -161,7 +161,7 @@ void LLCurl::Responder::completed(U32 status, const std::string& reason, const L
}
else
{
error(status, reason, content);
errorWithContent(status, reason, content);
}
}

View File

@ -85,7 +85,7 @@ public:
return((200 <= status) && (status < 300));
}
virtual void error(
virtual void errorWithContent(
U32 status,
const std::string& reason,
const LLSD& content);

View File

@ -626,7 +626,7 @@ LLSD LLHTTPAssetStorage::getPendingRequest(LLAssetStorage::ERequestType rt,
const request_list_t* running = getRunningList(rt);
if (running)
{
LLSD sd = LLAssetStorage::getPendingRequest(running, asset_type, asset_id);
LLSD sd = LLAssetStorage::getPendingRequestImpl(running, asset_type, asset_id);
if (sd)
{
sd["is_running"] = true;

View File

@ -62,6 +62,8 @@ public:
virtual ~LLHTTPAssetStorage();
using LLAssetStorage::storeAssetData; // Unhiding virtuals...
virtual void storeAssetData(
const LLUUID& uuid,
LLAssetType::EType atype,

View File

@ -98,19 +98,19 @@ namespace {
}
// virtual
LLSD LLHTTPNode::get() const
LLSD LLHTTPNode::simpleGet() const
{
throw NotImplemented();
}
// virtual
LLSD LLHTTPNode::put(const LLSD& input) const
LLSD LLHTTPNode::simplePut(const LLSD& input) const
{
throw NotImplemented();
}
// virtual
LLSD LLHTTPNode::post(const LLSD& input) const
LLSD LLHTTPNode::simplePost(const LLSD& input) const
{
throw NotImplemented();
}
@ -121,7 +121,7 @@ void LLHTTPNode::get(LLHTTPNode::ResponsePtr response, const LLSD& context) cons
{
try
{
response->result(get());
response->result(simpleGet());
}
catch (NotImplemented)
{
@ -134,7 +134,7 @@ void LLHTTPNode::put(LLHTTPNode::ResponsePtr response, const LLSD& context, cons
{
try
{
response->result(put(input));
response->result(simplePut(input));
}
catch (NotImplemented)
{
@ -147,7 +147,7 @@ void LLHTTPNode::post(LLHTTPNode::ResponsePtr response, const LLSD& context, con
{
try
{
response->result(post(input));
response->result(simplePost(input));
}
catch (NotImplemented)
{
@ -160,7 +160,7 @@ void LLHTTPNode::del(LLHTTPNode::ResponsePtr response, const LLSD& context) cons
{
try
{
response->result(del(context));
response->result(simpleDel(context));
}
catch (NotImplemented)
{
@ -170,7 +170,7 @@ void LLHTTPNode::del(LLHTTPNode::ResponsePtr response, const LLSD& context) cons
}
// virtual
LLSD LLHTTPNode::del(const LLSD&) const
LLSD LLHTTPNode::simpleDel(const LLSD&) const
{
throw NotImplemented();
}
@ -388,7 +388,7 @@ LLHTTPNode::Response::~Response()
{
}
void LLHTTPNode::Response::status(S32 code)
void LLHTTPNode::Response::statusUnknownError(S32 code)
{
status(code, "Unknown Error");
}

View File

@ -84,10 +84,10 @@ public:
//@{
public:
virtual LLSD get() const;
virtual LLSD put(const LLSD& input) const;
virtual LLSD post(const LLSD& input) const;
virtual LLSD del(const LLSD& context) const;
virtual LLSD simpleGet() const;
virtual LLSD simplePut(const LLSD& input) const;
virtual LLSD simplePost(const LLSD& input) const;
virtual LLSD simpleDel(const LLSD& context) const;
/**
* @brief Abstract Base Class declaring Response interface.
@ -117,7 +117,7 @@ public:
/**
* @brief Return no body, just status code and 'UNKNOWN ERROR'.
*/
virtual void status(S32 code);
virtual void statusUnknownError(S32 code);
virtual void notFound(const std::string& message);
virtual void notFound();
@ -293,6 +293,7 @@ public:
void result(const LLSD& result);
void extendedResult(S32 code, const std::string& body, const LLSD& headers);
void status(S32 code, const std::string& message);
void print(std::ostream& out) const;

View File

@ -105,6 +105,7 @@ private:
// from LLHTTPNode::Response
virtual void result(const LLSD&);
virtual void extendedResult(S32 code, const std::string& body, const LLSD& headers);
virtual void status(S32 code, const std::string& message);
void nullPipe();

View File

@ -82,6 +82,7 @@ public:
public:
VerifiedDestinationResponder(ResponsePtr data, const LLSD& content);
virtual void result(const LLSD& content);
virtual void error(U32 status, const std::string& reason);
private:
void retry();

View File

@ -56,7 +56,7 @@ public:
desc.source(__FILE__, __LINE__);
}
virtual LLSD get() const
virtual LLSD simpleGet() const
{
LLSD result;
LLApp* app = LLApp::instance();
@ -82,7 +82,7 @@ public:
desc.source(__FILE__, __LINE__);
}
virtual LLSD get() const
virtual LLSD simpleGet() const
{
return LLApp::instance()->getOptionData(
LLApp::PRIORITY_RUNTIME_OVERRIDE);

View File

@ -62,7 +62,7 @@ public:
desc.source(__FILE__, __LINE__);
}
virtual LLSD get() const
virtual LLSD simpleGet() const
{
LLSD result = "hello";
return result;
@ -86,7 +86,7 @@ public:
desc.source(__FILE__, __LINE__);
}
virtual LLSD post(const LLSD& params) const
virtual LLSD simplePost(const LLSD& params) const
{
return params;
}

View File

@ -94,7 +94,7 @@ void LLSDMessage::EventResponder::result(const LLSD& data)
}
}
void LLSDMessage::EventResponder::error(U32 status, const std::string& reason, const LLSD& content)
void LLSDMessage::EventResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
{
// If our caller passed an empty errorPump name, they're not
// listening: "default error handling is acceptable." Only post to an
@ -138,7 +138,7 @@ bool LLSDMessage::ResponderAdapter::listener(const LLSD& payload, bool success)
}
else
{
mResponder->error(payload["status"].asInteger(), payload["reason"], payload["content"]);
mResponder->errorWithContent(payload["status"].asInteger(), payload["reason"], payload["content"]);
}
/*---------------- MUST BE LAST STATEMENT BEFORE RETURN ----------------*/

View File

@ -133,7 +133,7 @@ private:
{}
virtual void result(const LLSD& data);
virtual void error(U32 status, const std::string& reason, const LLSD& content);
virtual void errorWithContent(U32 status, const std::string& reason, const LLSD& content);
private:
LLEventPumps& mPumps;

View File

@ -296,10 +296,10 @@ bool is_asset_id_knowable(LLAssetType::EType type)
case LLAssetType::AT_FAVORITE:
case LLAssetType::AT_LINK:
case LLAssetType::AT_LINK_FOLDER:
rv = true;
break;
default:
break;
rv = true;
break;
default:
break;
}
return rv;
}

View File

@ -34,7 +34,7 @@ void LLCurl::Responder::completed(U32 status, std::basic_string<char, std::char_
}
else
{
error(status, reason, mContent);
errorWithContent(status, reason, mContent);
}
}
@ -51,7 +51,7 @@ void LLCurl::Responder::completedRaw(unsigned,
{
}
void LLCurl::Responder::error(unsigned,
void LLCurl::Responder::errorWithContent(unsigned,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&,
LLSD const&)
{

View File

@ -26,7 +26,7 @@ include_directories(
set(llrender_SOURCE_FILES
llcubemap.cpp
llfont.cpp
llfontfreetype.cpp
llfontgl.cpp
llfontbitmapcache.cpp
llfontregistry.cpp
@ -36,6 +36,7 @@ set(llrender_SOURCE_FILES
llpostprocess.cpp
llrendersphere.cpp
llshadermgr.cpp
lltexture.cpp
llvertexbuffer.cpp
)
@ -44,7 +45,7 @@ set(llrender_HEADER_FILES
llcubemap.h
llfontgl.h
llfont.h
llfontfreetype.h
llfontbitmapcache.h
llfontregistry.h
llgl.h
@ -58,6 +59,7 @@ set(llrender_HEADER_FILES
llrender.h
llrendersphere.h
llshadermgr.h
lltexture.h
llvertexbuffer.h
)

View File

@ -36,7 +36,7 @@
#include <vector>
// Maintain a collection of bitmaps containing rendered glyphs.
// Generalizes the single-bitmap logic from LLFont and LLFontGL.
// Generalizes the single-bitmap logic from LLFontFreetype and LLFontGL.
class LLFontBitmapCache: public LLRefCount
{
public:

View File

@ -0,0 +1,630 @@
/**
* @file llfontfreetype.cpp
* @brief Freetype font library wrapper
*
* $LicenseInfo:firstyear=2002&license=viewergpl$
*
* Copyright (c) 2002-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llfontfreetype.h"
// Freetype stuff
#include <ft2build.h>
// For some reason, this won't work if it's not wrapped in the ifdef
#ifdef FT_FREETYPE_H
#include FT_FREETYPE_H
#endif
#include "llerror.h"
#include "llimage.h"
//#include "llimagej2c.h"
#include "llmath.h" // Linden math
#include "llstring.h"
//#include "imdebug.h"
#include "llfontbitmapcache.h"
#include "llgl.h"
FT_Render_Mode gFontRenderMode = FT_RENDER_MODE_NORMAL;
LLFontManager *gFontManagerp = NULL;
FT_Library gFTLibrary = NULL;
//static
void LLFontManager::initClass()
{
gFontManagerp = new LLFontManager;
}
//static
void LLFontManager::cleanupClass()
{
delete gFontManagerp;
gFontManagerp = NULL;
}
LLFontManager::LLFontManager()
{
int error;
error = FT_Init_FreeType(&gFTLibrary);
if (error)
{
// Clean up freetype libs.
llerrs << "Freetype initialization failure!" << llendl;
FT_Done_FreeType(gFTLibrary);
}
}
LLFontManager::~LLFontManager()
{
FT_Done_FreeType(gFTLibrary);
}
LLFontGlyphInfo::LLFontGlyphInfo(U32 index)
: mGlyphIndex(index),
mXBitmapOffset(0), // Offset to the origin in the bitmap
mYBitmapOffset(0), // Offset to the origin in the bitmap
mXBearing(0), // Distance from baseline to left in pixels
mYBearing(0), // Distance from baseline to top in pixels
mWidth(0), // In pixels
mHeight(0), // In pixels
mXAdvance(0.f), // In pixels
mYAdvance(0.f), // In pixels
mIsRendered(FALSE),
mMetricsValid(FALSE)
{
}
LLFontFreetype::LLFontFreetype()
: mFontBitmapCachep(new LLFontBitmapCache),
mValid(FALSE),
mAscender(0.f),
mDescender(0.f),
mLineHeight(0.f),
mIsFallback(FALSE),
mFTFace(NULL),
mRenderGlyphCount(0),
mAddGlyphCount(0),
mPointSize(0)
{
}
LLFontFreetype::~LLFontFreetype()
{
// Clean up freetype libs.
if (mFTFace)
FT_Done_Face(mFTFace);
mFTFace = NULL;
// Delete glyph info
std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer());
// mFontBitmapCachep will be cleaned up by LLPointer destructor.
// mFallbackFonts cleaned up by LLPointer destructor
}
BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, S32 components, BOOL is_fallback)
{
// Don't leak face objects. This is also needed to deal with
// changed font file names.
if (mFTFace)
{
FT_Done_Face(mFTFace);
mFTFace = NULL;
}
int error;
error = FT_New_Face( gFTLibrary,
filename.c_str(),
0,
&mFTFace );
if (error)
{
return FALSE;
}
mIsFallback = is_fallback;
F32 pixels_per_em = (point_size / 72.f)*vert_dpi; // Size in inches * dpi
error = FT_Set_Char_Size(mFTFace, /* handle to face object */
0, /* char_width in 1/64th of points */
(S32)(point_size*64), /* char_height in 1/64th of points */
(U32)horz_dpi, /* horizontal device resolution */
(U32)vert_dpi); /* vertical device resolution */
if (error)
{
// Clean up freetype libs.
FT_Done_Face(mFTFace);
mFTFace = NULL;
return FALSE;
}
F32 y_max, y_min, x_max, x_min;
F32 ems_per_unit = 1.f/ mFTFace->units_per_EM;
F32 pixels_per_unit = pixels_per_em * ems_per_unit;
// Get size of bbox in pixels
y_max = mFTFace->bbox.yMax * pixels_per_unit;
y_min = mFTFace->bbox.yMin * pixels_per_unit;
x_max = mFTFace->bbox.xMax * pixels_per_unit;
x_min = mFTFace->bbox.xMin * pixels_per_unit;
mAscender = mFTFace->ascender * pixels_per_unit;
mDescender = -mFTFace->descender * pixels_per_unit;
mLineHeight = mFTFace->height * pixels_per_unit;
S32 max_char_width = llround(0.5f + (x_max - x_min));
S32 max_char_height = llround(0.5f + (y_max - y_min));
mFontBitmapCachep->init(components, max_char_width, max_char_height);
if (!mFTFace->charmap)
{
//llinfos << " no unicode encoding, set whatever encoding there is..." << llendl;
FT_Set_Charmap(mFTFace, mFTFace->charmaps[0]);
}
if (!mIsFallback)
{
// Add the default glyph
addGlyph(0, 0);
}
mName = filename;
mPointSize = point_size;
return TRUE;
}
void LLFontFreetype::setFallbackFonts(const font_vector_t &font)
{
mFallbackFonts = font;
}
const LLFontFreetype::font_vector_t &LLFontFreetype::getFallbackFonts() const
{
return mFallbackFonts;
}
F32 LLFontFreetype::getLineHeight() const
{
return mLineHeight;
}
F32 LLFontFreetype::getAscenderHeight() const
{
return mAscender;
}
F32 LLFontFreetype::getDescenderHeight() const
{
return mDescender;
}
F32 LLFontFreetype::getXAdvance(llwchar wch) const
{
if (mFTFace == NULL)
return 0.0;
//llassert(!mIsFallback);
U32 glyph_index;
// Return existing info only if it is current
LLFontGlyphInfo* gi = getGlyphInfo(wch);
if (gi && gi->mMetricsValid)
{
return gi->mXAdvance;
}
const LLFontFreetype* fontp = this;
// Initialize char to glyph map
glyph_index = FT_Get_Char_Index(mFTFace, wch);
if (glyph_index == 0)
{
font_vector_t::const_iterator iter;
for(iter = mFallbackFonts.begin(); (iter != mFallbackFonts.end()) && (glyph_index == 0); iter++)
{
glyph_index = FT_Get_Char_Index((*iter)->mFTFace, wch);
if(glyph_index)
{
fontp = *iter;
}
}
}
if (glyph_index)
{
// This font has this glyph
fontp->renderGlyph(glyph_index);
// Create the entry if it's not there
char_glyph_info_map_t::iterator iter2 = mCharGlyphInfoMap.find(wch);
if (iter2 == mCharGlyphInfoMap.end())
{
gi = new LLFontGlyphInfo(glyph_index);
insertGlyphInfo(wch, gi);
}
else
{
gi = iter2->second;
}
gi->mWidth = fontp->mFTFace->glyph->bitmap.width;
gi->mHeight = fontp->mFTFace->glyph->bitmap.rows;
// Convert these from 26.6 units to float pixels.
gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
gi->mMetricsValid = TRUE;
return gi->mXAdvance;
}
else
{
gi = get_if_there(mCharGlyphInfoMap, (llwchar)0, (LLFontGlyphInfo*)NULL);
if (gi)
{
return gi->mXAdvance;
}
}
// Last ditch fallback - no glyphs defined at all.
return (F32)mFontBitmapCachep->getMaxCharWidth();
}
F32 LLFontFreetype::getXKerning(llwchar char_left, llwchar char_right) const
{
if (mFTFace == NULL)
return 0.0;
//llassert(!mIsFallback);
LLFontGlyphInfo* left_glyph_info = get_if_there(mCharGlyphInfoMap, char_left, (LLFontGlyphInfo*)NULL);
U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0;
// Kern this puppy.
LLFontGlyphInfo* right_glyph_info = get_if_there(mCharGlyphInfoMap, char_right, (LLFontGlyphInfo*)NULL);
U32 right_glyph = right_glyph_info ? right_glyph_info->mGlyphIndex : 0;
FT_Vector delta;
llverify(!FT_Get_Kerning(mFTFace, left_glyph, right_glyph, ft_kerning_unfitted, &delta));
return delta.x*(1.f/64.f);
}
BOOL LLFontFreetype::hasGlyph(llwchar wch) const
{
llassert(!mIsFallback);
const LLFontGlyphInfo* gi = getGlyphInfo(wch);
if (gi && gi->mIsRendered)
{
return TRUE;
}
else
{
return FALSE;
}
}
BOOL LLFontFreetype::addChar(llwchar wch) const
{
if (mFTFace == NULL)
return FALSE;
llassert(!mIsFallback);
//lldebugs << "Adding new glyph for " << wch << " to font" << llendl;
FT_UInt glyph_index;
// Initialize char to glyph map
glyph_index = FT_Get_Char_Index(mFTFace, wch);
if (glyph_index == 0)
{
//llinfos << "Trying to add glyph from fallback font!" << llendl
font_vector_t::const_iterator iter;
for(iter = mFallbackFonts.begin(); iter != mFallbackFonts.end(); iter++)
{
glyph_index = FT_Get_Char_Index((*iter)->mFTFace, wch);
if (glyph_index)
{
addGlyphFromFont(*iter, wch, glyph_index);
return TRUE;
}
}
}
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter == mCharGlyphInfoMap.end() || !(iter->second->mIsRendered))
{
BOOL result = addGlyph(wch, glyph_index);
return result;
}
return FALSE;
}
BOOL LLFontFreetype::addGlyph(llwchar wch, U32 glyph_index) const
{
return addGlyphFromFont(this, wch, glyph_index);
}
BOOL LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, llwchar wch, U32 glyph_index) const
{
if (mFTFace == NULL)
return FALSE;
llassert(!mIsFallback);
fontp->renderGlyph(glyph_index);
S32 width = fontp->mFTFace->glyph->bitmap.width;
S32 height = fontp->mFTFace->glyph->bitmap.rows;
S32 pos_x, pos_y;
S32 bitmap_num;
mFontBitmapCachep->nextOpenPos(width, pos_x, pos_y, bitmap_num);
mAddGlyphCount++;
LLFontGlyphInfo* gi = new LLFontGlyphInfo(glyph_index);
gi->mXBitmapOffset = pos_x;
gi->mYBitmapOffset = pos_y;
gi->mBitmapNum = bitmap_num;
gi->mWidth = width;
gi->mHeight = height;
gi->mXBearing = fontp->mFTFace->glyph->bitmap_left;
gi->mYBearing = fontp->mFTFace->glyph->bitmap_top;
// Convert these from 26.6 units to float pixels.
gi->mXAdvance = fontp->mFTFace->glyph->advance.x / 64.f;
gi->mYAdvance = fontp->mFTFace->glyph->advance.y / 64.f;
gi->mIsRendered = TRUE;
gi->mMetricsValid = TRUE;
insertGlyphInfo(wch, gi);
llassert(fontp->mFTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO
|| fontp->mFTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY);
if (fontp->mFTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO
|| fontp->mFTFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY)
{
U8 *buffer_data = fontp->mFTFace->glyph->bitmap.buffer;
S32 buffer_row_stride = fontp->mFTFace->glyph->bitmap.pitch;
U8 *tmp_graydata = NULL;
if (fontp->mFTFace->glyph->bitmap.pixel_mode
== FT_PIXEL_MODE_MONO)
{
// need to expand 1-bit bitmap to 8-bit graymap.
tmp_graydata = new U8[width * height];
S32 xpos, ypos;
for (ypos = 0; ypos < height; ++ypos)
{
S32 bm_row_offset = buffer_row_stride * ypos;
for (xpos = 0; xpos < width; ++xpos)
{
U32 bm_col_offsetbyte = xpos / 8;
U32 bm_col_offsetbit = 7 - (xpos % 8);
U32 bit =
!!(buffer_data[bm_row_offset
+ bm_col_offsetbyte
] & (1 << bm_col_offsetbit) );
tmp_graydata[width*ypos + xpos] =
255 * bit;
}
}
// use newly-built graymap.
buffer_data = tmp_graydata;
buffer_row_stride = width;
}
switch (mFontBitmapCachep->getNumComponents())
{
case 1:
mFontBitmapCachep->getImageRaw(bitmap_num)->setSubImage(pos_x,
pos_y,
width,
height,
buffer_data,
buffer_row_stride,
TRUE);
break;
case 2:
setSubImageLuminanceAlpha(pos_x,
pos_y,
bitmap_num,
width,
height,
buffer_data,
buffer_row_stride);
break;
default:
break;
}
if (tmp_graydata)
delete[] tmp_graydata;
} else {
// we don't know how to handle this pixel format from FreeType;
// omit it from the font-image.
}
return TRUE;
}
LLFontGlyphInfo* LLFontFreetype::getGlyphInfo(llwchar wch) const
{
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter != mCharGlyphInfoMap.end())
{
return iter->second;
}
return NULL;
}
void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const
{
char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.find(wch);
if (iter != mCharGlyphInfoMap.end())
{
delete iter->second;
iter->second = gi;
}
else
{
mCharGlyphInfoMap[wch] = gi;
}
}
void LLFontFreetype::renderGlyph(U32 glyph_index) const
{
if (mFTFace == NULL)
return;
int error = FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT );
llassert(!error);
error = FT_Render_Glyph(mFTFace->glyph, gFontRenderMode);
mRenderGlyphCount++;
llassert(!error);
}
void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi)
{
if (!mIsFallback)
{
// This is the head of the list - need to rebuild ourself and all fallbacks.
loadFace(mName, mPointSize, vert_dpi ,horz_dpi, mFontBitmapCachep->getNumComponents(), mIsFallback);
if (mFallbackFonts.empty())
{
llwarns << "LLFontGL::reset(), no fallback fonts present" << llendl;
}
else
{
for(font_vector_t::iterator it = mFallbackFonts.begin();
it != mFallbackFonts.end();
++it)
{
(*it)->reset(vert_dpi, horz_dpi);
}
}
}
resetBitmapCache();
}
void LLFontFreetype::resetBitmapCache()
{
// Iterate through glyphs and clear the mIsRendered flag
for (char_glyph_info_map_t::iterator iter = mCharGlyphInfoMap.begin();
iter != mCharGlyphInfoMap.end(); ++iter)
{
iter->second->mIsRendered = FALSE;
//FIXME: this is only strictly necessary when resetting the entire font,
//not just flushing the bitmap
iter->second->mMetricsValid = FALSE;
}
mFontBitmapCachep->reset();
// Add the empty glyph`5
addGlyph(0, 0);
}
void LLFontFreetype::destroyGL()
{
mFontBitmapCachep->destroyGL();
}
BOOL LLFontFreetype::getIsFallback() const
{
return mIsFallback;
}
const std::string &LLFontFreetype::getName() const
{
return mName;
}
F32 LLFontFreetype::getPointSize() const
{
return mPointSize;
}
const LLPointer<LLFontBitmapCache> LLFontFreetype::getFontBitmapCache() const
{
return mFontBitmapCachep;
}
void LLFontFreetype::setStyle(U8 style)
{
mStyle = style;
}
U8 LLFontFreetype::getStyle() const
{
return mStyle;
}
void LLFontFreetype::setSubImageLuminanceAlpha(U32 x, U32 y, U32 bitmap_num, U32 width, U32 height, U8 *data, S32 stride) const
{
LLImageRaw *image_raw = mFontBitmapCachep->getImageRaw(bitmap_num);
llassert(!mIsFallback);
llassert(image_raw && (image_raw->getComponents() == 2));
U8 *target = image_raw->getData();
if (!data)
{
return;
}
if (0 == stride)
stride = width;
U32 i, j;
U32 to_offset;
U32 from_offset;
U32 target_width = image_raw->getWidth();
for (i = 0; i < height; i++)
{
to_offset = (y + i)*target_width + x;
from_offset = (height - 1 - i)*stride;
for (j = 0; j < width; j++)
{
*(target + to_offset*2 + 1) = *(data + from_offset);
to_offset++;
from_offset++;
}
}
}

View File

@ -0,0 +1,380 @@
/**
* @file llfontfreetype.h
* @brief Font library wrapper
*
* $LicenseInfo:firstyear=2002&license=viewergpl$
*
* Copyright (c) 2002-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LL_LLFONTFREETYPE_H
#define LL_LLFONTFREETYPE_H
#include <map>
#include "llpointer.h"
#include "llstl.h"
#include "llimagegl.h"
#include "llfontbitmapcache.h"
// Hack. FT_Face is just a typedef for a pointer to a struct,
// but there's no simple forward declarations file for FreeType,
// and the main include file is 200K.
// We'll forward declare the struct here. JC
struct FT_FaceRec_;
typedef struct FT_FaceRec_* LLFT_Face;
class LLFontManager
{
public:
static void initClass();
static void cleanupClass();
private:
LLFontManager();
~LLFontManager();
};
class LLFontGlyphInfo
{
public:
LLFontGlyphInfo(U32 index);
U32 mGlyphIndex;
// Metrics
S32 mWidth; // In pixels
S32 mHeight; // In pixels
F32 mXAdvance; // In pixels
F32 mYAdvance; // In pixels
BOOL mMetricsValid; // We have up-to-date metrics for this glyph
// Information for actually rendering
BOOL mIsRendered; // We actually have rendered this glyph
S32 mXBitmapOffset; // Offset to the origin in the bitmap
S32 mYBitmapOffset; // Offset to the origin in the bitmap
S32 mXBearing; // Distance from baseline to left in pixels
S32 mYBearing; // Distance from baseline to top in pixels
S32 mBitmapNum; // Which bitmap in the bitmap cache contains this glyph
};
extern LLFontManager *gFontManagerp;
class LLFontFreetype : public LLRefCount
{
public:
LLFontFreetype();
~LLFontFreetype();
// is_fallback should be true for fallback fonts that aren't used
// to render directly (Unicode backup, primarily)
BOOL loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, S32 components, BOOL is_fallback);
typedef std::vector<LLPointer<LLFontFreetype> > font_vector_t;
void setFallbackFonts(const font_vector_t &font);
const font_vector_t &getFallbackFonts() const;
// Global font metrics - in units of pixels
F32 getLineHeight() const;
F32 getAscenderHeight() const;
F32 getDescenderHeight() const;
// For a lowercase "g":
//
// ------------------------------
// ^ ^
// | |
// xxx x |Ascender
// x x v |
// --------- xxxx-------------- Baseline
// ^ x |
// | Descender x |
// v xxxx |LineHeight
// ----------------------- |
// v
// ------------------------------
enum
{
FIRST_CHAR = 32,
NUM_CHARS = 127 - 32,
LAST_CHAR_BASIC = 127,
// Need full 8-bit ascii range for spanish
NUM_CHARS_FULL = 255 - 32,
LAST_CHAR_FULL = 255
};
F32 getXAdvance(llwchar wc) const;
F32 getXKerning(llwchar char_left, llwchar char_right) const; // Get the kerning between the two characters
BOOL hasGlyph(llwchar wch) const; // Has a glyph for this character
BOOL addChar(llwchar wch) const; // Add a new character to the font if necessary
BOOL addGlyph(llwchar wch, U32 glyph_index) const; // Add a new glyph to the existing font
BOOL addGlyphFromFont(const LLFontFreetype *fontp, llwchar wch, U32 glyph_index) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found)
LLFontGlyphInfo* getGlyphInfo(llwchar wch) const;
void insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const;
void renderGlyph(U32 glyph_index) const;
void reset(F32 vert_dpi, F32 horz_dpi);
void resetBitmapCache();
void destroyGL();
BOOL getIsFallback() const;
const std::string& getName() const;
F32 getPointSize() const;
const LLPointer<LLFontBitmapCache> getFontBitmapCache() const;
void setStyle(U8 style);
U8 getStyle() const;
private:
void setSubImageLuminanceAlpha(U32 x, U32 y, U32 bitmap_num, U32 width, U32 height, U8 *data, S32 stride = 0) const;
std::string mName;
U8 mStyle;
F32 mPointSize;
F32 mAscender;
F32 mDescender;
F32 mLineHeight;
LLFT_Face mFTFace;
BOOL mIsFallback;
font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars)
BOOL mValid;
typedef std::map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t;
mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap
mutable LLPointer<LLFontBitmapCache> mFontBitmapCachep;
mutable S32 mRenderGlyphCount;
mutable S32 mAddGlyphCount;
};
#endif // LL_FONTFREETYPE_H
/**
* @file llfontfreetype.h
* @brief Font library wrapper
*
* $LicenseInfo:firstyear=2002&license=viewergpl$
*
* Copyright (c) 2002-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LL_LLFONTFREETYPE_H
#define LL_LLFONTFREETYPE_H
#include <map>
#include "llpointer.h"
#include "llstl.h"
#include "llimagegl.h"
#include "llfontbitmapcache.h"
// Hack. FT_Face is just a typedef for a pointer to a struct,
// but there's no simple forward declarations file for FreeType,
// and the main include file is 200K.
// We'll forward declare the struct here. JC
struct FT_FaceRec_;
typedef struct FT_FaceRec_* LLFT_Face;
class LLFontManager
{
public:
static void initClass();
static void cleanupClass();
private:
LLFontManager();
~LLFontManager();
};
class LLFontGlyphInfo
{
public:
LLFontGlyphInfo(U32 index);
U32 mGlyphIndex;
// Metrics
S32 mWidth; // In pixels
S32 mHeight; // In pixels
F32 mXAdvance; // In pixels
F32 mYAdvance; // In pixels
BOOL mMetricsValid; // We have up-to-date metrics for this glyph
// Information for actually rendering
BOOL mIsRendered; // We actually have rendered this glyph
S32 mXBitmapOffset; // Offset to the origin in the bitmap
S32 mYBitmapOffset; // Offset to the origin in the bitmap
S32 mXBearing; // Distance from baseline to left in pixels
S32 mYBearing; // Distance from baseline to top in pixels
S32 mBitmapNum; // Which bitmap in the bitmap cache contains this glyph
};
extern LLFontManager *gFontManagerp;
class LLFontFreetype : public LLRefCount
{
public:
LLFontFreetype();
~LLFontFreetype();
// is_fallback should be true for fallback fonts that aren't used
// to render directly (Unicode backup, primarily)
BOOL loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, S32 components, BOOL is_fallback);
typedef std::vector<LLPointer<LLFontFreetype> > font_vector_t;
void setFallbackFonts(const font_vector_t &font);
const font_vector_t &getFallbackFonts() const;
// Global font metrics - in units of pixels
F32 getLineHeight() const;
F32 getAscenderHeight() const;
F32 getDescenderHeight() const;
// For a lowercase "g":
//
// ------------------------------
// ^ ^
// | |
// xxx x |Ascender
// x x v |
// --------- xxxx-------------- Baseline
// ^ x |
// | Descender x |
// v xxxx |LineHeight
// ----------------------- |
// v
// ------------------------------
enum
{
FIRST_CHAR = 32,
NUM_CHARS = 127 - 32,
LAST_CHAR_BASIC = 127,
// Need full 8-bit ascii range for spanish
NUM_CHARS_FULL = 255 - 32,
LAST_CHAR_FULL = 255
};
F32 getXAdvance(llwchar wc) const;
F32 getXKerning(llwchar char_left, llwchar char_right) const; // Get the kerning between the two characters
BOOL hasGlyph(llwchar wch) const; // Has a glyph for this character
BOOL addChar(llwchar wch) const; // Add a new character to the font if necessary
BOOL addGlyph(llwchar wch, U32 glyph_index) const; // Add a new glyph to the existing font
BOOL addGlyphFromFont(const LLFontFreetype *fontp, llwchar wch, U32 glyph_index) const; // Add a glyph from this font to the other (returns the glyph_index, 0 if not found)
LLFontGlyphInfo* getGlyphInfo(llwchar wch) const;
void insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const;
void renderGlyph(U32 glyph_index) const;
void reset(F32 vert_dpi, F32 horz_dpi);
void resetBitmapCache();
void destroyGL();
BOOL getIsFallback() const;
const std::string& getName() const;
F32 getPointSize() const;
const LLPointer<LLFontBitmapCache> getFontBitmapCache() const;
void setStyle(U8 style);
U8 getStyle() const;
private:
void setSubImageLuminanceAlpha(U32 x, U32 y, U32 bitmap_num, U32 width, U32 height, U8 *data, S32 stride = 0) const;
std::string mName;
U8 mStyle;
F32 mPointSize;
F32 mAscender;
F32 mDescender;
F32 mLineHeight;
LLFT_Face mFTFace;
BOOL mIsFallback;
font_vector_t mFallbackFonts; // A list of fallback fonts to look for glyphs in (for Unicode chars)
BOOL mValid;
typedef std::map<llwchar, LLFontGlyphInfo*> char_glyph_info_map_t;
mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap
mutable LLPointer<LLFontBitmapCache> mFontBitmapCachep;
mutable S32 mRenderGlyphCount;
mutable S32 mAddGlyphCount;
};
#endif // LL_FONTFREETYPE_H

File diff suppressed because it is too large Load Diff

View File

@ -35,21 +35,21 @@
#define LL_LLFONTGL_H
#include "llcoord.h"
#include "llfont.h"
#include "llfontregistry.h"
#include "llimagegl.h"
#include "llpointer.h"
#include "llrect.h"
#include "v2math.h"
class LLColor4;
class LLImageGL;
// Key used to request a font.
class LLFontDescriptor;
class LLFontFreetype;
// Structure used to store previously requested fonts.
class LLFontRegistry;
class LLFontGL : public LLFont
class LLFontGL
{
public:
enum HAlign
@ -85,130 +85,72 @@ public:
DROP_SHADOW,
DROP_SHADOW_SOFT
};
// Takes a string with potentially several flags, i.e. "NORMAL|BOLD|ITALIC"
static U8 getStyleFromString(const std::string &style);
LLFontGL();
LLFontGL(const LLFontGL &source);
~LLFontGL();
void init(); // Internal init, or reinitialization
void reset(); // Reset a font after GL cleanup. ONLY works on an already loaded font.
LLFontGL &operator=(const LLFontGL &source);
void destroyGL();
static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale,
const std::string& app_dir,
const std::vector<std::string>& xui_paths,
bool create_gl_textures = true);
BOOL loadFace(const std::string& filename, F32 point_size, const F32 vert_dpi, const F32 horz_dpi, const S32 components, BOOL is_fallback);
S32 render(const LLWString &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign = LEFT, VAlign valign = BASELINE, U8 style = NORMAL,
ShadowType shadow = NO_SHADOW, S32 max_chars = S32_MAX, S32 max_pixels = S32_MAX, F32* right_x=NULL, BOOL use_embedded = FALSE, BOOL use_ellipses = FALSE) const;
S32 render(const LLWString &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color) const;
// renderUTF8 does a conversion, so is slower!
S32 renderUTF8(const std::string &text, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses) const;
S32 renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color) const;
S32 renderUTF8(const std::string &text, S32 begin_offset, S32 x, S32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style = NORMAL, ShadowType shadow = NO_SHADOW) const;
// font metrics - override for LLFontFreetype that returns units of virtual pixels
F32 getLineHeight() const;
F32 getAscenderHeight() const;
F32 getDescenderHeight() const;
S32 getWidth(const std::string& utf8text) const;
S32 getWidth(const llwchar* wchars) const;
S32 getWidth(const std::string& utf8text, S32 offset, S32 max_chars ) const;
S32 getWidth(const llwchar* wchars, S32 offset, S32 max_chars, BOOL use_embedded = FALSE) const;
F32 getWidthF32(const std::string& utf8text) const;
F32 getWidthF32(const llwchar* wchars) const;
F32 getWidthF32(const std::string& text, S32 offset, S32 max_chars ) const;
F32 getWidthF32(const llwchar* wchars, S32 offset, S32 max_chars, BOOL use_embedded = FALSE ) const;
// The following are called often, frequently with large buffers, so do not use a string interface
// Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels
S32 maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars = S32_MAX, BOOL end_on_word_boundary = FALSE, BOOL use_embedded = FALSE, F32* drawn_pixels = NULL) const;
// Returns the index of the first complete characters from text that can be drawn in max_pixels
// given that the character at start_pos should be the last character (or as close to last as possible).
S32 firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_len, S32 start_pos=S32_MAX, S32 max_chars = S32_MAX) const;
// Returns the index of the character closest to pixel position x (ignoring text to the right of max_pixels and max_chars)
S32 charFromPixelOffset(const llwchar* wchars, S32 char_offset, F32 x, F32 max_pixels=F32_MAX, S32 max_chars = S32_MAX, BOOL round = TRUE, BOOL use_embedded = FALSE) const;
void addEmbeddedChar( llwchar wc, LLTexture* image, const std::string& label) const;
void addEmbeddedChar( llwchar wc, LLTexture* image, const LLWString& label) const;
void removeEmbeddedChar( llwchar wc ) const;
BOOL addChar(const llwchar wch) const;
const LLFontDescriptor& getFontDesc() const;
static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, const std::vector<std::string>& xui_paths, bool create_gl_textures = true);
// Load sans-serif, sans-serif-small, etc.
// Slow, requires multiple seconds to load fonts.
static bool loadDefaultFonts();
static void destroyDefaultFonts();
static void destroyAllGL();
void destroyGL();
/* virtual*/ BOOL loadFace(const std::string& filename,
const F32 point_size, const F32 vert_dpi, const F32 horz_dpi,
const S32 components, BOOL is_fallback);
S32 renderUTF8(const std::string &text, const S32 begin_offset,
S32 x, S32 y,
const LLColor4 &color) const
{
return renderUTF8(text, begin_offset, (F32)x, (F32)y, color,
LEFT, BASELINE, NORMAL, NO_SHADOW,
S32_MAX, S32_MAX, NULL, FALSE);
}
S32 renderUTF8(const std::string &text, const S32 begin_offset,
S32 x, S32 y,
const LLColor4 &color,
HAlign halign, VAlign valign, U8 style = NORMAL, ShadowType shadow = NO_SHADOW) const
{
return renderUTF8(text, begin_offset, (F32)x, (F32)y, color,
halign, valign, style, shadow,
S32_MAX, S32_MAX, NULL, FALSE);
}
// renderUTF8 does a conversion, so is slower!
S32 renderUTF8(const std::string &text,
S32 begin_offset,
F32 x, F32 y,
const LLColor4 &color,
HAlign halign,
VAlign valign,
U8 style,
ShadowType shadow,
S32 max_chars,
S32 max_pixels,
F32* right_x,
BOOL use_ellipses) const;
S32 render(const LLWString &text, const S32 begin_offset,
F32 x, F32 y,
const LLColor4 &color) const
{
return render(text, begin_offset, x, y, color,
LEFT, BASELINE, NORMAL, NO_SHADOW,
S32_MAX, S32_MAX, NULL, FALSE, FALSE);
}
S32 render(const LLWString &text,
S32 begin_offset,
F32 x, F32 y,
const LLColor4 &color,
HAlign halign = LEFT,
VAlign valign = BASELINE,
U8 style = NORMAL,
ShadowType shadow = NO_SHADOW,
S32 max_chars = S32_MAX,
S32 max_pixels = S32_MAX,
F32* right_x=NULL,
BOOL use_embedded = FALSE,
BOOL use_ellipses = FALSE) const;
// font metrics - override for LLFont that returns units of virtual pixels
/*virtual*/ F32 getLineHeight() const { return (F32)llround(mLineHeight / sScaleY); }
/*virtual*/ F32 getAscenderHeight() const { return (F32)llround(mAscender / sScaleY); }
/*virtual*/ F32 getDescenderHeight() const { return (F32)llround(mDescender / sScaleY); }
virtual S32 getWidth(const std::string& utf8text) const;
virtual S32 getWidth(const llwchar* wchars) const;
virtual S32 getWidth(const std::string& utf8text, const S32 offset, const S32 max_chars ) const;
virtual S32 getWidth(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE) const;
virtual F32 getWidthF32(const std::string& utf8text) const;
virtual F32 getWidthF32(const llwchar* wchars) const;
virtual F32 getWidthF32(const std::string& text, const S32 offset, const S32 max_chars ) const;
virtual F32 getWidthF32(const llwchar* wchars, const S32 offset, const S32 max_chars, BOOL use_embedded = FALSE ) const;
// The following are called often, frequently with large buffers, so do not use a string interface
// Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels
virtual S32 maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars = S32_MAX,
BOOL end_on_word_boundary = FALSE, const BOOL use_embedded = FALSE,
F32* drawn_pixels = NULL) const;
// Returns the index of the first complete characters from text that can be drawn in max_pixels
// given that the character at start_pos should be the last character (or as close to last as possible).
virtual S32 firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_len, S32 start_pos=S32_MAX, S32 max_chars = S32_MAX) const;
// Returns the index of the character closest to pixel position x (ignoring text to the right of max_pixels and max_chars)
virtual S32 charFromPixelOffset(const llwchar* wchars, const S32 char_offset,
F32 x, F32 max_pixels=F32_MAX, S32 max_chars = S32_MAX,
BOOL round = TRUE, BOOL use_embedded = FALSE) const;
LLImageGL *getImageGL() const;
void addEmbeddedChar( llwchar wc, LLImageGL* image, const std::string& label) const;
void addEmbeddedChar( llwchar wc, LLImageGL* image, const LLWString& label) const;
void removeEmbeddedChar( llwchar wc ) const;
// Takes a string with potentially several flags, i.e. "NORMAL|BOLD|ITALIC"
static U8 getStyleFromString(const std::string &style);
static std::string nameFromFont(const LLFontGL* fontp);
@ -218,28 +160,7 @@ public:
static std::string nameFromVAlign(LLFontGL::VAlign align);
static LLFontGL::VAlign vAlignFromName(const std::string& name);
static void setFontDisplay(BOOL flag) { sDisplayFont = flag ; }
protected:
struct embedded_data_t
{
embedded_data_t(LLImageGL* image, const LLWString& label) : mImage(image), mLabel(label) {}
LLPointer<LLImageGL> mImage;
LLWString mLabel;
};
const embedded_data_t* getEmbeddedCharData(const llwchar wch) const;
F32 getEmbeddedCharAdvance(const embedded_data_t* ext_data) const;
void clearEmbeddedChars();
void renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const;
void drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4& color, U8 style, ShadowType shadow, F32 drop_shadow_fade) const;
public:
static F32 sVertDPI;
static F32 sHorizDPI;
static F32 sScaleX;
static F32 sScaleY;
static BOOL sDisplayFont ;
static std::string sAppDir; // For loading fonts
static void setFontDisplay(BOOL flag) { sDisplayFont = flag; }
static LLFontGL* getFontMonospace();
static LLFontGL* getFontSansSerifSmall();
@ -252,32 +173,50 @@ public:
// Use with legacy names like "SANSSERIF_SMALL" or "OCRA"
static LLFontGL* getFontByName(const std::string& name);
static LLColor4 sShadowColor;
friend class LLTextBillboard;
friend class LLHUDText;
protected:
/*virtual*/ BOOL addChar(const llwchar wch) const;
protected:
typedef std::map<llwchar,embedded_data_t*> embedded_map_t;
mutable embedded_map_t mEmbeddedChars;
LLFontDescriptor mFontDesc;
// Registry holds all instantiated fonts.
static LLFontRegistry* sFontRegistry;
public:
static std::string getFontPathLocal();
static std::string getFontPathSystem();
static LLCoordFont sCurOrigin;
static std::vector<LLCoordFont> sOriginStack;
const LLFontDescriptor &getFontDesc() const { return mFontDesc; }
void setFontDesc(const LLFontDescriptor& font_desc) { mFontDesc = font_desc; }
static LLColor4 sShadowColor;
static F32 sVertDPI;
static F32 sHorizDPI;
static F32 sScaleX;
static F32 sScaleY;
static BOOL sDisplayFont ;
static std::string sAppDir; // For loading fonts
private:
friend class LLFontRegistry;
friend class LLTextBillboard;
friend class LLHUDText;
LLFontGL(const LLFontGL &source);
LLFontGL &operator=(const LLFontGL &source);
LLFontDescriptor mFontDescriptor;
LLPointer<LLFontFreetype> mFontFreetype;
struct embedded_data_t
{
embedded_data_t(LLImageGL* image, const LLWString& label) : mImage(image), mLabel(label) {}
LLPointer<LLImageGL> mImage;
LLWString mLabel;
};
typedef std::map<llwchar,embedded_data_t*> embedded_map_t;
mutable embedded_map_t mEmbeddedChars;
const embedded_data_t* getEmbeddedCharData(llwchar wch) const;
F32 getEmbeddedCharAdvance(const embedded_data_t* ext_data) const;
void clearEmbeddedChars();
void renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const;
void drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4& color, U8 style, ShadowType shadow, F32 drop_shadow_fade) const;
// Registry holds all instantiated fonts.
static LLFontRegistry* sFontRegistry;
};
#endif

View File

@ -33,8 +33,9 @@
#include "linden_common.h"
#include "llgl.h"
#include "llfontregistry.h"
#include "llfontfreetype.h"
#include "llfontgl.h"
#include "llfontregistry.h"
#include <boost/tokenizer.hpp>
#include "llcontrol.h"
#include "lldir.h"
@ -104,7 +105,7 @@ bool removeSubString(std::string& str, const std::string& substr)
size_t pos = str.find(substr);
if (pos != string::npos)
{
str.replace(pos,substr.length(), "", 0);
str.erase(pos);
return true;
}
return false;
@ -382,7 +383,14 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc)
if (it != mFontMap.end())
{
llinfos << "-- matching font exists: " << nearest_exact_desc.getName() << " size " << nearest_exact_desc.getSize() << " style " << ((S32) nearest_exact_desc.getStyle()) << llendl;
return it->second;
// copying underlying Freetype font, and storing in LLFontGL with requested font descriptor
LLFontGL *font = new LLFontGL;
font->mFontDescriptor = desc;
font->mFontFreetype = it->second->mFontFreetype;
mFontMap[desc] = font;
return font;
}
// Build list of font names to look for.
@ -410,10 +418,11 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc)
llwarns << "createFont failed, no file names specified" << llendl;
return NULL;
}
LLFontList *fontlistp = new LLFontList;
LLFontFreetype::font_vector_t fontlist;
LLFontGL *result = NULL;
// Snarf all fonts we can into fontlistp. First will get pulled
// Snarf all fonts we can into fontlist. First will get pulled
// off the list and become the "head" font, set to non-fallback.
// Rest will consitute the fallback list.
BOOL is_first_found = TRUE;
@ -455,23 +464,28 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc)
is_first_found = false;
}
else
fontlistp->addAtEnd(fontp);
{
fontlist.push_back(fontp->mFontFreetype);
}
}
}
if (result && !fontlistp->empty())
if (result && !fontlist.empty())
{
result->setFallbackFont(fontlistp);
result->mFontFreetype->setFallbackFonts(fontlist);
}
norm_desc.setStyle(match_desc->getStyle());
if (result)
result->setFontDesc(norm_desc);
if (!result)
{
result->mFontFreetype->setStyle(match_desc->getStyle());
result->mFontDescriptor = desc;
}
else
{
llwarns << "createFont failed in some way" << llendl;
}
mFontMap[norm_desc] = result;
mFontMap[desc] = result;
return result;
}
@ -511,21 +525,19 @@ void LLFontRegistry::destroyGL()
}
}
LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& orig_desc)
LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& desc)
{
LLFontDescriptor norm_desc = orig_desc.normalize();
font_reg_map_t::iterator it = mFontMap.find(norm_desc);
font_reg_map_t::iterator it = mFontMap.find(desc);
if (it != mFontMap.end())
return it->second;
else
{
LLFontGL *fontp = createFont(orig_desc);
LLFontGL *fontp = createFont(desc);
if (!fontp)
{
llwarns << "getFont failed, name " << orig_desc.getName()
<<" style=[" << ((S32) orig_desc.getStyle()) << "]"
<< " size=[" << orig_desc.getSize() << "]" << llendl;
llwarns << "getFont failed, name " << desc.getName()
<<" style=[" << ((S32) desc.getStyle()) << "]"
<< " size=[" << desc.getSize() << "]" << llendl;
}
return fontp;
}
@ -653,3 +665,8 @@ void LLFontRegistry::dump()
}
}
}
const string_vec_t& LLFontRegistry::getUltimateFallbackList() const
{
return mUltimateFallbackList;
}

View File

@ -98,7 +98,7 @@ public:
void dump();
const string_vec_t& getUltimateFallbackList() const { return mUltimateFallbackList; }
const string_vec_t& getUltimateFallbackList() const;
private:
LLFontGL *createFont(const LLFontDescriptor& desc);

View File

@ -46,7 +46,6 @@
//----------------------------------------------------------------------------
const F32 MIN_TEXTURE_LIFETIME = 10.f;
//statics
@ -61,7 +60,7 @@ S32 LLImageGL::sCount = 0;
BOOL LLImageGL::sGlobalUseAnisotropic = FALSE;
F32 LLImageGL::sLastFrameTime = 0.f;
LLImageGL* LLImageGL::sDefaultGLTexture = NULL ;
std::set<LLImageGL*> LLImageGL::sImageList;
//**************************************************************************************
@ -264,6 +263,7 @@ void LLImageGL::restoreGL()
//----------------------------------------------------------------------------
//for server side use only.
//static
BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, BOOL usemipmaps)
{
@ -271,12 +271,14 @@ BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, BOOL usemipmaps)
return TRUE;
}
//for server side use only.
BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, U32 width, U32 height, U8 components, BOOL usemipmaps)
{
dest = new LLImageGL(width, height, components, usemipmaps);
return TRUE;
}
//for server side use only.
BOOL LLImageGL::create(LLPointer<LLImageGL>& dest, const LLImageRaw* imageraw, BOOL usemipmaps)
{
dest = new LLImageGL(imageraw, usemipmaps);
@ -331,7 +333,6 @@ void LLImageGL::init(BOOL usemipmaps)
#endif
mPickMask = NULL;
mTextureState = NO_DELETE ;
mTextureMemory = 0;
mLastBindTime = 0.f;
@ -351,8 +352,7 @@ void LLImageGL::init(BOOL usemipmaps)
mComponents = 0;
mMaxDiscardLevel = MAX_DISCARD_LEVEL;
mCurrentDiscardLevel = -1;
mDontDiscard = FALSE;
mCurrentDiscardLevel = -1;
mFormatInternal = -1;
mFormatPrimary = (LLGLenum) 0;
@ -362,6 +362,7 @@ void LLImageGL::init(BOOL usemipmaps)
mGLTextureCreated = FALSE ;
mIsMask = FALSE;
mNeedsAlphaAndPickMask = TRUE ;
}
void LLImageGL::cleanup()
@ -462,7 +463,7 @@ void LLImageGL::dump()
//----------------------------------------------------------------------------
void LLImageGL::updateBindStats(void) const
BOOL LLImageGL::updateBindStats(S32 tex_mem) const
{
if (mTexName != 0)
{
@ -474,38 +475,18 @@ void LLImageGL::updateBindStats(void) const
{
// we haven't accounted for this texture yet this frame
sUniqueCount++;
updateBoundTexMem(mTextureMemory);
updateBoundTexMem(tex_mem);
mLastBindTime = sLastFrameTime;
if(LLFastTimer::sMetricLog)
{
updateTestStats() ;
}
return TRUE ;
}
}
return FALSE ;
}
//virtual
void LLImageGL::updateTestStats(void) const
F32 LLImageGL::getTimePassedSinceLastBound()
{
}
//virtual
bool LLImageGL::bindError(const S32 stage) const
{
return false;
}
//virtual
bool LLImageGL::bindDefaultImage(const S32 stage) const
{
return false;
}
//virtual
void LLImageGL::forceImmediateUpdate()
{
return ;
return sLastFrameTime - mLastBindTime ;
}
void LLImageGL::setExplicitFormat( LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes )
@ -1052,7 +1033,6 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
mTextureMemory = getMipBytes(discard_level);
sGlobalTextureMemoryInBytes += mTextureMemory;
setActive() ;
// mark this as bound at this point, so we don't throw it out immediately
mLastBindTime = sLastFrameTime;
@ -1068,12 +1048,7 @@ BOOL LLImageGL::setDiscardLevel(S32 discard_level)
discard_level = llclamp(discard_level, 0, (S32)mMaxDiscardLevel);
if (mDontDiscard)
{
// don't discard!
return FALSE;
}
else if (discard_level == mCurrentDiscardLevel)
if (discard_level == mCurrentDiscardLevel)
{
// nothing to do
return FALSE;
@ -1255,8 +1230,7 @@ void LLImageGL::destroyGLTexture()
sGlobalTextureMemoryInBytes -= mTextureMemory;
mTextureMemory = 0;
LLImageGL::deleteTextures(1, &mTexName);
mTextureState = DELETED ;
LLImageGL::deleteTextures(1, &mTexName);
mTexName = 0;
mCurrentDiscardLevel = -1 ; //invalidate mCurrentDiscardLevel.
mGLTextureCreated = FALSE ;
@ -1383,6 +1357,11 @@ void LLImageGL::setTarget(const LLGLenum target, const LLTexUnit::eTextureType b
void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
{
if(!mNeedsAlphaAndPickMask)
{
return ;
}
if (mFormatType != GL_UNSIGNED_BYTE)
{
llwarns << "Cannot analyze alpha for image with format type " << std::hex << mFormatType << std::dec << llendl;
@ -1440,60 +1419,14 @@ void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
}
}
BOOL LLImageGL::isDeleted()
{
return mTextureState == DELETED ;
}
BOOL LLImageGL::isInactive()
{
return mTextureState == INACTIVE ;
}
BOOL LLImageGL::isDeletionCandidate()
{
return mTextureState == DELETION_CANDIDATE ;
}
void LLImageGL::setDeletionCandidate()
{
if(mTexName && (mTextureState == INACTIVE))
{
mTextureState = DELETION_CANDIDATE ;
}
}
void LLImageGL::forceActive()
{
mTextureState = ACTIVE ;
}
void LLImageGL::setActive()
{
if(mTextureState != NO_DELETE)
{
mTextureState = ACTIVE ;
}
}
//set the texture inactive
void LLImageGL::setInactive()
{
if(mTexName && (mTextureState == ACTIVE) && !getBoundRecently())
{
mTextureState = INACTIVE ;
}
}
//set the texture to stay in memory
void LLImageGL::setNoDelete()
{
mTextureState = NO_DELETE ;
}
//----------------------------------------------------------------------------
void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in)
{
if(!mNeedsAlphaAndPickMask)
{
return ;
}
if (mFormatType != GL_UNSIGNED_BYTE ||
mFormatPrimary != GL_RGBA)
{

View File

@ -57,8 +57,8 @@ public:
static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height);
static S32 dataFormatComponents(S32 dataformat);
void updateBindStats(void) const;
virtual void updateTestStats(void) const;
BOOL updateBindStats(S32 tex_mem) const ;
F32 getTimePassedSinceLastBound();
// needs to be called every frame
static void updateStats(F32 current_time);
@ -71,13 +71,14 @@ public:
static S32 updateBoundTexMem(const S32 delta);
static bool checkSize(S32 width, S32 height);
//for server side use only.
// Not currently necessary for LLImageGL, but required in some derived classes,
// so include for compatability
static BOOL create(LLPointer<LLImageGL>& dest, BOOL usemipmaps = TRUE);
static BOOL create(LLPointer<LLImageGL>& dest, U32 width, U32 height, U8 components, BOOL usemipmaps = TRUE);
static BOOL create(LLPointer<LLImageGL>& dest, const LLImageRaw* imageraw, BOOL usemipmaps = TRUE);
public:
LLImageGL(BOOL usemipmaps = TRUE);
LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps = TRUE);
@ -90,11 +91,9 @@ protected:
public:
virtual void dump(); // debugging info to llinfos
virtual bool bindError(const S32 stage = 0) const;
virtual bool bindDefaultImage(const S32 stage = 0) const;
virtual void forceImmediateUpdate() ;
void setSize(S32 width, S32 height, S32 ncomponents);
void setComponents(S32 ncomponents) { mComponents = (S8)ncomponents ;}
// These 3 functions currently wrap glGenTextures(), glDeleteTextures(), and glTexImage2D()
// for tracking purposes and will be deprecated in the future
@ -116,7 +115,6 @@ public:
void destroyGLTexture();
void setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
void dontDiscard() { mDontDiscard = 1; mTextureState = NO_DELETE; }
S32 getDiscardLevel() const { return mCurrentDiscardLevel; }
S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; }
@ -145,9 +143,7 @@ public:
void setGLTextureCreated (bool initialized) { mGLTextureCreated = initialized; }
BOOL getUseMipMaps() const { return mUseMipMaps; }
void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; }
BOOL getUseDiscard() const { return mUseMipMaps && !mDontDiscard; }
BOOL getDontDiscard() const { return mDontDiscard; }
void setUseMipMaps(BOOL usemips) { mUseMipMaps = usemips; }
BOOL isValidForSculpt(S32 discard_level, S32 image_width, S32 image_height, S32 ncomponents) ;
@ -168,19 +164,10 @@ public:
void setFilteringOption(LLTexUnit::eTextureFilterOptions option);
LLTexUnit::eTextureFilterOptions getFilteringOption(void) const { return mFilterOption; }
BOOL isDeleted() ;
BOOL isInactive() ;
BOOL isDeletionCandidate();
void setDeletionCandidate() ;
void setInactive() ;
void setActive() ;
void forceActive() ;
void setNoDelete() ;
protected:
void init(BOOL usemipmaps);
virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors
void setNeedsAlphaAndPickMask(BOOL need_mask) {mNeedsAlphaAndPickMask = need_mask;}
public:
// Various GL/Rendering options
S32 mTextureMemory;
@ -194,6 +181,7 @@ private:
S8 mAutoGenMips;
BOOL mIsMask;
BOOL mNeedsAlphaAndPickMask;
bool mGLTextureCreated ;
LLGLuint mTexName;
@ -210,28 +198,15 @@ protected:
S8 mComponents;
S8 mMaxDiscardLevel;
S8 mDontDiscard; // Keep full res version of this image (for UI, etc)
bool mTexOptionsDirty;
LLTexUnit::eTextureAddressMode mAddressMode; // Defaults to TAM_WRAP
LLTexUnit::eTextureFilterOptions mFilterOption; // Defaults to TFO_TRILINEAR
LLGLint mFormatInternal; // = GL internalformat
LLGLenum mFormatPrimary; // = GL format (pixel data format)
LLGLenum mFormatType;
BOOL mFormatSwapBytes;// if true, use glPixelStorei(GL_UNPACK_SWAP_BYTES, 1)
protected:
typedef enum
{
DELETED = 0, //removed from memory
DELETION_CANDIDATE, //ready to be removed from memory
INACTIVE, //not be used for the last certain period (i.e., 30 seconds).
ACTIVE, //just being used, can become inactive if not being used for a certain time (10 seconds).
NO_DELETE = 99 //stay in memory, can not be removed.
} LLGLTexureState;
LLGLTexureState mTextureState ;
// STATICS
public:
@ -249,6 +224,7 @@ public:
static U32 sBindCount; // Tracks number of texture binds for current frame
static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
static BOOL sGlobalUseAnisotropic;
static LLImageGL* sDefaultGLTexture ;
#if DEBUG_MISS
BOOL mMissed; // Missed on last bind?

View File

@ -38,6 +38,7 @@
#include "llcubemap.h"
#include "llimagegl.h"
#include "llrendertarget.h"
#include "lltexture.h"
LLRender gGL;
@ -177,20 +178,21 @@ void LLTexUnit::disable(void)
}
}
bool LLTexUnit::bind(LLImageGL* texture, bool forceBind)
bool LLTexUnit::bind(LLTexture* texture, bool forceBind)
{
stop_glerror();
if (mIndex < 0) return false;
gGL.flush();
if (texture == NULL)
LLImageGL* gl_tex = NULL ;
if (texture == NULL || !(gl_tex = texture->getGLTexture()))
{
llwarns << "NULL LLTexUnit::bind texture" << llendl;
return false;
}
if (!texture->getTexName()) //if texture does not exist
if (!gl_tex->getTexName()) //if texture does not exist
{
//if deleted, will re-generate it immediately
texture->forceImmediateUpdate() ;
@ -198,14 +200,57 @@ bool LLTexUnit::bind(LLImageGL* texture, bool forceBind)
return texture->bindDefaultImage(mIndex);
}
if ((mCurrTexture != gl_tex->getTexName()) || forceBind)
{
activate();
enable(gl_tex->getTarget());
mCurrTexture = gl_tex->getTexName();
glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture);
if(gl_tex->updateBindStats(gl_tex->mTextureMemory))
{
texture->setActive() ;
texture->updateBindStatsForTester() ;
}
mHasMipMaps = gl_tex->mHasMipMaps;
if (gl_tex->mTexOptionsDirty)
{
gl_tex->mTexOptionsDirty = false;
setTextureAddressMode(gl_tex->mAddressMode);
setTextureFilteringOption(gl_tex->mFilterOption);
}
}
return true;
}
bool LLTexUnit::bind(LLImageGL* texture, bool forceBind)
{
stop_glerror();
if (mIndex < 0) return false;
if(!texture)
{
llwarns << "NULL LLTexUnit::bind texture" << llendl;
return false;
}
if(!texture->getTexName())
{
if(LLImageGL::sDefaultGLTexture && LLImageGL::sDefaultGLTexture->getTexName())
{
return bind(LLImageGL::sDefaultGLTexture) ;
}
return false ;
}
gGL.flush();
if ((mCurrTexture != texture->getTexName()) || forceBind)
{
activate();
enable(texture->getTarget());
mCurrTexture = texture->getTexName();
glBindTexture(sGLTextureType[texture->getTarget()], mCurrTexture);
texture->updateBindStats();
texture->setActive() ;
texture->updateBindStats(texture->mTextureMemory);
mHasMipMaps = texture->mHasMipMaps;
if (texture->mTexOptionsDirty)
{
@ -238,7 +283,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
mCurrTexture = cubeMap->mImages[0]->getTexName();
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture);
mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps;
cubeMap->mImages[0]->updateBindStats();
cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory);
if (cubeMap->mImages[0]->mTexOptionsDirty)
{
cubeMap->mImages[0]->mTexOptionsDirty = false;
@ -279,15 +324,21 @@ bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth)
bool LLTexUnit::bindManual(eTextureType type, U32 texture, bool hasMips)
{
if (mIndex < 0 || mCurrTexture == texture) return false;
if (mIndex < 0)
{
return false;
}
gGL.flush();
activate();
enable(type);
mCurrTexture = texture;
glBindTexture(sGLTextureType[type], texture);
mHasMipMaps = hasMips;
if(mCurrTexture != texture)
{
gGL.flush();
activate();
enable(type);
mCurrTexture = texture;
glBindTexture(sGLTextureType[type], texture);
mHasMipMaps = hasMips;
}
return true;
}

View File

@ -51,6 +51,7 @@ class LLVertexBuffer;
class LLCubeMap;
class LLImageGL;
class LLRenderTarget;
class LLTexture ;
class LLTexUnit
{
@ -149,6 +150,7 @@ public:
// Binds the LLImageGL to this texture unit
// (automatically enables the unit for the LLImageGL's texture type)
bool bind(LLImageGL* texture, bool forceBind = false);
bool bind(LLTexture* texture, bool forceBind = false);
// Binds a cubemap to this texture unit
// (automatically enables the texture unit for cubemaps)

View File

@ -0,0 +1,37 @@
/**
* @file lltexture.cpp
*
* $LicenseInfo:firstyear=2000&license=viewergpl$
*
* Copyright (c) 2000-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "lltexture.h"
//virtual
LLTexture::~LLTexture()
{
}

View File

@ -0,0 +1,77 @@
/**
* @file lltexture.h
* @brief LLTexture definition
*
* This class acts as a wrapper for OpenGL calls.
* The goal of this class is to minimize the number of api calls due to legacy rendering
* code, to define an interface for a multiple rendering API abstraction of the UI
* rendering, and to abstract out direct rendering calls in a way that is cleaner and easier to maintain.
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LL_TEXTURE_H
#define LL_TEXTURE_H
#include "llrefcount.h"
class LLImageGL ;
class LLTexUnit ;
class LLFontGL ;
//
//this is an abstract class as the parent for the class LLViewerTexture
//through the following virtual functions, the class LLViewerTexture can be reached from /llrender.
//
class LLTexture : public LLRefCount
{
friend class LLTexUnit ;
friend class LLFontGL ;
protected:
virtual ~LLTexture();
public:
LLTexture(){}
//
//interfaces to access LLViewerTexture
//
virtual bool bindDefaultImage(const S32 stage = 0) const = 0 ;
virtual void forceImmediateUpdate() = 0 ;
virtual void setActive() = 0 ;
virtual S32 getWidth(S32 discard_level = -1) const = 0 ;
virtual S32 getHeight(S32 discard_level = -1) const = 0 ;
private:
//note: do not make this function public.
virtual LLImageGL* getGLTexture() const = 0 ;
virtual void updateBindStatsForTester() = 0 ;
};
#endif

View File

@ -37,6 +37,7 @@ set(llui_SOURCE_FILES
lldraghandle.cpp
lleditmenuhandler.cpp
llf32uictrl.cpp
llfiltereditor.cpp
llfloater.cpp
llfloaterreg.cpp
llflyoutbutton.cpp
@ -60,6 +61,7 @@ set(llui_SOURCE_FILES
llresizebar.cpp
llresizehandle.cpp
llresmgr.cpp
llrngwriter.cpp
llscrollbar.cpp
llscrollcontainer.cpp
llscrollingpanellist.cpp
@ -68,7 +70,7 @@ set(llui_SOURCE_FILES
llscrolllistctrl.cpp
llscrolllistitem.cpp
llsdparam.cpp
llsearcheditor.cpp
llsearcheditor.cpp
llslider.cpp
llsliderctrl.cpp
llspinctrl.cpp
@ -82,6 +84,7 @@ set(llui_SOURCE_FILES
lltextparser.cpp
lltrans.cpp
llui.cpp
lluicolor.cpp
lluicolortable.cpp
lluictrl.cpp
lluictrlfactory.cpp
@ -109,11 +112,13 @@ set(llui_HEADER_FILES
lldraghandle.h
lleditmenuhandler.h
llf32uictrl.h
llfiltereditor.h
llfloater.h
llfloaterreg.h
llflyoutbutton.h
llfocusmgr.h
llfunctorregistry.h
llhandle.h
llhtmlhelp.h
lliconctrl.h
llinitparam.h
@ -135,6 +140,7 @@ set(llui_HEADER_FILES
llresizebar.h
llresizehandle.h
llresmgr.h
llrngwriter.h
llsearcheditor.h
llscrollbar.h
llscrollcontainer.h
@ -156,6 +162,7 @@ set(llui_HEADER_FILES
lltexteditor.h
lltextparser.h
lltrans.h
lluicolor.h
lluicolortable.h
lluiconstants.h
lluictrlfactory.h

View File

@ -32,7 +32,6 @@
#include "linden_common.h"
#define INSTANTIATE_GETCHILD_BUTTON
#include "llbutton.h"
// Linden library includes
@ -53,7 +52,7 @@
#include "llrender.h"
#include "lluictrlfactory.h"
static LLDefaultWidgetRegistry::Register<LLButton> r("button");
static LLDefaultChildRegistry::Register<LLButton> r("button");
// globals loaded from settings.xml
S32 LLBUTTON_H_PAD = 0;
@ -61,11 +60,9 @@ S32 LLBUTTON_V_PAD = 0;
S32 BTN_HEIGHT_SMALL= 0;
S32 BTN_HEIGHT = 0;
template LLButton* LLView::getChild<LLButton>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
LLButton::Params::Params()
: label_selected("label_selected"), // requires is_toggle true
label_dropshadow("label_shadow", true),
label_shadow("label_shadow", true),
auto_resize("auto_resize", false),
image_unselected("image_unselected"),
image_selected("image_selected"),
@ -136,7 +133,7 @@ LLButton::LLButton(const LLButton::Params& p)
mImageOverlayAlignment(LLFontGL::hAlignFromName(p.image_overlay_alignment)),
mIsToggle(p.is_toggle),
mScaleImage(p.scale_image),
mDropShadowedText(p.label_dropshadow),
mDropShadowedText(p.label_shadow),
mAutoResize(p.auto_resize),
mHAlign(p.font_halign),
mLeftHPad(p.pad_left),
@ -146,7 +143,7 @@ LLButton::LLButton(const LLButton::Params& p)
mFadeWhenDisabled(FALSE)
{
static LLUICachedControl<S32> llbutton_orig_h_pad ("UIButtonOrigHPad", 0);
static Params default_params(LLUICtrlFactory::getDefaultParams<Params>());
static Params default_params(LLUICtrlFactory::getDefaultParams<LLButton>());
//if we aren't a picture_style button set label as name if not provided
if (!p.picture_style.isProvided() || !p.picture_style)
@ -328,25 +325,27 @@ BOOL LLButton::handleKeyHere(KEY key, MASK mask )
BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask)
{
// Route future Mouse messages here preemptively. (Release on mouse up.)
gFocusMgr.setMouseCapture( this );
if (hasTabStop() && !getIsChrome())
if (!childrenHandleMouseDown(x, y, mask))
{
setFocus(TRUE);
// Route future Mouse messages here preemptively. (Release on mouse up.)
gFocusMgr.setMouseCapture( this );
if (hasTabStop() && !getIsChrome())
{
setFocus(TRUE);
}
mMouseDownSignal(this, LLSD());
mMouseDownTimer.start();
mMouseDownFrame = (S32) LLFrameTimer::getFrameCount();
mMouseHeldDownCount = 0;
if (getSoundFlags() & MOUSE_DOWN)
{
make_ui_sound("UISndClick");
}
}
mMouseDownSignal(this, LLSD());
mMouseDownTimer.start();
mMouseDownFrame = (S32) LLFrameTimer::getFrameCount();
mMouseHeldDownCount = 0;
if (getSoundFlags() & MOUSE_DOWN)
{
make_ui_sound("UISndClick");
}
return TRUE;
}
@ -381,20 +380,26 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
LLUICtrl::onCommit();
}
}
else
{
childrenHandleMouseUp(x, y, mask);
}
return TRUE;
}
BOOL LLButton::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
// Route future Mouse messages here preemptively. (Release on mouse up.)
gFocusMgr.setMouseCapture( this );
if (hasTabStop() && !getIsChrome())
if (!childrenHandleRightMouseDown(x, y, mask))
{
setFocus(TRUE);
}
// Route future Mouse messages here preemptively. (Release on mouse up.)
gFocusMgr.setMouseCapture( this );
if (hasTabStop() && !getIsChrome())
{
setFocus(TRUE);
}
}
return TRUE;
}
@ -412,6 +417,10 @@ BOOL LLButton::handleRightMouseUp(S32 x, S32 y, MASK mask)
mRightClickSignal(this, getValue());
}
}
else
{
childrenHandleRightMouseUp(x, y, mask);
}
return TRUE;
}
@ -429,21 +438,23 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask)
BOOL LLButton::handleHover(S32 x, S32 y, MASK mask)
{
if (mMouseDownTimer.getStarted())
if (!childrenHandleHover(x, y, mask))
{
F32 elapsed = getHeldDownTime();
if( mHeldDownDelay <= elapsed && mHeldDownFrameDelay <= (S32)LLFrameTimer::getFrameCount() - mMouseDownFrame)
if (mMouseDownTimer.getStarted())
{
LLSD param;
param["count"] = mMouseHeldDownCount++;
mHeldDownSignal(this, param);
F32 elapsed = getHeldDownTime();
if( mHeldDownDelay <= elapsed && mHeldDownFrameDelay <= (S32)LLFrameTimer::getFrameCount() - mMouseDownFrame)
{
LLSD param;
param["count"] = mMouseHeldDownCount++;
mHeldDownSignal(this, param);
}
}
// We only handle the click if the click both started and ended within us
getWindow()->setCursor(UI_CURSOR_ARROW);
lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl;
}
// We only handle the click if the click both started and ended within us
getWindow()->setCursor(UI_CURSOR_ARROW);
lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl;
return TRUE;
}

View File

@ -74,7 +74,7 @@ public:
{
// text label
Optional<std::string> label_selected;
Optional<bool> label_dropshadow;
Optional<bool> label_shadow;
Optional<bool> auto_resize;
// images
@ -105,9 +105,9 @@ public:
// callbacks
Optional<CommitCallbackParam> click_callback, // alias -> commit_callback
mouse_down_callback,
mouse_up_callback,
mouse_held_callback;
mouse_down_callback,
mouse_up_callback,
mouse_held_callback;
// misc
Optional<bool> is_toggle,
@ -352,11 +352,5 @@ private:
LLFrameTimer mFlashingTimer;
};
#ifdef LL_WINDOWS
#ifndef INSTANTIATE_GETCHILD_BUTTON
#pragma warning (disable : 4231)
extern template LLButton* LLView::getChild<LLButton>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
#endif
#endif
#endif // LL_LLBUTTON_H

View File

@ -31,8 +31,6 @@
*/
// The mutants are coming!
#define INSTANTIATE_GETCHILD_CHECKBOX
#include "linden_common.h"
#include "llcheckboxctrl.h"
@ -50,9 +48,7 @@
const U32 MAX_STRING_LENGTH = 10;
template LLCheckBoxCtrl* LLView::getChild<LLCheckBoxCtrl>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
static LLDefaultWidgetRegistry::Register<LLCheckBoxCtrl> r("check_box");
static LLDefaultChildRegistry::Register<LLCheckBoxCtrl> r("check_box");
LLCheckBoxCtrl::Params::Params()
: text_enabled_color("text_enabled_color"),

View File

@ -126,11 +126,4 @@ protected:
};
#ifdef LL_WINDOWS
#ifndef INSTANTIATE_GETCHILD_CHECKBOX
#pragma warning (disable : 4231)
extern template LLCheckBoxCtrl* LLView::getChild<LLCheckBoxCtrl>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
#endif
#endif
#endif // LL_LLCHECKBOXCTRL_H

View File

@ -33,8 +33,6 @@
// A control that displays the name of the chosen item, which when
// clicked shows a scrolling box of options.
#define INSTANTIATE_GETCHILD_COMBOBOX
#include "linden_common.h"
// file includes
@ -63,9 +61,7 @@ S32 LLCOMBOBOX_HEIGHT = 0;
S32 LLCOMBOBOX_WIDTH = 0;
S32 MAX_COMBO_WIDTH = 500;
template LLComboBox* LLView::getChild<LLComboBox>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
static LLDefaultWidgetRegistry::Register<LLComboBox> register_combo_box("combo_box");
static LLDefaultChildRegistry::Register<LLComboBox> register_combo_box("combo_box");
void LLComboBox::PreferredPositionValues::declareValues()
{
@ -83,12 +79,12 @@ LLComboBox::Params::Params()
: allow_text_entry("allow_text_entry", false),
show_text_as_tentative("show_text_as_tentative", true),
max_chars("max_chars", 20),
arrow_image("arrow_image"),
list_position("list_position", BELOW),
items("item"),
combo_button("combo_button"),
combo_list("combo_list"),
combo_editor("combo_editor")
combo_editor("combo_editor"),
drop_down_button("drop_down_button")
{
addSynonym(items, "combo_item");
}
@ -104,19 +100,32 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
mPrearrangeCallback(p.prearrange_callback()),
mTextEntryCallback(p.text_entry_callback()),
mSelectionCallback(p.selection_callback()),
mArrowImage(p.arrow_image),
mListPosition(p.list_position)
mListPosition(p.list_position),
mLastSelectedIndex(-1)
{
// Text label button
LLButton::Params button_params = p.combo_button;
LLButton::Params button_params = (mAllowTextEntry ? p.combo_button : p.drop_down_button);
button_params.mouse_down_callback.function(boost::bind(&LLComboBox::onButtonDown, this));
button_params.follows.flags(FOLLOWS_LEFT|FOLLOWS_BOTTOM|FOLLOWS_RIGHT);
button_params.rect(p.rect);
button_params.pad_right(2);
if(mAllowTextEntry)
{
button_params.pad_right(2);
}
mArrowImage = button_params.image_unselected;
mButton = LLUICtrlFactory::create<LLButton>(button_params);
mButton->setRightHPad(2); //redo to compensate for button hack that leaves space for a character
if(mAllowTextEntry)
{
//redo to compensate for button hack that leaves space for a character
//unless it is a "minimal combobox"(drop down)
mButton->setRightHPad(2);
}
addChild(mButton);
LLScrollListCtrl::Params params = p.combo_list;
@ -135,7 +144,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
LLScrollListItem::Params item_params = *it;
if (it->label.isProvided())
{
item_params.cells.add().value(it->label());
item_params.columns.add().value(it->label());
}
mList->addRow(item_params);
@ -424,7 +433,8 @@ void LLComboBox::setButtonVisible(BOOL visible)
LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
if (visible)
{
text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * drop_shadow_button;
S32 arrow_width = mArrowImage ? mArrowImage->getWidth() : 0;
text_entry_rect.mRight -= llmax(8,arrow_width) + 2 * drop_shadow_button;
}
//mTextEntry->setRect(text_entry_rect);
mTextEntry->reshape(text_entry_rect.getWidth(), text_entry_rect.getHeight(), TRUE);
@ -466,14 +476,15 @@ void LLComboBox::createLineEditor(const LLComboBox::Params& p)
LLRect rect = getLocalRect();
if (mAllowTextEntry)
{
S32 arrow_width = mArrowImage ? mArrowImage->getWidth() : 0;
S32 shadow_size = drop_shadow_button;
mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth()) - 2 * shadow_size,
mButton->setRect(LLRect( getRect().getWidth() - llmax(8,arrow_width) - 2 * shadow_size,
rect.mTop, rect.mRight, rect.mBottom));
mButton->setTabStop(FALSE);
mButton->setHAlign(LLFontGL::HCENTER);
LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth()) + 2 * drop_shadow_button;
text_entry_rect.mRight -= llmax(8,arrow_width) + 2 * drop_shadow_button;
// clear label on button
std::string cur_label = mButton->getLabelSelected();
LLLineEditor::Params params = p.combo_editor;
@ -615,15 +626,15 @@ void LLComboBox::showList()
mList->setVisible(TRUE);
setUseBoundingRect(TRUE);
mList->sortItems();
mLastSelectedIndex = mList->getFirstSelectedIndex();
}
void LLComboBox::hideList()
{
//*HACK: store the original value explicitly somewhere, not just in label
std::string orig_selection = mAllowTextEntry ? mTextEntry->getText() : mButton->getLabelSelected();
// assert selection in list
mList->selectItemByLabel(orig_selection, FALSE);
mList->selectNthItem(mLastSelectedIndex);
mButton->setToggleState(FALSE);
mList->setVisible(FALSE);
@ -681,6 +692,7 @@ void LLComboBox::onItemSelected(const LLSD& data)
const std::string name = mList->getSelectedItemLabel();
S32 cur_id = getCurrentIndex();
mLastSelectedIndex = cur_id;
if (cur_id != -1)
{
setLabel(name);
@ -732,12 +744,7 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_re
msg = tool_tip;
// Convert rect local to screen coordinates
localPointToScreen(
0, 0,
&(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
localPointToScreen(
getRect().getWidth(), getRect().getHeight(),
&(sticky_rect_screen->mRight), &(sticky_rect_screen->mTop) );
*sticky_rect_screen = calcScreenRect();
}
return TRUE;
}

View File

@ -39,7 +39,6 @@
#include "llbutton.h"
#include "lluictrl.h"
#include "llctrlselectioninterface.h"
#include "llimagegl.h"
#include "llrect.h"
#include "llscrolllistctrl.h"
#include "lllineeditor.h"
@ -84,7 +83,6 @@ public:
Optional<commit_callback_t> prearrange_callback,
text_entry_callback,
selection_callback;
Optional<LLUIImage*> arrow_image;
Optional<EPreferredPosition, PreferredPositionValues> list_position;
@ -93,6 +91,8 @@ public:
Optional<LLScrollListCtrl::Params> combo_list;
Optional<LLLineEditor::Params> combo_editor;
Optional<LLButton::Params> drop_down_button;
Multiple<ItemParams> items;
Params();
@ -232,13 +232,6 @@ private:
commit_callback_t mPrearrangeCallback;
commit_callback_t mTextEntryCallback;
commit_callback_t mSelectionCallback;
S32 mLastSelectedIndex;
};
#ifdef LL_WINDOWS
#ifndef INSTANTIATE_GETCHILD_COMBOBOX
#pragma warning (disable : 4231)
extern template LLComboBox* LLView::getChild<LLComboBox>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
#endif
#endif
#endif

View File

@ -177,8 +177,8 @@ void LLConsole::draw()
// F32 console_opacity = llclamp(gSavedSettings.getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);
F32 console_opacity = llclamp(LLUI::sSettingGroups["config"]->getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);
// LLColor4 color = gSavedSkinSettings.getColor("ConsoleBackground");
LLColor4 color = LLUI::sSettingGroups["color"]->getColor("ConsoleBackground");
// LLColor4 color = LLUIColorTable::instance().getColor("ConsoleBackground");
LLColor4 color = LLUIColorTable::instance().getColor("ConsoleBackground");
color.mV[VALPHA] *= console_opacity;
F32 line_height = mFont->getLineHeight();

View File

@ -58,7 +58,8 @@ public:
Optional<S32> font_size_index;
Params()
: max_lines("max_lines", LLUI::sSettingGroups["config"]->getS32("ConsoleMaxLines")),
persist_time("persist_time", 0.f) // forever
persist_time("persist_time", 0.f), // forever
font_size_index("font_size_index")
{
mouse_opaque(false);
}

View File

@ -42,7 +42,7 @@
#include "llscrollcontainer.h"
#include "lluictrlfactory.h"
static LLDefaultWidgetRegistry::Register<LLContainerView> r("container_view");
static LLDefaultChildRegistry::Register<LLContainerView> r("container_view");
LLContainerView::LLContainerView(const LLContainerView::Params& p)
: LLView(p),

View File

@ -317,6 +317,23 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask)
S32 delta_x = screen_x - mDragLastScreenX;
S32 delta_y = screen_y - mDragLastScreenY;
// if dragging a docked floater we want to undock
if (((LLFloater*)getParent())->isDocked())
{
const S32 SLOP = 12;
if (delta_y <= -SLOP ||
delta_y >= SLOP)
{
((LLFloater*)getParent())->setDocked(false, false);
return TRUE;
}
else
{
return FALSE;
}
}
LLRect original_rect = getParent()->getRect();
LLRect translated_rect = getParent()->getRect();
translated_rect.translate(delta_x, delta_y);

View File

@ -53,8 +53,9 @@ public:
Optional<LLUIColor> drag_shadow_color;
Params()
: drag_highlight_color("", LLUI::getCachedColorFunctor("DefaultHighlightLight")),
drag_shadow_color("", LLUI::getCachedColorFunctor("DefaultShadowDark"))
: label("label"),
drag_highlight_color("drag_highlight_color", LLUIColorTable::instance().getColor("DefaultHighlightLight")),
drag_shadow_color("drag_shadow_color", LLUIColorTable::instance().getColor("DefaultShadowDark"))
{
mouse_opaque(true);
follows.flags(FOLLOWS_ALL);

View File

@ -0,0 +1,110 @@
/**
* @file llfiltereditor.cpp
* @brief LLFilterEditor implementation
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
// Text editor widget to let users enter a single line.
#include "linden_common.h"
#include "llfiltereditor.h"
LLFilterEditor::LLFilterEditor(const LLFilterEditor::Params& p)
: LLUICtrl(p)
{
LLLineEditor::Params line_editor_p(p);
line_editor_p.name("filter edit box");
line_editor_p.rect(getLocalRect());
line_editor_p.follows.flags(FOLLOWS_ALL);
line_editor_p.text_pad_right(getRect().getHeight());
line_editor_p.keystroke_callback(boost::bind(&LLUICtrl::onCommit, this));
mFilterEditor = LLUICtrlFactory::create<LLLineEditor>(line_editor_p);
addChild(mFilterEditor);
S32 btn_width = getRect().getHeight(); // button is square, and as tall as search editor
LLRect clear_btn_rect(getRect().getWidth() - btn_width, getRect().getHeight(), getRect().getWidth(), 0);
LLButton::Params button_params(p.clear_filter_button);
button_params.name(std::string("clear filter"));
button_params.rect(clear_btn_rect) ;
button_params.follows.flags(FOLLOWS_RIGHT|FOLLOWS_TOP);
button_params.tab_stop(false);
button_params.click_callback.function(boost::bind(&LLFilterEditor::onClearFilter, this, _2));
mClearFilterButton = LLUICtrlFactory::create<LLButton>(button_params);
mFilterEditor->addChild(mClearFilterButton);
}
//virtual
void LLFilterEditor::setValue(const LLSD& value )
{
mFilterEditor->setValue(value);
}
//virtual
LLSD LLFilterEditor::getValue() const
{
return mFilterEditor->getValue();
}
//virtual
BOOL LLFilterEditor::setTextArg( const std::string& key, const LLStringExplicit& text )
{
return mFilterEditor->setTextArg(key, text);
}
//virtual
BOOL LLFilterEditor::setLabelArg( const std::string& key, const LLStringExplicit& text )
{
return mFilterEditor->setLabelArg(key, text);
}
//virtual
void LLFilterEditor::clear()
{
if (mFilterEditor)
{
mFilterEditor->clear();
}
}
void LLFilterEditor::draw()
{
mClearFilterButton->setVisible(!mFilterEditor->getWText().empty());
LLUICtrl::draw();
}
void LLFilterEditor::onClearFilter(const LLSD& data)
{
setText(LLStringUtil::null);
onCommit();
}

View File

@ -0,0 +1,86 @@
/**
* @file llfiltereditor.h
* @brief Text editor widget that represents a filter operation
*
* Features:
* Text entry of a single line (text, delete, left and right arrow, insert, return).
* Callbacks either on every keystroke or just on the return key.
* Focus (allow multiple text entry widgets)
* Clipboard (cut, copy, and paste)
* Horizontal scrolling to allow strings longer than widget size allows
* Pre-validation (limit which keys can be used)
* Optional line history so previous entries can be recalled by CTRL UP/DOWN
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LL_FILTEREDITOR_H
#define LL_FILTEREDITOR_H
#include "lllineeditor.h"
#include "llbutton.h"
class LLFilterEditor : public LLUICtrl
{
public:
struct Params : public LLInitParam::Block<Params, LLLineEditor::Params>
{
Optional<LLButton::Params> clear_filter_button;
Params()
: clear_filter_button("clear_filter_button")
{
name = "filter_editor";
}
};
protected:
LLFilterEditor(const Params&);
friend class LLUICtrlFactory;
public:
virtual ~LLFilterEditor() {}
/*virtual*/ void draw();
void setText(const LLStringExplicit &new_text) { mFilterEditor->setText(new_text); }
// LLUICtrl interface
virtual void setValue(const LLSD& value );
virtual LLSD getValue() const;
virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
virtual void clear();
private:
void onClearFilter(const LLSD& data);
LLLineEditor* mFilterEditor;
LLButton* mClearFilterButton;
};
#endif // LL_FILTEREDITOR_H

View File

@ -66,29 +66,37 @@ const S32 TABBED_FLOATER_OFFSET = 0;
std::string LLFloater::sButtonActiveImageNames[BUTTON_COUNT] =
{
"closebox.tga", //BUTTON_CLOSE
"Icon_Close_Foreground", //BUTTON_CLOSE
"restore.tga", //BUTTON_RESTORE
"minimize.tga", //BUTTON_MINIMIZE
"tearoffbox.tga", //BUTTON_TEAR_OFF
"closebox.tga", //BUTTON_EDIT
"Icon_Dock_Foreground",
"Icon_Undock_Foreground"
};
std::string LLFloater::sButtonInactiveImageNames[BUTTON_COUNT] =
// Empty string means programmatic glow effect, achieved by
// not setting explicit image.
std::string LLFloater::sButtonHoveredImageNames[BUTTON_COUNT] =
{
"close_inactive_blue.tga", //BUTTON_CLOSE
"restore_inactive.tga", //BUTTON_RESTORE
"minimize_inactive.tga", //BUTTON_MINIMIZE
"tearoffbox.tga", //BUTTON_TEAR_OFF
"close_inactive_blue.tga", //BUTTON_EDIT
"", //BUTTON_CLOSE
"restore_pressed.tga", //BUTTON_RESTORE
"minimize_pressed.tga", //BUTTON_MINIMIZE
"tearoff_pressed.tga", //BUTTON_TEAR_OFF
"close_in_blue.tga", //BUTTON_EDIT
"", //BUTTON_DOCK
"", //BUTTON_UNDOCK
};
std::string LLFloater::sButtonPressedImageNames[BUTTON_COUNT] =
{
"close_in_blue.tga", //BUTTON_CLOSE
"Icon_Close_Press", //BUTTON_CLOSE
"restore_pressed.tga", //BUTTON_RESTORE
"minimize_pressed.tga", //BUTTON_MINIMIZE
"tearoff_pressed.tga", //BUTTON_TEAR_OFF
"close_in_blue.tga", //BUTTON_EDIT
"Icon_Dock_Press",
"Icon_Undock_Press"
};
std::string LLFloater::sButtonNames[BUTTON_COUNT] =
@ -98,22 +106,25 @@ std::string LLFloater::sButtonNames[BUTTON_COUNT] =
"llfloater_minimize_btn", //BUTTON_MINIMIZE
"llfloater_tear_off_btn", //BUTTON_TEAR_OFF
"llfloater_edit_btn", //BUTTON_EDIT
"llfloater_dock_btn",
"llfloater_undock_btn"
};
std::string LLFloater::sButtonToolTips[BUTTON_COUNT] = {};
std::string LLFloater::sButtonToolTips[BUTTON_COUNT];
std::string LLFloater::sButtonToolTipsIndex[BUTTON_COUNT]=
{
#ifdef LL_DARWIN
"BUTTON_CLOSE_DARWIN",//LLTrans::getString("BUTTON_CLOSE_DARWIN"), //"Close (Cmd-W)", //BUTTON_CLOSE
"BUTTON_CLOSE_DARWIN", //"Close (Cmd-W)", //BUTTON_CLOSE
#else
"BUTTON_CLOSE_WIN", //LLTrans::getString("BUTTON_CLOSE_WIN"), //"Close (Ctrl-W)", //BUTTON_CLOSE
"BUTTON_CLOSE_WIN", //"Close (Ctrl-W)", //BUTTON_CLOSE
#endif
"BUTTON_RESTORE",//LLTrans::getString("BUTTON_RESTORE"), //"Restore", //BUTTON_RESTORE
"BUTTON_MINIMIZE",//LLTrans::getString("BUTTON_MINIMIZE"), //"Minimize", //BUTTON_MINIMIZE
"BUTTON_TEAR_OFF",//LLTrans::getString("BUTTON_TEAR_OFF"), //"Tear Off", //BUTTON_TEAR_OFF
"BUTTON_EDIT", //LLTrans::getString("BUTTON_EDIT"), // "Edit", //BUTTON_EDIT
"BUTTON_RESTORE", //"Restore", //BUTTON_RESTORE
"BUTTON_MINIMIZE", //"Minimize", //BUTTON_MINIMIZE
"BUTTON_TEAR_OFF", //"Tear Off", //BUTTON_TEAR_OFF
"BUTTON_EDIT", //"Edit", //BUTTON_EDIT
"BUTTON_DOCK",
"BUTTON_UNDOCK"
};
LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
@ -123,10 +134,13 @@ LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
LLFloater::onClickMinimize, //BUTTON_MINIMIZE
LLFloater::onClickTearOff, //BUTTON_TEAR_OFF
LLFloater::onClickEdit, //BUTTON_EDIT
LLFloater::onClickDock,
LLFloater::onClickDock
};
LLMultiFloater* LLFloater::sHostp = NULL;
BOOL LLFloater::sEditModeEnabled;
BOOL LLFloater::sEditModeEnabled = FALSE;
BOOL LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting
LLFloater::handle_map_t LLFloater::sFloaterMap;
LLFloaterView* gFloaterView = NULL;
@ -188,12 +202,44 @@ bool LLFloater::KeyCompare::equate(const LLSD& a, const LLSD& b)
//************************************
LLFloater::Params::Params()
: title("title"),
short_title("short_title"),
single_instance("single_instance", false),
auto_tile("auto_tile", false),
can_resize("can_resize", false),
can_minimize("can_minimize", true),
can_close("can_close", true),
can_drag_on_left("can_drag_on_left", false),
can_tear_off("can_tear_off", true),
save_rect("save_rect", false),
save_visibility("save_visibility", false),
open_callback("open_callback"),
close_callback("close_callback"),
can_dock("can_dock", false)
{
name = "floater";
// defaults that differ from LLPanel:
background_visible = true;
visible = false;
}
//static
const LLFloater::Params& LLFloater::getDefaultParams()
{
return LLUICtrlFactory::getDefaultParams<LLFloater::Params>();
return LLUICtrlFactory::getDefaultParams<LLFloater>();
}
//static
void LLFloater::initClass()
{
// translate tooltips for floater buttons
for (S32 i = 0; i < BUTTON_COUNT; i++)
{
sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] );
}
}
LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
: LLPanel(),
@ -216,30 +262,21 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
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 LLUICachedControl<LLColor4> default_background_color ("FloaterDefaultBackgroundColor", *(new LLColor4));
static LLUICachedControl<LLColor4> focus_background_color ("FloaterFocusBackgroundColor", *(new LLColor4));
for (S32 i = 0; i < BUTTON_COUNT; i++)
{
sButtonToolTips[i] =LLTrans::getString( sButtonToolTipsIndex[i]);
}
static LLUIColor default_background_color = LLUIColorTable::instance().getColor("FloaterDefaultBackgroundColor");
static LLUIColor focus_background_color = LLUIColorTable::instance().getColor("FloaterFocusBackgroundColor");
mHandle.bind(this);
mNotificationContext = new LLFloaterNotificationContext(getHandle());
mBgColorAlpha = default_background_color;
mBgColorOpaque = focus_background_color;
for (S32 i = 0; i < 4; i++)
{
mResizeBar[i] = NULL;
mResizeHandle[i] = NULL;
}
// Clicks stop here.
setMouseOpaque(TRUE);
@ -288,6 +325,11 @@ void LLFloater::initFloater()
mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
}
if(mCanDock)
{
mButtonsEnabled[BUTTON_DOCK] = TRUE;
}
buildButtons();
// Floaters are created in the invisible state
@ -399,6 +441,9 @@ void LLFloater::addResizeCtrls()
// Resize handles (corners)
LLResizeHandle::Params handle_p;
// handles must not be mouse-opaque, otherwise they block hover events
// to other buttons like the close box. JC
handle_p.mouse_opaque(false);
handle_p.rect(LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0));
handle_p.min_width(mMinWidth);
handle_p.min_height(mMinHeight);
@ -473,7 +518,7 @@ void LLFloater::storeRectControl()
void LLFloater::storeVisibilityControl()
{
if( mVisibilityControl.size() > 1 )
if( !sQuitting && mVisibilityControl.size() > 1 )
{
LLUI::sSettingGroups["floater"]->setBOOL( mVisibilityControl, getVisible() );
}
@ -481,7 +526,7 @@ void LLFloater::storeVisibilityControl()
void LLFloater::setVisible( BOOL visible )
{
LLPanel::setVisible(visible);
LLPanel::setVisible(visible); // calls handleVisibilityChange()
if( visible && mFirstLook )
{
mFirstLook = FALSE;
@ -516,14 +561,14 @@ void LLFloater::setVisible( BOOL visible )
}
// virtual
void LLFloater::onVisibilityChange ( BOOL new_visibility )
void LLFloater::handleVisibilityChange ( BOOL new_visibility )
{
if (new_visibility)
{
if (getHost())
getHost()->setFloaterFlashing(this, FALSE);
}
LLPanel::onVisibilityChange ( new_visibility );
LLPanel::handleVisibilityChange ( new_visibility );
}
void LLFloater::openFloater(const LLSD& key)
@ -560,11 +605,17 @@ void LLFloater::openFloater(const LLSD& key)
setVisibleAndFrontmost(mAutoFocus);
}
mOpenSignal(this, key);
onOpen(key);
}
void LLFloater::closeFloater(bool app_quitting)
{
if (app_quitting)
{
LLFloater::sQuitting = true;
}
// Always unminimize before trying to close.
// Most of the time the user will never see this state.
setMinimized(FALSE);
@ -622,8 +673,27 @@ void LLFloater::closeFloater(bool app_quitting)
}
}
// Let floater do cleanup.
onClose(app_quitting);
// Close callback
mCloseSignal(this, LLSD(app_quitting));
// Hide or Destroy
if (mSingleInstance)
{
// Hide the instance
if (getHost())
{
getHost()->setVisible(FALSE);
}
else
{
setVisible(FALSE);
}
}
else
{
setVisible(FALSE); // hide before destroying (so handleVisibilityChange() gets called)
destroy();
}
}
}
@ -1296,6 +1366,36 @@ void LLFloater::setFrontmost(BOOL take_focus)
}
}
void LLFloater::setCanDock(bool b)
{
if(b != mCanDock)
{
mCanDock = b;
if(mCanDock)
{
mButtonsEnabled[BUTTON_DOCK] = !mDocked;
mButtonsEnabled[BUTTON_UNDOCK] = mDocked;
}
else
{
mButtonsEnabled[BUTTON_DOCK] = FALSE;
mButtonsEnabled[BUTTON_UNDOCK] = FALSE;
}
}
updateButtons();
}
void LLFloater::setDocked(bool docked, bool pop_on_undock)
{
if(docked != mDocked && mCanDock)
{
mDocked = docked;
mButtonsEnabled[BUTTON_DOCK] = !mDocked;
mButtonsEnabled[BUTTON_UNDOCK] = mDocked;
updateButtons();
}
}
//static
void LLFloater::setEditModeEnabled(BOOL enable)
{
@ -1372,6 +1472,15 @@ void LLFloater::onClickEdit(LLFloater* self)
self->mEditing = self->mEditing ? FALSE : TRUE;
}
// static
void LLFloater::onClickDock(LLFloater* self)
{
if(self && self->mCanDock)
{
self->setDocked(!self->mDocked, true);
}
}
// static
LLFloater* LLFloater::getClosableFloaterFromFocus()
{
@ -1449,7 +1558,7 @@ void LLFloater::draw()
S32 bottom = LLPANEL_BORDER_WIDTH;
static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0);
static LLUICachedControl<LLColor4> shadow_color_cached ("ColorDropShadow", *(new LLColor4));
static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow");
LLColor4 shadow_color = shadow_color_cached;
F32 shadow_offset = (F32)shadow_offset_S32;
@ -1474,7 +1583,7 @@ void LLFloater::draw()
if(gFocusMgr.childHasKeyboardFocus(this) && !getIsChrome() && !getCurrentTitle().empty())
{
static LLUICachedControl<LLColor4> titlebar_focus_color ("TitleBarFocusColor", *(new LLColor4));
static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor");
// draw highlight on title bar to indicate focus. RDW
const LLFontGL* font = LLFontGL::getFontSansSerif();
LLRect r = getRect();
@ -1533,10 +1642,10 @@ void LLFloater::draw()
{
// add in a border to improve spacialized visual aclarity ;)
// use lines instead of gl_rect_2d so we can round the edges as per james' recommendation
static LLUICachedControl<LLColor4> focus_border_color ("FloaterFocusBorderColor", *(new LLColor4));
static LLUICachedControl<LLColor4> unfocus_border_color ("FloaterUnfocusBorderColor", *(new LLColor4));
static LLUIColor focus_border_color = LLUIColorTable::instance().getColor("FloaterFocusBorderColor");
static LLUIColor unfocus_border_color = LLUIColorTable::instance().getColor("FloaterUnfocusBorderColor");
LLUI::setLineWidth(1.5f);
LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? focus_border_color() : unfocus_border_color;
LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? focus_border_color : unfocus_border_color;
gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor, -LLPANEL_BORDER_WIDTH, FALSE);
LLUI::setLineWidth(1.f);
}
@ -1692,14 +1801,24 @@ void LLFloater::buildButtons()
p.rect(btn_rect);
p.label("");
p.image_unselected.name(sButtonActiveImageNames[i]);
// Selected, no matter if hovered or not, is "pressed"
p.image_selected.name(sButtonPressedImageNames[i]);
p.image_hover_selected.name(sButtonPressedImageNames[i]);
p.image_hover_unselected.name(sButtonPressedImageNames[i]);
// Empty string means programmatic glow effect, achieved by
// not setting explicit image.
if (sButtonHoveredImageNames[i].empty())
{
// These icons are really small, need glow amount increased
p.hover_glow_amount( 0.22f );
}
else
{
p.image_hover_unselected.name(sButtonHoveredImageNames[i]);
}
p.click_callback.function(boost::bind(sButtonCallbacks[i], this));
p.tab_stop(false);
p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT);
p.tool_tip(sButtonToolTips[i]);
p.image_color(LLUI::getCachedColorFunctor("FloaterButtonImageColor"));
p.scale_image(true);
LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p);
@ -2149,7 +2268,8 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
// convert to local coordinate frame
LLRect snap_rect_local = getLocalSnapRect();
if( floater->isResizable() )
// only automatically resize non-minimized, resizable floaters
if( floater->isResizable() && !floater->isMinimized() )
{
LLRect view_rect = floater->getRect();
S32 old_width = view_rect.getWidth();
@ -2447,6 +2567,7 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
setCanTearOff(p.can_tear_off);
setCanMinimize(p.can_minimize);
setCanClose(p.can_close);
setCanDock(p.can_dock);
mDragOnLeft = p.can_drag_on_left;
mResizable = p.can_resize;
@ -2463,18 +2584,25 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
{
mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
}
// open callback
if (p.open_callback.isProvided())
initCommitCallback(p.open_callback, mOpenSignal);
// close callback
if (p.close_callback.isProvided())
initCommitCallback(p.close_callback, mCloseSignal);
}
void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, BOOL open_floater, LLXMLNodePtr output_node)
void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
{
Params params(LLUICtrlFactory::getDefaultParams<LLFloater::Params>());
Params params(LLUICtrlFactory::getDefaultParams<LLFloater>());
LLXUIParser::instance().readXUI(node, params);
if (output_node)
{
Params output_params(params);
setupParamsForExport(output_params, parent);
Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater::Params>());
Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
output_node->setName(node->getName()->mString);
LLXUIParser::instance().writeXUI(
output_node, output_params, &default_params);
@ -2491,7 +2619,7 @@ void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, BOOL open_floa
LLFloater::setFloaterHost((LLMultiFloater*) this);
}
LLUICtrlFactory::createChildren(this, node, output_node);
LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
if (node->hasName("multi_floater"))
{
@ -2508,38 +2636,6 @@ void LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, BOOL open_floa
applyRectControl(); // If we have a saved rect control, apply it
gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen
if (open_floater)
{
this->openFloater(getKey());
}
moveResizeHandlesToFront();
}
// visibility methods
bool VisibilityPolicy<LLFloater>::visible(LLFloater* instance, const LLSD& key)
{
if (instance)
{
return !instance->isMinimized() && instance->isInVisibleChain();
}
return FALSE;
}
void VisibilityPolicy<LLFloater>::show(LLFloater* instance, const LLSD& key)
{
if (instance)
{
instance->openFloater(key);
if (instance->getHost())
{
instance->getHost()->openFloater(key);
}
}
}
void VisibilityPolicy<LLFloater>::hide(LLFloater* instance, const LLSD& key)
{
if (instance) instance->closeFloater();
}

View File

@ -97,11 +97,13 @@ public:
enum EFloaterButtons
{
BUTTON_CLOSE,
BUTTON_CLOSE = 0,
BUTTON_RESTORE,
BUTTON_MINIMIZE,
BUTTON_TEAR_OFF,
BUTTON_EDIT,
BUTTON_DOCK,
BUTTON_UNDOCK,
BUTTON_COUNT
};
@ -119,32 +121,22 @@ public:
can_drag_on_left,
can_tear_off,
save_rect,
save_visibility;
Params() :
title("title"),
short_title("short_title"),
single_instance("single_instance", false),
auto_tile("auto_tile", false),
can_resize("can_resize", false),
can_minimize("can_minimize", true),
can_close("can_close", true),
can_drag_on_left("can_drag_on_left", false),
can_tear_off("can_tear_off", true),
save_rect("save_rect", false),
save_visibility("save_visibility", false)
{
name = "floater";
// defaults that differ from LLPanel:
background_visible = true;
visible = false;
}
save_visibility,
can_dock;
Optional<CommitCallbackParam> open_callback,
close_callback;
Params();
};
// use this to avoid creating your own default LLFloater::Param instance
static const Params& getDefaultParams();
LLFloater(const LLSD& key = LLSD(), const Params& params = getDefaultParams());
// Load translations for tooltips for standard buttons
static void initClass();
LLFloater(const LLSD& key, const Params& params = getDefaultParams());
virtual ~LLFloater();
@ -152,7 +144,7 @@ public:
static void setupParamsForExport(Params& p, LLView* parent);
void initFromParams(const LLFloater::Params& p);
void initFloaterXML(LLXMLNodePtr node, LLView *parent, BOOL open_floater = TRUE, LLXMLNodePtr output_node = NULL);
void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL);
/*virtual*/ void handleReshape(const LLRect& new_rect, bool by_user = false);
/*virtual*/ BOOL canSnapTo(const LLView* other_view);
@ -166,7 +158,6 @@ public:
void openFloater(const LLSD& key = LLSD());
// If allowed, close the floater cleanly, releasing focus.
// app_quitting is passed to onClose() below.
void closeFloater(bool app_quitting = false);
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
@ -216,20 +207,16 @@ public:
virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
virtual void draw();
// *TODO: Eliminate this in favor of mOpenSignal
virtual void onOpen(const LLSD& key) {}
// Call destroy() to free memory, or setVisible(FALSE) to keep it
// If app_quitting, you might not want to save your visibility.
// Defaults to destroy().
virtual void onClose(bool app_quitting) { destroy(); }
// This cannot be "const" until all derived floater canClose()
// methods are const as well. JC
virtual BOOL canClose() { return TRUE; }
virtual void setVisible(BOOL visible);
virtual void onVisibilityChange ( BOOL curVisibilityIn );
/*virtual*/ void setVisible(BOOL visible); // do not override
/*virtual*/ void handleVisibilityChange ( BOOL new_visibility ); // do not override
void setFrontmost(BOOL take_focus = TRUE);
@ -245,6 +232,14 @@ public:
LLHandle<LLFloater> getHandle() const { return mHandle; }
const LLSD& getKey() { return mKey; }
BOOL matchesKey(const LLSD& key) { return mSingleInstance || KeyCompare::equate(key, mKey); }
const std::string& getInstanceName() { return mInstanceName; }
bool isDockable() const { return mCanDock; }
void setCanDock(bool b);
bool isDocked() const { return mDocked; }
virtual void setDocked(bool docked, bool pop_on_undock = true);
// Return a closeable floater, if any, given the current focus.
static LLFloater* getClosableFloaterFromFocus();
@ -262,6 +257,7 @@ public:
static void onClickMinimize(LLFloater* floater);
static void onClickTearOff(LLFloater* floater);
static void onClickEdit(LLFloater* floater);
static void onClickDock(LLFloater* floater);
static void setFloaterHost(LLMultiFloater* hostp) {sHostp = hostp; }
static void setEditModeEnabled(BOOL enable);
@ -287,10 +283,9 @@ protected:
void setAutoFocus(BOOL focus) { mAutoFocus = focus; } // whether to automatically take focus when opened
LLDragHandle* getDragHandle() const { return mDragHandle; }
void destroy() { die(); } // Don't call this directly. You probably want to call close(). JC
void destroy() { die(); } // Don't call this directly. You probably want to call closeFloater()
private:
void setForeground(BOOL b); // called only by floaterview
void cleanupHandles(); // remove handles to dead floaters
void createMinimizeButton();
@ -299,18 +294,20 @@ private:
BOOL offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButtons index);
void addResizeCtrls();
void addDragHandle();
protected:
std::string mRectControl;
std::string mVisibilityControl;
commit_signal_t mOpenSignal; // Called when floater is opened, passes mKey
commit_signal_t mCloseSignal; // Called when floater is closed, passes app_qitting as LLSD()
LLSD mKey; // Key used for retrieving instances; set (for now) by LLFLoaterReg
private:
LLRect mExpandedRect;
LLDragHandle* mDragHandle;
LLResizeBar* mResizeBar[4];
LLResizeHandle* mResizeHandle[4];
private:
LLRect mExpandedRect;
LLUIString mTitle;
LLUIString mShortTitle;
@ -349,10 +346,15 @@ private:
LLHandle<LLFloater> mHostHandle;
LLHandle<LLFloater> mLastHostHandle;
bool mCanDock;
bool mDocked;
static LLMultiFloater* sHostp;
static BOOL sEditModeEnabled;
static BOOL sQuitting;
static std::string sButtonActiveImageNames[BUTTON_COUNT];
static std::string sButtonInactiveImageNames[BUTTON_COUNT];
// Images to use when cursor hovered over an enabled button
static std::string sButtonHoveredImageNames[BUTTON_COUNT];
static std::string sButtonPressedImageNames[BUTTON_COUNT];
static std::string sButtonNames[BUTTON_COUNT];
static std::string sButtonToolTips[BUTTON_COUNT];
@ -378,6 +380,7 @@ private:
LLRootHandle<LLFloater> mHandle;
};
/////////////////////////////////////////////////////////////
// LLFloaterView
// Parent of all floating panels
@ -441,33 +444,6 @@ private:
S32 mSnapOffsetRight;
};
// singleton implementation for floaters
// https://wiki.lindenlab.com/mediawiki/index.php?title=LLFloaterSingleton&oldid=164990
//*******************************************************
//* TO BE DEPRECATED
//*******************************************************
// visibility policy specialized for floaters
template<>
class VisibilityPolicy<LLFloater>
{
public:
// visibility methods
static bool visible(LLFloater* instance, const LLSD& key);
static void show(LLFloater* instance, const LLSD& key);
static void hide(LLFloater* instance, const LLSD& key);
};
// singleton implementation for floaters (provides visibility policy)
// https://wiki.lindenlab.com/mediawiki/index.php?title=LLFloaterSingleton&oldid=164990
template <class T> class LLFloaterSingleton : public LLUISingleton<T, VisibilityPolicy<LLFloater> >
{
};
//
// Globals
//

View File

@ -121,8 +121,7 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
res = build_func(key);
const bool DONT_OPEN_FLOATER = false;
LLUICtrlFactory::getInstance()->buildFloater(res, xui_file, DONT_OPEN_FLOATER);
LLUICtrlFactory::getInstance()->buildFloater(res, xui_file, NULL);
// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
res->mKey = key;
@ -363,6 +362,24 @@ std::string LLFloaterReg::declareVisibilityControl(const std::string& name)
return controlname;
}
//static
void LLFloaterReg::registerControlVariables()
{
// Iterate through alll registered instance names and register rect and visibility control variables
for (build_map_t::iterator iter = sBuildMap.begin(); iter != sBuildMap.end(); ++iter)
{
const std::string& name = iter->first;
if (LLUI::sSettingGroups["floater"]->controlExists(getRectControlName(name)))
{
declareRectControl(name);
}
if (LLUI::sSettingGroups["floater"]->controlExists(getVisibilityControlName(name)))
{
declareVisibilityControl(name);
}
}
}
// Callbacks
// static

View File

@ -120,6 +120,7 @@ public:
static std::string declareRectControl(const std::string& name);
static std::string getVisibilityControlName(const std::string& name);
static std::string declareVisibilityControl(const std::string& name);
static void registerControlVariables();
// Callback wrappers
static void initUICtrlToFloaterVisibilityControl(LLUICtrl* ctrl, const LLSD& sdname);

View File

@ -35,7 +35,7 @@
// file includes
#include "llflyoutbutton.h"
//static LLDefaultWidgetRegistry::Register<LLFlyoutButton> r2("flyout_button");
//static LLDefaultChildRegistry::Register<LLFlyoutButton> r2("flyout_button");
const S32 FLYOUT_BUTTON_ARROW_WIDTH = 24;
@ -54,11 +54,6 @@ LLFlyoutButton::LLFlyoutButton(const Params& p)
mActionButton = LLUICtrlFactory::create<LLButton>(bp);
addChild(mActionButton);
mButton->setOrigin(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0);
mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight());
mButton->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM);
mButton->setImageOverlay(mListPosition == BELOW ? "down_arrow.tga" : "up_arrow.tga", LLFontGL::RIGHT);
}
void LLFlyoutButton::onActionButtonClick(const LLSD& data)
@ -75,7 +70,7 @@ void LLFlyoutButton::draw()
//FIXME: this should be an attribute of comboboxes, whether they have a distinct label or
// the label reflects the last selected item, for now we have to manually remove the label
mButton->setLabel(LLStringUtil::null);
setLabel(LLStringUtil::null);
LLComboBox::draw();
}

View File

@ -46,10 +46,14 @@ public:
struct Params : public LLInitParam::Block<Params, LLComboBox::Params>
{
Optional<LLButton::Params> action_button;
Deprecated allow_text_entry;
Params()
: action_button("action_button")
{}
: action_button("action_button"),
allow_text_entry("allow_text_entry")
{
LLComboBox::Params::allow_text_entry = false;
}
};
protected:

View File

@ -323,7 +323,7 @@ F32 LLFocusMgr::getFocusFlashAmt() const
LLColor4 LLFocusMgr::getFocusColor() const
{
static LLUICachedControl<LLColor4> focus_color_cached ("FocusColor", *(new LLColor4));
static LLUIColor focus_color_cached = LLUIColorTable::instance().getColor("FocusColor");
LLColor4 focus_color = lerp(focus_color_cached, LLColor4::white, getFocusFlashAmt());
// de-emphasize keyboard focus when app has lost focus (to avoid typing into wrong window problem)
if (!mAppHasFocus)

171
indra/llui/llhandle.h Normal file
View File

@ -0,0 +1,171 @@
/**
* @file llhandle.h
* @brief "Handle" to an object (usually a floater) whose lifetime you don't
* control.
*
* $LicenseInfo:firstyear=2001&license=viewergpl$
*
* Copyright (c) 2001-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#ifndef LLHANDLE_H
#define LLHANDLE_H
#include "llpointer.h"
template <typename T>
class LLTombStone : public LLRefCount
{
public:
LLTombStone(T* target = NULL) : mTarget(target) {}
void setTarget(T* target) { mTarget = target; }
T* getTarget() const { return mTarget; }
private:
T* mTarget;
};
// LLHandles are used to refer to objects whose lifetime you do not control or influence.
// Calling get() on a handle will return a pointer to the referenced object or NULL,
// if the object no longer exists. Note that during the lifetime of the returned pointer,
// you are assuming that the object will not be deleted by any action you perform,
// or any other thread, as normal when using pointers, so avoid using that pointer outside of
// the local code block.
//
// https://wiki.lindenlab.com/mediawiki/index.php?title=LLHandle&oldid=79669
template <typename T>
class LLHandle
{
public:
LLHandle() : mTombStone(sDefaultTombStone) {}
const LLHandle<T>& operator =(const LLHandle<T>& other)
{
mTombStone = other.mTombStone;
return *this;
}
bool isDead() const
{
return mTombStone->getTarget() == NULL;
}
void markDead()
{
mTombStone = sDefaultTombStone;
}
T* get() const
{
return mTombStone->getTarget();
}
friend bool operator== (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
{
return lhs.mTombStone == rhs.mTombStone;
}
friend bool operator!= (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
{
return !(lhs == rhs);
}
friend bool operator< (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
{
return lhs.mTombStone < rhs.mTombStone;
}
friend bool operator> (const LLHandle<T>& lhs, const LLHandle<T>& rhs)
{
return lhs.mTombStone > rhs.mTombStone;
}
protected:
protected:
LLPointer<LLTombStone<T> > mTombStone;
private:
static LLPointer<LLTombStone<T> > sDefaultTombStone;
};
// initialize static "empty" tombstone pointer
template <typename T> LLPointer<LLTombStone<T> > LLHandle<T>::sDefaultTombStone = new LLTombStone<T>();
template <typename T>
class LLRootHandle : public LLHandle<T>
{
public:
LLRootHandle(T* object) { bind(object); }
LLRootHandle() {};
~LLRootHandle() { unbind(); }
// this is redundant, since a LLRootHandle *is* an LLHandle
LLHandle<T> getHandle() { return LLHandle<T>(*this); }
void bind(T* object)
{
// unbind existing tombstone
if (LLHandle<T>::mTombStone.notNull())
{
if (LLHandle<T>::mTombStone->getTarget() == object) return;
LLHandle<T>::mTombStone->setTarget(NULL);
}
// tombstone reference counted, so no paired delete
LLHandle<T>::mTombStone = new LLTombStone<T>(object);
}
void unbind()
{
LLHandle<T>::mTombStone->setTarget(NULL);
}
//don't allow copying of root handles, since there should only be one
private:
LLRootHandle(const LLRootHandle& other) {};
};
// Use this as a mixin for simple classes that need handles and when you don't
// want handles at multiple points of the inheritance hierarchy
template <typename T>
class LLHandleProvider
{
protected:
typedef LLHandle<T> handle_type_t;
LLHandleProvider()
{
// provided here to enforce T deriving from LLHandleProvider<T>
}
LLHandle<T> getHandle()
{
// perform lazy binding to avoid small tombstone allocations for handle
// providers whose handles are never referenced
mHandle.bind(static_cast<T*>(this));
return mHandle;
}
private:
LLRootHandle<T> mHandle;
};
#endif

View File

@ -42,7 +42,7 @@
#include "lluictrlfactory.h"
#include "lluiimage.h"
static LLDefaultWidgetRegistry::Register<LLIconCtrl> r("icon");
static LLDefaultChildRegistry::Register<LLIconCtrl> r("icon");
LLIconCtrl::Params::Params()
: image("image_name"),

View File

@ -37,7 +37,6 @@
#include "v4color.h"
#include "lluictrl.h"
#include "stdenums.h"
#include "llimagegl.h"
class LLTextBox;
class LLUICtrlFactory;

View File

@ -38,7 +38,7 @@
#include "llresizebar.h"
#include "llcriticaldamp.h"
static LLDefaultWidgetRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack", &LLLayoutStack::fromXML);
static LLDefaultChildRegistry::Register<LLLayoutStack> register_layout_stack("layout_stack", &LLLayoutStack::fromXML);
//
@ -120,7 +120,8 @@ struct LLLayoutStack::LayoutPanel
LLLayoutStack::Params::Params()
: orientation("orientation", std::string("vertical")),
animate("animate", TRUE),
animate("animate", true),
clip("clip", true),
border_size("border_size", LLCachedControl<S32>(*LLUI::sSettingGroups["config"], "UIResizeBarHeight", 0))
{
name="stack";
@ -132,7 +133,8 @@ LLLayoutStack::LLLayoutStack(const LLLayoutStack::Params& p)
mMinHeight(0),
mPanelSpacing(p.border_size),
mOrientation((p.orientation() == "vertical") ? VERTICAL : HORIZONTAL),
mAnimate(p.animate)
mAnimate(p.animate),
mClip(p.clip)
{}
LLLayoutStack::~LLLayoutStack()
@ -163,7 +165,7 @@ void LLLayoutStack::draw()
LLPanel* panelp = (*panel_it)->mPanel;
LLLocalClipRect clip(clip_rect);
LLLocalClipRect clip(clip_rect, mClip);
// only force drawing invisible children if visible amount is non-zero
drawChild(panelp, 0, 0, !clip_rect.isNull());
}
@ -223,7 +225,7 @@ static void get_attribute_bool_and_write(LLXMLNodePtr node,
//static
LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
{
LLLayoutStack::Params p(LLUICtrlFactory::getDefaultParams<LLLayoutStack::Params>());
LLLayoutStack::Params p(LLUICtrlFactory::getDefaultParams<LLLayoutStack>());
LLXUIParser::instance().readXUI(node, p);
// Export must happen before setupParams() mungles rectangles and before
@ -233,7 +235,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
{
Params output_params(p);
setupParamsForExport(output_params, parent);
LLLayoutStack::Params default_params(LLUICtrlFactory::getDefaultParams<LLLayoutStack::Params>());
LLLayoutStack::Params default_params(LLUICtrlFactory::getDefaultParams<LLLayoutStack>());
output_node->setName(node->getName()->mString);
LLXUIParser::instance().writeXUI(
output_node, output_params, &default_params);
@ -296,7 +298,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
LLPanel::Params p;
LLPanel* panelp = LLUICtrlFactory::create<LLPanel>(p);
LLView* new_child = LLUICtrlFactory::getInstance()->createFromXML(child_node, panelp, LLStringUtil::null, output_child, parent ? parent->getChildRegistry() : LLDefaultWidgetRegistry::instance());
LLView* new_child = LLUICtrlFactory::getInstance()->createFromXML(child_node, panelp, LLStringUtil::null, LLPanel::child_registry_t::instance(), output_child);
if (new_child)
{
// put child in new embedded panel

View File

@ -43,7 +43,8 @@ public:
{
Optional<std::string> orientation;
Optional<S32> border_size;
Optional<bool> animate;
Optional<bool> animate;
Optional<bool> clip;
// mMinWidth and mMinHeight are calculated, not set in XML
Params();
@ -100,6 +101,7 @@ private:
S32 mPanelSpacing;
bool mAnimate;
bool mClip;
}; // end class LLLayoutStack
#endif

View File

@ -34,8 +34,6 @@
#include "linden_common.h"
#define INSTANTIATE_GETCHILD_LINEEDITOR
#include "lllineeditor.h"
#include "lltexteditor.h"
@ -72,9 +70,7 @@ const S32 SCROLL_INCREMENT_DEL = 4; // make space for baskspacing
const F32 AUTO_SCROLL_TIME = 0.05f;
const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. *TODO: make this equal to the double click interval?
static LLDefaultWidgetRegistry::Register<LLLineEditor> r1("line_editor");
template LLLineEditor* LLView::getChild<LLLineEditor>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
static LLDefaultChildRegistry::Register<LLLineEditor> r1("line_editor");
//
// Member functions
@ -95,7 +91,11 @@ void LLLineEditor::PrevalidateNamedFuncs::declareValues()
LLLineEditor::Params::Params()
: max_length_bytes("max_length", 254),
keystroke_callback("keystroke_callback"),
prevalidate_callback("prevalidate_callback"),
background_image("background_image"),
background_image_disabled("background_image_disabled"),
background_image_focused("background_image_focused"),
select_on_focus("select_on_focus", false),
handle_edit_keys_directly("handle_edit_keys_directly", false),
commit_on_focus_lost("commit_on_focus_lost", true),
@ -104,9 +104,8 @@ LLLineEditor::Params::Params()
text_color("text_color"),
text_readonly_color("text_readonly_color"),
text_tentative_color("text_tentative_color"),
bg_readonly_color("bg_readonly_color"),
bg_writeable_color("bg_writeable_color"),
bg_focus_color("bg_focus_color"),
highlight_color("highlight_color"),
preedit_bg_color("preedit_bg_color"),
border(""),
is_unicode("is_unicode"),
drop_shadow_visible("drop_shadow_visible"),
@ -119,6 +118,7 @@ LLLineEditor::Params::Params()
mouse_opaque = true;
addSynonym(select_on_focus, "select_all_on_focus_received");
addSynonym(border, "border");
addSynonym(label, "watermark_text");
}
LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
@ -128,6 +128,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
mScrollHPos( 0 ),
mTextPadLeft(p.text_pad_left),
mTextPadRight(p.text_pad_right),
mMinHPixels(0), // computed in updateTextPadding() below
mMaxHPixels(0), // computed in updateTextPadding() below
mCommitOnFocusLost( p.commit_on_focus_lost ),
mRevertOnEsc( TRUE ),
mKeystrokeCallback( p.keystroke_callback() ),
@ -146,18 +148,18 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
mSelectAllonFocusReceived( p.select_on_focus ),
mPassDelete(FALSE),
mReadOnly(FALSE),
mImage( NULL ),
mBgImage( p.background_image ),
mBgImageDisabled( p.background_image_disabled ),
mBgImageFocused( p.background_image_focused ),
mReplaceNewlinesWithSpaces( TRUE ),
mLabel(p.label),
mCursorColor(p.cursor_color()),
mFgColor(p.text_color()),
mReadOnlyFgColor(p.text_readonly_color()),
mTentativeFgColor(p.text_tentative_color()),
mWriteableBgColor(p.bg_writeable_color()),
mReadOnlyBgColor(p.bg_readonly_color()),
mFocusBgColor(p.bg_focus_color()),
mGLFont(p.font),
mGLFontStyle(LLFontGL::getStyleFromString(p.font.style))
mHighlightColor(p.highlight_color()),
mPreeditBgColor(p.preedit_bg_color()),
mGLFont(p.font)
{
llassert( mMaxLengthBytes > 0 );
@ -180,7 +182,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
LLViewBorder::Params border_p(p.border);
border_p.rect = border_rect;
border_p.follows.flags = FOLLOWS_ALL;
border_p.bevel_type = LLViewBorder::BEVEL_IN;
border_p.bevel_style = LLViewBorder::BEVEL_IN;
mBorder = LLUICtrlFactory::create<LLViewBorder>(border_p);
addChild( mBorder );
@ -233,6 +235,7 @@ void LLLineEditor::onFocusLost()
LLUICtrl::onFocusLost();
}
// virtual
void LLLineEditor::onCommit()
{
// put current line into the line history
@ -243,6 +246,33 @@ void LLLineEditor::onCommit()
selectAll();
}
// Returns TRUE if user changed value at all
// virtual
BOOL LLLineEditor::isDirty() const
{
return mText.getString() != mPrevText;
}
// Clear dirty state
// virtual
void LLLineEditor::resetDirty()
{
mPrevText = mText.getString();
}
// assumes UTF8 text
// virtual
void LLLineEditor::setValue(const LLSD& value )
{
setText(value.asString());
}
//virtual
LLSD LLLineEditor::getValue() const
{
return LLSD(getText());
}
// line history support
void LLLineEditor::updateHistory()
@ -1493,6 +1523,33 @@ void LLLineEditor::doDelete()
}
void LLLineEditor::drawBackground()
{
bool has_focus = hasFocus();
LLUIImage* image;
if ( mReadOnly )
{
image = mBgImageDisabled;
}
else if ( has_focus )
{
image = mBgImageFocused;
}
else
{
image = mBgImage;
}
// optionally draw programmatic border
if (has_focus)
{
image->drawBorder(0, 0, getRect().getWidth(), getRect().getHeight(),
gFocusMgr.getFocusColor(),
gFocusMgr.getFocusFlashWidth());
}
image->draw(getLocalRect());
}
void LLLineEditor::draw()
{
S32 text_len = mText.length();
@ -1523,37 +1580,12 @@ void LLLineEditor::draw()
LLRect background( 0, getRect().getHeight(), getRect().getWidth(), 0 );
background.stretch( -mBorderThickness );
LLColor4 bg_color = mReadOnlyBgColor.get();
#if 0 // for when we're ready for image art.
if( hasFocus())
{
mImage->drawBorder(0, 0, getRect().getWidth(), getRect().getHeight(), gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
}
mImage->draw(getLocalRect(), mReadOnly ? mReadOnlyBgColor : mWriteableBgColor );
#else // the old programmer art.
// drawing solids requires texturing be disabled
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
// draw background for text
if( !mReadOnly )
{
if( gFocusMgr.getKeyboardFocus() == this )
{
bg_color = mFocusBgColor.get();
}
else
{
bg_color = mWriteableBgColor.get();
}
}
gl_rect_2d(background, bg_color);
}
#endif
drawBackground();
// draw text
S32 cursor_bottom = background.mBottom + 1;
// With viewer-2 art files, input region is 2 pixels up
S32 cursor_bottom = background.mBottom + 2;
S32 cursor_top = background.mTop - 1;
LLColor4 text_color;
@ -1595,7 +1627,8 @@ void LLLineEditor::draw()
background.mBottom + preedit_standout_position,
preedit_pixels_right - preedit_standout_gap - 1,
background.mBottom + preedit_standout_position - preedit_standout_thickness,
(text_color * preedit_standout_brightness + bg_color * (1 - preedit_standout_brightness)).setAlpha(1.0f));
(text_color * preedit_standout_brightness
+ mPreeditBgColor * (1 - preedit_standout_brightness)).setAlpha(1.0f));
}
else
{
@ -1603,7 +1636,8 @@ void LLLineEditor::draw()
background.mBottom + preedit_marker_position,
preedit_pixels_right - preedit_marker_gap - 1,
background.mBottom + preedit_marker_position - preedit_marker_thickness,
(text_color * preedit_marker_brightness + bg_color * (1 - preedit_marker_brightness)).setAlpha(1.0f));
(text_color * preedit_marker_brightness
+ mPreeditBgColor * (1 - preedit_marker_brightness)).setAlpha(1.0f));
}
}
}
@ -1636,7 +1670,7 @@ void LLLineEditor::draw()
rendered_pixels_right, text_bottom,
text_color,
LLFontGL::LEFT, LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
select_left - mScrollHPos,
mMaxHPixels - llround(rendered_pixels_right),
@ -1645,7 +1679,7 @@ void LLLineEditor::draw()
if( (rendered_pixels_right < (F32)mMaxHPixels) && (rendered_text < text_len) )
{
LLColor4 color(1.f - bg_color.mV[0], 1.f - bg_color.mV[1], 1.f - bg_color.mV[2], 1.f);
LLColor4 color = mHighlightColor;
// selected middle
S32 width = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos + rendered_text, select_right - mScrollHPos - rendered_text);
width = llmin(width, mMaxHPixels - llround(rendered_pixels_right));
@ -1656,7 +1690,7 @@ void LLLineEditor::draw()
rendered_pixels_right, text_bottom,
LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], 1 ),
LLFontGL::LEFT, LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
select_right - mScrollHPos - rendered_text,
mMaxHPixels - llround(rendered_pixels_right),
@ -1671,7 +1705,7 @@ void LLLineEditor::draw()
rendered_pixels_right, text_bottom,
text_color,
LLFontGL::LEFT, LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
S32_MAX,
mMaxHPixels - llround(rendered_pixels_right),
@ -1685,13 +1719,13 @@ void LLLineEditor::draw()
rendered_pixels_right, text_bottom,
text_color,
LLFontGL::LEFT, LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
S32_MAX,
mMaxHPixels - llround(rendered_pixels_right),
&rendered_pixels_right);
}
#if 0 // for when we're ready for image art.
#if 1 // for when we're ready for image art.
mBorder->setVisible(FALSE); // no more programmatic art.
#endif
@ -1723,7 +1757,7 @@ void LLLineEditor::draw()
mGLFont->render(mText, getCursor(), (F32)(cursor_left + lineeditor_cursor_thickness / 2), text_bottom,
LLColor4( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], 1 ),
LLFontGL::LEFT, LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
1);
}
@ -1749,7 +1783,7 @@ void LLLineEditor::draw()
label_color,
LLFontGL::LEFT,
LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
S32_MAX,
mMaxHPixels - llround(rendered_pixels_right),
@ -1774,7 +1808,7 @@ void LLLineEditor::draw()
label_color,
LLFontGL::LEFT,
LLFontGL::BOTTOM,
mGLFontStyle,
0,
LLFontGL::NO_SHADOW,
S32_MAX,
mMaxHPixels - llround(rendered_pixels_right),

View File

@ -84,7 +84,9 @@ public:
Optional<LLViewBorder::Params> border;
Optional<LLUIImage*> background_image;
Optional<LLUIImage*> background_image,
background_image_disabled,
background_image_focused;
Optional<bool> select_on_focus,
handle_edit_keys_directly,
@ -96,10 +98,9 @@ public:
text_color,
text_readonly_color,
text_tentative_color,
bg_readonly_color,
bg_writeable_color,
bg_focus_color;
highlight_color,
preedit_bg_color;
Optional<S32> text_pad_left,
text_pad_right;
@ -107,7 +108,7 @@ public:
drop_shadow_visible,
border_drop_shadow_visible,
bg_visible;
Params();
};
protected:
@ -163,12 +164,12 @@ public:
virtual void setRect(const LLRect& rect);
virtual BOOL acceptsTextInput() const;
virtual void onCommit();
virtual BOOL isDirty() const { return mText.getString() != mPrevText; } // Returns TRUE if user changed value at all
virtual void resetDirty() { mPrevText = mText.getString(); } // Clear dirty state
virtual BOOL isDirty() const; // Returns TRUE if user changed value at all
virtual void resetDirty(); // Clear dirty state
// assumes UTF8 text
virtual void setValue(const LLSD& value ) { setText(value.asString()); }
virtual LLSD getValue() const { return LLSD(getText()); }
virtual void setValue(const LLSD& value );
virtual LLSD getValue() const;
virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text );
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
@ -197,16 +198,10 @@ public:
void setFgColor( const LLColor4& c ) { mFgColor = c; }
void setReadOnlyFgColor( const LLColor4& c ) { mReadOnlyFgColor = c; }
void setTentativeFgColor(const LLColor4& c) { mTentativeFgColor = c; }
void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; }
void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; }
void setFocusBgColor(const LLColor4& c) { mFocusBgColor = c; }
const LLColor4& getFgColor() const { return mFgColor.get(); }
const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor.get(); }
const LLColor4& getTentativeFgColor() const { return mTentativeFgColor.get(); }
const LLColor4& getWriteableBgColor() const { return mWriteableBgColor.get(); }
const LLColor4& getReadOnlyBgColor() const { return mReadOnlyBgColor.get(); }
const LLColor4& getFocusBgColor() const { return mFocusBgColor.get(); }
void setIgnoreArrowKeys(BOOL b) { mIgnoreArrowKeys = b; }
void setIgnoreTab(BOOL b) { mIgnoreTab = b; }
@ -266,6 +261,9 @@ private:
BOOL handleControlKey(KEY key, MASK mask);
S32 handleCommitKey(KEY key, MASK mask);
void updateTextPadding();
// Draw the background image depending on enabled/focused state.
void drawBackground();
//
// private data members
@ -294,7 +292,6 @@ protected:
LLViewBorder* mBorder;
const LLFontGL* mGLFont;
U8 mGLFontStyle;
S32 mMaxLengthBytes; // Max length of the UTF8 string in bytes
S32 mCursorPos; // I-beam is just after the mCursorPos-th character.
S32 mScrollHPos; // Horizontal offset from the start of mText. Used for scrolling.
@ -326,9 +323,8 @@ protected:
LLUIColor mFgColor;
LLUIColor mReadOnlyFgColor;
LLUIColor mTentativeFgColor;
LLUIColor mWriteableBgColor;
LLUIColor mReadOnlyBgColor;
LLUIColor mFocusBgColor;
LLUIColor mHighlightColor; // background for selected text
LLUIColor mPreeditBgColor; // preedit marker background color
S32 mBorderThickness;
@ -349,7 +345,9 @@ protected:
private:
// Instances that by default point to the statics but can be overidden in XML.
LLPointer<LLUIImage> mImage;
LLPointer<LLUIImage> mBgImage;
LLPointer<LLUIImage> mBgImageDisabled;
LLPointer<LLUIImage> mBgImageFocused;
BOOL mReplaceNewlinesWithSpaces; // if false, will replace pasted newlines with paragraph symbol.
@ -392,12 +390,6 @@ private:
}; // end class LLLineEditor
#ifdef LL_WINDOWS
#ifndef INSTANTIATE_GETCHILD_LINEEDITOR
#pragma warning (disable : 4231)
extern template LLLineEditor* LLView::getChild<LLLineEditor>( const std::string& name, BOOL recurse, BOOL create_if_missing ) const;
#endif
#endif
namespace LLInitParam
{

View File

@ -49,12 +49,12 @@
#include "llmath.h"
#include "llrender.h"
#include "llfocusmgr.h"
#include "llfont.h"
#include "llcoord.h"
#include "llwindow.h"
#include "llcriticaldamp.h"
#include "lluictrlfactory.h"
#include "llbutton.h"
#include "llfontgl.h"
#include "llresmgr.h"
#include "llui.h"
@ -89,7 +89,6 @@ const U32 RIGHT_PAD_PIXELS = 2;
const U32 RIGHT_WIDTH_PIXELS = 15;
const U32 RIGHT_PLAIN_PIXELS = RIGHT_PAD_PIXELS + RIGHT_WIDTH_PIXELS;
const U32 ACCEL_PAD_PIXELS = 10;
const U32 PLAIN_PAD_PIXELS = LEFT_PAD_PIXELS + LEFT_WIDTH_PIXELS + RIGHT_PAD_PIXELS + RIGHT_WIDTH_PIXELS;
const U32 BRIEF_PAD_PIXELS = 2;
@ -119,16 +118,12 @@ const F32 PIE_SHRINK_TIME = 0.2f; // time of transition between unbounded and bo
const F32 ACTIVATE_HIGHLIGHT_TIME = 0.3f;
// widget registrars
struct MenuRegistry : public LLWidgetRegistry<MenuRegistry>
{};
static MenuRegistry::Register<LLMenuItemSeparatorGL> register_separator("menu_item_separator");
static MenuRegistry::Register<LLMenuItemCallGL> register_menu_item_call("menu_item_call");
static MenuRegistry::Register<LLMenuItemCheckGL> register_menu_item_check("menu_item_check");
static MenuRegistry::Register<LLMenuGL> register_menu("menu");
static LLDefaultWidgetRegistry::Register<LLMenuGL> register_menu_default("menu");
static LLDefaultChildRegistry::Register<LLMenuGL> register_menu_default("menu");
@ -306,7 +301,7 @@ U32 LLMenuItemGL::getNominalHeight( void ) const
// Get the parent menu for this item
LLMenuGL* LLMenuItemGL::getMenu()
LLMenuGL* LLMenuItemGL::getMenu() const
{
return (LLMenuGL*) getParent();
}
@ -330,7 +325,7 @@ U32 LLMenuItemGL::getNominalWidth( void ) const
if( KEY_NONE != mAcceleratorKey )
{
width += ACCEL_PAD_PIXELS;
width += getMenu()->getShortcutPad();
std::string temp;
appendAcceleratorString( temp );
width += mFont->getWidth( temp );
@ -519,12 +514,13 @@ BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit&
return TRUE;
}
void LLMenuItemGL::onVisibilityChange(BOOL new_visibility)
void LLMenuItemGL::handleVisibilityChange(BOOL new_visibility)
{
if (getMenu())
{
getMenu()->needsArrange();
}
LLView::handleVisibilityChange(new_visibility);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -797,6 +793,16 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask )
return FALSE;
}
BOOL LLMenuItemCallGL::handleRightMouseUp(S32 x, S32 y, MASK mask)
{
if (pointInView(x, y))
{
mRightClickSignal(this, getValue());
}
return TRUE;
}
///============================================================================
/// Class LLMenuItemCheckGL
///============================================================================
@ -1061,13 +1067,13 @@ void LLMenuItemBranchGL::updateBranchParent(LLView* parentp)
}
}
void LLMenuItemBranchGL::onVisibilityChange( BOOL new_visibility )
void LLMenuItemBranchGL::handleVisibilityChange( BOOL new_visibility )
{
if (new_visibility == FALSE && getBranch() && !getBranch()->getTornOff())
{
getBranch()->setVisible(FALSE);
}
LLMenuItemGL::onVisibilityChange(new_visibility);
LLMenuItemGL::handleVisibilityChange(new_visibility);
}
BOOL LLMenuItemBranchGL::handleKeyHere( KEY key, MASK mask )
@ -1457,6 +1463,7 @@ void LLMenuItemBranchDownGL::draw( void )
setHover(FALSE);
}
class LLMenuScrollItem : public LLMenuItemCallGL
{
public:
@ -1465,10 +1472,18 @@ public:
ARROW_DOWN,
ARROW_UP
};
struct ArrowTypes : public LLInitParam::TypeValuesHelper<EArrowType, ArrowTypes>
{
static void declareValues()
{
declare("up", ARROW_UP);
declare("down", ARROW_DOWN);
}
};
struct Params : public LLInitParam::Block<Params, LLMenuItemCallGL::Params>
{
Optional<EArrowType> arrow_type;
Optional<EArrowType, ArrowTypes> arrow_type;
Optional<CommitCallbackParam> scroll_callback;
};
@ -1572,7 +1587,8 @@ LLMenuGL::LLMenuGL(const LLMenuGL::Params& p)
mJumpKey(p.jump_key),
mCreateJumpKeys(p.create_jump_keys),
mParentFloaterHandle(p.parent_floater),
mNeedsArrange(FALSE)
mNeedsArrange(FALSE),
mShortcutPad(p.shortcut_pad)
{
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("_");
@ -1646,15 +1662,17 @@ bool LLMenuGL::addChild(LLView* view, S32 tab_group)
void LLMenuGL::removeChild( LLView* ctrl)
{
LLMenuItemGL* itemp = dynamic_cast<LLMenuItemGL*>(ctrl);
if (itemp)
// previously a dynamic_cast with if statement to check validity
// unfortunately removeChild is called by ~LLView, and at that point the
// object being deleted is no longer a LLMenuItemGL so a dynamic_cast will fail
LLMenuItemGL* itemp = static_cast<LLMenuItemGL*>(ctrl);
item_list_t::iterator found_it = std::find(mItems.begin(), mItems.end(), (itemp));
if (found_it != mItems.end())
{
item_list_t::iterator found_it = std::find(mItems.begin(), mItems.end(), (itemp));
if (found_it != mItems.end())
{
mItems.erase(found_it);
}
mItems.erase(found_it);
}
return LLUICtrl::removeChild(ctrl);
}
@ -1664,12 +1682,6 @@ BOOL LLMenuGL::postBuild()
return LLUICtrl::postBuild();
}
const widget_registry_t& LLMenuGL::getChildRegistry() const
{
return MenuRegistry::instance();
}
// are we the childmost active menu and hence our jump keys should be enabled?
// or are we a free-standing torn-off menu (which uses jump keys too)
BOOL LLMenuGL::jumpKeysActive()
@ -2331,10 +2343,10 @@ BOOL LLMenuGL::appendMenu( LLMenuGL* menu )
p.label = menu->getLabel();
p.branch = menu;
p.jump_key = menu->getJumpKey();
p.enabled_color=LLUI::getCachedColorFunctor("MenuItemEnabledColor");
p.disabled_color=LLUI::getCachedColorFunctor("MenuItemDisabledColor");
p.highlight_bg_color=LLUI::getCachedColorFunctor("MenuItemHighlightBgColor");
p.highlight_fg_color=LLUI::getCachedColorFunctor("MenuItemHighlightFgColor");
p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor");
p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor");
p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor");
p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor");
LLMenuItemBranchGL* branch = LLUICtrlFactory::create<LLMenuItemBranchGL>(p);
success &= append( branch );
@ -2741,7 +2753,7 @@ void LLMenuGL::draw( void )
if (mDropShadowed && !mTornOff)
{
static LLUICachedControl<S32> drop_shadow_floater ("DropShadowFloater", 0);
static LLUICachedControl<LLColor4> color_drop_shadow ("ColorDropShadow", *(new LLColor4));
static LLUIColor color_drop_shadow = LLUIColorTable::instance().getColor("ColorDropShadow");
gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
color_drop_shadow, drop_shadow_floater );
}
@ -2883,7 +2895,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y)
/// Class LLMenuBarGL
///============================================================================
static LLDefaultWidgetRegistry::Register<LLMenuBarGL> r2("menu_bar");
static LLDefaultChildRegistry::Register<LLMenuBarGL> r2("menu_bar");
LLMenuBarGL::LLMenuBarGL( const Params& p )
: LLMenuGL(p),
@ -3115,10 +3127,10 @@ BOOL LLMenuBarGL::appendMenu( LLMenuGL* menu )
p.label = menu->getLabel();
p.visible = menu->getVisible();
p.branch = menu;
p.enabled_color=LLUI::getCachedColorFunctor("MenuItemEnabledColor");
p.disabled_color=LLUI::getCachedColorFunctor("MenuItemDisabledColor");
p.highlight_bg_color=LLUI::getCachedColorFunctor("MenuItemHighlightBgColor");
p.highlight_fg_color=LLUI::getCachedColorFunctor("MenuItemHighlightFgColor");
p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor");
p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor");
p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor");
p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor");
LLMenuItemBranchDownGL* branch = LLUICtrlFactory::create<LLMenuItemBranchDownGL>(p);
success &= branch->addToAcceleratorList(&mAccelerators);
@ -3202,6 +3214,8 @@ BOOL LLMenuBarGL::handleHover( S32 x, S32 y, MASK mask )
///============================================================================
/// Class LLMenuHolderGL
///============================================================================
LLCoordGL LLMenuHolderGL::sContextMenuSpawnPos(S32_MAX, S32_MAX);
LLMenuHolderGL::LLMenuHolderGL()
: LLPanel()
{
@ -3258,6 +3272,32 @@ BOOL LLMenuHolderGL::handleRightMouseDown( S32 x, S32 y, MASK mask )
return handled;
}
// This occurs when you mouse-down to spawn a context menu, hold the button
// down, move off the menu, then mouse-up. We want this to close the menu.
BOOL LLMenuHolderGL::handleRightMouseUp( S32 x, S32 y, MASK mask )
{
const S32 SLOP = 2;
S32 spawn_dx = (x - sContextMenuSpawnPos.mX);
S32 spawn_dy = (y - sContextMenuSpawnPos.mY);
if (-SLOP <= spawn_dx && spawn_dx <= SLOP
&& -SLOP <= spawn_dy && spawn_dy <= SLOP)
{
// we're still inside the slop region from spawning this menu
// so interpret the mouse-up as a single-click to show and leave on
// screen
sContextMenuSpawnPos.set(S32_MAX, S32_MAX);
return TRUE;
}
BOOL handled = LLView::childrenHandleRightMouseUp(x, y, mask) != NULL;
if (!handled)
{
// clicked off of menu, hide them all
hideMenus();
}
return handled;
}
void LLMenuHolderGL::reshape(S32 width, S32 height, BOOL called_from_parent)
{
if (width != getRect().getWidth() || height != getRect().getHeight())
@ -3320,7 +3360,7 @@ void LLMenuHolderGL::setActivatedItem(LLMenuItemGL* item)
/// Class LLTearOffMenu
///============================================================================
LLTearOffMenu::LLTearOffMenu(LLMenuGL* menup) :
LLFloater()
LLFloater(LLSD())
{
static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0);
@ -3353,6 +3393,16 @@ LLTearOffMenu::LLTearOffMenu(LLMenuGL* menup) :
mMenu->highlightNextItem(NULL);
}
LLTearOffMenu::~LLTearOffMenu()
{
}
// virtual
BOOL LLTearOffMenu::postBuild()
{
mCloseSignal.connect(boost::bind(&LLTearOffMenu::closeTearOff, this));
return TRUE;
}
void LLTearOffMenu::draw()
{
@ -3452,7 +3502,7 @@ LLTearOffMenu* LLTearOffMenu::create(LLMenuGL* menup)
return tearoffp;
}
void LLTearOffMenu::onClose(bool app_quitting)
void LLTearOffMenu::closeTearOff()
{
removeChild(mMenu);
mOldParent->addChild(mMenu);
@ -3462,7 +3512,6 @@ void LLTearOffMenu::onClose(bool app_quitting)
mMenu->setVisible(FALSE);
mMenu->setTornOff(FALSE);
mMenu->setDropShadowed(TRUE);
destroy();
}
@ -3540,7 +3589,7 @@ void LLContextMenuBranch::showSubMenu()
S32 center_x;
S32 center_y;
localPointToScreen(getRect().getWidth(), getRect().getHeight() , &center_x, &center_y);
mBranch->show( center_x, center_y, FALSE);
mBranch->show( center_x, center_y);
}
// onCommit() - do the primary funcationality of the menu item.
@ -3569,7 +3618,7 @@ void LLContextMenuBranch::setHighlight( BOOL highlight )
// class LLContextMenu
// A context menu
//-----------------------------------------------------------------------------
static LLDefaultWidgetRegistry::Register<LLContextMenu> context_menu_register("context_menu");
static LLDefaultChildRegistry::Register<LLContextMenu> context_menu_register("context_menu");
static MenuRegistry::Register<LLContextMenu> context_menu_register2("context_menu");
@ -3577,7 +3626,6 @@ LLContextMenu::LLContextMenu(const Params& p)
: LLMenuGL(p),
mHoveredAnyItem(FALSE),
mHoverItem(NULL)
{
//setBackgroundVisible(TRUE);
}
@ -3588,8 +3636,14 @@ void LLContextMenu::setVisible(BOOL visible)
hide();
}
void LLContextMenu::show(S32 x, S32 y,BOOL adjustCursor)
// Takes cursor position in screen space?
void LLContextMenu::show(S32 x, S32 y)
{
// Save click point for detecting cursor moves before mouse-up.
// Must be in local coords to compare with mouseUp events.
// If the mouse doesn't move, the menu will stay open ala the Mac.
LLMenuHolderGL::sContextMenuSpawnPos.set(x,y);
arrangeAndClear();
S32 width = getRect().getWidth();
@ -3597,29 +3651,41 @@ void LLContextMenu::show(S32 x, S32 y,BOOL adjustCursor)
const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
LLView* parent_view = getParent();
if(getParentMenuItem())
// Open upwards if menu extends past bottom
if (y - height < menu_region_rect.mBottom)
{
S32 parent_width = getParentMenuItem()->getRect().getWidth();
if(x + width > menu_region_rect.getWidth())
x -= parent_width + width;
if (getParentMenuItem()) // Adjust if this is a submenu
{
y += height - getParentMenuItem()->getNominalHeight();
}
else
{
y += height;
}
}
// Open out to the left if menu extends past right edge
if (x + width > menu_region_rect.mRight)
{
if (getParentMenuItem())
{
x -= getParentMenuItem()->getRect().getWidth() + width;
}
else
{
x -= width;
}
}
S32 local_x, local_y;
parent_view->screenPointToLocal(x, y, &local_x, &local_y);
// HACK: casting away const. Should use setRect or some helper function instead.
const_cast<LLRect&>(getRect()).setCenterAndSize(local_x + width/2, local_y - height/2, width, height);
LLRect rect;
rect.setLeftTopAndSize(local_x, local_y, width, height);
setRect(rect);
arrange();
if (translateIntoRect(menu_region_rect,FALSE) && adjustCursor)
{
LLUI::setCursorPositionLocal(getParent(), getRect().mLeft , getRect().mTop);
}
LLView::setVisible(TRUE);
}
void LLContextMenu::hide()
@ -3679,58 +3745,8 @@ BOOL LLContextMenu::handleHover( S32 x, S32 y, MASK mask )
return handled;
}
BOOL LLContextMenu::handleMouseDown( S32 x, S32 y, MASK mask )
{
BOOL handled = FALSE;
// The click was somewhere within our rectangle
LLMenuItemGL *item = getHighlightedItem();
// handleMouseDown and handleMouseUp are handled by LLMenuGL
if (item)
{
// lie to the item about where the click happened
// to make sure it's within the item's rectangle
handled = item->handleMouseDown( 0, 0, mask );
}
else
{
// call hidemenus to make sure transient selections get cleared
((LLMenuHolderGL*)getParent())->hideMenus();
}
// always handle mouse down as mouse up will close open menus
return handled;
}
BOOL LLContextMenu::handleMouseUp( S32 x, S32 y, MASK mask )
{
BOOL handled = FALSE;
// The click was somewhere within our rectangle
LLMenuItemGL *item = getHighlightedItem();
if (item)
{
// lie to the item about where the click happened
// to make sure it's within the item's rectangle
if (item->getEnabled())
{
handled = item->handleMouseUp( 0, 0, mask );
hide();
}
}
else
{
// call hidemenus to make sure transient selections get cleared
((LLMenuHolderGL*)getParent())->hideMenus();
}
if (!handled)
{
// call hidemenus to make sure transient selections get cleared
sMenuContainer->hideMenus();
}
return handled;
}
BOOL LLContextMenu::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
@ -3766,8 +3782,6 @@ BOOL LLContextMenu::handleRightMouseDown(S32 x, S32 y, MASK mask)
BOOL LLContextMenu::handleRightMouseUp( S32 x, S32 y, MASK mask )
{
// release mouse capture when right mouse button released, and we're past the shrink time
S32 local_x = x - getRect().mLeft;
S32 local_y = y - getRect().mBottom;
@ -3802,10 +3816,10 @@ BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu)
p.name = menu->getName();
p.label = menu->getLabel();
p.branch = menu;
p.enabled_color=LLUI::getCachedColorFunctor("MenuItemEnabledColor");
p.disabled_color=LLUI::getCachedColorFunctor("MenuItemDisabledColor");
p.highlight_bg_color=LLUI::getCachedColorFunctor("MenuItemHighlightBgColor");
p.highlight_fg_color=LLUI::getCachedColorFunctor("MenuItemHighlightFgColor");
p.enabled_color=LLUIColorTable::instance().getColor("MenuItemEnabledColor");
p.disabled_color=LLUIColorTable::instance().getColor("MenuItemDisabledColor");
p.highlight_bg_color=LLUIColorTable::instance().getColor("MenuItemHighlightBgColor");
p.highlight_fg_color=LLUIColorTable::instance().getColor("MenuItemHighlightFgColor");
item = LLUICtrlFactory::create<LLContextMenuBranch>(p);
LLMenuGL::sMenuContainer->addChild(item->getBranch());

View File

@ -81,7 +81,7 @@ public:
Params()
: shortcut("shortcut"),
jump_key("", KEY_NONE),
jump_key("jump_key", KEY_NONE),
use_mac_ctrl("use_mac_ctrl", false),
rect("rect"),
left("left"),
@ -106,7 +106,7 @@ protected:
friend class LLUICtrlFactory;
public:
virtual void setValue(const LLSD& value) { setLabel(value.asString()); }
/*virtual*/ void onVisibilityChange(BOOL new_visibility);
/*virtual*/ void handleVisibilityChange(BOOL new_visibility);
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
@ -137,7 +137,7 @@ public:
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
// Get the parent menu for this item
virtual class LLMenuGL* getMenu();
virtual class LLMenuGL* getMenu() const;
// returns the normal width of this control in pixels - this is
// used for calculating the widest item, as well as for horizontal
@ -283,6 +283,7 @@ public:
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
virtual BOOL handleKeyHere(KEY key, MASK mask);
virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
//virtual void draw();
@ -295,6 +296,11 @@ public:
{
return mEnableSignal.connect(cb);
}
boost::signals2::connection setRightClickedCallback( const commit_signal_t::slot_type& cb )
{
return mRightClickSignal.connect(cb);
}
private:
enable_signal_t mEnableSignal;
@ -356,6 +362,11 @@ private:
// it in the appendMenu() method.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// child widget registry
struct MenuRegistry : public LLChildRegistry<MenuRegistry>
{};
class LLMenuGL
: public LLUICtrl
{
@ -372,15 +383,18 @@ public:
keep_fixed_size,
scrollable;
Optional<LLUIColor> bg_color;
Optional<S32> shortcut_pad;
Params()
: jump_key("", KEY_NONE),
: jump_key("jump_key", KEY_NONE),
horizontal_layout("horizontal_layout"),
can_tear_off("tear_off", false),
drop_shadow("drop_shadow", true),
bg_visible("bg_visible", true),
create_jump_keys("create_jump_keys", false),
bg_color("bg_color", LLUI::getCachedColorFunctor( "MenuDefaultBgColor" )),
scrollable("scrollable", false)
bg_color("bg_color", LLUIColorTable::instance().getColor( "MenuDefaultBgColor" )),
scrollable("scrollable", false),
shortcut_pad("shortcut_pad")
{
addSynonym(bg_visible, "opaque");
addSynonym(bg_color, "color");
@ -388,6 +402,10 @@ public:
name = "menu";
}
};
// my valid children are contained in MenuRegistry
typedef MenuRegistry child_registry_t;
void initFromParams(const Params&);
protected:
@ -410,7 +428,6 @@ public:
/*virtual*/ bool addChild(LLView* view, S32 tab_group = 0);
/*virtual*/ void removeChild( LLView* ctrl);
/*virtual*/ BOOL postBuild();
/*virtual*/ const widget_registry_t& getChildRegistry() const;
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
@ -498,6 +515,8 @@ public:
static void setKeyboardMode(BOOL mode) { sKeyboardMode = mode; }
static BOOL getKeyboardMode() { return sKeyboardMode; }
S32 getShortcutPad() { return mShortcutPad; }
void scrollItemsUp();
void scrollItemsDown();
BOOL isScrollable() const { return mScrollable; }
@ -551,6 +570,7 @@ private:
LLHandle<LLFloater> mParentFloaterHandle;
KEY mJumpKey;
BOOL mCreateJumpKeys;
S32 mShortcutPad;
}; // end class LLMenuGL
@ -606,7 +626,7 @@ public:
virtual void updateBranchParent( LLView* parentp );
// LLView Functionality
virtual void onVisibilityChange( BOOL curVisibilityIn );
virtual void handleVisibilityChange( BOOL curVisibilityIn );
virtual void draw();
@ -651,16 +671,12 @@ public:
virtual void draw ();
virtual void show (S32 x, S32 y, BOOL adjustCursor = TRUE);
virtual void show (S32 x, S32 y);
virtual void hide ();
virtual BOOL handleHover ( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseDown ( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseUp ( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseUp ( S32 x, S32 y, MASK mask );
virtual bool addChild (LLView* view, S32 tab_group = 0);
@ -749,11 +765,18 @@ public:
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
// Close context menus on right mouse up not handled by menus.
/*virtual*/ BOOL handleRightMouseUp( S32 x, S32 y, MASK mask );
virtual const LLRect getMenuRect() const { return getLocalRect(); }
virtual BOOL hasVisibleMenu() const;
static void setActivatedItem(LLMenuItemGL* item);
// Need to detect if mouse-up after context menu spawn has moved.
// If not, need to keep the menu up.
static LLCoordGL sContextMenuSpawnPos;
private:
static LLHandle<LLView> sItemLastSelectedHandle;
static LLFrameTimer sItemActivationTimer;
@ -771,8 +794,10 @@ class LLTearOffMenu : public LLFloater
{
public:
static LLTearOffMenu* create(LLMenuGL* menup);
virtual ~LLTearOffMenu() {}
virtual void onClose(bool app_quitting);
virtual ~LLTearOffMenu();
virtual BOOL postBuild();
virtual void draw(void);
virtual void onFocusReceived();
virtual void onFocusLost();
@ -782,7 +807,9 @@ public:
private:
LLTearOffMenu(LLMenuGL* menup);
void closeTearOff();
LLView* mOldParent;
LLMenuGL* mMenu;
F32 mTargetHeight;

View File

@ -44,12 +44,11 @@
// static
std::list<LLModalDialog*> LLModalDialog::sModalStack;
LLModalDialog::LLModalDialog( const std::string& title, S32 width, S32 height, BOOL modal )
: LLFloater(),
LLModalDialog::LLModalDialog( const LLSD& key, S32 width, S32 height, BOOL modal )
: LLFloater(key),
mModal( modal )
{
setRect(LLRect( 0, height, width, 0 ));
setTitle(title);
if (modal)
{
setCanMinimize(FALSE);
@ -59,6 +58,7 @@ LLModalDialog::LLModalDialog( const std::string& title, S32 width, S32 height, B
setBackgroundVisible(TRUE);
setBackgroundOpaque(TRUE);
centerOnScreen(); // default position
mCloseSignal.connect(boost::bind(&LLModalDialog::stopModal, this));
}
LLModalDialog::~LLModalDialog()
@ -68,6 +68,18 @@ LLModalDialog::~LLModalDialog()
{
gFocusMgr.unlockFocus();
}
std::list<LLModalDialog*>::iterator iter = std::find(sModalStack.begin(), sModalStack.end(), this);
if (iter != sModalStack.end())
{
llerrs << "Attempt to delete dialog while still in sModalStack!" << llendl;
}
}
// virtual
BOOL LLModalDialog::postBuild()
{
return LLFloater::postBuild();
}
// virtual
@ -235,16 +247,10 @@ BOOL LLModalDialog::handleKeyHere(KEY key, MASK mask )
}
}
void LLModalDialog::onClose(bool app_quitting)
{
stopModal();
LLFloater::onClose(app_quitting);
}
// virtual
void LLModalDialog::draw()
{
static LLUICachedControl<LLColor4> shadow_color ("ColorDropShadow", *(new LLColor4));
static LLUIColor shadow_color = LLUIColorTable::instance().getColor("ColorDropShadow");
static LLUICachedControl<S32> shadow_lines ("DropShadowFloater", 0);
gl_drop_shadow( 0, getRect().getHeight(), getRect().getWidth(), 0,

View File

@ -45,9 +45,11 @@ class LLModalDialog;
class LLModalDialog : public LLFloater
{
public:
LLModalDialog( const std::string& title, S32 width, S32 height, BOOL modal = true );
LLModalDialog( const LLSD& key, S32 width, S32 height, BOOL modal = true );
/*virtual*/ ~LLModalDialog();
/*virtual*/ BOOL postBuild();
/*virtual*/ void openFloater(const LLSD& key = LLSD());
/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
@ -63,8 +65,6 @@ public:
/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask );
/*virtual*/ void onClose(bool app_quitting);
/*virtual*/ void setVisible(BOOL visible);
/*virtual*/ void draw();

View File

@ -42,8 +42,8 @@
// LLMultiFloater
//
LLMultiFloater::LLMultiFloater(const LLFloater::Params& params)
: LLFloater(),
LLMultiFloater::LLMultiFloater(const LLSD& key, const LLFloater::Params& params)
: LLFloater(key),
mTabContainer(NULL),
mTabPos(LLTabContainer::TOP),
mAutoResize(TRUE),
@ -74,20 +74,12 @@ void LLMultiFloater::buildTabContainer()
void LLMultiFloater::onOpen(const LLSD& key)
{
if (mTabContainer->getTabCount() <= 0)
{
// for now, don't allow multifloaters
// without any child floaters
closeFloater();
}
}
void LLMultiFloater::onClose(bool app_quitting)
{
if(closeAllFloaters() == TRUE)
{
LLFloater::onClose(app_quitting);
}//else not all tabs could be closed...
// if (mTabContainer->getTabCount() <= 0)
// {
// // for now, don't allow multifloaters
// // without any child floaters
// closeFloater();
// }
}
void LLMultiFloater::draw()
@ -124,7 +116,8 @@ BOOL LLMultiFloater::closeAllFloaters()
//Tab did not actually close, possibly due to a pending Save Confirmation dialog..
//so try and close the next one in the list...
tabToClose++;
}else
}
else
{
//Tab closed ok.
lastTabCount = mTabContainer->getTabCount();
@ -246,6 +239,9 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
{
floaterp->setVisible(FALSE);
}
// Tabs sometimes overlap resize handle
moveResizeHandlesToFront();
}
/**
@ -275,6 +271,7 @@ void LLMultiFloater::selectPrevFloater()
void LLMultiFloater::showFloater(LLFloater* floaterp, LLTabContainer::eInsertionPoint insertion_point)
{
if(!floaterp) return;
// we won't select a panel that already is selected
// it is hard to do this internally to tab container
// as tab selection is handled via index and the tab at a given
@ -288,7 +285,7 @@ void LLMultiFloater::showFloater(LLFloater* floaterp, LLTabContainer::eInsertion
void LLMultiFloater::removeFloater(LLFloater* floaterp)
{
if ( floaterp->getHost() != this )
if (!floaterp || floaterp->getHost() != this )
return;
floater_data_map_t::iterator found_data_it = mFloaterDataMap.find(floaterp->getHandle());
@ -447,6 +444,8 @@ void LLMultiFloater::setCanResize(BOOL can_resize)
BOOL LLMultiFloater::postBuild()
{
mCloseSignal.connect(boost::bind(&LLMultiFloater::closeAllFloaters, this));
// remember any original xml minimum size
getResizeLimits(&mOrigMinWidth, &mOrigMinHeight);

View File

@ -44,14 +44,13 @@
class LLMultiFloater : public LLFloater
{
public:
LLMultiFloater(const LLFloater::Params& params = LLFloater::getDefaultParams());
LLMultiFloater(const LLSD& key, const Params& params = getDefaultParams());
virtual ~LLMultiFloater() {};
void buildTabContainer();
virtual BOOL postBuild();
/*virtual*/ void onOpen(const LLSD& key);
/*virtual*/ void onClose(bool app_quitting);
/*virtual*/ void draw();
/*virtual*/ void setVisible(BOOL visible);
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);

View File

@ -40,12 +40,11 @@
#include "llfocusmgr.h"
#include "llkeyboard.h" // for the MASK constants
#include "llcontrol.h"
#include "llimagegl.h"
#include "lluictrlfactory.h"
#include <sstream>
static LLDefaultWidgetRegistry::Register<LLMultiSlider> r("multi_slider_bar");
static LLDefaultChildRegistry::Register<LLMultiSlider> r("multi_slider_bar");
const F32 FLOAT_THRESHOLD = 0.00001f;

Some files were not shown because too many files have changed in this diff Show More