void _RhythmiCcFilterSettings::AddViews(ArpBaseLayout* toLayout, ArpConfigureImpl& impl, float labelW, float intW, const BMessage& initSettings) { ArpBaseLayout* vBar = (new ArpRunningBar("SubVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ); toLayout->AddLayoutChild(vBar); vBar->AddLayoutChild((new AmControlChangeListPanel("Control Changes", this, initSettings)) ->SetParams(ArpMessage() .SetBool(ArpScrollArea::ScrollHorizontalP,false) .SetBool(ArpScrollArea::ScrollVerticalP,true) .SetBool(ArpScrollArea::InsetCornerP,false) .SetInt32(ArpScrollArea::BorderStyleP,B_FANCY_BORDER) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpWest) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ); ArpKnobPanel* kp = 0; vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(PROXIMITY_STR, "Proximity to beat:", impl.AttachControl(PROXIMITY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _ProximityFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(FREQUENCY_STR, "Frequency:", impl.AttachControl(FREQUENCY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _FrequencyFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(AMOUNT_STR, "Amount:", impl.AttachControl(AMOUNT_STR), MIN_AMOUNT, MAX_AMOUNT, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _OffPercentFormat() ); } mRhythmField = new_rhythm_menu_field(); if (mRhythmField) { vBar->AddLayoutChild(mRhythmField ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); } }
void ArpKnobPanel::DetachedFromWindow() { inherited::DetachedFromWindow(); ArpKnobControl* knobCtrl = KnobControl(); ArpIntControl* intCtrl = IntControl(); if( knobCtrl && intCtrl ) intCtrl->StopWatching( knobCtrl, ARPMSG_INT_CONTROL_CHANGED ); }
void ArpKnobPanel::AttachedToWindow() { inherited::AttachedToWindow(); if( Parent() ) SetViewColor( Parent()->ViewColor() ); ArpKnobControl* knobCtrl = KnobControl(); ArpIntControl* intCtrl = IntControl(); if( knobCtrl && intCtrl ) intCtrl->StartWatching( knobCtrl, ARPMSG_INT_CONTROL_CHANGED ); }
status_t _ControllerRangeSettings::RefreshRangeControls() { if (!mTable || !mLowCtrl || !mHighCtrl) return B_NO_MEMORY; int32 cc, low, high; mTable->GetCurrentRange(&cc, &low, &high); ArpVALIDATE(cc >= 0 && cc < ARP_CONTROLLER_SIZE, return B_ERROR); mLowCtrl->SetValue(low); mHighCtrl->SetValue(high); return B_OK; }
static ArpIntControl* new_component(BRect& f, float iw, const char* n, uint32 msg) { f.left = f.right + 2; f.right = f.left + iw; ArpIntControl* ic = new _ArpRgbaControl(f, n, NULL, new BMessage(msg)); if (!ic) return 0; ic->SetLimits(0, 255); return ic; }
/***************************************************************************** * ARP-UNCERTAIN-CHORUS-SETTINGS *****************************************************************************/ ArpUncertainChorusSettings::ArpUncertainChorusSettings( AmFilterHolderI* target, const BMessage& initSettings) : inherited(target, initSettings) { float labelW = -1, intW = -1; const BFont* font = be_plain_font; if (font) { labelW = font->StringWidth("Frequency:") + 5; intW = font->StringWidth("Always") + 5; } try { ArpKnobPanel* freqPanel = NULL; AddLayoutChild((new ArpRunningBar("TopVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ) ->AddLayoutChild((new ArpTextControl( SZ_FILTER_LABEL, "Label:","", mImpl.AttachTextControl(SZ_FILTER_LABEL))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "8") .SetString(ArpTextControl::PrefTextStringP, "8888888888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ->AddLayoutChild((new ArpViewWrapper(freqPanel = new ArpKnobPanel(FREQUENCY_STR, "Frequency:", mImpl.AttachControl(FREQUENCY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ); if (freqPanel) { ArpIntControl* intCtrl = freqPanel->IntControl(); if (intCtrl) intCtrl->SetFormatter(arp_new_frequency_formatter() ); } } catch(...) { throw; } Implementation().RefreshControls(mSettings); }
void _ControllerRangeSettings::MessageReceived(BMessage *msg) { switch (msg->what) { case ArpConfigureImpl::CONFIG_REPORT_MSG: { /* Interrupt reports from the int controls, because we need to * annotate them with more info. */ const char* p; if (mTable && mLowCtrl && mHighCtrl && msg->FindString("arp:param", &p) == B_OK && p && (strcmp(p, _LOW_VALUE) == 0 || strcmp(p, _HIGH_VALUE) == 0)) { int32 cc = mTable->CurrentSelection(), low = mLowCtrl->Value(), high = mHighCtrl->Value(); if (cc >= 0 && cc < ARP_CONTROLLER_SIZE) { BMessage upd, m; if (m.AddInt32(_CC_STR, cc) == B_OK && m.AddInt32(_LOW_VALUE, low) == B_OK && m.AddInt32(_HIGH_VALUE, high) == B_OK && upd.AddMessage(_RANGE_MSG, &m) == B_OK) { Implementation().SendConfiguration(&upd); RefreshControls(upd); } } break; } } case ARP_PUT_CONFIGURATION_MSG: { /* Right now this only happens as a result of the table being * selected, but if there are ever more controls generating * this message this will need to be a little smarter. */ RefreshRangeControls(); /* Don't break -- let the superclass handle, too. */ } default: inherited::MessageReceived(msg); } }
static void add_vaccine_box(ArpBaseLayout* toLayout, ArpConfigureImpl& impl, float labelW, float intW) { ArpBaseLayout* vBar = (new ArpRunningBar("SubVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ); toLayout->AddLayoutChild(vBar); ArpKnobPanel* kp = 0; vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(PROXIMITY_STR, "Proximity to beat:", impl.AttachControl(PROXIMITY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _ProximityFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(FREQUENCY_STR, "Frequency:", impl.AttachControl(FREQUENCY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _FrequencyFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(AMOUNT_STR, "Amount:", impl.AttachControl(AMOUNT_STR), MIN_AMOUNT, MAX_AMOUNT, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _OffPercentFormat() ); } }
void ArpKnobPanel::LayoutVertical( const char* name, const char* label, BMessage* message, int32 minValue, int32 maxValue, bool showIntControl, uint32 knobFlags, float labelWidth, float intControlWidth) { const BFont* font = be_plain_font; float fh = arp_get_font_height(font); float spaceY = 3; float top = 0; float widest = 0; // Cache the widest view just to save ourselves an // extra iteration over the views /* Add label */ BStringView* sv = 0; if( label ) { float w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label ); sv = new BStringView( BRect( 0, top, 0 + w, top + fh ), "label", label ); if( sv ) { AddChild( sv ); if( w > widest ) widest = w; } top += fh + spaceY; } /* Add knob */ float knobW, knobH; if( knobFlags&ARP_RING_ADORNMENT ) { knobW = Prefs().Size(KNOB_RING_X); knobH = Prefs().Size(KNOB_RING_Y); } else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) { knobW = Prefs().Size(KNOB_RING_TIGHT_X); knobH = Prefs().Size(KNOB_RING_TIGHT_Y); } else { knobW = Prefs().Size(KNOB_X); knobH = Prefs().Size(KNOB_Y); } ArpKnobControl* knob = new ArpKnobControl( BRect(0, top, knobW, top + knobH ), name, message, minValue, maxValue, knobFlags); if( knob ) { AddChild( knob ); if( knobW > widest ) widest = knobW; top += knobH + spaceY; } /* Add int control */ ArpIntControl* intCtrl = 0; if( showIntControl ) { float w = (intControlWidth >= 0) ? intControlWidth : knobW; intCtrl = new ArpIntControl( BRect(0, top, w, top + Prefs().Size(INT_CTRL_Y) ), "int_control", 0, 0); if( intCtrl ) { intCtrl->SetLimits( minValue, maxValue ); if( knob ) knob->SetIntControl( intCtrl ); AddChild( intCtrl ); if( w > widest ) widest = w; } } /* Now center everything based on the widest view. */ if( !sv && !intCtrl ) return; if( widest <= 0 ) return; BView* view; for( view = ChildAt(0); view; view = view->NextSibling() ) { BRect f = view->Frame(); if( f.Width() < widest ) view->MoveTo( (widest - f.Width()) / 2, f.top ); } }
void ArpKnobPanel::LayoutHorizontal(const char* name, const char* label, BMessage* message, int32 minValue, int32 maxValue, bool showIntControl, uint32 knobFlags, float labelWidth, float intControlWidth) { const BFont* font = be_plain_font; float fh = arp_get_font_height(font); float spaceX = 8; float left = 0; /* Add label */ BStringView* sv = 0; if( label ) { float w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label ); sv = new BStringView( BRect( left, 0, left + w, 0 + fh ), "label", label ); if( sv ) AddChild( sv ); left += w + spaceX; } /* Add knob */ float knobW, knobH; if( knobFlags&ARP_RING_ADORNMENT ) { knobW = Prefs().Size(KNOB_RING_X); knobH = Prefs().Size(KNOB_RING_Y); } else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) { knobW = Prefs().Size(KNOB_RING_TIGHT_X); knobH = Prefs().Size(KNOB_RING_TIGHT_Y); } else { knobW = Prefs().Size(KNOB_X); knobH = Prefs().Size(KNOB_Y); } ArpKnobControl* knob = new ArpKnobControl( BRect(left, 0, left + knobW, 0 + knobH ), name, message, minValue, maxValue, knobFlags); if( knob ) { AddChild( knob ); left += knobW + spaceX; } /* Add int control */ ArpIntControl* intCtrl = 0; if( showIntControl ) { float w = (intControlWidth >= 0) ? intControlWidth : knobW; intCtrl = new ArpIntControl( BRect(left, 0, left + w, 0 + Prefs().Size(INT_CTRL_Y) ), "int_control", 0, 0); if( intCtrl ) { intCtrl->SetLimits( minValue, maxValue ); if( knob ) knob->SetIntControl( intCtrl ); AddChild( intCtrl ); } } /* Now center everything based on the tallest view. */ if( !sv && !intCtrl ) return; float tallest = (knobH > fh) ? knobH : fh; BView* view; for( view = ChildAt(0); view; view = view->NextSibling() ) { BRect f = view->Frame(); if( f.Height() < tallest ) view->MoveTo( f.left, (tallest - f.Height()) / 2 ); } }