Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
LaxInterfaces::GradientInterface Class Reference

Manipulates GradientData objects. More...

Inheritance diagram for LaxInterfaces::GradientInterface:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 GradientInterface (int nid, Laxkit::Displayer *ndp)
 Default is a linear black to red.
virtual ~GradientInterface ()
 Empty destructor.
virtual Laxkit::ShortcutHandlerGetShortcuts ()
virtual anInterfaceduplicate (anInterface *dup)
 Return dup of this. Copies over creationstyle, creatp/v, createlen, col1, col2.
virtual const charIconId ()
virtual const charName ()
virtual const charwhattype ()
virtual const charwhatdatatype ()
virtual int InterfaceOn ()
 Sets showdecs=1, and needtodraw=1.
virtual int InterfaceOff ()
 Calls Clear(), sets showdecs=0, and needtodraw=1.
virtual int UseThis (Laxkit::anObject *newdata, unsigned int)
 Uses GradientData and foreground of a LineStyle.
virtual int UseThisObject (ObjectContext *oc)
virtual void Clear (SomeData *d)
virtual int LBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
 Creates new data if not click down on one...
virtual int LBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
 If data, then call viewport->ObjectMoved(data).
virtual int MouseMove (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const Laxkit::LaxKeyboard *d)
virtual int Refresh ()
 Refresh, calls drawLinear() and drawRadial(), then draws decorations.
virtual void drawLinear ()
 Draw linear gradient. Called from Refresh.
virtual void drawRadial ()
 Draw radial gradient. Called from Refresh.
virtual void drawRadialLine (double t)
 Draw a single line at t, where t==0 is data->p1 and t==1 is data->p2.
virtual int DrawData (Laxkit::anObject *ndata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=0)
 Standard drawdata function.
virtual int scan (int x, int y)
 Scan for point.
virtual int SelectPoint (int c)
 Select a color spot (not p (c==-1) or p+v (c==-2)).
virtual void deletedata ()
 Basically clear data. Decrement its count, and set to NULL.
virtual ObjectContextContext ()
virtual flatpoint getpoint (int c, int trans)
 Return a flatpoint corresponding to point index c in data space coordinates, or transformed if (trans).
virtual int sendcolor (Laxkit::ScreenColor *col)
 Send a "make curcolor" event to the viewport.
- Public Member Functions inherited from LaxInterfaces::anInterface
 anInterface ()
 This constructor assigns id=getUniqueNumber().
 anInterface (int nid)
 Constructor to assign just the id, set other stuff to 0.
 anInterface (int nid, Laxkit::Displayer *ndp)
 anInterface (anInterface *nowner, int nid)
 Constructor to assign owner and id.
 anInterface (anInterface *nowner, int nid, Laxkit::Displayer *ndp)
virtual int draws (const char *atype)
 Returns !strcmp(whatdatatype(),atype).
virtual void Clear ()
 Default just calls Clear(NULL).
virtual int RemoveChild ()
 If there is a child, do something to remove it.
virtual int AddChild (LaxInterfaces::anInterface *ch, int absorbcount, int addbefore)
virtual int Needtodraw ()
 Must return nonzero if the data needs to be drawn, that is to say Refresh must be called.
