Added LLInitParam. Not yet plugged into xml parsing.

This commit is contained in:
Shyotl
2012-02-24 20:16:33 -06:00
parent a6a69caa4f
commit a066730acb
14 changed files with 3128 additions and 163 deletions

View File

@@ -77,6 +77,7 @@ if (VIEWER)
add_subdirectory(${LIBS_OPEN_PREFIX}llcrashlogger)
add_subdirectory(${LIBS_OPEN_PREFIX}llplugin)
add_subdirectory(${LIBS_OPEN_PREFIX}llui)
add_subdirectory(${LIBS_OPEN_PREFIX}llxuixml)
# viewer plugins directory
add_subdirectory(${LIBS_OPEN_PREFIX}plugins)

View File

@@ -0,0 +1,7 @@
# -*- cmake -*-
set(LLXUIXML_INCLUDE_DIRS
${LIBS_OPEN_DIR}/llxuixml
)
set(LLXUIXML_LIBRARIES llxuixml)

View File

@@ -5,22 +5,26 @@ project(llui)
include(00-Common)
include(LLCommon)
include(LLImage)
include(LLInventory)
include(LLMath)
include(LLMessage)
include(LLRender)
include(LLWindow)
include(LLVFS)
include(LLXML)
include(LLXUIXML)
include_directories(
${LLCOMMON_INCLUDE_DIRS}
${LLIMAGE_INCLUDE_DIRS}
${LLINVENTORY_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLMESSAGE_INCLUDE_DIRS}
${LLRENDER_INCLUDE_DIRS}
${LLWINDOW_INCLUDE_DIRS}
${LLVFS_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
${LLXUIXML_INCLUDE_DIRS}
)
set(llui_SOURCE_FILES
@@ -159,6 +163,7 @@ target_link_libraries(llui
llwindow
llimage
llvfs # ugh, just for LLDir
llxuixml
llxml
llcommon # must be after llimage, llwindow, llrender
llmath

View File

@@ -38,6 +38,7 @@
#include "llcallbackmap.h"
#include "llfloater.h"
#include "llinitparam.h"
class LLView;
class LLPanel;

View File

@@ -83,76 +83,94 @@ S32 LLView::sLastBottomXML = S32_MIN;
BOOL LLView::sIsDrawing = FALSE;
#endif
LLView::LLView()
: mVisible(TRUE),
mInDraw(false),
mParentView(NULL),
mReshapeFlags(FOLLOWS_NONE),
mDefaultTabGroup(0),
mEnabled(TRUE),
mMouseOpaque(TRUE),
mSoundFlags(MOUSE_UP), // default to only make sound on mouse up
mSaveToXML(TRUE),
mIsFocusRoot(FALSE),
mLastVisible(TRUE),
mUseBoundingRect(FALSE),
mNextInsertionOrdinal(0),
mHoverCursor(UI_CURSOR_ARROW),
mLastTabGroup(0),
// <edit>
mDelayedDelete(FALSE)
// </edit>
LLView::Follows::Follows()
: string(""),
flags("flags", FOLLOWS_NONE)
{}
LLView::Params::Params()
: name("name", std::string("unnamed")),
enabled("enabled", true),
visible("visible", true),
mouse_opaque("mouse_opaque", true),
follows("follows"),
hover_cursor("hover_cursor", "UI_CURSOR_ARROW"),
use_bounding_rect("use_bounding_rect", false),
tab_group("tab_group", 0),
default_tab_group("default_tab_group"),
//tool_tip("tool_tip"),
sound_flags("sound_flags", MOUSE_UP),
layout("layout"),
rect("rect"),
bottom_delta("bottom_delta", S32_MAX),
top_pad("top_pad"),
top_delta("top_delta", S32_MAX),
left_pad("left_pad"),
left_delta("left_delta", S32_MAX),
from_xui("from_xui", true),
focus_root("focus_root", false),
needs_translate("translate"),
xmlns("xmlns"),
xmlns_xsi("xmlns:xsi"),
xsi_schemaLocation("xsi:schemaLocation"),
xsi_type("xsi:type")
{
addSynonym(rect, "");
}
LLView::LLView(const LLView::Params& p)
{
init(p);
}
void LLView::init(const LLView::Params& p)
{
mVisible = p.visible;
mInDraw = false;
mName = p.name;
mParentView = NULL;
mReshapeFlags = FOLLOWS_NONE;
mSaveToXML = p.from_xui;
mIsFocusRoot = p.focus_root;
mLastVisible = FALSE;
mNextInsertionOrdinal = 0;
mHoverCursor = getCursorFromString(p.hover_cursor);
mEnabled = p.enabled;
mMouseOpaque = p.mouse_opaque;
mSoundFlags = p.sound_flags;
mUseBoundingRect = p.use_bounding_rect;
mDefaultTabGroup = p.default_tab_group;
mLastTabGroup = 0;
//mToolTipMsg((LLStringExplicit)p.tool_tip()),
//mDefaultWidgets(NULL)
// create rect first, as this will supply initial follows flags
setShape(p.rect);
mReshapeFlags = p.follows.flags;
}
LLView::LLView()
{
init(LLView::Params());
}
LLView::LLView(const std::string& name, BOOL mouse_opaque)
: mVisible(TRUE),
mInDraw(false),
mName(name),
mParentView(NULL),
mReshapeFlags(FOLLOWS_NONE),
mDefaultTabGroup(0),
mEnabled(TRUE),
mMouseOpaque(mouse_opaque),
mSoundFlags(MOUSE_UP), // default to only make sound on mouse up
mSaveToXML(TRUE),
mIsFocusRoot(FALSE),
mLastVisible(TRUE),
mUseBoundingRect(FALSE),
mNextInsertionOrdinal(0),
mHoverCursor(UI_CURSOR_ARROW),
mLastTabGroup(0),
// <edit>
mDelayedDelete(FALSE)
// </edit>
{
LLView::Params p;
p.name = name;
p.mouse_opaque = mouse_opaque;
init(p);
}
LLView::LLView(
const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 reshape)
: mVisible(TRUE),
mInDraw(false),
mName(name),
mParentView(NULL),
mRect(rect),
mBoundingRect(rect),
mReshapeFlags(reshape),
mDefaultTabGroup(0),
mEnabled(TRUE),
mMouseOpaque(mouse_opaque),
mSoundFlags(MOUSE_UP), // default to only make sound on mouse up
mSaveToXML(TRUE),
mIsFocusRoot(FALSE),
mLastVisible(TRUE),
mUseBoundingRect(FALSE),
mNextInsertionOrdinal(0),
mHoverCursor(UI_CURSOR_ARROW),
mLastTabGroup(0),
// <edit>
mDelayedDelete(FALSE)
// </edit>
LLView::LLView( const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 reshape)
{
LLView::Params p;
p.name = name;
p.mouse_opaque = mouse_opaque;
p.rect = rect;
p.follows.flags = reshape;
init(p);
}
@@ -160,15 +178,10 @@ LLView::~LLView()
{
//llinfos << "Deleting view " << mName << ":" << (void*) this << llendl;
// llassert(LLView::sIsDrawing == FALSE);
if( gFocusMgr.getKeyboardFocus() == this )
{
llwarns << "View holding keyboard focus deleted: " << getName() << ". Keyboard focus removed." << llendl;
gFocusMgr.removeKeyboardFocusWithoutCallback( this );
}
if( hasMouseCapture() )
{
llwarns << "View holding mouse capture deleted: " << getName() << ". Mouse capture removed." << llendl;
//llwarns << "View holding mouse capture deleted: " << getName() << ". Mouse capture removed." << llendl;
gFocusMgr.removeMouseCaptureWithoutCallback( this );
}
@@ -616,11 +629,6 @@ void LLView::setVisible(BOOL visible)
{
if ( mVisible != visible )
{
if( !visible && (gFocusMgr.getTopCtrl() == this) )
{
gFocusMgr.setTopCtrl( NULL );
}
mVisible = visible;
// notify children of visibility change if root, or part of visible hierarchy

View File

@@ -54,6 +54,7 @@
#include "stdenums.h"
#include "lluistring.h"
#include "llcursortypes.h"
#include "llinitparam.h"
#include "llfocusmgr.h"
const U32 FOLLOWS_NONE = 0x00;
@@ -68,88 +69,6 @@ const BOOL NOT_MOUSE_OPAQUE = FALSE;
const U32 GL_NAME_UI_RESERVED = 2;
/*
// virtual functions defined in LLView:
virtual BOOL isCtrl() const;
LLUICtrl
virtual BOOL isPanel();
LLPanel
virtual void setRect(const LLRect &rect);
LLLineEditor
virtual void addCtrl( LLUICtrl* ctrl, S32 tab_group);
virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group);
virtual void removeCtrl( LLUICtrl* ctrl);
LLPanel
virtual BOOL canFocusChildren() const { return TRUE; }
LLFolderView
virtual void deleteAllChildren();
LLFolderView, LLPanelObjectInventory
virtual void setTentative(BOOL b) {}
LLUICtrl, LLSliderCtrl, LLSpinCtrl
virtual BOOL getTentative() const { return FALSE; }
LLUICtrl, LLCheckBoxCtrl
virtual void setVisible(BOOL visible);
LLFloater, LLAlertDialog, LLMenuItemGL, LLModalDialog
virtual void setEnabled(BOOL enabled) { mEnabled = enabled; }
LLCheckBoxCtrl, LLComboBox, LLLineEditor, LLMenuGL, LLRadioGroup, etc
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ) { return FALSE; }
LLUICtrl, LLButton, LLCheckBoxCtrl, LLLineEditor, LLMenuGL, LLSliderCtrl
virtual void handleVisibilityChange ( BOOL curVisibilityIn );
LLMenuGL
virtual LLRect getSnapRect() const { return mRect; } *TODO: Make non virtual
LLFloater
virtual LLRect getRequiredRect() { return mRect; }
LLScrolllistCtrl
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
LLUICtrl, et. al.
virtual void translate( S32 x, S32 y );
LLMenuGL
virtual void handleReshape(const LLRect& new_rect, bool by_user = false);
LLFloater, LLScrollLIstVtrl
virtual LLView* findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, LLView::ESnapType snap_type, S32 threshold, S32 padding = 0);
virtual LLView* findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding = 0);
LLScrollListCtrl
virtual BOOL canSnapTo(const LLView* other_view) { return other_view != this && other_view->getVisible(); }
LLFloater
virtual void setSnappedTo(const LLView* snap_view) {}
LLFloater
virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
*
virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
*
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,EDragAndDropType cargo_type,void* cargo_data,EAcceptance* accept,std::string& tooltip_msg);
*
virtual void draw();
*
*
virtual LLXMLNodePtr getXML(bool save_children = true) const;
*
virtual void initFromXML(LLXMLNodePtr node, LLView* parent);
*
virtual void onFocusLost() {}
LLUICtrl, LLScrollListCtrl, LLMenuGL, LLLineEditor, LLComboBox
virtual void onFocusReceived() {}
LLUICtrl, LLTextEditor, LLScrollListVtrl, LLMenuGL, LLLineEditor
virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
LLTabContainer, LLPanel, LLMenuGL
virtual void setControlName(const std::string& control, LLView *context);
LLSliderCtrl, LLCheckBoxCtrl
virtual std::string getControlName() const { return mControlName; }
LLSliderCtrl, LLCheckBoxCtrl
virtual bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
LLMenuItem
virtual void setValue(const LLSD& value);
*
protected:
virtual BOOL handleKeyHere(KEY key, MASK mask);
*
virtual BOOL handleUnicodeCharHere(llwchar uni_char);
*
*/
class LLUICtrlFactory;
// maps xml strings to widget classes
@@ -209,9 +128,73 @@ public:
}
};
class LLView : public LLMouseHandler, public LLMortician, public LLFocusableElement
class LLView
: public LLMouseHandler, // handles mouse events
public LLFocusableElement, // handles keyboard events
public LLMortician // lazy deletion
//public LLHandleProvider<LLView> // passes out weak references to self
{
public:
struct Follows : public LLInitParam::ChoiceBlock<Follows>
{
Alternative<std::string> string;
Alternative<U32> flags;
Follows();
};
struct Params : public LLInitParam::Block<Params>
{
Mandatory<std::string> name;
Optional<bool> enabled,
visible,
mouse_opaque,
use_bounding_rect,
from_xui,
focus_root;
Optional<S32> tab_group,
default_tab_group;
Optional<std::string> tool_tip;
Optional<S32> sound_flags;
Optional<Follows> follows;
Optional<std::string> hover_cursor;
Optional<std::string> layout;
Optional<LLRect> rect;
// Historical bottom-left layout used bottom_delta and left_delta
// for relative positioning. New layout "topleft" prefers specifying
// based on top edge.
Optional<S32> bottom_delta, // from last bottom to my bottom
top_pad, // from last bottom to my top
top_delta, // from last top to my top
left_pad, // from last right to my left
left_delta; // from last left to my left
//FIXME: get parent context involved in parsing traversal
Ignored needs_translate, // cue for translation tools
xmlns, // xml namespace
xmlns_xsi, // xml namespace
xsi_schemaLocation, // xml schema
xsi_type; // xml schema type
Params();
};
void initFromParams(const LLView::Params&);
protected:
LLView(const LLView::Params&);
//friend class LLUICtrlFactory;
private:
void init(const LLView::Params&);
private:
// widgets in general are not copyable
LLView(const LLView& other) {};
public:
#if LL_DEBUG
static BOOL sIsDrawing;
@@ -663,15 +646,9 @@ private:
LLRootHandle<LLView> mHandle;
BOOL mLastVisible;
S32 mNextInsertionOrdinal;
bool mInDraw;
// <edit>
public:
BOOL mDelayedDelete;
// </edit>
private:
static LLWindow* sWindow; // All root views must know about their window.

View File

@@ -0,0 +1,40 @@
# -*- cmake -*-
project(llxuixml)
include(00-Common)
include(LLCommon)
include(LLMath)
include(LLXML)
include_directories(
${LLCOMMON_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
)
set(llxuixml_SOURCE_FILES
llinitparam.cpp
lluicolor.cpp
)
set(llxuixml_HEADER_FILES
CMakeLists.txt
llinitparam.h
lluicolor.h
)
set_source_files_properties(${llxuixml_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND llxuixml_SOURCE_FILES ${llxuixml_HEADER_FILES})
add_library (llxuixml ${llxuixml_SOURCE_FILES})
# Libraries on which this library depends, needed for Linux builds
# Sort by high-level to low-level
target_link_libraries(llxuixml
llxml
llcommon
llmath
)

View File

@@ -0,0 +1,469 @@
/**
* @file llinitparam.cpp
* @brief parameter block abstraction for creating complex objects and
* parsing construction parameters from xml and LLSD
*
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llinitparam.h"
namespace LLInitParam
{
//
// Param
//
Param::Param(BaseBlock* enclosing_block)
: mIsProvided(false)
{
const U8* my_addr = reinterpret_cast<const U8*>(this);
const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
mEnclosingBlockOffset = 0x7FFFffff & (U32)(my_addr - block_addr);
}
//
// ParamDescriptor
//
ParamDescriptor::ParamDescriptor(param_handle_t p,
merge_func_t merge_func,
deserialize_func_t deserialize_func,
serialize_func_t serialize_func,
validation_func_t validation_func,
inspect_func_t inspect_func,
S32 min_count,
S32 max_count)
: mParamHandle(p),
mMergeFunc(merge_func),
mDeserializeFunc(deserialize_func),
mSerializeFunc(serialize_func),
mValidationFunc(validation_func),
mInspectFunc(inspect_func),
mMinCount(min_count),
mMaxCount(max_count),
mUserData(NULL)
{}
ParamDescriptor::ParamDescriptor()
: mParamHandle(0),
mMergeFunc(NULL),
mDeserializeFunc(NULL),
mSerializeFunc(NULL),
mValidationFunc(NULL),
mInspectFunc(NULL),
mMinCount(0),
mMaxCount(0),
mUserData(NULL)
{}
ParamDescriptor::~ParamDescriptor()
{
delete mUserData;
}
//
// Parser
//
Parser::~Parser()
{}
void Parser::parserWarning(const std::string& message)
{
if (mParseSilently) return;
llwarns << message << llendl;
}
void Parser::parserError(const std::string& message)
{
if (mParseSilently) return;
llerrs << message << llendl;
}
//
// BlockDescriptor
//
void BlockDescriptor::aggregateBlockData(BlockDescriptor& src_block_data)
{
mNamedParams.insert(src_block_data.mNamedParams.begin(), src_block_data.mNamedParams.end());
std::copy(src_block_data.mUnnamedParams.begin(), src_block_data.mUnnamedParams.end(), std::back_inserter(mUnnamedParams));
std::copy(src_block_data.mValidationList.begin(), src_block_data.mValidationList.end(), std::back_inserter(mValidationList));
std::copy(src_block_data.mAllParams.begin(), src_block_data.mAllParams.end(), std::back_inserter(mAllParams));
}
BlockDescriptor::BlockDescriptor()
: mMaxParamOffset(0),
mInitializationState(UNINITIALIZED),
mCurrentBlockPtr(NULL)
{}
// called by each derived class in least to most derived order
void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size)
{
descriptor.mCurrentBlockPtr = this;
descriptor.mMaxParamOffset = block_size;
switch(descriptor.mInitializationState)
{
case BlockDescriptor::UNINITIALIZED:
// copy params from base class here
descriptor.aggregateBlockData(base_descriptor);
descriptor.mInitializationState = BlockDescriptor::INITIALIZING;
break;
case BlockDescriptor::INITIALIZING:
descriptor.mInitializationState = BlockDescriptor::INITIALIZED;
break;
case BlockDescriptor::INITIALIZED:
// nothing to do
break;
}
}
param_handle_t BaseBlock::getHandleFromParam(const Param* param) const
{
const U8* param_address = reinterpret_cast<const U8*>(param);
const U8* baseblock_address = reinterpret_cast<const U8*>(this);
return (param_address - baseblock_address);
}
bool BaseBlock::submitValue(Parser::name_stack_t& name_stack, Parser& p, bool silent)
{
if (!deserializeBlock(p, std::make_pair(name_stack.begin(), name_stack.end()), true))
{
if (!silent)
{
p.parserWarning(llformat("Failed to parse parameter \"%s\"", p.getCurrentElementName().c_str()));
}
return false;
}
return true;
}
bool BaseBlock::validateBlock(bool emit_errors) const
{
const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
for (BlockDescriptor::param_validation_list_t::const_iterator it = block_data.mValidationList.begin(); it != block_data.mValidationList.end(); ++it)
{
const Param* param = getParamFromHandle(it->first);
if (!it->second(param))
{
if (emit_errors)
{
llwarns << "Invalid param \"" << getParamName(block_data, param) << "\"" << llendl;
}
return false;
}
}
return true;
}
void BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t& name_stack, const LLInitParam::BaseBlock* diff_block) const
{
// named param is one like LLView::Params::follows
// unnamed param is like LLView::Params::rect - implicit
const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
for (BlockDescriptor::param_list_t::const_iterator it = block_data.mUnnamedParams.begin();
it != block_data.mUnnamedParams.end();
++it)
{
param_handle_t param_handle = (*it)->mParamHandle;
const Param* param = getParamFromHandle(param_handle);
ParamDescriptor::serialize_func_t serialize_func = (*it)->mSerializeFunc;
if (serialize_func)
{
const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL;
// each param descriptor remembers its serial number
// so we can inspect the same param under different names
// and see that it has the same number
name_stack.push_back(std::make_pair("", true));
serialize_func(*param, parser, name_stack, diff_param);
name_stack.pop_back();
}
}
for(BlockDescriptor::param_map_t::const_iterator it = block_data.mNamedParams.begin();
it != block_data.mNamedParams.end();
++it)
{
param_handle_t param_handle = it->second->mParamHandle;
const Param* param = getParamFromHandle(param_handle);
ParamDescriptor::serialize_func_t serialize_func = it->second->mSerializeFunc;
if (serialize_func && param->anyProvided())
{
// Ensure this param has not already been serialized
// Prevents <rect> from being serialized as its own tag.
bool duplicate = false;
for (BlockDescriptor::param_list_t::const_iterator it2 = block_data.mUnnamedParams.begin();
it2 != block_data.mUnnamedParams.end();
++it2)
{
if (param_handle == (*it2)->mParamHandle)
{
duplicate = true;
break;
}
}
//FIXME: for now, don't attempt to serialize values under synonyms, as current parsers
// don't know how to detect them
if (duplicate)
{
continue;
}
name_stack.push_back(std::make_pair(it->first, !duplicate));
const Param* diff_param = diff_block ? diff_block->getParamFromHandle(param_handle) : NULL;
serialize_func(*param, parser, name_stack, diff_param);
name_stack.pop_back();
}
}
}
bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack, S32 min_count, S32 max_count) const
{
// named param is one like LLView::Params::follows
// unnamed param is like LLView::Params::rect - implicit
const BlockDescriptor& block_data = mostDerivedBlockDescriptor();
for (BlockDescriptor::param_list_t::const_iterator it = block_data.mUnnamedParams.begin();
it != block_data.mUnnamedParams.end();
++it)
{
param_handle_t param_handle = (*it)->mParamHandle;
const Param* param = getParamFromHandle(param_handle);
ParamDescriptor::inspect_func_t inspect_func = (*it)->mInspectFunc;
if (inspect_func)
{
name_stack.push_back(std::make_pair("", true));
inspect_func(*param, parser, name_stack, (*it)->mMinCount, (*it)->mMaxCount);
name_stack.pop_back();
}
}
for(BlockDescriptor::param_map_t::const_iterator it = block_data.mNamedParams.begin();
it != block_data.mNamedParams.end();
++it)
{
param_handle_t param_handle = it->second->mParamHandle;
const Param* param = getParamFromHandle(param_handle);
ParamDescriptor::inspect_func_t inspect_func = it->second->mInspectFunc;
if (inspect_func)
{
// Ensure this param has not already been inspected
bool duplicate = false;
for (BlockDescriptor::param_list_t::const_iterator it2 = block_data.mUnnamedParams.begin();
it2 != block_data.mUnnamedParams.end();
++it2)
{
if (param_handle == (*it2)->mParamHandle)
{
duplicate = true;
break;
}
}
name_stack.push_back(std::make_pair(it->first, !duplicate));
inspect_func(*param, parser, name_stack, it->second->mMinCount, it->second->mMaxCount);
name_stack.pop_back();
}
}
return true;
}
bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack_range, bool ignored)
{
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
bool names_left = name_stack_range.first != name_stack_range.second;
bool new_name = names_left
? name_stack_range.first->second
: true;
if (names_left)
{
const std::string& top_name = name_stack_range.first->first;
ParamDescriptor::deserialize_func_t deserialize_func = NULL;
Param* paramp = NULL;
BlockDescriptor::param_map_t::iterator found_it = block_data.mNamedParams.find(top_name);
if (found_it != block_data.mNamedParams.end())
{
// find pointer to member parameter from offset table
paramp = getParamFromHandle(found_it->second->mParamHandle);
deserialize_func = found_it->second->mDeserializeFunc;
Parser::name_stack_range_t new_name_stack(name_stack_range.first, name_stack_range.second);
++new_name_stack.first;
if (deserialize_func(*paramp, p, new_name_stack, new_name))
{
// value is no longer new, we know about it now
name_stack_range.first->second = false;
return true;
}
else
{
return false;
}
}
}
// try to parse unnamed parameters, in declaration order
for ( BlockDescriptor::param_list_t::iterator it = block_data.mUnnamedParams.begin();
it != block_data.mUnnamedParams.end();
++it)
{
Param* paramp = getParamFromHandle((*it)->mParamHandle);
ParamDescriptor::deserialize_func_t deserialize_func = (*it)->mDeserializeFunc;
if (deserialize_func && deserialize_func(*paramp, p, name_stack_range, new_name))
{
return true;
}
}
// if no match, and no names left on stack, this is just an existence assertion of this block
// verify by calling readValue with NoParamValue type, an inherently unparseable type
if (!names_left)
{
Flag no_value;
return p.readValue(no_value);
}
return false;
}
//static
void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptorPtr in_param, const char* char_name)
{
// create a copy of the param descriptor in mAllParams
// so other data structures can store a pointer to it
block_data.mAllParams.push_back(in_param);
ParamDescriptorPtr param(block_data.mAllParams.back());
std::string name(char_name);
if ((size_t)param->mParamHandle > block_data.mMaxParamOffset)
{
llerrs << "Attempted to register param with block defined for parent class, make sure to derive from LLInitParam::Block<YOUR_CLASS, PARAM_BLOCK_BASE_CLASS>" << llendl;
}
if (name.empty())
{
block_data.mUnnamedParams.push_back(param);
}
else
{
// don't use insert, since we want to overwrite existing entries
block_data.mNamedParams[name] = param;
}
if (param->mValidationFunc)
{
block_data.mValidationList.push_back(std::make_pair(param->mParamHandle, param->mValidationFunc));
}
}
void BaseBlock::addSynonym(Param& param, const std::string& synonym)
{
BlockDescriptor& block_data = mostDerivedBlockDescriptor();
if (block_data.mInitializationState == BlockDescriptor::INITIALIZING)
{
param_handle_t handle = getHandleFromParam(&param);
// check for invalid derivation from a paramblock (i.e. without using
// Block<T, Base_Class>
if ((size_t)handle > block_data.mMaxParamOffset)
{
llerrs << "Attempted to register param with block defined for parent class, make sure to derive from LLInitParam::Block<YOUR_CLASS, PARAM_BLOCK_BASE_CLASS>" << llendl;
}
ParamDescriptorPtr param_descriptor = findParamDescriptor(param);
if (param_descriptor)
{
if (synonym.empty())
{
block_data.mUnnamedParams.push_back(param_descriptor);
}
else
{
block_data.mNamedParams[synonym] = param_descriptor;
}
}
}
}
const std::string& BaseBlock::getParamName(const BlockDescriptor& block_data, const Param* paramp) const
{
param_handle_t handle = getHandleFromParam(paramp);
for (BlockDescriptor::param_map_t::const_iterator it = block_data.mNamedParams.begin(); it != block_data.mNamedParams.end(); ++it)
{
if (it->second->mParamHandle == handle)
{
return it->first;
}
}
return LLStringUtil::null;
}
ParamDescriptorPtr BaseBlock::findParamDescriptor(const Param& param)
{
param_handle_t handle = getHandleFromParam(&param);
BlockDescriptor& descriptor = mostDerivedBlockDescriptor();
BlockDescriptor::all_params_list_t::iterator end_it = descriptor.mAllParams.end();
for (BlockDescriptor::all_params_list_t::iterator it = descriptor.mAllParams.begin();
it != end_it;
++it)
{
if ((*it)->mParamHandle == handle) return *it;
}
return ParamDescriptorPtr();
}
// take all provided params from other and apply to self
// NOTE: this requires that "other" is of the same derived type as this
bool BaseBlock::mergeBlock(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite)
{
bool some_param_changed = false;
BlockDescriptor::all_params_list_t::const_iterator end_it = block_data.mAllParams.end();
for (BlockDescriptor::all_params_list_t::const_iterator it = block_data.mAllParams.begin();
it != end_it;
++it)
{
const Param* other_paramp = other.getParamFromHandle((*it)->mParamHandle);
ParamDescriptor::merge_func_t merge_func = (*it)->mMergeFunc;
if (merge_func)
{
Param* paramp = getParamFromHandle((*it)->mParamHandle);
llassert(paramp->mEnclosingBlockOffset == (*it)->mParamHandle);
some_param_changed |= merge_func(*paramp, *other_paramp, overwrite);
}
}
return some_param_changed;
}
}

2294
indra/llxuixml/llinitparam.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
/**
* @file lluicolor.cpp
* @brief brief LLUIColor class implementation file
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "lluicolor.h"
LLUIColor::LLUIColor()
:mColorPtr(NULL)
{
}
LLUIColor::LLUIColor(const LLColor4& color)
: mColor(color),
mColorPtr(NULL)
{
}
LLUIColor::LLUIColor(const LLUIColor* color)
: mColorPtr(color)
{
}
void LLUIColor::set(const LLColor4& color)
{
mColor = color;
mColorPtr = NULL;
}
void LLUIColor::set(const LLUIColor* color)
{
mColorPtr = color;
}
const LLColor4& LLUIColor::get() const
{
return (mColorPtr == NULL ? mColor : mColorPtr->get());
}
LLUIColor::operator const LLColor4& () const
{
return get();
}
const LLColor4& LLUIColor::operator()() const
{
return get();
}
bool LLUIColor::isReference() const
{
return mColorPtr != NULL;
}
namespace LLInitParam
{
// used to detect equivalence with default values on export
bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
{
// do not detect value equivalence, treat pointers to colors as distinct from color values
return (a.mColorPtr == NULL && b.mColorPtr == NULL ? a.mColor == b.mColor : a.mColorPtr == b.mColorPtr);
}
}

View File

@@ -0,0 +1,71 @@
/**
* @file lluicolor.h
* @brief brief LLUIColor class header file
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLUICOLOR_H_
#define LL_LLUICOLOR_H_
#include "v4color.h"
namespace LLInitParam
{
template<typename T, bool>
struct ParamCompare;
}
class LLUIColor
{
public:
LLUIColor();
LLUIColor(const LLColor4& color);
LLUIColor(const LLUIColor* color);
void set(const LLColor4& color);
void set(const LLUIColor* color);
const LLColor4& get() const;
operator const LLColor4& () const;
const LLColor4& operator()() const;
bool isReference() const;
private:
friend struct LLInitParam::ParamCompare<LLUIColor, false>;
const LLUIColor* mColorPtr;
LLColor4 mColor;
};
namespace LLInitParam
{
template<>
struct ParamCompare<LLUIColor, false>
{
static bool equals(const LLUIColor& a, const LLUIColor& b);
};
}
#endif

View File

@@ -37,6 +37,7 @@ include(LLUI)
include(LLVFS)
include(LLWindow)
include(LLXML)
include(LLXUIXML)
include(LScript)
include(Linking)
include(NDOF)
@@ -71,6 +72,7 @@ include_directories(
${LLVFS_INCLUDE_DIRS}
${LLWINDOW_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
${LLXUIXML_INCLUDE_DIRS}
${LSCRIPT_INCLUDE_DIRS}
${LSCRIPT_INCLUDE_DIRS}/lscript_compile
)
@@ -1535,6 +1537,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${LLVFS_LIBRARIES}
${LLWINDOW_LIBRARIES}
${LLXML_LIBRARIES}
${LLXUIXML_LIBRARIES}
${LSCRIPT_LIBRARIES}
${LLMATH_LIBRARIES}
${LLCOMMON_LIBRARIES}

View File

@@ -106,7 +106,7 @@ void LLBuildNewViewsScheduler::buildNewViews(LLInventoryPanel* panelp, LLInvento
if (itemp)
{
itemp->mDelayedDelete = TRUE;
//itemp->mDelayedDelete = TRUE;
if (parent_folder)
{
itemp->addToFolder(parent_folder, panelp->getRootFolder());

View File

@@ -9,6 +9,7 @@ include(LLMessage) # This is needed by LLPlugin.
include(LLMath)
include(LLVFS)
include(LLXML)
include(LLXUIXML)
include(LLWindow)
include(LLUI)
include(LLRender)
@@ -25,6 +26,7 @@ include_directories(
${LLMATH_INCLUDE_DIRS}
${LLVFS_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
${LLXUIXML_INCLUDE_DIRS}
${LLWINDOW_INCLUDE_DIRS}
${LLUI_INCLUDE_DIRS}
${LLRENDER_INCLUDE_DIRS}