diff options
Diffstat (limited to 'linden/indra/llui/llbutton.cpp')
-rw-r--r-- | linden/indra/llui/llbutton.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/linden/indra/llui/llbutton.cpp b/linden/indra/llui/llbutton.cpp index 1d44537..de8b82e 100644 --- a/linden/indra/llui/llbutton.cpp +++ b/linden/indra/llui/llbutton.cpp | |||
@@ -615,6 +615,56 @@ void LLButton::draw() | |||
615 | gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0, LLColor4::pink1, FALSE); | 615 | gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0, LLColor4::pink1, FALSE); |
616 | } | 616 | } |
617 | 617 | ||
618 | // draw overlay image | ||
619 | if (mImageOverlay.notNull()) | ||
620 | { | ||
621 | const S32 IMG_PAD = 4; | ||
622 | // get max width and height (discard level 0) | ||
623 | S32 overlay_width = mImageOverlay->getWidth(0); | ||
624 | S32 overlay_height = mImageOverlay->getHeight(0); | ||
625 | |||
626 | F32 scale_factor = llmin((F32)mRect.getWidth() / (F32)overlay_width, (F32)mRect.getHeight() / (F32)overlay_height, 1.f); | ||
627 | overlay_width = llround((F32)overlay_width * scale_factor); | ||
628 | overlay_height = llround((F32)overlay_height * scale_factor); | ||
629 | |||
630 | S32 center_x = getLocalRect().getCenterX(); | ||
631 | S32 center_y = getLocalRect().getCenterY(); | ||
632 | |||
633 | switch(mImageOverlayAlignment) | ||
634 | { | ||
635 | case LLFontGL::LEFT: | ||
636 | gl_draw_scaled_image( | ||
637 | IMG_PAD, | ||
638 | center_y - (overlay_height / 2), | ||
639 | overlay_width, | ||
640 | overlay_height, | ||
641 | mImageOverlay, | ||
642 | LLColor4::white); | ||
643 | break; | ||
644 | case LLFontGL::HCENTER: | ||
645 | gl_draw_scaled_image( | ||
646 | center_x - (overlay_width / 2), | ||
647 | center_y - (overlay_height / 2), | ||
648 | overlay_width, | ||
649 | overlay_height, | ||
650 | mImageOverlay, | ||
651 | LLColor4::white); | ||
652 | break; | ||
653 | case LLFontGL::RIGHT: | ||
654 | gl_draw_scaled_image( | ||
655 | mRect.getWidth() - IMG_PAD - overlay_width, | ||
656 | center_y - (overlay_height / 2), | ||
657 | overlay_width, | ||
658 | overlay_height, | ||
659 | mImageOverlay, | ||
660 | LLColor4::white); | ||
661 | break; | ||
662 | default: | ||
663 | // draw nothing | ||
664 | break; | ||
665 | } | ||
666 | } | ||
667 | |||
618 | // Draw label | 668 | // Draw label |
619 | if( !label.empty() ) | 669 | if( !label.empty() ) |
620 | { | 670 | { |
@@ -826,6 +876,21 @@ void LLButton::setHoverImages( const LLString& image_name, const LLString& selec | |||
826 | setImageHoverSelected(selected_name); | 876 | setImageHoverSelected(selected_name); |
827 | } | 877 | } |
828 | 878 | ||
879 | void LLButton::setImageOverlay(const LLString &image_name, LLFontGL::HAlign alignment) | ||
880 | { | ||
881 | if (image_name.empty()) | ||
882 | { | ||
883 | mImageOverlay = NULL; | ||
884 | } | ||
885 | else | ||
886 | { | ||
887 | LLUUID overlay_image_id = LLUI::findAssetUUIDByName(image_name); | ||
888 | mImageOverlay = LLUI::sImageProvider->getUIImageByID(overlay_image_id); | ||
889 | mImageOverlayAlignment = alignment; | ||
890 | } | ||
891 | } | ||
892 | |||
893 | |||
829 | void LLButton::onMouseCaptureLost() | 894 | void LLButton::onMouseCaptureLost() |
830 | { | 895 | { |
831 | mMouseDownTimer.stop(); | 896 | mMouseDownTimer.stop(); |
@@ -998,6 +1063,18 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa | |||
998 | LLString image_disabled; | 1063 | LLString image_disabled; |
999 | if (node->hasAttribute("image_disabled")) node->getAttributeString("image_disabled",image_disabled); | 1064 | if (node->hasAttribute("image_disabled")) node->getAttributeString("image_disabled",image_disabled); |
1000 | 1065 | ||
1066 | LLString image_overlay; | ||
1067 | node->getAttributeString("image_overlay", image_overlay); | ||
1068 | |||
1069 | LLFontGL::HAlign image_overlay_alignment = LLFontGL::HCENTER; | ||
1070 | LLString image_overlay_alignment_string; | ||
1071 | if (node->hasAttribute("image_overlay_alignment")) | ||
1072 | { | ||
1073 | node->getAttributeString("image_overlay_alignment", image_overlay_alignment_string); | ||
1074 | image_overlay_alignment = LLFontGL::hAlignFromName(image_overlay_alignment_string); | ||
1075 | } | ||
1076 | |||
1077 | |||
1001 | LLButton *button = new LLButton(name, | 1078 | LLButton *button = new LLButton(name, |
1002 | LLRect(), | 1079 | LLRect(), |
1003 | image_unselected, | 1080 | image_unselected, |
@@ -1020,6 +1097,7 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa | |||
1020 | 1097 | ||
1021 | if(image_disabled != LLString::null) button->setImageDisabled(image_disabled); | 1098 | if(image_disabled != LLString::null) button->setImageDisabled(image_disabled); |
1022 | 1099 | ||
1100 | if(image_overlay != LLString::null) button->setImageOverlay(image_overlay, image_overlay_alignment); | ||
1023 | 1101 | ||
1024 | if (node->hasAttribute("halign")) | 1102 | if (node->hasAttribute("halign")) |
1025 | { | 1103 | { |