virtual int Needtodraw (int n)
virtual int MBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int RBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int MBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int RBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int WheelUp (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int WheelDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int KeyUp (unsigned int ch, unsigned int state, const Laxkit::LaxKeyboard *d)
virtual int DeviceChange (const Laxkit::DeviceEventData *e)
virtual int Event (const Laxkit::EventData *e, const char *mes)
 Respond to events, particularly menu events from a menu created from ContextMenu().
virtual void ExposeChange (Laxkit::ScreenEventData *e)
virtual void ViewportResized ()
 Called after the parent viewport gets resized.
virtual void Mapped ()
 Called after the parent viewport gets mapped (made visible).
virtual void Unmapped ()
 Called after the parent viewport gets mapped (made invisible, such as offscreen, not merely obscured).
virtual void PostMessage (const char *message)
 If viewport, use that, else app->postmessage().
virtual Laxkit::MenuInfoContextMenu (int x, int y, int deviceid)
 Return a context sensitive menu for screen position (x,y).
virtual int UseThis (int id, int ndata)
 Return 1 if the id/ndata is used, otherwise zero.
virtual Laxkit::anXWindowCurrentWindow (Laxkit::anXWindow *ncur)
 Set the window the interface works on to ncur. Returns ncur. If ncur==NULL, then just return current viewport.
virtual void Dp (Laxkit::Displayer *ndp)
 Set the dp to ndp, and update curwindow/viewport.
virtual int DrawDataDp (Laxkit::Displayer *tdp, SomeData *tdata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=1)
 Use a different dp to draw data with.
virtual flatpoint realtoscreen (flatpoint r)
 Do a little extra checking to find what point r should correspond to.
virtual flatpoint screentoreal (int x, int y)
 Do a little extra checking to find what point (x,y) should correspond to.
virtual double Getmag (int c=0)
 Do a little extra checking to find what the magnification is.
virtual double GetVMag (int x, int y)
 Do a little extra checking to find what the magnification is.
virtual void dump_out (FILE *f, int indent, int what, Laxkit::anObject *savecontext)
 Default settings saving is to output nothing.
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *loadcontext)
 Placeholder for dumping in settings.
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual Attributedump_out_atts (Attribute *att, int what, Laxkit::anObject *savecontext)
 Default is return NULL. what==0 means write out normal Attribute formatted things.
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.

Public Attributes

unsigned long controlcolor
int creationstyle
int showdecs
int usepreview
 Whether to draw the gradient on each refresh or use a cached preview.
Laxkit::ScreenColor col1
Laxkit::ScreenColor col2
flatpoint createv
double creater1
double creater2
int gradienttype
 0 for either radial or linear. 1 for linear only. 2 for radial only.
GradientDatadata
ObjectContextgoc
- Public Attributes inherited from LaxInterfaces::anInterface
charname
 An instance name.. ***don't think this is used anywhere at the moment.
int id
 Must be positive, other values are reserved for internal use.
unsigned long style
 Style flags for the interface. Meaning depends on the interface.
int interface_type
 What sort of interface this is. Default is INTERFACE_Tool.
Laxkit::anXAppapp
 The application this interface works with.
Laxkit::anXWindowcurwindow
 The window the interface currently works on.
anInterfaceowner
 The interface that owns this one.
anInterfacechild
 The child of this interface. See anInterface::owner. This is dec_counted in destructor.
int primary
 Whether this is supposed to be a 'main' interface, or merely a helper.
int needtodraw
 Whether the interface thinks it has to refresh.

Protected Member Functions

virtual void newData (int x, int y)
 Create new data for screen point x,y, with a count of 1 plus viewport counts via viewport->NewData(ndata).
virtual int PerformAction (int action)

Protected Attributes

int mx
int my
int draggingmode
int curpoint
Laxkit::NumStack< intcurpoints
 Stack of currently selected color spots.
flatpoint leftp
 the point in the gradient space that the button is clicked down on
Laxkit::ShortcutHandlersc
- Protected Attributes inherited from LaxInterfaces::anInterface
Laxkit::ButtonDownInfo buttondown
ViewportWindowviewport
 curwindow dynamically cast to ViewportWindow. Thus, it will be NULL if it is not a ViewportWindow.
Laxkit::Displayerdp
 The Displayer used by the controlling window.

Detailed Description

Manipulates GradientData objects.

With this interface, you can change gradients right on the screen and move around the little color indicators without having to open some other gradient editor.

Todo:
figure out how to incorporate color mapping functions..

Member Function Documentation

void LaxInterfaces::GradientInterface::drawLinear ( )
virtual

Draw linear gradient. Called from Refresh.

This assumes that dp has transform to object space.

Draws in x:[p1,p2], y:[r1,-r2]

