Viewer 2.4 (as of 15 Nov 2010) with llTextBox support merged in
commit
3b85391839
|
|
@ -443,6 +443,7 @@ set(viewer_SOURCE_FILES
|
|||
lltoastimpanel.cpp
|
||||
lltoastnotifypanel.cpp
|
||||
lltoastpanel.cpp
|
||||
lltoastscripttextbox.cpp
|
||||
lltool.cpp
|
||||
lltoolbrush.cpp
|
||||
lltoolcomp.cpp
|
||||
|
|
@ -971,6 +972,7 @@ set(viewer_HEADER_FILES
|
|||
lltoastimpanel.h
|
||||
lltoastnotifypanel.h
|
||||
lltoastpanel.h
|
||||
lltoastscripttextbox.h
|
||||
lltool.h
|
||||
lltoolbrush.h
|
||||
lltoolcomp.h
|
||||
|
|
|
|||
|
|
@ -32,11 +32,13 @@
|
|||
#include "llchannelmanager.h"
|
||||
#include "llchiclet.h"
|
||||
#include "llfloaterreg.h"
|
||||
#include "lllslconstants.h"
|
||||
#include "llnotifications.h"
|
||||
#include "llnotificationsutil.h"
|
||||
#include "llscreenchannel.h"
|
||||
#include "llsyswellwindow.h"
|
||||
#include "lltoastnotifypanel.h"
|
||||
#include "lltoastscripttextbox.h"
|
||||
#include "lltrans.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llimfloater.h"
|
||||
|
|
@ -151,10 +153,18 @@ void LLScriptFloater::createForm(const LLUUID& notification_id)
|
|||
|
||||
// create new form
|
||||
LLRect toast_rect = getRect();
|
||||
// LLToastNotifyPanel will fit own content in vertical direction,
|
||||
// but it needs an initial rect to properly calculate its width
|
||||
// Use an initial rect of the script floater to make the floater window more configurable.
|
||||
mScriptForm = new LLToastNotifyPanel(notification, toast_rect);
|
||||
if (isScriptTextbox(notification))
|
||||
{
|
||||
mScriptForm = new LLToastScriptTextbox(notification);
|
||||
}
|
||||
else
|
||||
{
|
||||
// LLToastNotifyPanel will fit own content in vertical direction,
|
||||
// but it needs an initial rect to properly calculate its width
|
||||
// Use an initial rect of the script floater to make the floater
|
||||
// window more configurable.
|
||||
mScriptForm = new LLToastNotifyPanel(notification, toast_rect);
|
||||
}
|
||||
addChild(mScriptForm);
|
||||
|
||||
// position form on floater
|
||||
|
|
@ -564,4 +574,32 @@ void LLScriptFloaterManager::setFloaterVisible(const LLUUID& notification_id, bo
|
|||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
bool LLScriptFloater::isScriptTextbox(LLNotificationPtr notification)
|
||||
{
|
||||
// get a form for the notification
|
||||
LLNotificationFormPtr form(notification->getForm());
|
||||
|
||||
if (form)
|
||||
{
|
||||
// get number of elements in the form
|
||||
int num_options = form->getNumElements();
|
||||
|
||||
// if ANY of the buttons have the magic lltextbox string as
|
||||
// name, then treat the whole dialog as a simple text entry
|
||||
// box (i.e. mixed button and textbox forms are not supported)
|
||||
for (int i=0; i<num_options; ++i)
|
||||
{
|
||||
LLSD form_element = form->getElement(i);
|
||||
if (form_element["name"].asString() == TEXTBOX_MAGIC_TOKEN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#define LL_SCRIPTFLOATER_H
|
||||
|
||||
#include "lltransientdockablefloater.h"
|
||||
#include "llnotificationptr.h"
|
||||
|
||||
class LLToastNotifyPanel;
|
||||
|
||||
|
|
@ -203,6 +204,8 @@ protected:
|
|||
void dockToChiclet(bool dock);
|
||||
|
||||
private:
|
||||
bool isScriptTextbox(LLNotificationPtr notification);
|
||||
|
||||
LLToastNotifyPanel* mScriptForm;
|
||||
LLUUID mNotificationId;
|
||||
LLUUID mObjectId;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(LLNotificationPtr& notification
|
|||
LLGroupData groupData;
|
||||
if (!gAgent.getGroupData(payload["group_id"].asUUID(),groupData))
|
||||
{
|
||||
llwarns << "Group notice for unkown group: " << payload["group_id"].asUUID() << llendl;
|
||||
llwarns << "Group notice for unknown group: " << payload["group_id"].asUUID() << llendl;
|
||||
}
|
||||
|
||||
//group icon
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
// library includes
|
||||
#include "lldbstrings.h"
|
||||
#include "lllslconstants.h"
|
||||
#include "llnotifications.h"
|
||||
#include "lluiconstants.h"
|
||||
#include "llrect.h"
|
||||
|
|
@ -70,11 +71,11 @@ mCloseNotificationOnDestroy(true)
|
|||
mControlPanel = getChild<LLPanel>("control_panel");
|
||||
BUTTON_WIDTH = gSavedSettings.getS32("ToastButtonWidth");
|
||||
// customize panel's attributes
|
||||
// is it intended for displaying a tip
|
||||
// is it intended for displaying a tip?
|
||||
mIsTip = notification->getType() == "notifytip";
|
||||
// is it a script dialog
|
||||
// is it a script dialog?
|
||||
mIsScriptDialog = (notification->getName() == "ScriptDialog" || notification->getName() == "ScriptDialogGroup");
|
||||
// is it a caution
|
||||
// is it a caution?
|
||||
//
|
||||
// caution flag can be set explicitly by specifying it in the notification payload, or it can be set implicitly if the
|
||||
// notify xml template specifies that it is a caution
|
||||
|
|
@ -139,6 +140,12 @@ mCloseNotificationOnDestroy(true)
|
|||
LLSD form_element = form->getElement(i);
|
||||
if (form_element["type"].asString() != "button")
|
||||
{
|
||||
// not a button.
|
||||
continue;
|
||||
}
|
||||
if (form_element["name"].asString() == TEXTBOX_MAGIC_TOKEN)
|
||||
{
|
||||
// a textbox pretending to be a button.
|
||||
continue;
|
||||
}
|
||||
LLButton* new_button = createButton(form_element, TRUE);
|
||||
|
|
@ -159,7 +166,7 @@ mCloseNotificationOnDestroy(true)
|
|||
if(h_pad < 2*HPAD)
|
||||
{
|
||||
/*
|
||||
* Probably it is a scriptdialog toast
|
||||
* Probably it is a scriptdialog toast
|
||||
* for a scriptdialog toast h_pad can be < 2*HPAD if we have a lot of buttons.
|
||||
* In last case set default h_pad to avoid heaping of buttons
|
||||
*/
|
||||
|
|
@ -261,7 +268,7 @@ LLButton* LLToastNotifyPanel::createButton(const LLSD& form_element, BOOL is_opt
|
|||
}
|
||||
else if (mIsScriptDialog && is_ignore_btn)
|
||||
{
|
||||
// this is ignore button,make it smaller
|
||||
// this is ignore button, make it smaller
|
||||
p.rect.height = BTN_HEIGHT_SMALL;
|
||||
p.rect.width = 1;
|
||||
p.auto_resize = true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* @file lltoastscripttextbox.cpp
|
||||
* @brief Panel for script llTextBox dialogs
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&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 "llviewerprecompiledheaders.h"
|
||||
|
||||
#include "lltoastscripttextbox.h"
|
||||
|
||||
#include "llfocusmgr.h"
|
||||
|
||||
#include "llbutton.h"
|
||||
#include "llnotifications.h"
|
||||
#include "llviewertexteditor.h"
|
||||
|
||||
#include "llavatarnamecache.h"
|
||||
#include "lluiconstants.h"
|
||||
#include "llui.h"
|
||||
#include "llviewercontrol.h"
|
||||
#include "lltrans.h"
|
||||
#include "llstyle.h"
|
||||
|
||||
#include "llglheaders.h"
|
||||
#include "llagent.h"
|
||||
|
||||
const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 7;
|
||||
|
||||
LLToastScriptTextbox::LLToastScriptTextbox(LLNotificationPtr& notification)
|
||||
: LLToastNotifyPanel(notification)
|
||||
{
|
||||
buildFromFile( "panel_notify_textbox.xml");
|
||||
|
||||
const LLSD& payload = notification->getPayload();
|
||||
|
||||
//message body
|
||||
const std::string& message = payload["message"].asString();
|
||||
|
||||
LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message");
|
||||
pMessageText->clear();
|
||||
|
||||
LLStyle::Params style;
|
||||
style.font = pMessageText->getDefaultFont();
|
||||
pMessageText->appendText(message, TRUE, style);
|
||||
|
||||
//submit button
|
||||
LLButton* pSubmitBtn = getChild<LLButton>("btn_submit");
|
||||
pSubmitBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickSubmit, this)));
|
||||
setDefaultBtn(pSubmitBtn);
|
||||
|
||||
S32 maxLinesCount;
|
||||
std::istringstream ss( getString("message_max_lines_count") );
|
||||
if (!(ss >> maxLinesCount))
|
||||
{
|
||||
maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT;
|
||||
}
|
||||
//snapToMessageHeight(pMessageText, maxLinesCount);
|
||||
}
|
||||
|
||||
// virtual
|
||||
LLToastScriptTextbox::~LLToastScriptTextbox()
|
||||
{
|
||||
}
|
||||
|
||||
void LLToastScriptTextbox::close()
|
||||
{
|
||||
die();
|
||||
}
|
||||
|
||||
#include "lllslconstants.h"
|
||||
void LLToastScriptTextbox::onClickSubmit()
|
||||
{
|
||||
LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message");
|
||||
|
||||
if (pMessageText)
|
||||
{
|
||||
LLSD response = mNotification->getResponseTemplate();
|
||||
response[TEXTBOX_MAGIC_TOKEN] = pMessageText->getText();
|
||||
if (response[TEXTBOX_MAGIC_TOKEN].asString().empty())
|
||||
{
|
||||
// so we can distinguish between a successfully
|
||||
// submitted blank textbox, and an ignored toast
|
||||
response[TEXTBOX_MAGIC_TOKEN] = true;
|
||||
}
|
||||
mNotification->respond(response);
|
||||
close();
|
||||
llwarns << response << llendl;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* @file lltoastscripttextbox.h
|
||||
* @brief Panel for script llTextBox dialogs
|
||||
*
|
||||
* $LicenseInfo:firstyear=2001&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_LLTOASTSCRIPTTEXTBOX_H
|
||||
#define LL_LLTOASTSCRIPTTEXTBOX_H
|
||||
|
||||
#include "lltoastnotifypanel.h"
|
||||
#include "llnotificationptr.h"
|
||||
|
||||
class LLButton;
|
||||
|
||||
/**
|
||||
* Toast panel for scripted llTextbox notifications.
|
||||
*/
|
||||
class LLToastScriptTextbox
|
||||
: public LLToastNotifyPanel
|
||||
{
|
||||
public:
|
||||
void close();
|
||||
|
||||
static bool onNewNotification(const LLSD& notification);
|
||||
|
||||
// Non-transient messages. You can specify non-default button
|
||||
// layouts (like one for script dialogs) by passing various
|
||||
// numbers in for "layout".
|
||||
LLToastScriptTextbox(LLNotificationPtr& notification);
|
||||
|
||||
/*virtual*/ ~LLToastScriptTextbox();
|
||||
protected:
|
||||
void onClickSubmit();
|
||||
private:
|
||||
static const S32 DEFAULT_MESSAGE_MAX_LINE_COUNT;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
#include "llfloaterreg.h"
|
||||
#include "llfollowcamparams.h"
|
||||
#include "llinventorydefines.h"
|
||||
#include "lllslconstants.h"
|
||||
#include "llregionhandle.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llteleportflags.h"
|
||||
|
|
@ -6435,8 +6436,22 @@ const char* SCRIPT_DIALOG_HEADER = "Script Dialog:\n";
|
|||
bool callback_script_dialog(const LLSD& notification, const LLSD& response)
|
||||
{
|
||||
LLNotificationForm form(notification["form"]);
|
||||
std::string button = LLNotification::getSelectedOptionName(response);
|
||||
S32 button_idx = LLNotification::getSelectedOption(notification, response);
|
||||
|
||||
std::string rtn_text;
|
||||
S32 button_idx;
|
||||
button_idx = LLNotification::getSelectedOption(notification, response);
|
||||
if (response[TEXTBOX_MAGIC_TOKEN].isDefined())
|
||||
{
|
||||
if (response[TEXTBOX_MAGIC_TOKEN].isString())
|
||||
rtn_text = response[TEXTBOX_MAGIC_TOKEN].asString();
|
||||
else
|
||||
rtn_text.clear(); // bool marks empty string
|
||||
}
|
||||
else
|
||||
{
|
||||
rtn_text = LLNotification::getSelectedOptionName(response);
|
||||
}
|
||||
|
||||
// Didn't click "Ignore"
|
||||
if (button_idx != -1)
|
||||
{
|
||||
|
|
@ -6449,7 +6464,7 @@ bool callback_script_dialog(const LLSD& notification, const LLSD& response)
|
|||
msg->addUUID("ObjectID", notification["payload"]["object_id"].asUUID());
|
||||
msg->addS32("ChatChannel", notification["payload"]["chat_channel"].asInteger());
|
||||
msg->addS32("ButtonIndex", button_idx);
|
||||
msg->addString("ButtonLabel", button);
|
||||
msg->addString("ButtonLabel", rtn_text);
|
||||
msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||||
<panel
|
||||
background_visible="true"
|
||||
height="230"
|
||||
label="instant_message"
|
||||
layout="topleft"
|
||||
left="0"
|
||||
name="panel_notify_textbox"
|
||||
top="0"
|
||||
width="305">
|
||||
<string
|
||||
name="message_max_lines_count"
|
||||
value="7" />
|
||||
<panel
|
||||
bevel_style="none"
|
||||
follows="left|right|top"
|
||||
height="150"
|
||||
label="info_panel"
|
||||
layout="topleft"
|
||||
left="0"
|
||||
name="info_panel"
|
||||
top="0"
|
||||
width="305">
|
||||
<text_editor
|
||||
parse_urls="true"
|
||||
enabled="true"
|
||||
follows="all"
|
||||
height="60"
|
||||
layout="topleft"
|
||||
left="25"
|
||||
max_length="250"
|
||||
name="message"
|
||||
parse_highlights="true"
|
||||
read_only="false"
|
||||
top="40"
|
||||
type="string"
|
||||
use_ellipses="true"
|
||||
value="message"
|
||||
width="260"
|
||||
word_wrap="true" >
|
||||
</text_editor>
|
||||
parse_urls="false"
|
||||
<button
|
||||
top="110"
|
||||
follows="top|left"
|
||||
height="20"
|
||||
label="Submit"
|
||||
layout="topleft"
|
||||
left="25"
|
||||
name="btn_submit"
|
||||
width="70" />
|
||||
</panel>
|
||||
<panel
|
||||
background_visible="false"
|
||||
follows="left|right|bottom"
|
||||
height="0"
|
||||
width="290"
|
||||
label="control_panel"
|
||||
layout="topleft"
|
||||
left="10"
|
||||
name="control_panel"
|
||||
top_pad="5">
|
||||
<!--
|
||||
Notes:
|
||||
This panel holds the Ignore button and possibly other buttons of notification.
|
||||
-->
|
||||
</panel>
|
||||
</panel>
|
||||
Loading…
Reference in New Issue