COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 12-27-2012, 10:57 AM   #1
Grag38
Human being with feelings
 
Join Date: Jun 2010
Posts: 57
Default WDL-OL TEXT ENTRY

I try since few days of using an text entry with WDL-OL without success...

I tried to modify a lot the IPLUGMultiTarget example. It works with values, but no succes to modify an existing text.

My goal is to have un text entry with an default value, and be able to modify it. I plan to use it to enter an IPV4 address.

So from the default address would be : 127.0.0.1 and I would like to modify it to 192.168.11.34

Any help would be nice from some of you.

Best regards.
Grag38 is offline   Reply With Quote
Old 12-27-2012, 05:31 PM   #2
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

post your code
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 01-04-2013, 04:11 AM   #3
Grag38
Human being with feelings
 
Join Date: Jun 2010
Posts: 57
Default

the question is simple...

Is there into the classes of wdl-ol a simple way of using an entry text ?

My code will be open source when I will decide it runs well.

Thanks.
Grag38 is offline   Reply With Quote
Old 01-04-2013, 05:59 AM   #4
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

you need to create a custom IControl to do this. There is one in the IPlugEEL example that does what you want.

Code:
class AlgDisplay : public IControl
{
public:
  AlgDisplay(IPlugBase* pPlug, IRECT pR, IText* pText, const char* str = "127.0.0.1")
  : IControl(pPlug, pR)
  {
    mDisablePrompt = true;
    mText = *pText;
    mStr.Set(str);
  }
  
  ~AlgDisplay() {}

  bool Draw(IGraphics* pGraphics)
  {  
    return pGraphics->DrawIText(&mText, mStr.Get(), &mRECT);
  }
  
  void OnMouseDown(int x, int y, IMouseMod* pMod)
  {
    mPlug->GetGUI()->CreateTextEntry(this, &mText, &mRECT, mStr.Get());
  }
  
  void TextFromTextEntry(const char* txt)
  {
    mStr.Set(txt, MAX_ALG_LENGTH);
    
    //TODO: update alg
    
    SetDirty(false);
  }
  
protected:
  WDL_String mStr;
};
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 01-05-2013, 09:58 AM   #5
Grag38
Human being with feelings
 
Join Date: Jun 2010
Posts: 57
Default

Nice.

Thank you very much. I have to spend more time with the understanding of the WDL-OL classes.

Best Regards
Grag38 is offline   Reply With Quote
Old 04-29-2017, 04:59 PM   #6
clau_ste
Human being with feelings
 
Join Date: Apr 2017
Posts: 1
Default

I implemented this control and i found two problems

1. The text is not centered vertically and i can't figure out how to put it at the left of the IRECT

2. How can i get the text of this control if i have a pointer to it? Which function should i call?
clau_ste is offline   Reply With Quote
Old 07-20-2017, 02:16 PM   #7
MSK
Human being with feelings
 
Join Date: Jan 2017
Posts: 43
Default

Quote:
Originally Posted by clau_ste View Post
I implemented this control and i found two problems

1. The text is not centered vertically and i can't figure out how to put it at the left of the IRECT

2. How can i get the text of this control if i have a pointer to it? Which function should i call?
Bump for #1. Has anyone made a text entry where the text is centered vertically? My only solution is to have the text entry have no background and draw my own offset background around it to manually make the text centered, which is less than ideal...

In response to #2, I'm not sure exactly what you were asking. If you mean get the text from inside the control, that's handled, like Oli said, by:

void TextFromTextEntry(const char* txt){}

If you mean how do you access the text from outside the control, you'd probably want to copy the text to an internal variable and write a GetText() method. Something like this:

Code:
char * storedText = "";
void TextFromTextEntry(const char* txt){

   //do something with the text
   storedText = txt;

}

char * GetText(){ return storedText; }
Then somewhere else you'd get it like this:
Code:
char * txt = pControl -> GetText();
MSK
MSK is offline   Reply With Quote
Old 08-03-2017, 10:42 PM   #8
MSK
Human being with feelings
 
Join Date: Jan 2017
Posts: 43
Default

Bump bump.

The method in my post above works fine in Live, but in Reaper the background of the text entry is black no matter what I set BGColor (and FGColor) in the IText to.

Does anyone have a more elegant solution for text entry?

Here's my code:
Code:
const IColor bgColor = IColor(0, 130, 130, 130);
const IColor fgColor = IColor(255, 30, 30, 30);