References Laxkit::coloravg(), LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawline(), Laxkit::Displayer::DrawReal(), Laxkit::Displayer::DrawScreen(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, Laxkit::Displayer::NewFG(), and Laxkit::Displayer::realtoscreen().

Referenced by Refresh().

void LaxInterfaces::GradientInterface::drawRadial ( )
virtual

Draw radial gradient. Called from Refresh.

This assumes that dp has transform to object space.

Todo:
this could be rather a lot smarter... like by finding how many XPoints to generate based on the radius of the given circle...

References Laxkit::coloravg(), LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawlines(), Laxkit::Displayer::DrawReal(), Laxkit::Displayer::DrawScreen(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, Laxkit::Displayer::NewFG(), norm(), and Laxkit::Displayer::realtoscreen().

Referenced by Refresh().

void LaxInterfaces::GradientInterface::drawRadialLine ( double  t)
virtual

Draw a single line at t, where t==0 is data->p1 and t==1 is data->p2.

Uses the current color and line width settings. This should only be called from Refresh, as it assumes dp to be set to gradient space.

References LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawlines(), Laxkit::Displayer::DrawReal(), Laxkit::Displayer::DrawScreen(), norm(), and Laxkit::Displayer::realtoscreen().

Referenced by Refresh().

flatpoint LaxInterfaces::GradientInterface::getpoint ( int  c,
int  trans 
)
virtual

Return a flatpoint corresponding to point index c in data space coordinates, or transformed if (trans).

c is:

   -5  a
   -4  linear:(a,r1),  radial:(p1,r1) rotated by a
   -3  linear:(a,-r2), radial:(p2,r2) rotated by a
   -2  (p1,0)
   -1  (p2,0)
   >=0 color spot index.
  

Otherwise (0,0) is returned.

If trans, then transform the point by data->m().

References LaxInterfaces::GradientData::a, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, and Laxkit::transform_point().

Referenced by LBDown(), Refresh(), and scan().

const char * LaxInterfaces::GradientInterface::IconId ( )
virtual

Differentiates based on gradienttype.

Reimplemented from LaxInterfaces::anInterface.

References gradienttype.

int LaxInterfaces::GradientInterface::LBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const Laxkit::LaxMouse d 
)
virtual
const char * LaxInterfaces::GradientInterface::Name ( )
virtual

Differentiates based on gradienttype.

Reimplemented from LaxInterfaces::anInterface.

References gradienttype.

int LaxInterfaces::GradientInterface::Refresh ( )
virtual
int LaxInterfaces::GradientInterface::scan ( int  x,
int  y 
)
virtual

Scan for point.

Returns:

   -8=no data
   -7 data but not on it
   -6 on data but not on a point 
   -5 on controller for data->a
   -4 on r1
   -3 on r2
   -2 on p1
   -1 on p2
   >=0 color spot index.
  

References distance(), LaxInterfaces::anInterface::Getmag(), getpoint(), Laxkit::PtrStack< T >::n, norm(), LaxInterfaces::GradientData::pointin(), LaxInterfaces::anInterface::screentoreal(), Laxkit::transform_point(), and Laxkit::transform_point_inverse().

Referenced by LBDown().

int LaxInterfaces::GradientInterface::SelectPoint ( int  c)
virtual

Select a color spot (not p (c==-1) or p+v (c==-2)).

Returns 0 on success.

This only allows selecting the color spots. Perhaps in future allow select -1 or -2?

Todo:
could have state passed in...

References curpoints, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, LaxInterfaces::anInterface::needtodraw, Laxkit::NumStack< T >::pushnodup(), and sendcolor().

int LaxInterfaces::GradientInterface::sendcolor ( Laxkit::ScreenColor col)
virtual

Send a "make curcolor" event to the viewport.

Todo:
bit of a hack here.

References LaxInterfaces::anInterface::app, LaxInterfaces::anInterface::curwindow, and Laxkit::anXApp::SendMessage().

Referenced by LBDown(), and SelectPoint().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:58, Laxkit