From efa0d701845542e9ef555260fe6d2ad0beeb0760 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 11 Sep 2009 00:33:33 -0700 Subject: Backported clickable object names from 1.23 --- linden/indra/llui/llpanel.cpp | 4 ++-- linden/indra/llui/llpanel.h | 2 +- linden/indra/llui/lltextbox.cpp | 7 +++++-- linden/indra/llui/lltextbox.h | 3 +-- linden/indra/llui/lltexteditor.cpp | 16 ++++++++-------- linden/indra/llui/lltexteditor.h | 8 ++++---- linden/indra/llui/llview.cpp | 20 +++++++++++++++----- linden/indra/llui/llview.h | 5 ++++- 8 files changed, 40 insertions(+), 25 deletions(-) (limited to 'linden/indra/llui') diff --git a/linden/indra/llui/llpanel.cpp b/linden/indra/llui/llpanel.cpp index d37517f..05103dc 100644 --- a/linden/indra/llui/llpanel.cpp +++ b/linden/indra/llui/llpanel.cpp @@ -982,12 +982,12 @@ void LLPanel::childSetAction(const std::string& id, void(*function)(void*), void } } -void LLPanel::childSetActionTextbox(const std::string& id, void(*function)(void*)) +void LLPanel::childSetActionTextbox(const std::string& id, void(*function)(void*), void* value) { LLTextBox* textbox = getChild(id); if (textbox) { - textbox->setClickedCallback(function); + textbox->setClickedCallback(function, value); } } diff --git a/linden/indra/llui/llpanel.h b/linden/indra/llui/llpanel.h index 46022e5..8dea9b1 100644 --- a/linden/indra/llui/llpanel.h +++ b/linden/indra/llui/llpanel.h @@ -220,7 +220,7 @@ public: // LLButton void childSetAction(const std::string& id, void(*function)(void*), void* value); - void childSetActionTextbox(const std::string& id, void(*function)(void*)); + void childSetActionTextbox(const std::string& id, void(*function)(void*), void* value = NULL); void childSetControlName(const std::string& id, const std::string& control_name); // Error reporting diff --git a/linden/indra/llui/lltextbox.cpp b/linden/indra/llui/lltextbox.cpp index f43b7d2..e45f97b 100644 --- a/linden/indra/llui/lltextbox.cpp +++ b/linden/indra/llui/lltextbox.cpp @@ -33,6 +33,7 @@ #include "lltextbox.h" #include "lluictrlfactory.h" #include "llfocusmgr.h" +#include "llwindow.h" static LLRegisterWidget r("text"); @@ -193,12 +194,14 @@ BOOL LLTextBox::handleMouseUp(S32 x, S32 y, MASK mask) BOOL LLTextBox::handleHover(S32 x, S32 y, MASK mask) { + BOOL handled = LLView::handleHover(x,y,mask); if(mHoverActive) { mHasHover = TRUE; // This should be set every frame during a hover. - return TRUE; + getWindow()->setCursor(UI_CURSOR_ARROW); } - return LLView::handleHover(x,y,mask); + + return (handled || mHasHover); } void LLTextBox::setText(const LLStringExplicit& text) diff --git a/linden/indra/llui/lltextbox.h b/linden/indra/llui/lltextbox.h index 83e4a9b..aac5344 100644 --- a/linden/indra/llui/lltextbox.h +++ b/linden/indra/llui/lltextbox.h @@ -88,8 +88,7 @@ public: void setVPad(S32 pixels) { mVPad = pixels; } void setRightAlign() { mHAlign = LLFontGL::RIGHT; } void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; } - void setClickedCallback( void (*cb)(void *data) ){ mClickedCallback = cb; } // mouse down and up within button - void setCallbackUserData( void* data ) { mCallbackUserData = data; } + void setClickedCallback( void (*cb)(void *data), void* data = NULL ){ mClickedCallback = cb; mCallbackUserData = data; } // mouse down and up within button const LLFontGL* getFont() const { return mFontGL; } diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 95cce60..8fa253a 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -3605,13 +3605,13 @@ void LLTextEditor::appendColoredText(const std::string &new_text, style->setVisible(true); style->setColor(color); style->setFontName(font_name); - appendStyledText(new_text, allow_undo, prepend_newline, &style); + appendStyledText(new_text, allow_undo, prepend_newline, style); } void LLTextEditor::appendStyledText(const std::string &new_text, - bool allow_undo, + bool allow_undo, bool prepend_newline, - const LLStyleSP *stylep) + const LLStyleSP stylep) { if(mParseHTML) { @@ -3626,14 +3626,14 @@ void LLTextEditor::appendStyledText(const std::string &new_text, html->setColor(mLinkColor); if (stylep) { - html->setFontName((*stylep)->getFontString()); + html->setFontName(stylep->getFontString()); } html->mUnderline = TRUE; if (start > 0) appendText(text.substr(0,start),allow_undo, prepend_newline, stylep); html->setLinkHREF(text.substr(start,end-start)); - appendText(text.substr(start, end-start),allow_undo, prepend_newline, &html); - if (end < (S32)text.length()) + appendText(text.substr(start, end-start),allow_undo, prepend_newline, html); + if (end < (S32)text.length()) { text = text.substr(end,text.length() - end); end=0; @@ -3653,7 +3653,7 @@ void LLTextEditor::appendStyledText(const std::string &new_text, // Appends new text to end of document void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool prepend_newline, - const LLStyleSP *stylep) + const LLStyleSP stylep) { // Save old state BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()); @@ -3685,7 +3685,7 @@ void LLTextEditor::appendText(const std::string &new_text, bool allow_undo, bool { S32 segment_start = old_length; S32 segment_end = getLength(); - LLTextSegment* segment = new LLTextSegment(*stylep, segment_start, segment_end ); + LLTextSegment* segment = new LLTextSegment(stylep, segment_start, segment_end ); mSegments.push_back(segment); } diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index 0777e5f..7e93de1 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h @@ -146,16 +146,16 @@ public: void insertText(const std::string &text); // appends text at end void appendText(const std::string &wtext, bool allow_undo, bool prepend_newline, - const LLStyleSP *stylep = NULL); + const LLStyleSP stylep = NULL); - void appendColoredText(const std::string &wtext, bool allow_undo, + void appendColoredText(const std::string &wtext, bool allow_undo, bool prepend_newline, const LLColor4 &color, const std::string& font_name = LLStringUtil::null); // if styled text starts a line, you need to prepend a newline. - void appendStyledText(const std::string &new_text, bool allow_undo, + void appendStyledText(const std::string &new_text, bool allow_undo, bool prepend_newline, - const LLStyleSP *stylep = NULL); + const LLStyleSP stylep = NULL); // Removes text from the end of document // Does not change highlight or cursor position. diff --git a/linden/indra/llui/llview.cpp b/linden/indra/llui/llview.cpp index 78bf168..e3652b7 100644 --- a/linden/indra/llui/llview.cpp +++ b/linden/indra/llui/llview.cpp @@ -85,7 +85,8 @@ LLView::LLView() : mLastVisible(TRUE), mUseBoundingRect(FALSE), mVisible(TRUE), - mNextInsertionOrdinal(0) + mNextInsertionOrdinal(0), + mHoverCursor(UI_CURSOR_ARROW) { } @@ -102,7 +103,8 @@ LLView::LLView(const std::string& name, BOOL mouse_opaque) : mLastVisible(TRUE), mUseBoundingRect(FALSE), mVisible(TRUE), - mNextInsertionOrdinal(0) + mNextInsertionOrdinal(0), + mHoverCursor(UI_CURSOR_ARROW) { } @@ -123,7 +125,8 @@ LLView::LLView( mLastVisible(TRUE), mUseBoundingRect(FALSE), mVisible(TRUE), - mNextInsertionOrdinal(0) + mNextInsertionOrdinal(0), + mHoverCursor(UI_CURSOR_ARROW) { } @@ -657,7 +660,7 @@ BOOL LLView::handleHover(S32 x, S32 y, MASK mask) if( !handled && blockMouseEvent(x, y) ) { - LLUI::sWindow->setCursor(UI_CURSOR_ARROW); + LLUI::sWindow->setCursor(mHoverCursor); lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << llendl; handled = TRUE; } @@ -2622,7 +2625,14 @@ void LLView::initFromXML(LLXMLNodePtr node, LLView* parent) node->getAttributeBOOL("visible", visible); setVisible(visible); } - + + if (node->hasAttribute("hover_cursor")) + { + std::string cursor_string; + node->getAttributeString("hover_cursor", cursor_string); + mHoverCursor = getCursorFromString(cursor_string); + } + node->getAttributeBOOL("use_bounding_rect", mUseBoundingRect); node->getAttributeBOOL("mouse_opaque", mMouseOpaque); diff --git a/linden/indra/llui/llview.h b/linden/indra/llui/llview.h index da7f164..df34a3e 100644 --- a/linden/indra/llui/llview.h +++ b/linden/indra/llui/llview.h @@ -51,6 +51,7 @@ #include "llxmlnode.h" #include "stdenums.h" #include "lluistring.h" +#include "llcursortypes.h" const U32 FOLLOWS_NONE = 0x00; const U32 FOLLOWS_LEFT = 0x01; @@ -653,7 +654,9 @@ private: mutable dummy_widget_map_t mDummyWidgets; boost::signals::connection mControlConnection; - + + ECursorType mHoverCursor; + public: static BOOL sDebugRects; // Draw debug rects behind everything. static BOOL sDebugKeys; -- cgit v1.1