IText text = IText(21, &COLOR_ORANGE, font, IText::kStyleNormal, IText::kAlignCenter, 0, IText::kQualityAntiAliased, &bgColor, &fgColor);

mPlug -> GetGUI() -> CreateTextEntry(this, &text, &entryTextRect, testText);
Thanks!
MSK
MSK is offline   Reply With Quote
Old 08-08-2017, 10:46 AM   #9
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

what operating system are you using? think I have some fixes for coloured text entry boxes
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 08-08-2017, 11:23 AM   #10
MSK
Human being with feelings
 
Join Date: Jan 2017
Posts: 43
Default

Quote:
Originally Posted by olilarkin View Post
what operating system are you using? think I have some fixes for coloured text entry boxes

I've noticed the issue in Reaper (64 bit) on both macOS 10.11 and 10.12.

As far as I can tell in my setup:

- The IColor that's supposed to be the text color (COLOR_ORANGE) does nothing.

- The background color works in hosts other than Reaper.

- The foreground color is what the text is actually colored as.

What I've been doing is drawing the background manually and setting the background color alpha to 0, but in Reaper it just defaults to black. I figured out how to detect which host the plugin is running in, so I could just draw everything differently in Reaper, but ideally there's some fix and things could be consistent across hosts.

Any fixes you've figured out would be wonderful!

Just in case I'm doing something stupid (very likely), this is all the relevant parts of my text entry code:
Code:
    // TextEntry background color , ICOLOR(A, R, G, B)
    const IColor bgColor = IColor(0, 130, 130, 130);
    // Text color
    const IColor fgColor = IColor(255, 30, 30, 30);
    
    IText text = IText(21, &COLOR_ORANGE, font, IText::kStyleNormal, IText::kAlignCenter, 0, IText::kQualityAntiAliased, &bgColor, &fgColor);

void OnMouseDown(int x, int y, IMouseMod* pMod){
        
        if (((x >= entryDrawRectL) && (x <= entryDrawRectL + entryDrawRectW)) && ((y >= entryDrawRectT) && (y <= entryDrawRectT + entryDrawRectH))){
            
            const char* testText = "";
            mPlug -> GetGUI() -> CreateTextEntry(this, &text, &entryTextRect, testText);
            textEntryClicked = true;
        
        }
}

Last edited by MSK; 08-24-2017 at 03:21 PM.
MSK is offline   Reply With Quote
Old 08-24-2017, 11:05 AM   #11
HoRNet
Human being with feelings
 
Join Date: Feb 2011
Posts: 171
Default

The only way to center text vertically with iplug is to modify quite a bit of code in IGraphics.cpp

In IGraphics:rawIText at line 1105 i added:

Code:
	if (pTxt->mValign == IText::kAlignTop) {
		fmt |= DT_TOP;
	} else if (pTxt->mValign == IText::kAlignBottom) {
		fmt |= DT_BOTTOM;
	} else {
		fmt |= DT_VCENTER;
#ifdef OS_WIN
		fmt |= DT_SINGLELINE;
#endif
	}
I also added the valign property inside the IText struct in IPlugStructs.h:

Code:
enum EValign { kAlignTop, kAlignBottom, kAlignMiddle } mValign;
Saverio
HoRNet is offline   Reply With Quote
Old 12-11-2017, 09:00 AM   #12
jan hase
Human being with feelings
 
Join Date: Jul 2017
Posts: 25
Default

Quote:
Originally Posted by HoRNet View Post
The only way to center text vertically with iplug is to modify quite a bit of code in IGraphics.cpp

In IGraphics:rawIText at line 1105 i added:

Code:
	if (pTxt->mValign == IText::kAlignTop) {
		fmt |= DT_TOP;
	} else if (pTxt->mValign == IText::kAlignBottom) {
		fmt |= DT_BOTTOM;
	} else {
		fmt |= DT_VCENTER;
#ifdef OS_WIN
		fmt |= DT_SINGLELINE;
#endif
	}
I also added the valign property inside the IText struct in IPlugStructs.h:

Code:
enum EValign { kAlignTop, kAlignBottom, kAlignMiddle } mValign;
Saverio
works just fine, thank you!
jan hase is offline   Reply With Quote
Old 12-12-2017, 05:57 AM   #13
HoRNet
Human being with feelings
 
Join Date: Feb 2011
Posts: 171
Default

BTW I pushed this change into Youlean repository, i don't know if I have to push this into Oli's too because he's going under heavy refactoring...

Saverio
HoRNet 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 06:33 AM.


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