COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 03-26-2020, 03:58 AM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 258
Default Can't serialize (WDL-OL)

Hi,

I was looking for text entry and found AlgDisplay in IPlugEEL. Working fine but can't serialize it to remember entered text after closing and re-opening DAW.

I tried but can't find the way...

Let me know what i'm doing wrong...

Thanks.

Here is my code;

Plug.h

Code:
    
  WDL_String Text01;
  
  char CharText01[4096] = "Track Name";
Plug.cpp

Code:
  mTextControl = new AlgDisplay(this, r, &textProps, CharText01);
  pGraphics->AttachControl(mTextControl);

-
-
-

bool Plug::SerializeState(ByteChunk* pChunk)
{
  TRACE;
  IMutexLock lock(this);
  
  Text01.Set(CharText01);
  
  pChunk->PutStr(Text01.Get());
  
  return IPlugBase::SerializeParams(pChunk);
}

int Plug::UnserializeState(ByteChunk* pChunk, int startPos)
{
  TRACE;
  IMutexLock lock(this);
  
  startPos = pChunk->GetStr(&Text01, startPos);
  
  strcpy(CharText01, Text01.Get());
  
  return IPlugBase::UnserializeParams(pChunk, startPos);
}

Last edited by Tunca; 03-26-2020 at 04:31 AM.
Tunca is offline   Reply With Quote
Old 03-27-2020, 03:22 AM   #2
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 258
Default

Still trying different methods but no luck...

Any help?
Tunca is offline   Reply With Quote
Old 03-28-2020, 09:38 AM   #3
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 258
Default

Figured it out.

Thanks.
Tunca is offline   Reply With Quote
Old 07-01-2020, 01:52 AM   #4
TheHornet
Human being with feelings
 
Join Date: Oct 2016
Posts: 1
Default

Quote:
Originally Posted by Tunca View Post
Figured it out.

Thanks.
please--->how?
TheHornet is offline   Reply With Quote
Old 08-01-2020, 08:17 AM   #5
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 258
Default

Quote:
Originally Posted by TheHornet View Post
please--->how?
Hi,

Sorry for late response. I was offline for a month because of civil duty. Now, i'm back.

I used serialization for text storage that entered by users on GUI.

Used this code to entry text.

Code:
class TextEntry : public IControl
{
protected:
  WDL_String mStr;
public:
  TextEntry(IPlugBase* pPlug, IRECT pR, IText* pText, const char* str = ""): IControl(pPlug, pR)
  {
    mDisablePrompt = true;
    mText = *pText;
    mStr.Set(str);
  }
  
  ~TextEntry() {}
  
  bool Draw(IGraphics* pGraphics)
  {
    return pGraphics->DrawIText(&mText, mStr.Get(), &mRECT);
  }
  
  void OnMouseDblClick(int x, int y, IMouseMod* pMod)
  {
    mPlug->GetGUI()->CreateTextEntry(this, &mText, &mRECT, mStr.Get());
  }
  
  char *GetTextEntry()
  {
    return mStr.Get();
  }
  
  void TextFromTextEntry(const char* txt)
  {
    mStr.Set(txt);
    
    //TODO: update alg
    
    SetDirty(false);
  }
};
In plugname.h

Code:
  TextEntry* nameEntry1;

  WDL_String *SavedString1 = new WDL_String;
In plugname.cpp

Code:
  IText textProps(18, &COLOR_BLACK, "Futura", IText::kStyleNormal, IText::kAlignCenter, 0, IText::kQualityAntiAliased);

...

  nameEntry1 = new TextEntry(this, R1.GetPadded(0, 642, 0, 642), &textProps, "Track Name");
  pGraphics->AttachControl(nameEntry1);

...

bool plugname::SerializeState(ByteChunk* pChunk)
{
  IMutexLock lock(this);
  
  SavedString1->Set((const char*)nameEntry1->GetTextEntry());

  pChunk->PutStr(SavedString1->Get());

  return SerializeParams(pChunk);
}

int plugname::UnserializeState(ByteChunk* pChunk, int startPos)
{
  IMutexLock lock(this);
  
  startPos = pChunk->GetStr(SavedString1, startPos);

  nameEntry1->TextFromTextEntry(SavedString1->Get());

  return UnserializeParams(pChunk, startPos);
}
Tunca is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.