diff options
| author | pepper <pepper@chimecrisis.com> | 2015-01-31 21:41:28 -0800 |
|---|---|---|
| committer | pepper <pepper@chimecrisis.com> | 2015-01-31 21:41:28 -0800 |
| commit | 97587996ee9db30ce00190bdcedd8210490b99f5 (patch) | |
| tree | d8554969ac496be3a1b02a159f2a4b5b79f9492e /vstgui.sf/drawtest/source | |
backup vst 2.4
Diffstat (limited to 'vstgui.sf/drawtest/source')
| -rw-r--r-- | vstgui.sf/drawtest/source/controlsgui.cpp | 541 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/controlsgui.h | 51 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtesteditor.cpp | 266 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtesteditor.h | 48 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtesteffect.cpp | 177 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtesteffect.h | 38 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtestmain.cpp | 78 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtestview.cpp | 299 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pdrawtestview.h | 44 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pprimitivesviews.cpp | 245 | ||||
| -rw-r--r-- | vstgui.sf/drawtest/source/pprimitivesviews.h | 37 |
11 files changed, 1824 insertions, 0 deletions
diff --git a/vstgui.sf/drawtest/source/controlsgui.cpp b/vstgui.sf/drawtest/source/controlsgui.cpp new file mode 100644 index 0000000..0e5b76e --- /dev/null +++ b/vstgui.sf/drawtest/source/controlsgui.cpp @@ -0,0 +1,541 @@ +#ifndef __controlsgui__ +#include "controlsgui.h" +#endif + +#include "cfileselector.h" + +#include <stdio.h> + +enum +{ + // bitmaps + kBackgroundBitmap = 10001, + + kSliderHBgBitmap, + kSliderVBgBitmap, + kSliderHandleBitmap, + + kSwitchHBitmap, + kSwitchVBitmap, + + kOnOffBitmap, + + kKnobHandleBitmap, + kKnobBgBitmap, + + kDigitBitmap, + kRockerBitmap, + + kVuOnBitmap, + kVuOffBitmap, + + kSplashBitmap, + + kMovieKnobBitmap, + + kMovieBitmap, + + // others + kBackgroundW = 420, + kBackgroundH = 210 +}; +//----------------------------------------------------------------------------- +// CLabel declaration +//----------------------------------------------------------------------------- +class CLabel : public CParamDisplay +{ +public: + CLabel (CRect &size, char *text); + + void draw (CDrawContext *pContext); + + void setLabel (char *text); + virtual bool onDrop (CDrawContext* context, CDragContainer* drag, const CPoint& where); + virtual void onDragEnter (CDrawContext* context, CDragContainer* drag, const CPoint& where); + virtual void onDragLeave (CDrawContext* context, CDragContainer* drag, const CPoint& where); + virtual void onDragMove (CDrawContext* context, CDragContainer* drag, const CPoint& where); + +protected: + char label[256]; + bool focus; +}; + +//----------------------------------------------------------------------------- +// CLabel implementation +//----------------------------------------------------------------------------- +CLabel::CLabel (CRect &size, char *text) +: CParamDisplay (size) +, focus (false) +{ + strcpy (label, ""); + setLabel (text); +} + +//------------------------------------------------------------------------ +void CLabel::setLabel (char *text) +{ + if (text) + strcpy (label, text); + setDirty (); +} + +bool CLabel::onDrop (CDrawContext* context, CDragContainer* drag, const CPoint& where) +{ + long size, type; + void* ptr = drag->first (size, type); + if (ptr) + { + setLabel ((char*)ptr); + } + return true; +} + +void CLabel::onDragEnter (CDrawContext* context, CDragContainer* drag, const CPoint& where) +{ + getFrame ()->setCursor (kCursorCopy); + focus = true; + setDirty (); +} + +void CLabel::onDragLeave (CDrawContext* context, CDragContainer* drag, const CPoint& where) +{ + getFrame ()->setCursor (kCursorNotAllowed); + focus = false; + setDirty (); +} + +void CLabel::onDragMove (CDrawContext* context, CDragContainer* drag, const CPoint& where) +{ +} + +//------------------------------------------------------------------------ +void CLabel::draw (CDrawContext *pContext) +{ + pContext->setFillColor (backColor); + pContext->fillRect (size); + pContext->setLineWidth (focus ? 2 : 1); + pContext->setFrameColor (fontColor); + pContext->drawRect (size); + + pContext->setFont (fontID); + pContext->setFontColor (fontColor); + pContext->drawString (label, size, false, kCenterText); + setDirty (false); +} + +enum +{ + kSliderHTag = 0, + kSliderVTag, + kKnobTag, + + kNumParams, + + kOnOffTag, + kKickTag, + kMovieButtonTag, + kAutoAnimationTag, + kOptionMenuTag, + + kRockerSwitchTag, + kSwitchHTag, + kSwitchVTag, + + kSplashTag, + kMovieBitmapTag, + kAnimKnobTag, + kDigitTag, + kTextEditTag, + + kAbout +}; + +ControlsGUI::ControlsGUI (const CRect &inSize, CFrame *frame, CBitmap *pBackground) +: CViewContainer (inSize, frame, pBackground) +{ + setMode (kOnlyDirtyUpdate); + + // get version + int version = (VSTGUI_VERSION_MAJOR << 16) + VSTGUI_VERSION_MINOR; + int verMaj = (version & 0xFF00) >> 16; + int verMin = (version & 0x00FF); + + // init the background bitmap + CBitmap *background = new CBitmap (kBackgroundBitmap); + + setBackground (background); + + background->forget (); + + CPoint point (0, 0); + + //--COnOffButton----------------------------------------------- + CBitmap *onOffButton = new CBitmap (kOnOffBitmap); + + CRect size (0, 0, onOffButton->getWidth (), onOffButton->getHeight () / 2); + size.offset (20, 20); + cOnOffButton = new COnOffButton (size, this, kOnOffTag, onOffButton); + addView (cOnOffButton); + + + //--CKickButton----------------------------------------------- + size.offset (70, 0); + point (0, 0); + cKickButton = new CKickButton (size, this, kKickTag, onOffButton->getHeight() / 2, onOffButton, point); + addView (cKickButton); + + + //--CKnob-------------------------------------- + CBitmap *knob = new CBitmap (kKnobHandleBitmap); + CBitmap *bgKnob = new CBitmap (kKnobBgBitmap); + + size (0, 0, bgKnob->getWidth (), bgKnob->getHeight ()); + size.offset (140 + 15, 15); + point (0, 0); + cKnob = new CKnob (size, this, kKnobTag, bgKnob, knob, point); + cKnob->setInsetValue (7); + addView (cKnob); + knob->forget (); + bgKnob->forget (); + + + //--CMovieButton-------------------------------------- + size (0, 0, onOffButton->getWidth (), onOffButton->getHeight () / 2); + size.offset (210 + 20, 20); + point (0, 0); + cMovieButton = new CMovieButton (size, this, kMovieButtonTag, onOffButton->getHeight () / 2, onOffButton, point); + addView (cMovieButton); + + onOffButton->forget (); + + + //--CAnimKnob-------------------------------------- + CBitmap *movieKnobBitmap = new CBitmap (kMovieKnobBitmap); + + size (0, 0, movieKnobBitmap->getWidth (), movieKnobBitmap->getHeight () / 7); + size.offset (280 + 15, 15); + point (0, 0); + cAnimKnob = new CAnimKnob (size, this, kAnimKnobTag, 7, movieKnobBitmap->getHeight () / 7, movieKnobBitmap, point); + addView (cAnimKnob); + + movieKnobBitmap->forget (); + + + //--COptionMenu-------------------------------------- + size (0, 0, 50, 14); + size.offset (350 + 10, 30); + + long style = k3DIn | kMultipleCheckStyle; + cOptionMenu = new COptionMenu (size, this, kOptionMenuTag, bgKnob, 0, style); + if (cOptionMenu) + { + cOptionMenu->setFont (kNormalFont); + cOptionMenu->setFontColor (kWhiteCColor); + cOptionMenu->setBackColor (kRedCColor); + cOptionMenu->setFrameColor (kWhiteCColor); + cOptionMenu->setHoriAlign (kLeftText); + int i; + for (i = 0; i < 3; i++) + { + char txt[256]; + sprintf (txt, "Entry %d", i); + cOptionMenu->addEntry (txt); + } + cOptionMenu->addEntry ("-"); + for (i = 3; i < 60; i++) + { + char txt[256]; + sprintf (txt, "Entry %d", i); + cOptionMenu->addEntry (txt); + } + + addView (cOptionMenu); + } + + + //--CRockerSwitch-------------------------------------- + CBitmap *rocker = new CBitmap (kRockerBitmap); + size (0, 0, rocker->getWidth (), rocker->getHeight () / 3); + size.offset (9, 70 + 29); + point (0, 0); + cRockerSwitch = new CRockerSwitch (size, this, kRockerSwitchTag, rocker->getHeight () / 3, rocker, point); + addView (cRockerSwitch); + rocker->forget (); + + + //--CHorizontalSwitch-------------------------------------- + CBitmap *switchHBitmap = new CBitmap (kSwitchHBitmap); + size (0, 0, switchHBitmap->getWidth (), switchHBitmap->getHeight () / 4); + size.offset (70 + 10, 70 + 30); + point (0, 0); + cHorizontalSwitch = new CHorizontalSwitch (size, this, kSwitchHTag, 4, switchHBitmap->getHeight () / 4, 4, switchHBitmap, point); + addView (cHorizontalSwitch); + switchHBitmap->forget (); + + + //--CVerticalSwitch-------------------------------------- + CBitmap *switchVBitmap = new CBitmap (kSwitchVBitmap); + + size (0, 0, switchVBitmap->getWidth (), switchVBitmap->getHeight () / 4); + size.offset (140 + 30, 70 + 5); + cVerticalSwitch = new CVerticalSwitch (size, this, kSwitchVTag, 4, switchVBitmap->getHeight () / 4, 4, switchVBitmap, point); + addView (cVerticalSwitch); + switchVBitmap->forget (); + + + //--CHorizontalSlider-------------------------------------- + CBitmap *sliderHBgBitmap = new CBitmap (kSliderHBgBitmap); + CBitmap *sliderHandleBitmap = new CBitmap (kSliderHandleBitmap); + + size (0, 0, sliderHBgBitmap->getWidth (), sliderHBgBitmap->getHeight ()); + size.offset (10, 30); + + point (0, 0); +#if 1 + cHorizontalSlider = new CHorizontalSlider (size, this, kSliderHTag, size.left + 2, size.left + sliderHBgBitmap->getWidth () - sliderHandleBitmap->getWidth () - 1, sliderHandleBitmap, sliderHBgBitmap, point, kLeft); + point (0, 2); + cHorizontalSlider->setOffsetHandle (point); +#else + CPoint handleOffset (2, 2); + cHorizontalSlider = new CHorizontalSlider (size, this, kSliderHTag, handleOffset, size.width () - 2 * handleOffset.h, sliderHandleBitmap, sliderHBgBitmap, point, kLeft); +#endif + cHorizontalSlider->setFreeClick (false); + size.offset (0, -30 + 10); + + style = k3DIn | kCheckStyle; + COptionMenu *cOptionMenu2 = new COptionMenu (size, this, kOptionMenuTag, bgKnob, 0, style); + if (cOptionMenu2) + { + cOptionMenu2->setFont (kNormalFont); + cOptionMenu2->setFontColor (kWhiteCColor); + cOptionMenu2->setBackColor (kRedCColor); + cOptionMenu2->setFrameColor (kWhiteCColor); + cOptionMenu2->setHoriAlign (kLeftText); + int i; + for (i = 0; i < 3; i++) + { + char txt[256]; + sprintf (txt, "Entry %d", i); + cOptionMenu2->addEntry (txt); + } + } + + // add this 2 control in a CViewContainer + size (0, 0, 70, 45); + size.offset (210, 70); + cViewContainer = new CViewContainer (size, frame, background); + cViewContainer->addView (cHorizontalSlider); + cViewContainer->addView (cOptionMenu2); + addView (cViewContainer); + + sliderHBgBitmap->forget (); + + + //--CVerticalSlider-------------------------------------- + CBitmap *sliderVBgBitmap = new CBitmap (kSliderVBgBitmap); + + size (0, 0, sliderVBgBitmap->getWidth (), sliderVBgBitmap->getHeight ()); + size.offset (280 + 30, 70 + 5); +#if 1 + point (0, 0); + cVerticalSlider = new CVerticalSlider (size, this, kSliderVTag, size.top + 2, size.top + sliderVBgBitmap->getHeight () - sliderHandleBitmap->getHeight () - 1, sliderHandleBitmap, sliderVBgBitmap, point, kBottom); + point (2, 0); + cVerticalSlider->setOffsetHandle (point); +#else + point (0, 0); + CPoint handleOffset (2, 2); + cVerticalSlider = new CVerticalSlider (size, this, kSliderVTag, handleOffset, + size.height () - 2 * handleOffset.v, sliderHandleBitmap, sliderVBgBitmap, point, kBottom); +#endif + cVerticalSlider->setFreeClick (false); + addView (cVerticalSlider); + + sliderVBgBitmap->forget (); + sliderHandleBitmap->forget (); + + + //--CTextEdit-------------------------------------- + size (0, 0, 50, 12); + size.offset (350 + 10, 70 + 30); + cTextEdit = new CTextEdit (size, this, kTextEditTag, 0, 0, k3DIn); + if (cTextEdit) + { + cTextEdit->setFont (kNormalFontVerySmall); + cTextEdit->setFontColor (kWhiteCColor); + cTextEdit->setBackColor (kBlackCColor); + cTextEdit->setFrameColor (kWhiteCColor); + cTextEdit->setHoriAlign (kCenterText); + addView (cTextEdit); + } + + //--CSplashScreen-------------------------------------- + CBitmap *splashBitmap = new CBitmap (kSplashBitmap); + + size (0, 0, 70, 70); + size.offset (0, 140); + point (0, 0); + CRect toDisplay (0, 0, splashBitmap->getWidth (), splashBitmap->getHeight ()); + toDisplay.offset (100, 50); + + cSplashScreen = new CSplashScreen (size, this, kAbout, splashBitmap, toDisplay, point); + addView (cSplashScreen); + splashBitmap->forget (); + + + //--CMovieBitmap-------------------------------------- + CBitmap *movieBitmap = new CBitmap (kMovieBitmap); + + size (0, 0, movieBitmap->getWidth (), movieBitmap->getHeight () / 10); + size.offset (70 + 15, 140 + 15); + point (0, 0); + cMovieBitmap = new CMovieBitmap (size, this, kMovieBitmapTag, 10, movieBitmap->getHeight () / 10, movieBitmap, point); + addView (cMovieBitmap); + + + //--CAutoAnimation-------------------------------------- + size (0, 0, movieBitmap->getWidth (), movieBitmap->getHeight () / 10); + size.offset (140 + 15, 140 + 15); + point (0, 0); + cAutoAnimation = new CAutoAnimation (size, this, kAutoAnimationTag, 10, movieBitmap->getHeight () / 10, movieBitmap, point); + addView (cAutoAnimation); + movieBitmap->forget (); + + + //--CSpecialDigit-------------------------------------- + CBitmap *specialDigitBitmap = new CBitmap (kDigitBitmap); + + size (0, 0, specialDigitBitmap->getWidth () * 7, specialDigitBitmap->getHeight () / 10); + size.offset (210 + 10, 140 + 30); + + cSpecialDigit = new CSpecialDigit (size, this, kDigitTag, 0, 7, 0, 0, specialDigitBitmap->getWidth (), specialDigitBitmap->getHeight () / 10 , specialDigitBitmap); + addView (cSpecialDigit); + specialDigitBitmap->forget (); + + + //--CParamDisplay-------------------------------------- + size (0, 0, 50, 15); + size.offset (280 + 10, 140 + 30); + cParamDisplay = new CParamDisplay (size); + if (cParamDisplay) + { + cParamDisplay->setFont (kNormalFontSmall); + cParamDisplay->setFontColor (kWhiteCColor); + cParamDisplay->setBackColor (kBlackCColor); + addView (cParamDisplay); + } + + + //--CVuMeter-------------------------------------- + CBitmap* vuOnBitmap = new CBitmap (kVuOnBitmap); + CBitmap* vuOffBitmap = new CBitmap (kVuOffBitmap); + + size (0, 0, vuOnBitmap->getWidth (), vuOnBitmap->getHeight ()); + size.offset (350 + 30, 140 + 5); + cVuMeter = new CVuMeter (size, vuOnBitmap, vuOffBitmap, 14); + cVuMeter->setDecreaseStepValue (0.1f); + addView (cVuMeter); + vuOnBitmap->forget (); + vuOffBitmap->forget (); + + //--My controls--------------------------------- + //--CLabel-------------------------------------- + size (0, 0, 349, 14); + size.offset (0, 140); + cLabel = new CLabel (size, "Type a Key or Drop a file..."); + if (cLabel) + { + cLabel->setFont (kNormalFontSmall); + cLabel->setFontColor (kWhiteCColor); + cLabel->setBackColor (kGreyCColor); + addView (cLabel); + } + + //--CLabel-------------------------------------- + size (0, 0, 65, 12); + size.offset (1, 40); + CLabel *cLabel2 = new CLabel (size, "FileSelector"); + if (cLabel2) + { + cLabel2->setFont (kNormalFontSmaller); + cLabel2->setFontColor (kWhiteCColor); + cLabel2->setBackColor (kGreyCColor); + addView (cLabel2); + } + + size (inSize.right, inSize.bottom, inSize.right + 100, inSize.bottom + 100); + CLabel* outsideLabel = new CLabel (size, "This label is outside its superview"); + addView (outsideLabel); + outsideLabel->setDirty (true); +} + +void ControlsGUI::valueChanged (CDrawContext *pContext, CControl *pControl) +{ + // this is only to provide the same behaviour as the original controlsgui editor class in the vst sdk 2.3 + // do not take this as an example on how to code !!! + + float value = pControl->getValue (); + switch (pControl->getTag ()) + { + case kSliderVTag: + case kSliderHTag: + case kKnobTag: + case kAnimKnobTag: + { + cHorizontalSlider->setValue (value); + cVerticalSlider->setValue (value); + cKnob->setValue (value); + cAnimKnob->setValue (value); + cSpecialDigit->setValue (1000000 * value); + cParamDisplay->setValue (value); + cVuMeter->setValue (value); + cMovieBitmap->setValue (value); + break; + } + + case kOnOffTag: + { + if (value > 0.5f) + { + VstFileType aiffType ("AIFF File", "AIFF", "aif", "aiff", "audio/aiff", "audio/x-aiff"); + VstFileType aifcType ("AIFC File", "AIFC", "aif", "aifc", "audio/x-aifc"); + VstFileType waveType ("Wave File", "WAVE", "wav", "wav", "audio/wav", "audio/x-wav"); + VstFileType sdIIType ("SoundDesigner II File", "Sd2f", "sd2", "sd2"); + VstFileType types[] = {aiffType, aifcType, waveType, sdIIType}; + + VstFileSelect vstFileSelect; + memset (&vstFileSelect, 0, sizeof (VstFileSelect)); + + vstFileSelect.command = kVstFileLoad; + vstFileSelect.type = kVstFileType; + strcpy (vstFileSelect.title, "Test for open file selector"); + vstFileSelect.nbFileTypes = 4; + vstFileSelect.fileTypes = (VstFileType*)&types; + vstFileSelect.returnPath = new char[1024]; + vstFileSelect.initialPath = 0; + vstFileSelect.future[0] = 1; // utf-8 path on macosx + CFileSelector selector (NULL); + if (selector.run (&vstFileSelect)) + { + if (cLabel) + cLabel->setLabel (vstFileSelect.returnPath); + } + else + { + if (cLabel) + cLabel->setLabel ("OpenFileSelector: canceled!!!!"); + } + delete []vstFileSelect.returnPath; + if (vstFileSelect.initialPath) + delete []vstFileSelect.initialPath; + } + break; + } + } +} + +void ControlsGUI::onIdle () +{ + // trigger animation + if(cAutoAnimation) + cAutoAnimation->nextPixmap (); +}
\ No newline at end of file diff --git a/vstgui.sf/drawtest/source/controlsgui.h b/vstgui.sf/drawtest/source/controlsgui.h new file mode 100644 index 0000000..dae8bdc --- /dev/null +++ b/vstgui.sf/drawtest/source/controlsgui.h @@ -0,0 +1,51 @@ +#ifndef __controlsgui__ +#define __controlsgui__ + +#ifndef __vstcontrols__ +#include "vstcontrols.h" +#endif + +class CLabel; + +class ControlsGUI : public CViewContainer, CControlListener +{ +public: + ControlsGUI (const CRect &size, CFrame *pParent, CBitmap *pBackground = 0); + + virtual void onIdle (); + + virtual void valueChanged (CDrawContext *pContext, CControl *pControl); + +protected: + + COnOffButton *cOnOffButton; + CKickButton *cKickButton; + CKnob *cKnob; + CMovieButton *cMovieButton; + CAnimKnob *cAnimKnob; + COptionMenu *cOptionMenu; + + CRockerSwitch *cRockerSwitch; + CHorizontalSwitch *cHorizontalSwitch; + CVerticalSwitch *cVerticalSwitch; + CHorizontalSlider *cHorizontalSlider; + CHorizontalSlider *cHorizontalSlider2; + CVerticalSlider *cVerticalSlider; + CTextEdit *cTextEdit; + + CSplashScreen *cSplashScreen; + CMovieBitmap *cMovieBitmap; + CAutoAnimation *cAutoAnimation; + CSpecialDigit *cSpecialDigit; + CParamDisplay *cParamDisplay; + CVuMeter *cVuMeter; + + CViewContainer *cViewContainer; + + // others + CLabel *cLabel; + + long oldTicks; +}; + +#endif diff --git a/vstgui.sf/drawtest/source/pdrawtesteditor.cpp b/vstgui.sf/drawtest/source/pdrawtesteditor.cpp new file mode 100644 index 0000000..7e7f3af --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtesteditor.cpp @@ -0,0 +1,266 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#include "pdrawtesteditor.h" +#include "pdrawtestview.h" +#include "cscrollview.h" +#include "ctabview.h" +#include "controlsgui.h" +#include "pprimitivesviews.h" + +enum { + kBackgroundBitmap = 1, + kTabButtonBitmap = 100, + kTestBitmap = 1000, +}; + +class MyTabView : public CTabView +{ +public: + MyTabView (const CRect& size, CFrame* parent, CBitmap* tabBitmap, CBitmap* background = 0, long tabPosition = kPositionTop, DrawTestEditor* editor = 0) + : CTabView (size, parent, tabBitmap, background, tabPosition) + , editor (editor) {} + + virtual void mouse (CDrawContext *pContext, CPoint &where, long button = -1) + { + if (button == kRButton) + { + CView* view = getViewAt (where); + if (!view || view->isTypeOf ("CTabButton")) + { + CRect r; + localToFrame (where); + r.offset (where.x, where.y); + r.offset (-size.left, -size.top); + COptionMenu* menu = new COptionMenu (r, NULL, 0); + menu->addEntry ("Tabs Left"); + menu->addEntry ("Tabs Right"); + menu->addEntry ("Tabs Top"); + menu->addEntry ("Tabs Bottom"); + menu->addEntry ("-"); + menu->addEntry ("Align Tabs Centered"); + menu->addEntry ("Align Tabs Left/Top"); + menu->addEntry ("Align Tabs Right/Bottom"); + getFrame ()->addView (menu); + menu->takeFocus (); + long res = menu->getLastResult (); + getFrame ()->removeView (menu); + if (res != -1) + { + if (res < 4) + { + r = size; + editor->setTabView (getFrame (), r, res); + } + else + { + alignTabs (kAlignCenter + res - 5); + } + } + return; + } + } + CTabView::mouse (pContext, where, button); + } + + virtual bool selectTab (long index) + { + bool result = CTabView::selectTab (index); + #if DEBUG + getFrame ()->dumpHierarchy (); + #endif + return result; + } + +protected: + DrawTestEditor* editor; +}; + +class MyColoredView : public CView +{ +public: + MyColoredView (const CRect& size) : CView (size) {} + + void draw (CDrawContext* context) + { + context->setFillColor (backgroundColor); + context->setFrameColor (kBlackCColor); + context->drawRect (size, kDrawFilledAndStroked); + setDirty (false); + } + + void setBackgroundColor (const CColor& c) { backgroundColor = c; } + +protected: + CColor backgroundColor; +}; + +DrawTestEditor::DrawTestEditor (void* effect) +#if AU +: AEffGUIEditor (effect) +#else +: AEffGUIEditor ((AudioEffect*)effect) +#endif +, controlsView (0) +{ + backgroundBitmap = new CBitmap (kBackgroundBitmap); + // setup size of editor + rect.left = 0; + rect.top = 0; + #if AU + rect.right = (short)backgroundBitmap->getWidth (); + rect.bottom = (short)backgroundBitmap->getHeight (); + #else + rect.right = (VstInt16)backgroundBitmap->getWidth (); + rect.bottom = (VstInt16)backgroundBitmap->getHeight (); + #endif +} + +DrawTestEditor::~DrawTestEditor () +{ + backgroundBitmap->forget (); +} + +void DrawTestEditor::valueChanged (CDrawContext *pContext, CControl *pControl) +{ +} + +void DrawTestEditor::setTabView (CFrame* frame, const CRect& r, long position) +{ + frame->removeAll (); + CBitmap* tabButtonBitmap = new CBitmap (kTabButtonBitmap); + CTabView* tabView = new MyTabView (r, frame, tabButtonBitmap, NULL, position, this); + tabView->setTransparency (true); + frame->addView (tabView); + CRect tabSize = tabView->getTabViewSize (tabSize); +// tabSize.inset (1, 1); + // add tabs + CView* testView; + CBitmap* testBitmap = new CBitmap (kTestBitmap); + CRect containerSize; + containerSize.right = testBitmap->getWidth (); + containerSize.bottom = testBitmap->getHeight (); + // the first tab is a scroll view with a movie bitmap + CScrollView* scrollview = new CScrollView (tabSize, containerSize, frame, CScrollView::kHorizontalScrollbar|CScrollView::kVerticalScrollbar); + CPoint p (0,0); + testView = new CMovieBitmap (containerSize, NULL, 0, 1, testBitmap->getHeight (), testBitmap, p); + testBitmap->forget (); + scrollview->addView (testView); + tabView->addTab (scrollview, "Scroll View"); + + // the second tab is a draw primitives view +// testView = new CDrawTestView (tabSize); +// tabView->addTab (testView, "Primitives"); + testView = new PLinesView (tabSize); + tabView->addTab (testView, "Lines"); + + testView = new PRectsView (tabSize); + tabView->addTab (testView, "Rects"); + + testView = new PMiscView (tabSize); + tabView->addTab (testView, "Misc"); + + // the third tab is the old controlsgui view embeded into a container view + CRect controlsGUISize (0, 0, 420, 210); + controlsGUISize.offset (5, 5); + testView = controlsView = new ControlsGUI (controlsGUISize, frame); + + CViewContainer* controlContainer = new CViewContainer (tabSize, frame); + controlContainer->setTransparency (true); + controlContainer->addView (testView); + + tabView->addTab (controlContainer, "Controls"); + + CColor redColor = {255, 0, 0, 150}; + CColor greenColor = {0, 255, 0, 150}; + CColor blueColor = {0, 0, 255, 150}; + + CViewContainer* clipView = new CViewContainer (tabSize, frame); + clipView->setTransparency (true); + CRect clipViewSize (0, 0, tabSize.getWidth () / 4, tabSize.getHeight () / 2); + MyColoredView* cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (redColor); + clipView->addView (cv); + clipViewSize.offset (clipViewSize.getWidth (), 0); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (greenColor); + clipView->addView (cv); + clipViewSize.offset (clipViewSize.getWidth (), 0); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (blueColor); + clipView->addView (cv); + clipViewSize.offset (clipViewSize.getWidth (), 0); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (redColor); + clipView->addView (cv); + clipViewSize (0, tabSize.getHeight () / 2, tabSize.getWidth () / 4, tabSize.getHeight ()); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (greenColor); + clipView->addView (cv); + clipViewSize.offset (clipViewSize.getWidth (), 0); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (blueColor); + clipView->addView (cv); + clipViewSize.offset (clipViewSize.getWidth (), 0); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (redColor); + clipView->addView (cv); + clipViewSize.offset (clipViewSize.getWidth (), 0); + cv = new MyColoredView (clipViewSize); + cv->setBackgroundColor (greenColor); + clipView->addView (cv); + + tabView->addTab (clipView, "Clip Test"); + tabView->alignTabs (CTabView::kAlignCenter); + + tabButtonBitmap->forget (); + frame->setDirty (); +} + +bool DrawTestEditor::open (void *ptr) +{ + AEffGUIEditor::open (ptr); + CRect size (rect.left , rect.top, rect.right, rect.bottom); + CFrame* frame = new CFrame (size, ptr, this); + frame->setBackground (backgroundBitmap); + size.inset (8, 8); + size.top++; // the background bitmap is not correct + size.left++; // the background bitmap is not correct + setTabView (frame, size, CTabView::kPositionBottom); + // last but not least set the class variable frame to our newly created frame + this->frame = frame; + return true; +} + +void DrawTestEditor::close () +{ + // don't forget to remove the frame !! + if (frame) + delete frame; + frame = 0; + controlsView = 0; +} + +void DrawTestEditor::idle () +{ + AEffGUIEditor::idle (); + + if(controlsView) + controlsView->onIdle (); +}
\ No newline at end of file diff --git a/vstgui.sf/drawtest/source/pdrawtesteditor.h b/vstgui.sf/drawtest/source/pdrawtesteditor.h new file mode 100644 index 0000000..8c20a82 --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtesteditor.h @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#ifndef __pdrawtesteditor__ +#define __pdrawtesteditor__ + +#ifndef __vstcontrols__ +#include "vstcontrols.h" +#endif + +class ControlsGUI; + +class DrawTestEditor : public AEffGUIEditor, CControlListener +{ +public: + DrawTestEditor (void* effect); + virtual ~DrawTestEditor (); + + void setTabView (CFrame* frame, const CRect& r, long position); + + virtual void valueChanged (CDrawContext *pContext, CControl *pControl); + +protected: + virtual bool open (void *ptr); + virtual void close (); + virtual void idle (); + + CBitmap* backgroundBitmap; + ControlsGUI* controlsView; +}; + +#endif diff --git a/vstgui.sf/drawtest/source/pdrawtesteffect.cpp b/vstgui.sf/drawtest/source/pdrawtesteffect.cpp new file mode 100644 index 0000000..7db11fa --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtesteffect.cpp @@ -0,0 +1,177 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#if AU +#include "AUEffectBase.h" +#include "pdrawtesteditor.h" + +#define kComponentSubType 'vgdt' +#define kComponentManuf 'Xxxx' +#define kVersionNumber 0x00010000 + +class DrawTestAU : public AUEffectBase +{ +public: + DrawTestAU (AudioUnit au) + : AUEffectBase (au) + { + // editor = new DrawTestEditor (this); + } + + virtual ~DrawTestAU () + { + //if (editor) + //delete editor; + } + + virtual int GetNumCustomUIComponents () + { + return 1; + } + + virtual ComponentResult Version () { return kVersionNumber; } + + virtual void GetUIComponentDescs (ComponentDescription* inDescArray) + { + inDescArray[0].componentType = kAudioUnitCarbonViewComponentType; + inDescArray[0].componentSubType = kComponentSubType; + inDescArray[0].componentManufacturer = kComponentManuf; + inDescArray[0].componentFlags = 0; + inDescArray[0].componentFlagsMask = 0; + } + +/* ComponentResult GetPropertyInfo (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32 &outDataSize, Boolean &outWritable) + { + if (inID == 64000) + { + if (editor) + { + outDataSize = sizeof (PluginGUIEditor*); + outWritable = false; + return noErr; + } + return kAudioUnitErr_InvalidProperty; + } + return AUEffectBase::GetPropertyInfo (inID, inScope, inElement, outDataSize, outWritable); + } + + ComponentResult GetProperty (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void *outData) + { + if (inID == 64000) + { + if (editor) + { + long ptr = (long)editor; + *((long*)outData) = ptr; + return noErr; + } + else + *((long*)outData) = 0; + return kAudioUnitErr_InvalidProperty; + } + return AUEffectBase::GetProperty (inID, inScope, inElement, outData); + } +*/ +protected: + DrawTestEditor* editor; +}; + + +#include "AUCarbonViewBase.h" +#include "plugguieditor.h" + +class VSTGUIAUView : public AUCarbonViewBase +{ +public: + VSTGUIAUView (AudioUnitCarbonView auv) + : AUCarbonViewBase (auv) + , editor (0) + , xOffset (0) + , yOffset (0) + { + } + + virtual ~VSTGUIAUView () + { + if (editor) + { + editor->close (); + } + } + + void RespondToEventTimer (EventLoopTimerRef inTimer) + { + if (editor) + editor->doIdleStuff (); + } + + virtual OSStatus CreateUI(Float32 xoffset, Float32 yoffset) + { + AudioUnit unit = GetEditAudioUnit (); + if (unit) + { + editor = new DrawTestEditor (unit); + WindowRef window = GetCarbonWindow (); + editor->open (window); +// HIViewMoveBy ((HIViewRef)editor->getFrame ()->getPlatformControl (), xoffset, yoffset); + EmbedControl ((HIViewRef)editor->getFrame ()->getPlatformControl ()); + CRect fsize = editor->getFrame ()->getViewSize (fsize); + SizeControl (mCarbonPane, fsize.width (), fsize.height ()); + CreateEventLoopTimer (kEventDurationSecond, kEventDurationSecond / 24); + HIViewSetVisible ((HIViewRef)editor->getFrame ()->getPlatformControl (), true); + HIViewSetNeedsDisplay ((HIViewRef)editor->getFrame ()->getPlatformControl (), true); + } + return noErr; + } + + Float32 xOffset, yOffset; +protected: + PluginGUIEditor* editor; +}; + +COMPONENT_ENTRY(VSTGUIAUView); +COMPONENT_ENTRY(DrawTestAU); + + +#else +#include "pdrawtesteffect.h" +#include "pdrawtesteditor.h" + +DrawTestEffect::DrawTestEffect (audioMasterCallback audioMaster) +: AudioEffectX (audioMaster, 1, 0) +{ + editor = new DrawTestEditor (this); +} + +DrawTestEffect::~DrawTestEffect () +{ +} + +void DrawTestEffect::processReplacing (float **inputs, float **outputs, VstInt32 sampleFrames) +{ +} + +VstInt32 DrawTestEffect::canDo (char* text) +{ + if (!strcmp (text, "wantsUTF8Paths")) + return 1; + return 0; +} + +#endif diff --git a/vstgui.sf/drawtest/source/pdrawtesteffect.h b/vstgui.sf/drawtest/source/pdrawtesteffect.h new file mode 100644 index 0000000..9e73589 --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtesteffect.h @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#ifndef __pdrawtesteffect__ +#define __pdrawtesteffect__ + +#ifndef __audioeffectx__ +#include "audioeffectx.h" +#endif + +class DrawTestEffect : public AudioEffectX +{ +public: + DrawTestEffect (audioMasterCallback audioMaster); + ~DrawTestEffect (); + + virtual void processReplacing (float **inputs, float **outputs, VstInt32 sampleFrames); + + VstInt32 canDo (char* text); +}; + +#endif diff --git a/vstgui.sf/drawtest/source/pdrawtestmain.cpp b/vstgui.sf/drawtest/source/pdrawtestmain.cpp new file mode 100644 index 0000000..ada29d9 --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtestmain.cpp @@ -0,0 +1,78 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#include "pdrawtesteffect.h" + +bool oome = false; + +#if MAC +#pragma export on +#endif + +//------------------------------------------------------------------------ +// Prototype of the export function main +//------------------------------------------------------------------------ +#if BEOS +#define main main_plugin +extern "C" __declspec(dllexport) AEffect *main_plugin (audioMasterCallback audioMaster); + +#elif MACX +#define main main_macho +extern "C" AEffect *main_macho (audioMasterCallback audioMaster); + +#else +#define main VSTPluginMain +AEffect *main (audioMasterCallback audioMaster); +#endif + +//------------------------------------------------------------------------ +AEffect *main (audioMasterCallback audioMaster) +{ + // Get VST Version + if (!audioMaster (0, audioMasterVersion, 0, 0, 0, 0)) + return 0; // old version + + // Create the AudioEffect + DrawTestEffect* effect = new DrawTestEffect (audioMaster); + if (!effect) + return 0; + + // Check if no problem in constructor of AGain + if (oome) + { + delete effect; + return 0; + } + return effect->getAeffect (); +} + +#if MAC +#pragma export off +#endif + + +#if WIN32 +#include <windows.h> +void* hInstance; +BOOL WINAPI DllMain (HINSTANCE hInst, DWORD dwReason, LPVOID lpvReserved) +{ + hInstance = hInst; + return 1; +} +#endif diff --git a/vstgui.sf/drawtest/source/pdrawtestview.cpp b/vstgui.sf/drawtest/source/pdrawtestview.cpp new file mode 100644 index 0000000..914aeab --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtestview.cpp @@ -0,0 +1,299 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#ifndef __pdrawtestview__ +#include "pdrawtestview.h" +#endif + +#include <stdio.h> + +static long diffX, diffY; + +CDrawTestView::CDrawTestView (const CRect& size) +: CView (size) +, value (0) +{ + diffX = diffY = 0; +} + +static inline void testDrawRect (CDrawContext *pContext, CRect r, int _offset = 0) +{ + int offset = _offset ? _offset : pContext->getLineWidth (); + int i = 0; + while (r.width () > 1 && r.height () > 1) + { + if (i++ % 2) + pContext->setFrameColor (kBlackCColor); + else + pContext->setFrameColor (kRedCColor); + pContext->drawRect (r); + r.inset (offset, offset); + } +} + +static inline void testFillRect (CDrawContext *pContext, CRect r) +{ + int i = 0; + while (r.width () > 1 && r.height () > 1) + { + if (i++ % 2) + pContext->setFillColor (kYellowCColor); + else + pContext->setFillColor (kCyanCColor); + r.inset (1,1); + pContext->fillRect (r); + } +} + +static inline void testDrawLine (CDrawContext *pContext, CRect r, int _offset = 0) +{ + int offset = _offset ? _offset : pContext->getLineWidth (); + int i = 0; + while (r.width () > 1 && r.height () > 1) + { + if (i++ % 2) + pContext->setFrameColor (kBlueCColor); + else + pContext->setFrameColor (kGreenCColor); +// pContext->setClipRect (r); + pContext->moveTo (CPoint (r.left, r.top)); + pContext->lineTo (CPoint (r.right, r.top)); + pContext->lineTo (CPoint (r.right, r.bottom)); + pContext->lineTo (CPoint (r.left, r.bottom)); + pContext->lineTo (CPoint (r.left, r.top)); +// pContext->drawRect (r); + r.inset (offset,offset); + } +} + +static inline void drawVerticalLines (CDrawContext *pContext, CRect r, int _offset = 0) +{ + int offset = _offset ? _offset : pContext->getLineWidth (); + int i = 0; + CPoint p (0, r.top); + while (p.y < r.bottom) + { + if (i++ % 2) + pContext->setFrameColor (kBlueCColor); + else + pContext->setFrameColor (kGreenCColor); + pContext->moveTo (CPoint (r.left, p.y)); + pContext->lineTo (CPoint (r.right, p.y)); + p.offset (0,offset); + } +} + +static inline void clearRect (CDrawContext* pContext, const CRect& r) +{ + pContext->setFillColor (kWhiteCColor); + pContext->fillRect (r); + pContext->setLineWidth (1); + pContext->setFrameColor (kBlackCColor); + pContext->drawRect (r); +} + +static inline void drawLines (CDrawContext* pContext, CRect r, int offset = 2) +{ + CRect size (r); + pContext->setFrameColor (kBlueCColor); + int i; + for (i = 0; i < size.height (); i++) + { + pContext->moveTo (CPoint (r.left, r.top)); + pContext->lineTo (CPoint (r.right, r.bottom)); + r.offset (0, offset); + } + for (i = 0; i < size.height (); i++) + { + size.offset (0, -offset); + pContext->moveTo (CPoint (size.left, size.top)); + pContext->lineTo (CPoint (size.right, size.bottom)); + } +} + + +CColor arcColors[] = { {0,0,255,255}, {255,0,255,255}, {0,255,0,255}, {255,0,0,255}, {255, 255, 0, 255} }; + +#define numArcColors 4 + +static inline void drawArcs (CDrawContext* pContext, CRect r, int offset = 2) +{ + r.inset (diffX, diffY); + int i = 0; + long n = r.height () > r.width () ? r.width () : r.height (); + while (r.width () > 1 && r.height () > 1) + { + pContext->setFrameColor (arcColors[i++]); if (i > numArcColors) i = 0; + pContext->drawArc (r, CPoint (r.left, r.top + r.height () / 2), CPoint (r.left + r.width () / 2, r.bottom)); + pContext->setFrameColor (arcColors[i++]); if (i > numArcColors) i = 0; + pContext->drawArc (r, CPoint (r.left + r.width () / 2, r.bottom), CPoint (r.right, r.top + r.height () / 2)); + pContext->setFrameColor (arcColors[i++]); if (i > numArcColors) i = 0; + pContext->drawArc (r, CPoint (r.right, r.top + r.height () / 2), CPoint (r.left + r.width () / 2, r.top)); + pContext->setFrameColor (arcColors[i++]); if (i > numArcColors) i = 0; + pContext->drawArc (r, CPoint (r.left + r.width () / 2, r.top), CPoint (r.left, r.top + r.height () / 2)); + r.inset (offset, offset); + } +} + +static inline void drawEllipses (CDrawContext* pContext, CRect r, int offset = 2) +{ + r.inset (diffX, diffY); + int i = 0; + long n = r.height () > r.width () ? r.width () : r.height (); + while (r.width () > 1 && r.height () > 1) + { + pContext->setFrameColor (arcColors[i++]); if (i > numArcColors) i = 0; + pContext->drawEllipse (r); + r.inset (offset, offset); + } +} + +#define kMaxValue 10 + +void CDrawTestView::draw (CDrawContext *pContext) +{ + char str[256]; + str[0] = 0; + sprintf (str, "Click for Next"); + CRect r (size); + pContext->setDrawMode (kCopyMode); + clearRect (pContext, r); + r.inset (1, 1); + switch (value) + { + case 0: + { + pContext->setLineWidth (1); + testDrawRect (pContext, r); + break; + } + case 1: + { + pContext->setLineWidth (1); + testDrawLine (pContext, r, 2); + break; + } + case 2: + { + testFillRect (pContext, r); + break; + } + case 3: + { + pContext->setLineWidth (2); + testDrawLine (pContext, r); + break; + } + case 4: + { + pContext->setDrawMode (kAntialias); + pContext->setLineWidth (2); + testDrawLine (pContext, size); + break; + } + case 5: + { + pContext->setDrawMode (kAntialias); + pContext->setLineWidth (1); + testDrawLine (pContext, r); + break; + } + case 6: + { + pContext->setLineWidth (1); + drawLines (pContext, r, 4); + break; + } + case 7: + { + pContext->setDrawMode (kAntialias); + pContext->setLineWidth (1); + drawLines (pContext, r, 4); + break; + } + case 8: + { + pContext->setDrawMode (kAntialias); + pContext->setLineWidth (4); + drawArcs (pContext, r, 8); + break; + } + case 9: + { + pContext->setDrawMode (kAntialias); + pContext->setLineWidth (4); + drawEllipses (pContext, r, 8); + break; + } + case 10: + { + pContext->setLineStyle (kLineOnOffDash); + //pContext->setDrawMode (kAntialias); + pContext->setLineWidth (1); + drawVerticalLines (pContext, r, 3); + break; + } + } + pContext->setFont (kSystemFont); + pContext->setFontColor (kWhiteCColor); + pContext->drawString (str, r); + pContext->setFontColor (kBlackCColor); + r.offset (-1, -1); + pContext->drawString (str, r, true); + pContext->setDrawMode (kCopyMode); + setDirty (false); +} + +void CDrawTestView::mouse (CDrawContext* pContext, CPoint& where, long buttons) +{ + if (buttons & kLButton) + { + if (buttons & kShift) + { + CPoint start (where); + while ((buttons = pContext->getMouseButtons ())) + { + if (pContext->waitDrag ()) + { + CPoint now; + getMouseLocation (pContext, now); + diffX += start.x - now.x; + diffY += start.y - now.y; + start = now; + setDirty (true); + if (pParentFrame) pParentFrame->doIdleStuff (); + } + } + } + else + { + value++; + if (value > kMaxValue) + value = 0; + } + } + else if (buttons & kRButton) + { + value--; + if (value < 0) + value = kMaxValue; + } + setDirty (true); +} + diff --git a/vstgui.sf/drawtest/source/pdrawtestview.h b/vstgui.sf/drawtest/source/pdrawtestview.h new file mode 100644 index 0000000..4861819 --- /dev/null +++ b/vstgui.sf/drawtest/source/pdrawtestview.h @@ -0,0 +1,44 @@ +//------------------------------------------------------------------------------------------------------- +// VSTGUI Test View plugin +// Copyright (c) 2004 Arne Scheffler. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//------------------------------------------------------------------------------------------------------- + +#ifndef __pdrawtestview__ +#define __pdrawtestview__ + +#ifndef __vstgui__ +#include "vstgui.h" +#endif + +BEGIN_NAMESPACE_VSTGUI + +class CDrawTestView : public CView +{ +public: + CDrawTestView (const CRect& size); + + virtual void draw (CDrawContext *pContext); + + virtual void mouse (CDrawContext* pContext, CPoint& where, long buttons); + +protected: + int value; +}; + +END_NAMESPACE_VSTGUI + +#endif
\ No newline at end of file diff --git a/vstgui.sf/drawtest/source/pprimitivesviews.cpp b/vstgui.sf/drawtest/source/pprimitivesviews.cpp new file mode 100644 index 0000000..e0e668c --- /dev/null +++ b/vstgui.sf/drawtest/source/pprimitivesviews.cpp @@ -0,0 +1,245 @@ +#ifndef __pprimitivesviews__ +#include "pprimitivesviews.h" +#endif + +#include <stdio.h> + +const CColor kBlueAlphaCColor = { 0, 0, 255, 200}; +const CColor kRedAlphaCColor = { 255, 0, 0, 200}; +const CColor kYellowAlphaCColor = { 255, 255, 0, 200}; +const CColor kGreenAlphaCColor = { 0, 255, 0, 200}; +const CColor kMagentaAlphaCColor= { 255, 0, 255, 200}; + +PMiscView::PMiscView (const CRect& size) +: CView (size), xOffset (0), yOffset (0) +{ + setTransparency (true); +} + +void PMiscView::mouse (CDrawContext* pContext, CPoint &where, long buttons) +{ + if (pContext->waitDrag ()) + { + while (pContext->getMouseButtons () == kLButton) + { + CPoint cl; + getMouseLocation (pContext, cl); + if (cl != where) + { + xOffset -= (where.x - cl.x); + yOffset -= (where.y - cl.y); + where = cl; + setDirty (true); + } + getFrame ()->doIdleStuff (); + } + } +} + +static inline void offsetPoints (CPoint* points, long numPoints, CPoint offset) +{ + for (long i = 0; i < numPoints; i++) + points[i].offset (offset.x, offset.y); +} + +void PMiscView::draw (CDrawContext* pContext) +{ + drawGrid (pContext); + CPoint polyPoints[10]; + polyPoints[0] = CPoint (50,0); + polyPoints[1] = CPoint (100,50); + polyPoints[2] = CPoint (50,100); + polyPoints[3] = CPoint (0,50); + polyPoints[4] = CPoint (50,0); + offsetPoints (polyPoints, 5, CPoint (size.left + xOffset, size.top + yOffset)); + pContext->setDrawMode (kAntialias); + pContext->setFrameColor (kBlackCColor); + pContext->drawPolygon (polyPoints, 5, kDrawStroked); + offsetPoints (polyPoints, 5, CPoint (50, 0)); + pContext->setFillColor (kBlueAlphaCColor); + pContext->drawPolygon (polyPoints, 5, kDrawFilled); + offsetPoints (polyPoints, 5, CPoint (50, 0)); + pContext->setFillColor (kRedAlphaCColor); + pContext->drawPolygon (polyPoints, 5, kDrawFilledAndStroked); + + CRect ellipseRect (200, 0, 300, 100); + ellipseRect.offset (size.left + xOffset, size.top + yOffset); + pContext->drawEllipse (ellipseRect, kDrawStroked); + ellipseRect.offset (50, 0); + pContext->setFillColor (kBlueAlphaCColor); + pContext->drawEllipse (ellipseRect, kDrawFilled); + ellipseRect.offset (50, 0); + pContext->setFillColor (kRedAlphaCColor); + pContext->drawEllipse (ellipseRect, kDrawFilledAndStroked); + + setDirty (false); +} + +void PMiscView::drawGrid (CDrawContext* pContext) +{ + static long gridOffset = 10; + long x = size.left; + long y = size.top; + long numHLines = size.getWidth () / gridOffset + 1; + long numVLines = size.getHeight () / gridOffset + 1; + CPoint* points = new CPoint [numHLines*2 + numVLines*2]; + long i; + for (i = 0; i < numHLines*2; i+=2, x += gridOffset) + { + points[i] = CPoint (x, size.top); + points[i+1] = CPoint (x, size.bottom); + } + for (i = 0; i < numVLines*2; i+=2, y += gridOffset) + { + points[numHLines*2+i] = CPoint (size.left, y); + points[numHLines*2+i+1] = CPoint (size.right, y); + } + pContext->setDrawMode (kCopyMode); + pContext->setFrameColor (kGreyCColor); + pContext->drawLines (points, numHLines+numVLines); + delete [] points; +} + +PLinesView::PLinesView (const CRect& size) +: CView (size) +{ + setTransparency (true); +} + +void PLinesView::draw (CDrawContext *context) +{ + int i; + char text[512]; + text[0] = 0; + context->setFont (kNormalFontSmall); + context->setFrameColor (kWhiteCColor); + context->setFontColor (kBlackCColor); + CRect r (size); + r.left += 10; + r.right -= 2; + r.setHeight (12); + context->drawString ("Normal Lines with different line widths", r); + context->setLineStyle (kLineSolid); + r.offset (0, 12); + for (i = 1; i <= 5; i++) + { + context->setLineWidth (i); + CPoint p (r.left, r.bottom - r.getHeight () / 2); + context->moveTo (p); + p.x = r.right; + context->lineTo (p); + CRect textSize (r.left-10, r.top, r.left, r.bottom); + sprintf (text, "%d", i); + context->drawString (text, textSize); + r.offset (0, 12); + } + context->drawString ("Dotted Lines with different line widths", r); + context->setLineStyle (kLineOnOffDash); + r.offset (0, 12); + for (i = 1; i <= 5; i++) + { + context->setLineWidth (i); + CPoint p (r.left, r.bottom - r.getHeight () / 2); + context->moveTo (p); + p.x = r.right; + context->lineTo (p); + CRect textSize (r.left-10, r.top, r.left, r.bottom); + sprintf (text, "%d", i); + context->drawString (text, textSize); + r.offset (0, 12); + } + context->drawString ("Normal Lines Antialiased with different line widths", r); + context->setLineStyle (kLineSolid); + context->setDrawMode (kAntialias); + r.offset (0, 12); + for (i = 1; i <= 5; i++) + { + context->setLineWidth (i); + CPoint p (r.left, r.bottom - r.getHeight () / 2); + context->moveTo (p); + p.x = r.right; + context->lineTo (p); + CRect textSize (r.left-10, r.top, r.left, r.bottom); + sprintf (text, "%d", i); + context->drawString (text, textSize); + r.offset (0, 12); + } + context->drawString ("Dotted Lines Antialiased with different line widths", r); + context->setLineStyle (kLineOnOffDash); + r.offset (0, 12); + for (i = 1; i <= 5; i++) + { + context->setLineWidth (i); + CPoint p (r.left, r.bottom - r.getHeight () / 2); + context->moveTo (p); + p.x = r.right; + context->lineTo (p); + CRect textSize (r.left-10, r.top, r.left, r.bottom); + sprintf (text, "%d", i); + context->drawString (text, textSize); + r.offset (0, 12); + } + context->setLineStyle (kLineSolid); + context->setLineWidth (1); + context->setDrawMode (kCopyMode); + + setDirty (false); +} + +PRectsView::PRectsView (const CRect& size) +: CView (size) +{ + setTransparency (true); +} + +void PRectsView::draw (CDrawContext *context) +{ + char text[512]; + text[0] = 0; + context->setFont (kNormalFontSmall); + context->setFrameColor (kRedCColor); + context->setFontColor (kBlackCColor); + CRect r (size); + context->drawRect (r); +// r.inset (1,1); + context->setFillColor (kWhiteCColor); + context->drawRect (r,kDrawFilled); + r.inset (2, 2); + context->setDrawMode (kAntialias); + context->drawRect (r); + context->setDrawMode (kCopyMode); + r.inset (5, 5); + CRect r1 (r); + r1.setHeight (r1.getHeight () / 2); + r1.setWidth (r1.getWidth () / 2); + CRect r2 (r1); + r2.inset (1, 1); + context->setFillColor (kBlueAlphaCColor); + context->drawRect (r2, kDrawFilledAndStroked); + r2 = r1; + r2.offset (r2.getWidth (), 0); + r2.inset (1,1); + context->setFillColor (kYellowAlphaCColor); + context->drawRect (r2, kDrawFilledAndStroked); + r2 = r1; + r2.offset (0, r2.getHeight ()); + r2.inset (1,1); + context->setFillColor (kGreenAlphaCColor); + context->drawRect (r2, kDrawFilledAndStroked); + r2 = r1; + r2.offset (r2.getWidth (), r2.getHeight ()); + r2.inset (1,1); + context->setFillColor (kMagentaAlphaCColor); + context->drawRect (r2, kDrawFilledAndStroked); + + r2 = r; + r2.inset (r2.getWidth () / 4, r2.getHeight () / 4); + CColor alphaColor = {0, 0, 0, 130}; + context->setFillColor (alphaColor); + context->fillRect (r2); + r2.inset (r2.getWidth () / 4, r2.getHeight () / 4); + CColor alpha2Color = {255, 255, 255, 130}; + context->setFillColor (alpha2Color); + context->fillRect (r2); + setDirty (false); +} diff --git a/vstgui.sf/drawtest/source/pprimitivesviews.h b/vstgui.sf/drawtest/source/pprimitivesviews.h new file mode 100644 index 0000000..90c339a --- /dev/null +++ b/vstgui.sf/drawtest/source/pprimitivesviews.h @@ -0,0 +1,37 @@ +#ifndef __pprimitivesviews__ +#define __pprimitivesviews__ + +#ifndef __vstgui__ +#include "vstgui.h" +#endif + +class PLinesView : public CView +{ +public: + PLinesView (const CRect& size); + + virtual void draw (CDrawContext *pContext); +}; + +class PRectsView : public CView +{ +public: + PRectsView (const CRect& size); + + virtual void draw (CDrawContext *pContext); +}; + +class PMiscView : public CView +{ +public: + PMiscView (const CRect& size); + + virtual void draw (CDrawContext* pContext); + virtual void mouse (CDrawContext* pContext, CPoint &where, long buttons = -1); +protected: + void drawGrid (CDrawContext* pContext); + long xOffset; + long yOffset; +}; + +#endif |
