Laxkit
0.0.7.1
|
Manipulates GradientData objects. More...
Public Member Functions | |
GradientInterface (int nid, Laxkit::Displayer *ndp) | |
Default is a linear black to red. | |
virtual | ~GradientInterface () |
Empty destructor. | |
virtual Laxkit::ShortcutHandler * | GetShortcuts () |
virtual anInterface * | duplicate (anInterface *dup) |
Return dup of this. Copies over creationstyle, creatp/v, createlen, col1, col2. | |
virtual const char * | IconId () |
virtual const char * | Name () |
virtual const char * | whattype () |
virtual const char * | whatdatatype () |
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 ObjectContext * | Context () |
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::MenuInfo * | ContextMenu (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::anXWindow * | CurrentWindow (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 Attribute * | dump_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. | |
GradientData * | data |
ObjectContext * | goc |
Public Attributes inherited from LaxInterfaces::anInterface | |
char * | name |
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::anXApp * | app |
The application this interface works with. | |
Laxkit::anXWindow * | curwindow |
The window the interface currently works on. | |
anInterface * | owner |
The interface that owns this one. | |
anInterface * | child |
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< int > | curpoints |
Stack of currently selected color spots. | |
flatpoint | leftp |
the point in the gradient space that the button is clicked down on | |
Laxkit::ShortcutHandler * | sc |
Protected Attributes inherited from LaxInterfaces::anInterface | |
Laxkit::ButtonDownInfo | buttondown |
ViewportWindow * | viewport |
curwindow dynamically cast to ViewportWindow. Thus, it will be NULL if it is not a ViewportWindow. | |
Laxkit::Displayer * | dp |
The Displayer used by the controlling window. |
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.
|
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().
|
virtual |
Draw radial gradient. Called from Refresh.
This assumes that dp has transform to object space.
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().
|
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().
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().
|
virtual |
Differentiates based on gradienttype.
Reimplemented from LaxInterfaces::anInterface.
References gradienttype.
|
virtual |
Creates new data if not click down on one...
Shift-click makes a new color spot.
Get rid of old data if not clicking in it.
Reimplemented from LaxInterfaces::anInterface.
References LaxInterfaces::GradientData::AddColor(), Laxkit::ButtonDownInfo::any(), LaxInterfaces::ViewportWindow::ChangeObject(), curpoints, deletedata(), Laxkit::ButtonDownInfo::down(), LaxInterfaces::GradientData::dump_out(), LaxInterfaces::ObjectContext::duplicate(), Laxkit::NumStack< T >::e, Laxkit::PtrStack< T >::e, LaxInterfaces::ViewportWindow::FindObject(), Laxkit::NumStack< T >::flush(), getpoint(), Laxkit::anObject::inc_count(), leftp, Laxkit::NumStack< T >::n, Laxkit::PtrStack< T >::n, LaxInterfaces::anInterface::needtodraw, newData(), Laxkit::NumStack< T >::pop(), LaxInterfaces::anInterface::primary, Laxkit::NumStack< T >::push(), Laxkit::NumStack< T >::pushnodup(), scan(), LaxInterfaces::anInterface::screentoreal(), sendcolor(), Laxkit::transform_point_inverse(), Laxkit::ButtonDownInfo::up(), and LaxInterfaces::anInterface::viewport.
|
virtual |
Differentiates based on gradienttype.
Reimplemented from LaxInterfaces::anInterface.
References gradienttype.
|
virtual |
Refresh, calls drawLinear() and drawRadial(), then draws decorations.
Reimplemented from LaxInterfaces::anInterface.
References Laxkit::Displayer::BlendMode(), curpoints, LaxInterfaces::anInterface::dp, Laxkit::Displayer::drawarrow(), Laxkit::Displayer::drawline(), drawLinear(), Laxkit::Displayer::drawpoint(), drawRadial(), drawRadialLine(), Laxkit::Displayer::DrawReal(), Laxkit::Displayer::DrawScreen(), Laxkit::NumStack< T >::e, Laxkit::PtrStack< T >::e, getpoint(), LaxInterfaces::SomeData::GetPreview(), Laxkit::LaxImage::h(), Laxkit::Displayer::imageout(), Laxkit::LAXOP_Source, Laxkit::Displayer::LineAttributes(), Laxkit::NumStack< T >::n, Laxkit::PtrStack< T >::n, LaxInterfaces::anInterface::needtodraw, Laxkit::Displayer::NewFG(), Laxkit::Displayer::realtoscreen(), usepreview, and Laxkit::LaxImage::w().
Referenced by DrawData().
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().
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?
References curpoints, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, LaxInterfaces::anInterface::needtodraw, Laxkit::NumStack< T >::pushnodup(), and sendcolor().
|
virtual |
Send a "make curcolor" event to the viewport.
References LaxInterfaces::anInterface::app, LaxInterfaces::anInterface::curwindow, and Laxkit::anXApp::SendMessage().
Referenced by LBDown(), and SelectPoint().