void CEQDisplay::SetBandInfo(tuint uiBand, tbool bEnabled, tfloat32 fFreqIndex, tfloat32 fdBIndex) { tfloat32 fXIndex = fFreqIndex; tfloat32 fYIndex = 1 - fdBIndex; tint32 iXPositions = dynamic_cast<I2D*>(*(mControls.begin()))->GetXPositions(); tint32 iYPositions = dynamic_cast<I2D*>(*(mControls.begin()))->GetYPositions(); tint32 iXPos = Float2Int(fXIndex * (iXPositions - 1)); tint32 iYPos = Float2Int(fYIndex * (iYPositions - 1)); tint32 iValue = iXPos << 16 | iYPos; // Get the control std::list<IControl*>::iterator it = mControls.begin(); tuint uiIndex = uiBand; while (uiIndex) { it++; uiIndex--; } IControl* pControl = *it; pControl->SetValue(iValue, false); pControl->SetVisible(bEnabled); }
void IGraphics::OnFileDropped(const char* path, int x, int y) { int i = GetMouseControlIdx(x, y); IControl* control = GetControl(i); if (control != NULL) { control->OnFileDropped(path); } }
void DrawChildren(PaintInfo &pi) { const U32 DISPLAY_MASK = STATE_ACTIVE | STATE_VISIBLE; NList<IControl>::Iterator i(&children); // Draw children from lowest Z-pos to highest for (i.GoToTail(); *i; i--) { IControl *child = *i; if ((child->GetControlState() & DISPLAY_MASK) == DISPLAY_MASK) { PaintInfo p = child->GetPaintInfo(); // Convert to screen coordinates before drawing Point<S32> origin = child->GetPos() + pi.client.p0; p.window += origin; p.client += origin; // Clamp rectangles to client area of listbox if (p.window.p1.x > pi.client.p1.x) { p.window.p1.x = pi.client.p1.x; p.client.p1.x = pi.client.p1.x; } // Apply global alpha scale p.alphaScale *= IFace::data.alphaScale; child->Draw(p); } } }
bool IGraphics::IsDirty(IRECT* pR) { bool dirty = false; int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->IsDirty()) { *pR = pR->Union(pControl->GetRECT()); dirty = true; } } #ifdef USE_IDLE_CALLS if (dirty) { mIdleTicks = 0; } else if (++mIdleTicks > IDLE_TICKS) { OnGUIIdle(); mIdleTicks = 0; } #endif return dirty; }
void IGraphics::SetParameterFromPlug(int paramIdx, double value, bool normalized) { if (!normalized) { IParam* pParam = mPlug->GetParam(paramIdx); value = pParam->GetNormalized(value); } int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->ParamIdx() == paramIdx) { //WDL_MutexLock lock(&mMutex); pControl->SetValueFromPlug(value); // Could be more than one, don't break until we check them all. } // now look for any auxilliary parameters int auxParamIdx = pControl->AuxParamIdx(paramIdx); if (auxParamIdx > -1) // there are aux params { pControl->SetAuxParamValueFromPlug(auxParamIdx, value); } } }
void IGraphics::OnGUIIdle() { int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; pControl->OnGUIIdle(); } }
void IGraphics::SetAllControlsDirty() { int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; pControl->SetDirty(false); } }
void IControlGroup::ShowControls() { for (int i = 0; i < controlProps.size(); i++) { IControl *pControl = controlProps[i].control; if (pControl->GetGUIResize() && pControl->GetGUIResize()->IsAttachedToIPlugBase()) pControl->GetGUIResize()->ShowControl(pControl); else controlProps[i].control->Hide(false); } }
/** * Runs the motors under driver control with either tank or arcade steering selected * by a jumper in DS Digin 0. Also an arm will operate based on a joystick Y-axis. */ void OperatorControl() { control->initialize(); while (IsOperatorControl()) { control->run(); dsLCD->UpdateLCD(); Wait(0.005); } }
void IGraphics::OnMouseOut() { int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; pControl->OnMouseOut(); } mMouseOver = -1; }
/** * Drive left & right motors for 2 seconds, enabled by a jumper (jumper * must be in for autonomous to operate). */ void Autonomous() { control->initializeAuto(); while (IsAutonomous()) { control->runAuto(); dsLCD->UpdateLCD(); Wait(0.005); } }
// // ICTicker::FindTicker // // Find a ICTicker control // ICTicker *ICTicker::FindTicker(const char *path) { IControl *ctrl = IFace::FindByName(path); // This currently does not check for correct type if (ctrl && ctrl->DerivedFrom(ICTicker::ClassId())) { return (ICTicker *)ctrl; } return NULL; }
// // ICRoot::PurgeNonSystem // // Delete all non system controls // void ICRoot::PurgeNonSystem() { for (NList<IControl>::Iterator i(&children); *i; i++) { IControl *ctrl = *i; if (!(ctrl->controlStyle & IControl::STYLE_SYSTEMWIDE)) { ctrl->MarkForDeletion(); } } }
void IGraphics::OnMouseDown(int x, int y, IMouseMod* pMod) { ReleaseMouseCapture(); int c = GetMouseControlIdx(x, y); if (c >= 0) { mMouseCapture = c; mMouseX = x; mMouseY = y; IControl* pControl = mControls.Get(c); int paramIdx = pControl->ParamIdx(); #if defined OS_WIN || defined VST3_API // on Mac, IGraphics.cpp is not compiled in a static library, so this can be #ifdef'd if (mPlug->GetAPI() == kAPIVST3) { if (pMod->R && paramIdx >= 0) { ReleaseMouseCapture(); mPlug->PopupHostContextMenuForParam(paramIdx, x, y); return; } } #endif #ifdef AAX_API if (mAAXViewContainer && paramIdx >= 0) { uint32_t mods = GetAAXModifiersFromIMouseMod(pMod); #ifdef OS_WIN // required to get start/windows and alt keys uint32_t aaxViewMods = 0; mAAXViewContainer->GetModifiers(&aaxViewMods); mods |= aaxViewMods; #endif WDL_String paramID; paramID.SetFormatted(32, "%i", paramIdx+1); if (mAAXViewContainer->HandleParameterMouseDown(paramID.Get(), mods) == AAX_SUCCESS) { return; // event handled by PT } } #endif if (paramIdx >= 0) { mPlug->BeginInformHostOfParamChange(paramIdx); } pControl->OnMouseDown(x, y, pMod); } }
void IGraphics::GrayOutControl(int paramIdx, bool gray) { int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->ParamIdx() == paramIdx) { pControl->GrayOut(gray); } // Could be more than one, don't break until we check them all. } }
void IGraphics::SetParameterFromGUI(int paramIdx, double normalizedValue) { int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->ParamIdx() == paramIdx) { pControl->SetValueFromUserInput(normalizedValue); // Could be more than one, don't break until we check them all. } } }
void IGraphics::OnMouseUp(int x, int y, IMouseMod* pMod) { int c = GetMouseControlIdx(x, y); mMouseCapture = mMouseX = mMouseY = -1; if (c >= 0) { IControl* pControl = mControls.Get(c); pControl->OnMouseUp(x, y, pMod); int paramIdx = pControl->ParamIdx(); if (paramIdx >= 0) { mPlug->EndInformHostOfParamChange(paramIdx); } } }
void IGraphics::AssignParamNameToolTips() { int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->ParamIdx() > -1) { pControl->SetTooltip(pControl->GetParam()->GetNameForHost()); } } }
// // ICRoot::RefreshControls // // Deactivate/reactivate top level windows // void ICRoot::RefreshControls() { for (NList<IControl>::Iterator i(&children); *i; i++) { IControl *ctrl = *i; if (ctrl->controlState & IControl::STATE_ACTIVE) { ctrl->Deactivate(); ctrl->Activate(); } } }
// // ICRoot::FindByName // // Find a root level control by name // // The syntax for this function is as follow // // '^' - begins searching from previous control // '|' - begins searching from the root // '<' - moves to the parent of the current control // more '<' characters will move up more levels // // In the structure: // // root // +- child1 // | +- a // | +- b // | // +- child2 // +- a // // with base of 'b': // '<a' refers to the window 'root\child1\a' // '<<<child2.a' refers to the window 'root\child2\a' // '|child2.a' also refers to 'root\child2\a' // IControl *ICRoot::FindByName(const char *name, IControl *base) { char path[256]; char *token, *p = path; IControl *ctrl = base ? base : this; Utils::Strmcpy(path, name, sizeof(path)); // if we find '^' then if (*p == '^' && previous.Alive()) { ctrl = previous; p++; } else { // if we find '|' then base search from root while (*p == '|') { ctrl = this; p++; } } // for each '<' move base up one level while (*p == '<') { if (ctrl == NULL) { ERR_FATAL(("Too many '<' in control name [%s]", name)); } ctrl = ctrl->parent; p++; } // descend into the tree searching for '.' seperated names if (ctrl) { token = strtok(p, "."); while (token && ctrl) { ctrl = ctrl->Find(Crc::CalcStr(token)); token = strtok(NULL, "."); } } return ctrl; }
// --------------------------------------------------------------------------- void __fastcall TImageRotationForm::FormGesture(TObject *Sender, const TGestureEventInfo &EventInfo, bool &Handled) { if (EventInfo.GestureID == static_cast<short>(igiRotate)) { IControl * LObj = this->ObjectAtPoint(ClientToScreen(EventInfo.Location)); if (static_cast<TImage*>((TImage*)LObj)) { // rotate the image TImage * LImage = dynamic_cast<TImage*>(LObj->GetObject()); if (EventInfo.Flags.Contains(TInteractiveGestureFlag::gfBegin)) { FLastAngle = LImage->RotationAngle; } else if (EventInfo.Angle != 0) { LImage->RotationAngle = FLastAngle - (EventInfo.Angle * 180) / M_PI; } } } }
void IGraphics::OnMouseDown(int x, int y, IMouseMod* pMod) { ReleaseMouseCapture(); int c = GetMouseControlIdx(x, y); if (c >= 0) { mMouseCapture = c; mMouseX = x; mMouseY = y; IControl* pControl = mControls.Get(c); pControl->OnMouseDown(x, y, pMod); int paramIdx = pControl->ParamIdx(); if (paramIdx >= 0) { mPlug->BeginInformHostOfParamChange(paramIdx); } } }
void IGraphics::OnMouseUp(int x, int y, IMouseMod* pMod) { int c = GetMouseControlIdx(x, y); mMouseCapture = mMouseX = mMouseY = -1; if (c >= 0) { IControl* pControl = mControls.Get(c); pControl->OnMouseUp(x, y, pMod); pControl = mControls.Get(c); // needed if the mouse message caused a resize/rebuild int paramIdx = pControl->ParamIdx(); if ((paramIdx >= 0) && (paramIdx < mPlug->NParams())) { mPlug->EndInformHostOfParamChange(paramIdx); } } }
void IGraphics::SetParameterFromPlug(int paramIdx, double value, bool normalized) { if (!normalized) { IParam* pParam = mPlug->GetParam(paramIdx); value = pParam->GetNormalized(value); } int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->ParamIdx() == paramIdx) { //WDL_MutexLock lock(&mMutex); pControl->SetValueFromPlug(value); // Could be more than one, don't break until we check them all. } } }
void IGraphics::ClampControl(int paramIdx, double lo, double hi, bool normalized) { if (!normalized) { IParam* pParam = mPlug->GetParam(paramIdx); lo = pParam->GetNormalized(lo); hi = pParam->GetNormalized(hi); } int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->ParamIdx() == paramIdx) { pControl->Clamp(lo, hi); } // Could be more than one, don't break until we check them all. } }
void CEQDisplay::SetSize(const SSize& Size, tbool bRedraw) { CPane::SetSize(Size, bRedraw); if (mpfBufferCurveBand) { delete[] mpfBufferCurveBand; } mpfBufferCurveBand = new tfloat32[GetSize().iCX]; if (mpfBufferCurveTotal) { delete[] mpfBufferCurveTotal; } mpfBufferCurveTotal = new tfloat32[GetSize().iCX]; std::list<IControl*>::iterator it = mControls.begin(); for (; it != mControls.end(); it++) { IControl* pControl = *it; pControl->SetSize(GetSize() + SSize(miDotOffsetX * 2, miDotOffsetY * 2)); } }
bool IGraphics::OnMouseDblClick(int x, int y, IMouseMod* pMod) { ReleaseMouseCapture(); bool newCapture = false; int c = GetMouseControlIdx(x, y); if (c >= 0) { IControl* pControl = mControls.Get(c); if (pControl->MouseDblAsSingleClick()) { mMouseCapture = c; mMouseX = x; mMouseY = y; pControl->OnMouseDown(x, y, pMod); newCapture = true; } else { pControl->OnMouseDblClick(x, y, pMod); } } return newCapture; }
//--------------------------------------------------------------------------- void __fastcall TPinchZoom::FormGesture(TObject *Sender, const TGestureEventInfo &EventInfo, bool &Handled) { if (EventInfo.GestureID == static_cast<short>(igiZoom)) { IControl *LObj = this->ObjectAtPoint(ClientToScreen(EventInfo.Location)); if (static_cast<TImage*>((TImage*)LObj)) { if (!EventInfo.Flags.Contains(TInteractiveGestureFlag::gfBegin) && !EventInfo.Flags.Contains(TInteractiveGestureFlag::gfEnd)) { // zoom the image TImage * LImage = dynamic_cast<TImage*>(LObj->GetObject()); TPointF LImageCenter = LImage->Position->Point + PointF(LImage->Width / 2, LImage->Height / 2); LImage->Width = LImage->Width + (EventInfo.Distance - FLastDistance); LImage->Height = LImage->Height + (EventInfo.Distance - FLastDistance); LImage->Position->X = LImageCenter.X - LImage->Width / 2; LImage->Position->Y = LImageCenter.Y - LImage->Height / 2; } FLastDistance = EventInfo.Distance; } } }
int IGraphics::GetMouseControlIdx(int x, int y, bool mo) { if (mMouseCapture >= 0) { return mMouseCapture; } bool allow; // this is so that mouseovers can still be called when a control is greyed out // The BG is a control and will catch everything, so assume the programmer // attached the controls from back to front, and return the frontmost match. int i = mControls.GetSize() - 1; IControl** ppControl = mControls.GetList() + i; for (/* */; i >= 0; --i, --ppControl) { IControl* pControl = *ppControl; if (mo) { if (pControl->GetMOWhenGrayed()) allow = true; else allow = !pControl->IsGrayed(); } else { allow = !pControl->IsGrayed(); } if (!pControl->IsHidden() && allow && pControl->IsHit(x, y)) { return i; } } return -1; }
void IControl::setFocus(IControl & control) { if (focus != NULL) { focus->SetForeground(ForegroundColor::White); focus->SetBackground(BackgroundColor::Black); focus->Show(); } if (control.getType() == "TextBox") { control._graphics.setCursorVisibility(true); } else control._graphics.setCursorVisibility(false); //control._graphics.resetColor(); focus = &control; focus->invertColors(); focus->Show(); /*if (focus->getType() == "textbox") focus->_graphics.moveTo(focus->getLeft() + focus->GetValue().size(), focus->getTop() + 1); else focus->_graphics.moveTo(focus->getLeft() + 1, focus->getTop() + 1);*/ }