LLSpinCtrl::LLSpinCtrl( const std::string& name, const LLRect& rect, const std::string& label, const LLFontGL* font, void (*commit_callback)(LLUICtrl*, void*), void* callback_user_data, F32 initial_value, F32 min_value, F32 max_value, F32 increment, const std::string& control_name, S32 label_width) : LLUICtrl(name, rect, TRUE, commit_callback, callback_user_data, FOLLOWS_LEFT | FOLLOWS_TOP ), mValue( initial_value ), mInitialValue( initial_value ), mMaxValue( max_value ), mMinValue( min_value ), mIncrement( increment ), mPrecision( 3 ), mLabelBox( NULL ), mTextEnabledColor( LLUI::sColorsGroup->getColor( "LabelTextColor" ) ), mTextDisabledColor( LLUI::sColorsGroup->getColor( "LabelDisabledColor" ) ), mbHasBeenSet( FALSE ) { S32 top = getRect().getHeight(); S32 bottom = top - 2 * SPINCTRL_BTN_HEIGHT; S32 centered_top = top; S32 centered_bottom = bottom; S32 btn_left = 0; // Label if( !label.empty() ) { LLRect label_rect( 0, centered_top, label_width, centered_bottom ); mLabelBox = new LLTextBox( std::string("SpinCtrl Label"), label_rect, label, font ); addChild(mLabelBox); btn_left += label_rect.mRight + SPINCTRL_SPACING; } S32 btn_right = btn_left + SPINCTRL_BTN_WIDTH; // Spin buttons LLRect up_rect( btn_left, top, btn_right, top - SPINCTRL_BTN_HEIGHT ); std::string out_id = "UIImgBtnSpinUpOutUUID"; std::string in_id = "UIImgBtnSpinUpInUUID"; mUpBtn = new LLButton(std::string("SpinCtrl Up"), up_rect, out_id, in_id, LLStringUtil::null, &LLSpinCtrl::onUpBtn, this, LLFontGL::getFontSansSerif() ); mUpBtn->setFollowsLeft(); mUpBtn->setFollowsBottom(); mUpBtn->setHeldDownCallback( &LLSpinCtrl::onUpBtn ); mUpBtn->setTabStop(FALSE); addChild(mUpBtn); LLRect down_rect( btn_left, top - SPINCTRL_BTN_HEIGHT, btn_right, bottom ); out_id = "UIImgBtnSpinDownOutUUID"; in_id = "UIImgBtnSpinDownInUUID"; mDownBtn = new LLButton(std::string("SpinCtrl Down"), down_rect, out_id, in_id, LLStringUtil::null, &LLSpinCtrl::onDownBtn, this, LLFontGL::getFontSansSerif() ); mDownBtn->setFollowsLeft(); mDownBtn->setFollowsBottom(); mDownBtn->setHeldDownCallback( &LLSpinCtrl::onDownBtn ); mDownBtn->setTabStop(FALSE); addChild(mDownBtn); LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom ); mEditor = new LLLineEditor( std::string("SpinCtrl Editor"), editor_rect, LLStringUtil::null, font, MAX_STRING_LENGTH, &LLSpinCtrl::onEditorCommit, NULL, NULL, this, &LLLineEditor::prevalidateFloat ); mEditor->setFollowsLeft(); mEditor->setFollowsBottom(); mEditor->setFocusReceivedCallback( &LLSpinCtrl::onEditorGainFocus, this ); //RN: this seems to be a BAD IDEA, as it makes the editor behavior different when it has focus // than when it doesn't. Instead, if you always have to double click to select all the text, // it's easier to understand //mEditor->setSelectAllonFocusReceived(TRUE); mEditor->setIgnoreTab(TRUE); addChild(mEditor); updateEditor(); setUseBoundingRect( TRUE ); }
LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p) : LLF32UICtrl(p), mLabelBox(NULL), mbHasBeenSet( FALSE ), mPrecision(p.decimal_digits), mTextEnabledColor(p.text_enabled_color()), mTextDisabledColor(p.text_disabled_color()) { static LLUICachedControl<S32> spinctrl_spacing ("UISpinctrlSpacing", 0); static LLUICachedControl<S32> spinctrl_btn_width ("UISpinctrlBtnWidth", 0); static LLUICachedControl<S32> spinctrl_btn_height ("UISpinctrlBtnHeight", 0); S32 centered_top = getRect().getHeight(); S32 centered_bottom = getRect().getHeight() - 2 * spinctrl_btn_height; S32 btn_left = 0; // reserve space for spinner S32 label_width = llclamp(p.label_width(), 0, llmax(0, getRect().getWidth() - 40)); // Label if( !p.label().empty() ) { LLRect label_rect( 0, centered_top, label_width, centered_bottom ); LLTextBox::Params params; params.wrap(p.label_wrap); params.name("SpinCtrl Label"); params.rect(label_rect); params.initial_value(p.label()); if (p.font.isProvided()) { params.font(p.font); } mLabelBox = LLUICtrlFactory::create<LLTextBox> (params); addChild(mLabelBox); btn_left += label_rect.mRight + spinctrl_spacing; } S32 btn_right = btn_left + spinctrl_btn_width; // Spin buttons LLButton::Params up_button_params(p.up_button); up_button_params.rect = LLRect(btn_left, getRect().getHeight(), btn_right, getRect().getHeight() - spinctrl_btn_height); up_button_params.click_callback.function(boost::bind(&LLSpinCtrl::onUpBtn, this, _2)); up_button_params.mouse_held_callback.function(boost::bind(&LLSpinCtrl::onUpBtn, this, _2)); mUpBtn = LLUICtrlFactory::create<LLButton>(up_button_params); addChild(mUpBtn); LLButton::Params down_button_params(p.down_button); down_button_params.rect = LLRect(btn_left, getRect().getHeight() - spinctrl_btn_height, btn_right, getRect().getHeight() - 2 * spinctrl_btn_height); down_button_params.click_callback.function(boost::bind(&LLSpinCtrl::onDownBtn, this, _2)); down_button_params.mouse_held_callback.function(boost::bind(&LLSpinCtrl::onDownBtn, this, _2)); mDownBtn = LLUICtrlFactory::create<LLButton>(down_button_params); addChild(mDownBtn); LLRect editor_rect( btn_right + 1, centered_top, getRect().getWidth(), centered_bottom ); LLLineEditor::Params params; params.name("SpinCtrl Editor"); params.rect(editor_rect); if (p.font.isProvided()) { params.font(p.font); } params.max_length.bytes(MAX_STRING_LENGTH); params.commit_callback.function((boost::bind(&LLSpinCtrl::onEditorCommit, this, _2))); //*NOTE: allow entering of any chars for LLCalc, proper input will be evaluated on commit params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); mEditor = LLUICtrlFactory::create<LLLineEditor> (params); mEditor->setFocusReceivedCallback( boost::bind(&LLSpinCtrl::onEditorGainFocus, _1, this )); //RN: this seems to be a BAD IDEA, as it makes the editor behavior different when it has focus // than when it doesn't. Instead, if you always have to double click to select all the text, // it's easier to understand //mEditor->setSelectAllonFocusReceived(TRUE); mEditor->setSelectAllonCommit(FALSE); addChild(mEditor); updateEditor(); setUseBoundingRect( TRUE ); }
void MainWindowViewHandler::OnResize(const ax::Size& size) { if (_view_mode) { return; } int INSPECTOR_MENU_WIDTH = _main_window->INSPECTOR_MENU_WIDTH; int STATUS_BAR_HEIGHT = _main_window->STATUS_BAR_HEIGHT; int BOTTOM_BAR_HEIGHT = _main_window->BOTTOM_BAR_HEIGHT; // Resize status bar. ax::Size top_menu_size(_main_window->_statusBar->GetWindow()->dimension.GetSize()); top_menu_size.w = size.w; _main_window->_statusBar->GetWindow()->dimension.SetSize(top_menu_size); bool widget_menu = _main_window->_left_menu->GetWindow()->IsShown(); bool inspector = _main_window->_right_menu->GetWindow()->IsShown(); bool code_editor = _main_window->_bottom_section->GetWindow()->IsShown(); int editor_height = 0; if (code_editor) { editor_height = _main_window->_bottom_section->GetWindow()->dimension.GetSize().h; if (editor_height > size.h - _main_window->STATUS_BAR_HEIGHT) { editor_height = size.h - _main_window->STATUS_BAR_HEIGHT; } } int grid_height = size.h - _main_window->STATUS_BAR_HEIGHT - editor_height - _main_window->BOTTOM_BAR_HEIGHT; int widget_menu_width = _main_window->_left_menu->GetWindow()->dimension.GetRect().size.w; if (widget_menu && inspector) { ax::Size widget_menu_size(widget_menu_width, size.h - _main_window->STATUS_BAR_HEIGHT - _main_window->BOTTOM_BAR_HEIGHT); _main_window->_left_menu->GetWindow()->dimension.SetSize(widget_menu_size); ax::Rect grid_rect(widget_menu_width, _main_window->STATUS_BAR_HEIGHT, size.w - widget_menu_width - _main_window->INSPECTOR_MENU_WIDTH, grid_height); _main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect); ax::Rect info_rect(size.w - _main_window->INSPECTOR_MENU_WIDTH, _main_window->STATUS_BAR_HEIGHT, _main_window->INSPECTOR_MENU_WIDTH, size.h - _main_window->STATUS_BAR_HEIGHT - _main_window->BOTTOM_BAR_HEIGHT); _main_window->_right_menu->GetWindow()->dimension.SetRect(info_rect); if (code_editor) { ax::Rect editor_rect(widget_menu_width + 1, size.h - editor_height - _main_window->BOTTOM_BAR_HEIGHT, size.w - widget_menu_width - _main_window->INSPECTOR_MENU_WIDTH, editor_height); _main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect); } } else if (widget_menu) { ax::Size widget_menu_size(widget_menu_width, size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT); _main_window->_left_menu->GetWindow()->dimension.SetSize(widget_menu_size); ax::Rect grid_rect( widget_menu_width, _main_window->STATUS_BAR_HEIGHT, size.w - widget_menu_width, grid_height); _main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect); if (code_editor) { ax::Rect editor_rect(widget_menu_width + 1, size.h - editor_height - BOTTOM_BAR_HEIGHT, size.w - widget_menu_width, editor_height); _main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect); } } else if (inspector) { ax::Rect grid_rect(0, STATUS_BAR_HEIGHT, size.w - INSPECTOR_MENU_WIDTH, grid_height); _main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect); ax::Rect info_rect(size.w - INSPECTOR_MENU_WIDTH, STATUS_BAR_HEIGHT, INSPECTOR_MENU_WIDTH, size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT); _main_window->_right_menu->GetWindow()->dimension.SetRect(info_rect); if (code_editor) { ax::Rect editor_rect(1, size.h - editor_height - BOTTOM_BAR_HEIGHT, size.w - INSPECTOR_MENU_WIDTH, editor_height); _main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect); } } else { ax::Rect grid_rect(0, STATUS_BAR_HEIGHT, size.w, grid_height); _main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect); if (code_editor) { ax::Rect editor_rect(1, size.h - editor_height - BOTTOM_BAR_HEIGHT, size.w, editor_height); _main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect); } } // Midi feedback. _main_window->_midi_feedback->GetWindow()->dimension.SetPosition(ax::Point(size.w - 17, size.h - 15)); AttachHelpInfo(_main_window->_midi_feedback->GetWindow(), "Midi input activity."); }