InfernoLayer
Hook Functions
Init()
SaveState()
InitCheck()
Bounds()
GetData()
Render()
Thumb()
GetLayerConfig()
Cut()
Copy()
Paste()
Crop()
Perform()
InfernoLayer()
InfernoLayer(const BMessage *initmsg,InfernoCommon *IC)
|
|
Creates a new layer.
&
Layers define the data structure and method in which
the layer is stored and drawn. They are inited via
a passed in message created by the system which you
should pass along to your own Init() most likely
and can at any time be re-inited via Init(). The
Layer is responcible for managing all inter data,
Update its Bounds and its layer_status varibales.
Updateing layer_status is verry importatn becase
thats what InitCheck() rides on top of, and the
the core checks this quite reugularly.
Because layers can be of any type and not alwasy a
Bitmap we provide a GetData() method. You should
return a struct with relivant infomation to access
you layer as this is how Tools will get you content
to manipulate. This method is quick and dirty, but
does however work well. The only draw back is that
if you change your info structure that you pass
back to the tools .. the all the tools must be
recompiled to take advantage of your changes.
Layers shoud define there type by exporting
there name. This is the same name that gets
Returned via GetType() (which will be removed
in the future)
Somethink like the following should be in your
.cpp file.
LAYER_SYMBOLS char LAYER_TYPE[] = "Bitmap";
|
|
The Render method is the heart of the Layer. Each
layer is responsible for rendering itself to any
view that requests it. Render is given a clipping
rect that tells it what areas of the view that we
think are dirty (area rect is only provided as a
optimization feature, but we higly recomend that
you try and use it) The layer should also respect
its current Pos and its LayerAlpha. LayerAlpha is
a global transparancy level for the layer.
The SaveUndoState and ExecuteUndo are pritty simple.
Given a rect you need to save off any data that is
required to restor that area and store that info
off into the message. When a user wants to undo
a acction the message will be passed back to you
via ExecuteUndo().
At some Point we may want to add a extra data
field to the SaveUndoSate() as things like a
Vector area are not based on area, also the
Text Layer would need to know more about what
realy happend than just the dirty rect.
Some layers may need some spesific settings as
how they should draw or what mode they are in.
To present the user with the option to configure
these settings you can use GetLayerConfig(). You
are responcible for the view and should delete
it when your finished
~InfernoLayer()
boom
Init()
status_t Init(const BMessage *initmsg)
|
|
This will return a pointer to a layer spesifice
struct/BMessage/Bitmap whatever that can be edited
by tools.
The core uses this extensivly to ReInit layers when
doing this like filters and such.
|
You should call the inherated ver of this from
withing your own. It will inti the name/alpha/pos
automaticly for you.
|
SaveState()
void SaveState(BMessage *prefs)
|
|
This lets the layer save off its state. This comes
into use when we are copying layers or saveing them
off to disk
|
Call the inherited ver of this withing your
code to alow for Name/Alpha/Position restoration
|
InitCheck()
The core checks this value when createing
and Init()ing your layer. It returns layer_status,
a variable you should keep up to data at all times
with the current status of the Layers last action.
Bounds()
Returns the size of the layer
This is the root of all evil in Inferno regards to
bounds and bounds checking. You see we should be
returning W-1,H-1 .. but we don't. This causes
some pritty ugly errors down the line, however if
we change this it will effect lots of code, so we
let it be for now.
Bounds does not need to be virtual due
to the fact that we have a internal W
and H var in our class and Bounds pulls
from that, but some people may want to use
it for something crazy, so don't mess with it
unless you think you realy need to
GetData()
This will return a pointer to a layer spesifice
struct/BMessage/Bitmap whatever that can be edited
by tools
Example of getting bitmap layer data:
bitmap_layer_info *bli = (bitmap_layer_info*) ILay->GetData()
|
|
Render()
status_t Render(BRect area,BBitmap *final,BView *view)
|
|
The heart of a Layer. This will actually
render you layer date to a bitmap for displaying on
the screen. This should be FAST! we provide a rect
of the dirty area and a attached BView if you wish to
fall back to useing that to draw.
Thumb()
BBitmap* Thumb(int32 size = THUMB_NAIL_SIZE)
|
|
The Thumb method provides a quick way for you to
get a preview of the image (mainly for layer window)
This is the size that we create for our Thumb...
If one is not avaliable it will return NULL
A small note about the Thumb Bitmap your return
This bitmap is owned by us (the layer) so we can
cache it if we feel we are smart enough for that.
Also this means that we need to delete it when
we are finished or we create a new thumb or such.
GetLayerConfig()
Cut()
void Cut(BMessage *clip,BBitmap *selection)
|
|
From the area described by the Selection,
you should cut that out of this layer. Putting the
results into msg clip. This msg will be passed back
to you via the paste method.
Copy()
void Copy(BMessage *clip,BBitmap *selection)
|
|
Same as Cut but does not change the Layer
Paste()
void Paste(BMessage *clip)
|
|
Puts the data from clip into the layer
if clip is not of a valid Cut message (defined on a
layer basis) then you should do nothing.(return B_ERROR
but we didn't do that ops)
Crop()
status_t Crop(int32 deltaLeft,int32 deltaTop,int32 deltaRight,int32 deltaBottom)
|
|
IsHidden()
Lets others see if we are hidden
MoveTo()
void MoveTo(BPoint where)
|
|
Sets the new home (topleft corner) of this layer
MoveTo()
void MoveTo(float x, float y)
|
|
Sets the new home (topleft corner) of this layer
Position()
Returns where the topleft corner should be located
at when drawing this layer
GetType()
Retuns the type of layer we are. Thats is if we are
a 'Bitmap' Layer or a 'Vector' layer or 'Text' Layer
or any other type of layer.
GetEditTool()
This is the string (Name) of the Tool that we can
be edited by. A Bitmap tool has Generic editor which
will just pop up normal layer info, however a Text
layer would retun TextTool here so that when editing
this layer it knows what tool to invoke. This
however requires that the tool knows how to post-edit
a layer.
Name()
Return the human friendly name of this layer
Alpha()
Returns the Global Alpha value for this layer
SetName()
void SetName(const char *name)
|
|
Sets the Human friendly name of this layer
and posts I_LAYER_OTHER action
SetAlpha()
void SetAlpha(uint8 alpha)
|
|
Sets globale layer Alpha value and
postes Layer change I_LAYER_OTHER msg
Perform()
status_t Perform(perform_code d, void *arg)
|
|
Class Constants
Name
|
Description
|
LAYER_BOUNDS_BUG
|
if true then the Layer bounds bug has not been fixed.
|
THUMB_NAIL_SIZE
|
Default thumb size
|
|
Generated on 12/27/2001
Copyright © 1999-2001 Inferno Dev Team. All rights reserved.