Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » GetProperty() / SetProperty() for Ctrl
GetProperty() / SetProperty() for Ctrl [message #29796] Wed, 17 November 2010 17:46 Go to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
hi guys

in my struggle with a 'scriptable' layout for OSC interfaces i came along the need / idea to make the controls more open to manipulation in terms of their properties (not the hardwired things like callbacks).

so one could imagine a uniform interface like
void Ctrl::SetProperty(const String& name, const Value& v);
void Ctrl::GetProperty(const String& name, Value& v);


now this would enable / map things like
c.SetProperty("background", Black);
c.GetProperty("background", v);

c.SetProperty("min", 123);
c.GetProperty("max", v);

c.SetProperty("xalign", "left");
c.SetProperty("xpos", 123);
c.SetProperty("yalign", "center");
c.SetProperty("ypos", 45);

c.SetProperty("pattern", "%.g");
c.SetProperty("grid" ValueArray(Vector<int>() << 5 << 6));

//would map to GetData / SetData directly i.e.
c.SetProperty("data", 345);
c.GetProperty("data", v);

c.GetProperty("count", v);

c.SetProperty("enable", true);
c.GetProperty("enable, v);

c.SetProperty("show", false);
c.SetProperty("title", "MyTitle");
c.SetProperty("tip", "GoHelp");

//query all getable properties
c.GetProperty("rprops", v);
//query all setable properties
c.GetProperty("wprops", v);

..
and many more..


this would ease things like a custom gui creation / live edit of controls..

this is just an idea, where std Ctrl could already map to a lot of things by itself.. and derived Ctrls simply extending the 'dictionary' of properties and managing the properties..

i imagine to extend it on template base if not desired in upp, but having a uniform polymorphic interface already from Ctrl level would help a great deal in this.

i might provide an example implementation soon..
just wanted to know your opinion.

cheers

[Updated on: Wed, 17 November 2010 17:50]

Report message to a moderator

Re: GetProperty() / SetProperty() for Ctrl [message #29806 is a reply to message #29796] Thu, 18 November 2010 15:12 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
got something working, almost the way desired, and without manipulating Ctrl..

it's Callback map based approach to handlers.. using public interface of the controls. the lack of virtualisation made it nessessary to pay attention to the derive hierarchy, to invoke things from base first.

attached is a test
comments/ideas..
  • Attachment: CtrlProp.rar
    (Size: 1.83KB, Downloaded 176 times)
Re: GetProperty() / SetProperty() for Ctrl [message #29808 is a reply to message #29806] Thu, 18 November 2010 18:28 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3045
Registered: August 2008
Ultimate Member
Hello kohait00

This is the window. How is it used?

index.php?t=getfile&id=2937&private=0
  • Attachment: dib.PNG
    (Size: 4.95KB, Downloaded 978 times)


Best regards
IƱaki
Re: GetProperty() / SetProperty() for Ctrl [message #29811 is a reply to message #29808] Thu, 18 November 2010 20:03 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
sorry, the 'test' case was just veeeeery brief Smile to be able to look at the 'api'.. it was just to show that the respective calls to SetData() has arrived successfully..

the api is very simple

bool SetProperty(Ctrl& c, const String& n, const Value& v);
bool GetProperty(const Ctrl&, const String& n, Value& v);

both return false if no property with name n could be found for Ctrl& c. or if in case of SetProperty the Value v had incompatible type..

this is just a very bried first - shot idea, without need of manipulating Ctrl at all but still yielding full support to all top level Ctrls. in this case it is an EditInt beeing passed as Ctrl&, and still can set Min and Max values...so this is a uniform api.

my point is to have a feedback on wheather stuff like that is of use or if there is a more intelligent way to export and access properties of controls in a uniform way other than the pure compile time c++ api, but also as runtime manipulation api..

cheers
Re: GetProperty() / SetProperty() for Ctrl [message #29812 is a reply to message #29811] Thu, 18 November 2010 23:20 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
here comes a new Test Case, which i think shows where the idea was going to..

a 'dynamic' property list editor...

i am still not happey with the 'listget' and 'listset' option, but i cant imagine how to filter them out in an effective way..

ideas..
Re: GetProperty() / SetProperty() for Ctrl [message #29864 is a reply to message #29812] Wed, 24 November 2010 17:51 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
hi guys, is there any ideas on that one?
i'd need to know if it's worth to go in that direction, especially in terms of setting up an OSC controls layout Smile
hope not to come harsh..
Re: GetProperty() / SetProperty() for Ctrl [message #29888 is a reply to message #29864] Sat, 27 November 2010 18:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12125
Registered: November 2005
Ultimate Member
Perhaps I could express my opinion if I knew what is "osc control" Wink
Re: GetProperty() / SetProperty() for Ctrl [message #29897 is a reply to message #29888] Sun, 28 November 2010 11:01 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
in fact, i started a post about osc, which has drifted towards audio interface things in u++ Smile

osc is actually a parameters manipulating language / message protocol. there are applications, where one can put together control elements, and assign them osc patterns (the parameters they will be operating on) and thus have remote control interfaces..

these interfaces can be created in layout editors, where one can edit the controls' properties, like size, position etc..

see
http://hexler.net/software/touchosc
there is also an editor to download...

http://opensoundcontrol.org/spec-1_0
the specification
Re: GetProperty() / SetProperty() for Ctrl [message #29935 is a reply to message #29897] Tue, 30 November 2010 21:12 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
any idea if/how this can be done better?
Re: GetProperty() / SetProperty() for Ctrl [message #29940 is a reply to message #29935] Wed, 01 December 2010 09:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12125
Registered: November 2005
Ultimate Member
I would use some nice macros to automate the most of process...
Re: GetProperty() / SetProperty() for Ctrl [message #29941 is a reply to message #29940] Wed, 01 December 2010 10:04 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
i think macros wont do in my case..since i need it at runtime. macros would fix everything at compile time..

or did i get you wrong? some example?
Re: GetProperty() / SetProperty() for Ctrl [message #29968 is a reply to message #29941] Wed, 01 December 2010 18:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12125
Registered: November 2005
Ultimate Member
kohait00 wrote on Wed, 01 December 2010 04:04

i think macros wont do in my case..since i need it at runtime. macros would fix everything at compile time..

or did i get you wrong? some example?


Oh, no, I mean macros to automate what you are already doing, just with less code.

I believe that something like

CTRL_PROPERTIES(EditInt)
    PROPERTY(int, Min)
    PROPERTY_SET(bool, "NotNull", NotNull)
    PROPERTY_GET(bool, "NotNull", IsNotNull)
END_CTRL_PROPERTIES


should be possible.

Mirek
Re: GetProperty() / SetProperty() for Ctrl [message #29977 is a reply to message #29968] Wed, 01 December 2010 20:22 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
that is, ofcorse better in terms of API, lets see how to fit that in. my problem is that i actually dont want to mess with Ctrl stuff. trying to extend it from public interface point of view, idea is to have typeid() do the entrance point from where to start parsing the properties..and need to resemble a bit the derive hierarchy if meaningfull..
thanks for the hint.
Re: GetProperty() / SetProperty() for Ctrl [message #29982 is a reply to message #29977] Thu, 02 December 2010 08:44 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
still not what i am proud of, but first scores are done Smile
i think this is quite helpful for dynamic control editing..
Re: GetProperty() / SetProperty() for Ctrl [message #29983 is a reply to message #29982] Thu, 02 December 2010 09:24 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
BTW: found 2 const correctness issues in CtrlCore.h

CtrlCore.h:1199
	bool    IsInitFocus() const                { return initfocus; }


CtrlCore.h:1249
	int     GetBackPaint() const               { return backpaint; }
Re: GetProperty() / SetProperty() for Ctrl [message #29984 is a reply to message #29977] Thu, 02 December 2010 11:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12125
Registered: November 2005
Ultimate Member
kohait00 wrote on Wed, 01 December 2010 14:22

that is, ofcorse better in terms of API, lets see how to fit that in. my problem is that i actually dont want to mess with Ctrl stuff. trying to extend it from public interface point of view, idea is to have typeid() do the entrance point from where to start parsing the properties..and need to resemble a bit the derive hierarchy if meaningfull..
thanks for the hint.


I would rather go with dynamic_cast... Makes more sense.

Mirek
Re: GetProperty() / SetProperty() for Ctrl [message #29989 is a reply to message #29984] Thu, 02 December 2010 11:18 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
what would be the benefit in terms of organisation of the callback structures? you mean to automate the checking for even unregistered types? that would probably be an advantage, but then, i'd have to check for a whole bunch of types (performance) for each property. i couldnt use mapping anymore..

a help would be so kind of a
virtual String Ctrl::PropertyHook() const { return "Upp::Ctrl"; }

which i could use for querying maps..
then, derived controls, that dont extend property stuff would still be mapped easily (because their base specifies the hook correctly)..but this means extending the Ctrl API. but only this one single method..what do you think about it?

a EditInt i.e would, then, need to
virtual String EditInt::PropertyHook() const { return "Upp::EditInt"; }

to anounce, that it wants own property entrance in the map

also, String(typeid(CLASSNAME).name()) could be used..

then, a #define would do it to anounc

#define HASPROPERTY \
virtual String PropertyHook() const { return String(typeid(CLASSNAME).name()); }

[Updated on: Thu, 02 December 2010 11:24]

Report message to a moderator

Re: GetProperty() / SetProperty() for Ctrl [message #29990 is a reply to message #29989] Thu, 02 December 2010 11:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12125
Registered: November 2005
Ultimate Member
kohait00 wrote on Thu, 02 December 2010 05:18

what would be the benefit in terms of organisation of the callback structures? you mean to automate the checking for even unregistered types? that would probably be an advantage, but then, i'd have to check for a whole bunch of types (performance) for each property. i couldnt use mapping anymore..

a help would be so kind of a
virtual String Ctrl::PropertyHook() const { return "Upp::Ctrl"; }

which i could use for querying maps..
then, derived controls, that dont extend property stuff would still be mapped easily..but this means extending the Ctrl API..what do you thing about it?

a EditInt i.e would, then, need to
virtual String EditInt::PropertyHook() const { return "Upp::EditInt"; }

to anounce, that it wants own property entrance in the map

also, String(typeid(CLASSNAME).name()) could be used..

then, a #define would do it to anounc

#define HASPROPERTY \
virtual String PropertyHook() const { return String(typeid(CLASSNAME).name()); }




Overengineering.

Mirek
Re: GetProperty() / SetProperty() for Ctrl [message #29991 is a reply to message #29990] Thu, 02 December 2010 11:24 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 934
Registered: July 2009
Location: Germany
Experienced Contributor
sure, it's not easy to think simple Smile
so what do you mean with dynamic_cast? how to use that here?

[Updated on: Thu, 02 December 2010 11:26]

Report message to a moderator

Re: GetProperty() / SetProperty() for Ctrl [message #29994 is a reply to message #29991] Thu, 02 December 2010 13:33 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 12125
Registered: November 2005
Ultimate Member
kohait00 wrote on Thu, 02 December 2010 05:24

sure, it's not easy to think simple Smile
so what do you mean with dynamic_cast? how to use that here?


CTRL_PROPERTIES(EditInt)
    PROPERTY(int, Min)
    PROPERTY_SET(bool, "NotNull", NotNull)
    PROPERTY_GET(bool, "NotNull", IsNotNull)
END_CTRL_PROPERTIES

static void GetSet_uniquebyline(Ctrl& c, Value& v, const String& prop, bool set)
{
   EditInt *c = dynamic_cast<EditInt>(&x);
   if(!c) return;
   if(prop == "Min" && set)
      c->Min(v);
   if(prop == "Min" && !set)
      v = c->GetMin();
   ....
}

INITBLOCK { RegisterCtrlGetSet(GetSet_uniquebyline); }


(Will take some effort to really squeeze to macros, but should be possible to do so).
Previous Topic: Drag and Drop between instances [FEATURE REQUEST]
Next Topic: PrinterJob prints blank pages in linux
Goto Forum:
  


Current Time: Fri Dec 13 22:53:10 CET 2019

Total time taken to generate the page: 0.01875 seconds