void CCControlBase::needsLayout() { CCSize ctrlSize(getPreferredSize()); if(getBackGroundSprite() == nullptr) { if(ctrlSize.width == 0) { ctrlSize.width = 100; } if(ctrlSize.height == 0) { ctrlSize.height = 100; } } else { ctrlSize = getBackGroundSprite()->getContentSize(); if(getPreferredSize().width != 0) { ctrlSize.width = getPreferredSize().width; } if(getPreferredSize().height != 0) { ctrlSize.height = getPreferredSize().height; } if(ctrlSize.equals(getBackGroundSprite()->getContentSize()) == false) { getBackGroundSprite()->setContentSize(ctrlSize); } const CCPoint& anchorPoint(getAnchorPoint()); if(isIgnoreAnchorPointForPosition()) { getBackGroundSprite()->setPosition( ccp( ctrlSize.width * 0.5f, ctrlSize.height * 0.5f ) ); } else { getBackGroundSprite()->setPosition( ccp( ctrlSize.width, ctrlSize.height ) ); } } setContentSize(ctrlSize); }
bool PluginOptionsDialog::init() { CCDictionary* dataSource(NetworkState::getInstanceDictionary( SL_SERIALIZEKEY_PLUGIN_GLOBAL_SETTINGS)); // configure once Dictionary::setObjectIfNotExist(dataSource, CCString::create("networklessons"),SL_SERIALIZEKEY_PEER_SESSION_PASSWORD); Dictionary::setObjectIfNotExist(dataSource, CCDouble::create(50),SL_SERIALIZEKEY_PHYSICSFRAMERATE); setDataSource(dataSource); CCSize ctrlSize(CCSizeMake(0,0)); CCArray* optionCtrls = CCArray::create(); CCControlBase* ctrlContainer(nullptr); if(_pluginLayerContent != nullptr) { if(_pluginLayerContent->getPluginHasNetwork()) { ctrlContainer = ControlUtils::createEditBox("Session password:"******"Physics framerate (hz):", ctrlSize); ctrlContainer->setValueKey(SL_SERIALIZEKEY_PHYSICSFRAMERATE); ctrlContainer->getCtrlLayoutFlags().addFlag(ECtrlLayoutFlag_ResetPreferredSizeOnSerialize); ctrlContainer->deserialize(dataSource); optionCtrls->addObject(ctrlContainer); // TODO: @student : check this code - this is an example how to track edit box changes _ctrlPhysicsFrameRate = dynamic_cast<CCControlEditBox*>(ctrlContainer); } } if(optionCtrls->count() == 0) { ctrlContainer = ControlUtils::createValueBox("Option Info:", ctrlSize, "no plugin wide options available"); optionCtrls->addObject(ctrlContainer); } CCControlColumn* ctrlOptionsContainer = ControlUtils::createControlColumn(optionCtrls,ctrlSize); ctrlOptionsContainer->getCtrlFlags().removeFlag(ECtrlFlag_UseScissorTest); CCArray* dialogCtrls = CCArray::create(); dialogCtrls->addObject(ctrlOptionsContainer); dialogCtrls->addObject(createOkBtn()); CCControlColumn* ctrlDialogContainer = ControlUtils::createControlColumn(dialogCtrls,ctrlSize); ctrlDialogContainer->getCtrlFlags().removeFlag(ECtrlFlag_UseScissorTest); CCSize dlgSize(ctrlDialogContainer->getContentSize()); setPreferredSize(ctrlSize); // call the base class here we don't want all those background sprites bool initialized(CCControlBase::init()); addChild(ctrlDialogContainer); setCtrlColumn(ctrlDialogContainer); // read the data from the datastore // we need to redo the layout as we have some edit controls // inside this dialog // so force a new layout deserializeAll(getDataSource(), true); return initialized; }
MixerTrackCluster::MixerTrackCluster(wxWindow* parent, MixerBoard* grandParent, AudacityProject* project, WaveTrack* pLeftTrack, WaveTrack* pRightTrack /*= NULL*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/) : wxPanel(parent, -1, pos, size) { mMixerBoard = grandParent; mProject = project; mLeftTrack = pLeftTrack; mRightTrack = pRightTrack; this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); // Create the controls programmatically. // Not sure why, but sizers weren't getting offset vertically, // probably because not using wxDefaultPosition, // so positions are calculated explicitly below, and sizers code was removed. // (Still available in Audacity_UmixIt branch off 1.2.6.) // track name wxPoint ctrlPos(kDoubleInset, kDoubleInset); wxSize ctrlSize(size.GetWidth() - kQuadrupleInset, TRACK_NAME_HEIGHT); mStaticText_TrackName = new wxStaticText(this, -1, mLeftTrack->GetName(), ctrlPos, ctrlSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE | wxSUNKEN_BORDER); //v Useful when different tracks are different colors, but not now. // mStaticText_TrackName->SetBackgroundColour(this->GetTrackColor()); // pan slider ctrlPos.x = size.GetWidth() / 10; ctrlPos.y += TRACK_NAME_HEIGHT + kDoubleInset; ctrlSize = wxSize((size.GetWidth() * 4 / 5), PAN_HEIGHT); // The width of the pan slider must be odd (don't ask). if (!(ctrlSize.x & 1)) ctrlSize.x--; mSlider_Pan = new MixerTrackSlider( this, ID_SLIDER_PAN, /* i18n-hint: Title of the Pan slider, used to move the sound left or right */ _("Pan"), ctrlPos, ctrlSize, PAN_SLIDER, true); this->UpdatePan(); // gain slider at left ctrlPos.x = kDoubleInset; ctrlPos.y += PAN_HEIGHT + kDoubleInset; const int nGainSliderHeight = size.GetHeight() - ctrlPos.y - kQuadrupleInset; ctrlSize = wxSize(kLeftSideStackWidth - kQuadrupleInset, nGainSliderHeight); mSlider_Gain = new MixerTrackSlider( this, ID_SLIDER_GAIN, /* i18n-hint: Title of the Gain slider, used to adjust the volume */ _("Gain"), ctrlPos, ctrlSize, DB_SLIDER, true, true, 0.0, wxVERTICAL); // too much color: mSlider_Gain->SetBackgroundColour(this->GetTrackColor()); // too dark: mSlider_Gain->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW)); //#ifdef __WXMAC__ // mSlider_Gain->SetBackgroundColour(wxColour(220, 220, 220)); //#else // mSlider_Gain->SetBackgroundColour(wxColour(192, 192, 192)); //#endif this->UpdateGain(); // meter and other controls at right // musical instrument image ctrlPos.x = kInset + kLeftSideStackWidth; ctrlSize = wxSize(MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH, MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH); wxBitmap* bitmap = mMixerBoard->GetMusicalInstrumentBitmap(mLeftTrack); wxASSERT(bitmap); mBitmapButton_MusicalInstrument = new wxBitmapButton(this, ID_BITMAPBUTTON_MUSICAL_INSTRUMENT, *bitmap, ctrlPos, ctrlSize, wxBU_AUTODRAW, wxDefaultValidator, _("Musical Instrument")); // meter ctrlPos.y += MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH + kDoubleInset; const int nMeterHeight = nGainSliderHeight - (MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH + kDoubleInset) - kQuadrupleInset - kRequiredHeightBelowMeter; ctrlSize.Set(kRightSideStackWidth, nMeterHeight); mMeter = new Meter(this, -1, // wxWindow* parent, wxWindowID id, false, // bool isInput ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, Meter::MixerTrackCluster); // Style style = HorizontalStereo, // mute/solo buttons stacked below meter ctrlPos.y += nMeterHeight + kQuadrupleInset; ctrlSize = wxSize(mMixerBoard->mMuteSoloWidth, MUTE_SOLO_HEIGHT); mToggleButton_Mute = new AButton(this, ID_TOGGLEBUTTON_MUTE, ctrlPos, ctrlSize, *(mMixerBoard->mImageMuteUp), *(mMixerBoard->mImageMuteOver), *(mMixerBoard->mImageMuteDown), *(mMixerBoard->mImageMuteDisabled), true); // toggle button mToggleButton_Mute->SetAlternateImages( *(mMixerBoard->mImageMuteUp), *(mMixerBoard->mImageMuteOver), *(mMixerBoard->mImageMuteDown), *(mMixerBoard->mImageMuteDisabled)); this->UpdateMute(); ctrlPos.y += MUTE_SOLO_HEIGHT; mToggleButton_Solo = new AButton(this, ID_TOGGLEBUTTON_SOLO, ctrlPos, ctrlSize, *(mMixerBoard->mImageSoloUp), *(mMixerBoard->mImageSoloOver), *(mMixerBoard->mImageSoloDown), *(mMixerBoard->mImageSoloDisabled), true); // toggle button this->UpdateSolo(); #if wxUSE_TOOLTIPS mStaticText_TrackName->SetToolTip(mLeftTrack->GetName()); mToggleButton_Mute->SetToolTip(_T("Mute")); mToggleButton_Solo->SetToolTip(_T("Solo")); mMeter->SetToolTip(_T("Signal Level Meter")); #endif // wxUSE_TOOLTIPS #ifdef __WXMAC__ wxSizeEvent dummyEvent; this->OnSize(dummyEvent); UpdateGain(); #endif }