Name Editors are Name UI too!
This commit is contained in:
@@ -34,80 +34,49 @@
|
|||||||
|
|
||||||
#include "llnameeditor.h"
|
#include "llnameeditor.h"
|
||||||
#include "llcachename.h"
|
#include "llcachename.h"
|
||||||
#include "llagent.h"
|
#include "llmenugl.h"
|
||||||
|
#include "lluictrlfactory.h"
|
||||||
#include "llfontgl.h"
|
|
||||||
|
|
||||||
#include "lluuid.h"
|
|
||||||
#include "llrect.h"
|
|
||||||
#include "llstring.h"
|
|
||||||
#include "llui.h"
|
|
||||||
|
|
||||||
static LLRegisterWidget<LLNameEditor> r("name_editor");
|
static LLRegisterWidget<LLNameEditor> r("name_editor");
|
||||||
|
|
||||||
// statics
|
|
||||||
std::set<LLNameEditor*> LLNameEditor::sInstances;
|
|
||||||
|
|
||||||
LLNameEditor::LLNameEditor(const std::string& name, const LLRect& rect,
|
LLNameEditor::LLNameEditor(const std::string& name, const LLRect& rect,
|
||||||
const LLUUID& name_id,
|
const LLUUID& name_id,
|
||||||
BOOL is_group,
|
bool is_group,
|
||||||
|
const std::string& loading,
|
||||||
const LLFontGL* glfont,
|
const LLFontGL* glfont,
|
||||||
S32 max_text_length)
|
S32 max_text_length)
|
||||||
: LLLineEditor(name, rect,
|
: LLNameUI(loading, name_id, is_group)
|
||||||
std::string("(retrieving)"),
|
, LLLineEditor(name, rect, LLStringUtil::null, glfont, max_text_length)
|
||||||
glfont,
|
|
||||||
max_text_length),
|
|
||||||
mNameID(name_id)
|
|
||||||
{
|
{
|
||||||
LLNameEditor::sInstances.insert(this);
|
if (!name_id.isNull())
|
||||||
if(!name_id.isNull())
|
|
||||||
{
|
{
|
||||||
setNameID(name_id, is_group);
|
setNameID(name_id, is_group);
|
||||||
}
|
}
|
||||||
|
else setText(mInitialValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// virtual
|
||||||
LLNameEditor::~LLNameEditor()
|
BOOL LLNameEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
|
||||||
{
|
{
|
||||||
LLNameEditor::sInstances.erase(this);
|
bool simple_menu = mContextMenuHandle.get()->getName() != "rclickmenu";
|
||||||
|
std::string new_menu;
|
||||||
|
// Singu TODO: Generic menus for groups
|
||||||
|
if ((mIsGroup || mNameID.isNull()) && simple_menu)
|
||||||
|
{
|
||||||
|
new_menu = "menu_texteditor.xml";
|
||||||
|
}
|
||||||
|
else if (!simple_menu && !mIsGroup)
|
||||||
|
{
|
||||||
|
new_menu = "menu_nameeditor_avatar.xml";
|
||||||
|
}
|
||||||
|
if (!new_menu.empty()) setContextMenu(LLUICtrlFactory::instance().buildMenu(new_menu, LLMenuGL::sMenuContainer));
|
||||||
|
|
||||||
|
return LLLineEditor::handleRightMouseDown(x, y, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLNameEditor::setNameID(const LLUUID& name_id, BOOL is_group)
|
void LLNameEditor::setText(const std::string& text)
|
||||||
{
|
{
|
||||||
mNameID = name_id;
|
LLLineEditor::setText(text);
|
||||||
|
|
||||||
std::string name;
|
|
||||||
|
|
||||||
if (!is_group)
|
|
||||||
{
|
|
||||||
gCacheName->getFullName(name_id, name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gCacheName->getGroupName(name_id, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
setText(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LLNameEditor::refresh(const LLUUID& id, const std::string& full_name, bool is_group)
|
|
||||||
{
|
|
||||||
if (id == mNameID)
|
|
||||||
{
|
|
||||||
setText(full_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LLNameEditor::refreshAll(const LLUUID& id, const std::string& full_name, bool is_group)
|
|
||||||
{
|
|
||||||
std::set<LLNameEditor*>::iterator it;
|
|
||||||
for (it = LLNameEditor::sInstances.begin();
|
|
||||||
it != LLNameEditor::sInstances.end();
|
|
||||||
++it)
|
|
||||||
{
|
|
||||||
LLNameEditor* box = *it;
|
|
||||||
box->refresh(id, full_name, is_group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLNameEditor::setValue( const LLSD& value )
|
void LLNameEditor::setValue( const LLSD& value )
|
||||||
@@ -135,22 +104,21 @@ LLView* LLNameEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory
|
|||||||
LLRect rect;
|
LLRect rect;
|
||||||
createRect(node, rect, parent, LLRect());
|
createRect(node, rect, parent, LLRect());
|
||||||
|
|
||||||
S32 max_text_length = 128;
|
S32 max_text_length = 1024;
|
||||||
node->getAttributeS32("max_length", max_text_length);
|
node->getAttributeS32("max_length", max_text_length);
|
||||||
|
bool is_group = false;
|
||||||
LLFontGL* font = LLView::selectFont(node);
|
node->getAttribute_bool("is_group", is_group);
|
||||||
|
LLUUID id;
|
||||||
|
node->getAttributeUUID("id", id);
|
||||||
|
std::string loading;
|
||||||
|
node->getAttributeString("label", loading);
|
||||||
|
|
||||||
LLNameEditor* line_editor = new LLNameEditor("name_editor",
|
LLNameEditor* line_editor = new LLNameEditor("name_editor",
|
||||||
rect,
|
rect,
|
||||||
LLUUID::null, FALSE,
|
id, is_group, loading,
|
||||||
font,
|
LLView::selectFont(node),
|
||||||
max_text_length);
|
max_text_length);
|
||||||
|
|
||||||
std::string label;
|
|
||||||
if(node->getAttributeString("label", label))
|
|
||||||
{
|
|
||||||
line_editor->setLabel(label);
|
|
||||||
}
|
|
||||||
line_editor->setColorParameters(node);
|
line_editor->setColorParameters(node);
|
||||||
line_editor->initFromXML(node, parent);
|
line_editor->initFromXML(node, parent);
|
||||||
|
|
||||||
|
|||||||
@@ -33,50 +33,31 @@
|
|||||||
#ifndef LL_LLNAMEEDITOR_H
|
#ifndef LL_LLNAMEEDITOR_H
|
||||||
#define LL_LLNAMEEDITOR_H
|
#define LL_LLNAMEEDITOR_H
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "llview.h"
|
|
||||||
#include "v4color.h"
|
|
||||||
#include "llstring.h"
|
|
||||||
#include "llfontgl.h"
|
|
||||||
#include "lllineeditor.h"
|
#include "lllineeditor.h"
|
||||||
|
#include "llnameui.h"
|
||||||
|
|
||||||
class LLNameEditor
|
class LLNameEditor
|
||||||
: public LLLineEditor
|
: public LLLineEditor
|
||||||
|
, public LLNameUI
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LLNameEditor(const std::string& name, const LLRect& rect,
|
LLNameEditor(const std::string& name, const LLRect& rect,
|
||||||
const LLUUID& name_id = LLUUID::null,
|
const LLUUID& name_id = LLUUID::null,
|
||||||
BOOL is_group = FALSE,
|
bool is_group = false,
|
||||||
const LLFontGL* glfont = NULL,
|
const std::string& loading = LLStringUtil::null,
|
||||||
|
const LLFontGL* glfont = nullptr,
|
||||||
S32 max_text_length = 254);
|
S32 max_text_length = 254);
|
||||||
// By default, follows top and left and is mouse-opaque.
|
|
||||||
// If no text, text = name.
|
|
||||||
// If no font, uses default system font.
|
|
||||||
|
|
||||||
virtual ~LLNameEditor();
|
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) override final;
|
||||||
|
|
||||||
virtual LLXMLNodePtr getXML(bool save_children = true) const;
|
LLXMLNodePtr getXML(bool save_children = true) const override final;
|
||||||
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
|
||||||
|
|
||||||
void setNameID(const LLUUID& name_id, BOOL is_group);
|
|
||||||
|
|
||||||
void refresh(const LLUUID& id, const std::string& full_name, bool is_group);
|
|
||||||
|
|
||||||
static void refreshAll(const LLUUID& id, const std::string& full_name, bool is_group);
|
|
||||||
|
|
||||||
|
|
||||||
// Take/return agent UUIDs
|
// Take/return agent UUIDs
|
||||||
virtual void setValue( const LLSD& value );
|
void setValue(const LLSD& value) override final;
|
||||||
virtual LLSD getValue() const;
|
LLSD getValue() const override final;
|
||||||
|
|
||||||
private:
|
|
||||||
static std::set<LLNameEditor*> sInstances;
|
|
||||||
|
|
||||||
private:
|
|
||||||
LLUUID mNameID;
|
|
||||||
|
|
||||||
|
void setText(const std::string& text) override final;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user