From a5261a5fa8fad810ecb5c260d92c3e771822bf58 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 23:46:23 +0100 Subject: Convert BOOL to bool in llui --- indra/newview/lltoastscriptquestion.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/lltoastscriptquestion.cpp') diff --git a/indra/newview/lltoastscriptquestion.cpp b/indra/newview/lltoastscriptquestion.cpp index 7a3a1d8fd7..be5bb24b36 100644 --- a/indra/newview/lltoastscriptquestion.cpp +++ b/indra/newview/lltoastscriptquestion.cpp @@ -40,7 +40,7 @@ LLToastPanel(notification) buildFromFile("panel_script_question_toast.xml"); } -BOOL LLToastScriptQuestion::postBuild() +bool LLToastScriptQuestion::postBuild() { createButtons(); @@ -52,11 +52,11 @@ BOOL LLToastScriptQuestion::postBuild() snapToMessageHeight(); - return TRUE; + return true; } // virtual -void LLToastScriptQuestion::setFocus(BOOL b) +void LLToastScriptQuestion::setFocus(bool b) { LLToastPanel::setFocus(b); // toast can fade out and disappear with focus ON, so reset to default anyway -- cgit v1.2.3 From 60d3dd98a44230c21803c1606552ee098ed9fa7c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 21:05:14 +0100 Subject: Convert remaining BOOL to bool --- indra/newview/lltoastscriptquestion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltoastscriptquestion.cpp') diff --git a/indra/newview/lltoastscriptquestion.cpp b/indra/newview/lltoastscriptquestion.cpp index be5bb24b36..f6fc9e7889 100644 --- a/indra/newview/lltoastscriptquestion.cpp +++ b/indra/newview/lltoastscriptquestion.cpp @@ -134,7 +134,7 @@ void LLToastScriptQuestion::createButtons() if (form_element.has("default") && form_element["default"].asBoolean()) { - button->setFocus(TRUE); + button->setFocus(true); setDefaultBtn(button); } } -- cgit v1.2.3 From a865d423974ea06dffa47798c81e98e7570b02ec Mon Sep 17 00:00:00 2001 From: Alexander Gavriliuk Date: Tue, 5 Mar 2024 17:03:11 +0100 Subject: viewer#819 Avoid reading the same XML file multiple times --- indra/newview/lltoastscriptquestion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltoastscriptquestion.cpp') diff --git a/indra/newview/lltoastscriptquestion.cpp b/indra/newview/lltoastscriptquestion.cpp index f6fc9e7889..49fbf885eb 100644 --- a/indra/newview/lltoastscriptquestion.cpp +++ b/indra/newview/lltoastscriptquestion.cpp @@ -37,7 +37,7 @@ LLToastScriptQuestion::LLToastScriptQuestion(const LLNotificationPtr& notificati : LLToastPanel(notification) { - buildFromFile("panel_script_question_toast.xml"); + buildFromFile("panel_script_question_toast.xml", true); } bool LLToastScriptQuestion::postBuild() -- cgit v1.2.3 From 2008f87f10d51a2f9372aa4a4d72e86ac94e1e81 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 13 May 2024 18:26:53 +0300 Subject: Revert "viewer#819 Avoid reading the same XML file multiple times" This reverts commit a865d423974ea06dffa47798c81e98e7570b02ec. Reason for revert: viewer#1420, reverting to not hold maint-A (is deepCopy not full?) --- indra/newview/lltoastscriptquestion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltoastscriptquestion.cpp') diff --git a/indra/newview/lltoastscriptquestion.cpp b/indra/newview/lltoastscriptquestion.cpp index 49fbf885eb..f6fc9e7889 100644 --- a/indra/newview/lltoastscriptquestion.cpp +++ b/indra/newview/lltoastscriptquestion.cpp @@ -37,7 +37,7 @@ LLToastScriptQuestion::LLToastScriptQuestion(const LLNotificationPtr& notificati : LLToastPanel(notification) { - buildFromFile("panel_script_question_toast.xml", true); + buildFromFile("panel_script_question_toast.xml"); } bool LLToastScriptQuestion::postBuild() -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/newview/lltoastscriptquestion.cpp | 298 ++++++++++++++++---------------- 1 file changed, 149 insertions(+), 149 deletions(-) (limited to 'indra/newview/lltoastscriptquestion.cpp') diff --git a/indra/newview/lltoastscriptquestion.cpp b/indra/newview/lltoastscriptquestion.cpp index 35d32b85cf..25dc0982b8 100644 --- a/indra/newview/lltoastscriptquestion.cpp +++ b/indra/newview/lltoastscriptquestion.cpp @@ -1,149 +1,149 @@ -/** - * @file lltoastscriptquestion.cpp - * - * $LicenseInfo:firstyear=2010&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, 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 "llbutton.h" -#include "llnotifications.h" -#include "lltoastscriptquestion.h" - -const int LEFT_PAD = 10; -const int BUTTON_HEIGHT = 27; -const int MAX_LINES_COUNT = 50; - -LLToastScriptQuestion::LLToastScriptQuestion(const LLNotificationPtr& notification) -: -LLToastPanel(notification) -{ - buildFromFile("panel_script_question_toast.xml"); -} - -bool LLToastScriptQuestion::postBuild() -{ - createButtons(); - - LLTextBox* mMessage = getChild("top_info_message"); - LLTextBox* mFooter = getChild("bottom_info_message"); - - mMessage->setValue(mNotification->getMessage()); - mFooter->setValue(mNotification->getFooter()); - - snapToMessageHeight(); - - return true; -} - -// virtual -void LLToastScriptQuestion::setFocus(bool b) -{ - LLToastPanel::setFocus(b); - // toast can fade out and disappear with focus ON, so reset to default anyway - LLButton* dfbutton = getDefaultButton(); - if (dfbutton && dfbutton->getVisible() && dfbutton->getEnabled()) - { - dfbutton->setFocus(b); - } -} - -void LLToastScriptQuestion::snapToMessageHeight() -{ - LLTextBox* mMessage = getChild("top_info_message"); - LLTextBox* mFooter = getChild("bottom_info_message"); - if (!mMessage || !mFooter) - { - return; - } - - if (mMessage->getVisible() && mFooter->getVisible()) - { - S32 heightDelta = 0; - S32 maxTextHeight = (mMessage->getFont()->getLineHeight() * MAX_LINES_COUNT) - + (mFooter->getFont()->getLineHeight() * MAX_LINES_COUNT); - - LLRect messageRect = mMessage->getRect(); - LLRect footerRect = mFooter->getRect(); - - S32 oldTextHeight = messageRect.getHeight() + footerRect.getHeight(); - - S32 requiredTextHeight = mMessage->getTextBoundingRect().getHeight() + mFooter->getTextBoundingRect().getHeight(); - S32 newTextHeight = llmin(requiredTextHeight, maxTextHeight); - - heightDelta = newTextHeight - oldTextHeight - heightDelta; - - reshape( getRect().getWidth(), llmax(getRect().getHeight() + heightDelta, MIN_PANEL_HEIGHT)); - } -} - -void LLToastScriptQuestion::createButtons() -{ - LLNotificationFormPtr form = mNotification->getForm(); - int num_elements = form->getNumElements(); - int buttons_width = 0; - - for (int i = 0; i < num_elements; ++i) - { - LLSD form_element = form->getElement(i); - if ("button" == form_element["type"].asString()) - { - LLButton::Params p; - const LLFontGL* font = LLFontGL::getFontSansSerif(); - p.name(form_element["name"].asString()); - p.label(form_element["text"].asString()); - p.layout("topleft"); - p.font(font); - p.rect.height(BUTTON_HEIGHT); - p.click_callback.function(boost::bind(&LLToastScriptQuestion::onButtonClicked, this, form_element["name"].asString())); - p.rect.left = LEFT_PAD; - p.rect.width = font->getWidth(form_element["text"].asString()); - p.auto_resize = true; - p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); - p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); - p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); - - LLButton* button = LLUICtrlFactory::create(p); - button->autoResize(); - getChild("buttons_panel")->addChild(button); - - LLRect rect = button->getRect(); - rect.setLeftTopAndSize(buttons_width, rect.mTop, rect.getWidth(), rect.getHeight()); - button->setRect(rect); - - buttons_width += rect.getWidth() + LEFT_PAD; - - if (form_element.has("default") && form_element["default"].asBoolean()) - { - button->setFocus(true); - setDefaultBtn(button); - } - } - } -} - -void LLToastScriptQuestion::onButtonClicked(std::string btn_name) -{ - LLSD response = mNotification->getResponseTemplate(); - response[btn_name] = true; - mNotification->respond(response); -} +/** + * @file lltoastscriptquestion.cpp + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 "llbutton.h" +#include "llnotifications.h" +#include "lltoastscriptquestion.h" + +const int LEFT_PAD = 10; +const int BUTTON_HEIGHT = 27; +const int MAX_LINES_COUNT = 50; + +LLToastScriptQuestion::LLToastScriptQuestion(const LLNotificationPtr& notification) +: +LLToastPanel(notification) +{ + buildFromFile("panel_script_question_toast.xml"); +} + +bool LLToastScriptQuestion::postBuild() +{ + createButtons(); + + LLTextBox* mMessage = getChild("top_info_message"); + LLTextBox* mFooter = getChild("bottom_info_message"); + + mMessage->setValue(mNotification->getMessage()); + mFooter->setValue(mNotification->getFooter()); + + snapToMessageHeight(); + + return true; +} + +// virtual +void LLToastScriptQuestion::setFocus(bool b) +{ + LLToastPanel::setFocus(b); + // toast can fade out and disappear with focus ON, so reset to default anyway + LLButton* dfbutton = getDefaultButton(); + if (dfbutton && dfbutton->getVisible() && dfbutton->getEnabled()) + { + dfbutton->setFocus(b); + } +} + +void LLToastScriptQuestion::snapToMessageHeight() +{ + LLTextBox* mMessage = getChild("top_info_message"); + LLTextBox* mFooter = getChild("bottom_info_message"); + if (!mMessage || !mFooter) + { + return; + } + + if (mMessage->getVisible() && mFooter->getVisible()) + { + S32 heightDelta = 0; + S32 maxTextHeight = (mMessage->getFont()->getLineHeight() * MAX_LINES_COUNT) + + (mFooter->getFont()->getLineHeight() * MAX_LINES_COUNT); + + LLRect messageRect = mMessage->getRect(); + LLRect footerRect = mFooter->getRect(); + + S32 oldTextHeight = messageRect.getHeight() + footerRect.getHeight(); + + S32 requiredTextHeight = mMessage->getTextBoundingRect().getHeight() + mFooter->getTextBoundingRect().getHeight(); + S32 newTextHeight = llmin(requiredTextHeight, maxTextHeight); + + heightDelta = newTextHeight - oldTextHeight - heightDelta; + + reshape( getRect().getWidth(), llmax(getRect().getHeight() + heightDelta, MIN_PANEL_HEIGHT)); + } +} + +void LLToastScriptQuestion::createButtons() +{ + LLNotificationFormPtr form = mNotification->getForm(); + int num_elements = form->getNumElements(); + int buttons_width = 0; + + for (int i = 0; i < num_elements; ++i) + { + LLSD form_element = form->getElement(i); + if ("button" == form_element["type"].asString()) + { + LLButton::Params p; + const LLFontGL* font = LLFontGL::getFontSansSerif(); + p.name(form_element["name"].asString()); + p.label(form_element["text"].asString()); + p.layout("topleft"); + p.font(font); + p.rect.height(BUTTON_HEIGHT); + p.click_callback.function(boost::bind(&LLToastScriptQuestion::onButtonClicked, this, form_element["name"].asString())); + p.rect.left = LEFT_PAD; + p.rect.width = font->getWidth(form_element["text"].asString()); + p.auto_resize = true; + p.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); + p.image_color(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); + p.image_color_disabled(LLUIColorTable::instance().getColor("ButtonCautionImageColor")); + + LLButton* button = LLUICtrlFactory::create(p); + button->autoResize(); + getChild("buttons_panel")->addChild(button); + + LLRect rect = button->getRect(); + rect.setLeftTopAndSize(buttons_width, rect.mTop, rect.getWidth(), rect.getHeight()); + button->setRect(rect); + + buttons_width += rect.getWidth() + LEFT_PAD; + + if (form_element.has("default") && form_element["default"].asBoolean()) + { + button->setFocus(true); + setDefaultBtn(button); + } + } + } +} + +void LLToastScriptQuestion::onButtonClicked(std::string btn_name) +{ + LLSD response = mNotification->getResponseTemplate(); + response[btn_name] = true; + mNotification->respond(response); +} -- cgit v1.2.3