Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "AmiDock and Dockies"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
 
(45 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
= Introduction =
 
= Introduction =
   
AmiDock is a toolbar system. It is a commodity program that will stay on the Workbench screen. Amidock allows the user to always have at hand program icons or to keep an eye on some information. This way it is very easy to run a program: one click is enough. Also Amidock can host some small programs that displays some information. The user can then get these information in a blink of an eye.
+
AmiDock is a tool to maintain a graphical menu bars (Docks) at the Workbench screen that can be used or to execute other programs from a selection of icons (either in the main Dock or in sub-Docks as specified by the AmiDock preferences), or to handle special kind of application called "Dockies", which can provide different functionality: render different kind of data right into the dock, provide user with a menu related to the Docky of choice and so on.
   
  +
AmiDock implemented as commodity, and together with being responsible for creating and controlling Docks and Dockies it provide different functionality such as ARexx support and a rich API by which your Dockies can control most of AmiDock's features.
== What is a Dock and a Docky ==
 
   
=== Dock ===
+
= What is a Dock and a Docky? =
A Dock is an area/a window (currently provided by the "AmiDock" commodity) where the user can put some icons and other stuff. Some may call it "Panels".
 
   
  +
== Dock ==
   
  +
A Dock is an area or window where the user can put a program icon or an interactive program.
So, Docks can be used as Launcher Panels:
 
 
   
 
[[File:Laucher_dock.png|center]]
 
[[File:Laucher_dock.png|center]]
   
  +
== Docky ==
   
  +
A Docky is a little program to be placed in a dock. Dockies are able to control most of AmiDock's features and provides a great way to expand AmiDock beyond its default functionality. Dockies may be invisible to the user or show static or dynamic (animated) content. You may change their behavior, size and look according to requirements. Dockies are one of two main types:
And as Tray Bar panels:
 
   
  +
=== Standalone Dockies ===
[[File:Tray_doc.jpg|center]]
 
   
  +
A standalone Docky is a special type of program which is made to show an icon in a Dock, delivering some functionality to the user. It is the most common type of Docky. This Docky type uses the standard shared library feature of AmigaOS as a common interface.
   
  +
=== Application Dockies ===
As anything else anyone can come up with: you can put everything inside of panels of any size, structure and design it as you wish.
 
   
  +
The second type of Docky is an application Docky which may sometimes be known as an 'AppDocky' or 'AppDockIcon Docky'. An AppDocky is a Docky which is introduced to the system at run time by an application using the application.library registration mechanism for applications. The biggest difference between the two types of Dockies types is that AppDockies belong to a running application and usually are used to represent the current state of the owning application.
=== Docky ===
 
 
A Docky is this item the user can place in the dock: a program icon or an interactive program. Dockies are able to control most of AmiDocks feature and provide a great way to expand AmiDocks features beyond its default features. Dockies may be invisible to the user or show static or dynamic (animated) content. You may change their behavior, size and look acording their current equirements. Dockies can be of 2 main types:
 
 
'''Standalone Dockies'''.
 
 
Is a special type of program which is made to show an icon in a Dock, delivering some functionality to the user. It is the most common form of Dockies. This docky-type uses the shared library feature of AmigaOS4 as common interface to the internal properties and behavioral possibilities of a docky.
 
 
'''Application Dockies'''.
 
 
That second type of dockies are application dockies (short form 'AppDockies' or as some call it 'AppDockIcon Dockies'). An AppDocky is a docky which is introduced to the system during runtime by an application using application.library registration mechanism for applications. The biggest diference between the two docky types is that AppDockies belong to a running application and usually are used to represent the current state of the owning application.
 
   
 
To sum up in "standalone dockies" the docky itself is the application (the only reason of existence of the application is the docky) while for "AppDockIcon dockies" the docky is just a graphical representation of a bigger application (the docky is just here to add user friendliness or visual feedback of the surrounding application)
 
To sum up in "standalone dockies" the docky itself is the application (the only reason of existence of the application is the docky) while for "AppDockIcon dockies" the docky is just a graphical representation of a bigger application (the docky is just here to add user friendliness or visual feedback of the surrounding application)
   
  +
= How to create and manipulate a simple docky =
= What is AmiDock =
 
   
  +
You write a docky just like you'd write a standard Exec library. In your code you must implement certain specifically-named functions like DockyGet(), DockyProcess(), DockySet() etc. The docky manager (AmiDock) calls these functions when it needs to.
== Dockies provided with AmigaOS4 ==
 
   
  +
See the [http://os4depot.net/share/utility/docky/datetime_docky.lha datetime.docky source code] to get started.
=== Access.docky ===
 
   
  +
= FAQ =
Single click with the left mouse button on this docky to open a list of screens and windows. Select a window and it will be activated and come to front (optionally). This docky especially is cool when using a hotkey - this way you can use the popup on EVERY screen. Just specify the hotkey like you do it with normal icons, too. Use the context menu to toggle to-front mode
 
   
  +
== Is it possible to create an application docky and then update its content on the fly and how? ==
=== Anim.docky ===
 
   
  +
Set the icon type to APPICONT_Docky; but you'll need to create a real docky as well then. If it doesn't need to be truly active it is possible just to change the icon's imagery (I think you have to un-register/re-register to get it to change though, so no good for frequent changes)
On a empty Anim.docky (no Animation assigned yet), drop a GIF-Animation (e.g. Boing#?.gif) on this dockie to change the current animation(in a selected dock) point with the mouse pointer over the docky and press the "+"/"-"-Keys to change animation speed. Use the context menu to specify a tool which shall be combined with this docky. You can also change the used animation here.
 
   
  +
== I have successfully drawn a datatype (a picture) in a Docky and the picture file has more than 256 colors but it is rendered in 256 colors only. Why? ==
=== Button.docky ===
 
   
  +
Just add PDTA_DestMode, PMODE_V43 to the NewDTObject call. You might also want to add DTA_GroupID, GID_PICTURE in order to restrict the file type to pictures.
On a empty Button.docky (no Picture assigned yet), drop a picture on this docky to change the current image. Use the context menu to specify a tool which shall be combined with this docky. You can also change the used picture here.
 
   
  +
== How are context menus created? ==
=== Clock.docky ===
 
   
  +
Context menus are dynamically built in response to DOCKYGET_ContextMenu attribute:
A analog clock in the dock. This docky changes automatically to a digital clock if you change to name or button style docks. Double click the docky or use the context menu to open the system time preferences.
 
   
  +
<syntaxhighlight>
=== Debugger.docky ===
 
  +
BOOL DockyGet (struct DockyIFace *Self, uint32 msgType, uint32 *msgData)
  +
{
  +
switch (msgType)
  +
{
  +
/* ... */
   
  +
case DOCKYGET_ContextMenu:
This docky opens a window and shows debugging information for docky-programmers. Needed only for people developing third-party dockies. Single-click it to enable/disable debug mode. Debugger.docky saves its state in its preferences. Use the context menu to toggle between single-dock and global (all docks) debugging.
 
  +
{
  +
Object *contextMenu = (Object *)msgData;
   
  +
Object *item1 = PopupMenuItemObject,
=== Lens.docky ===
 
  +
PMIA_Title, GetString(&li, LOCALE_ITEM_PREFS),
  +
PMIA_ID, PMID_PREFS,
  +
PopupMenuItemEnd;
   
  +
Object *item2 = PopupMenuItemObject,
Double click this docky to switch between normal or maximized view
 
  +
PMIA_Title, GetString(&li, LOCALE_ITEM_SAVEASDEFAULT),
  +
PMIA_ID, PMID_SAVEASDEFAULT,
  +
PopupMenuItemEnd;
   
  +
Object *item3 = PopupMenuItemObject,
Note: Normal and maximized view do have their own settings. Do that in a selected dock:
 
  +
PMIA_Title, GetString(&li, LOCALE_ITEM_USEASDEFAULT),
  +
PMIA_ID, PMID_USEASDEFAULT,
  +
PopupMenuItemEnd;
   
  +
if (item1 && item2 && item3)
point with the mouse pointer over the docky and press the key "x" - this will toggle between "cross-hair" mode and non-cross-hair mode.
 
  +
{
point with the mouse pointer over the docky and press the "+"/"-"-Keys to change the used magnification
 
  +
IIntuition->IDoMethod(contextMenu, OM_ADDMEMBER, item1);
point with the mouse pointer over the docky and press the key "c" to enable coordinates
 
  +
IIntuition->IDoMethod(contextMenu, OM_ADDMEMBER, item2);
point with the mouse pointer over the docky and press the key "v" to enable RGB values output (only available in a maximized lens!!)
 
  +
IIntuition->IDoMethod(contextMenu, OM_ADDMEMBER, item3);
point with the mouse pointer over the docky and press the key "g" to enable/disable the grid.
 
  +
}
   
  +
}
You can also use the context menu to change all the above described settings.
 
  +
break;
   
  +
/* ... */
=== Minimizer.docky ===
 
  +
}
  +
</syntaxhighlight>
   
  +
== How do you use an alpha layer for a Docky? ==
As soon as this docky was added to a dock (to make the docky "invisible" use another category for placing the docky), the dock will shrink to the minimized state after some time. As soon as the pointer is placed over the drag-bar, it expands to normal size. You can change the delay time until this docky minimizes the dock using the contextual menu.
 
   
  +
On non-composited screens, AmiDock uses a "fake" transparency effect (i.e. the bitmap is filled with the contents of the window behind the dock), meaning that you can only add things over the background but you cannot render half or totally transparent contents without doing the blending at the same time (or you'll lose background information).
=== Online.docky ===
 
   
  +
So if you want to support this configuration you need to follow this rule or provide an alternate rendering if you want to do fancy stuff when compositing is enabled.
Allows you to go on- and offline with RoadShow. Not fully implemented yet!!!
 
   
  +
Now, what you are trying to do should work on composited screens, but you have to tell AmiDock that you are using composited mode (see DOCKYGET_SupportsComposite and DOCKYGET_CompositeMode) so that it does not try to de-multiply the docky bitmap. Also I'm not sure you can use legacy pens to fill alpha channel, you're better off with direct ARGB painting (see SetRPAttrs() with RPTAG_APenColor).
=== Rainbow.docky ===
 
   
  +
== Is there a way to trigger a redraw from outside the docky? ==
This docky shows a colorful rainbow with alpha channel (!) - but nothing more. Double click it to toggle between icon and image view. This dock needs screen depth >8Bit. AmiDock will deny it on screen depths below 8Bit.
 
   
  +
Use DOCKYGET_NeedsAttention for this. This is how a docky can be notified from an external task by signaling AmiDock process. Quite straightforward, this is how e.g. [http://os4depot.net/share/utility/docky/winbar-docky.lha winbar.docky] ([http://os4depot.net/share/utility/docky/winbar_docky_src.zip source code is here], prefsobjects_macro.h include file which is required [http://openamiga.org/attachment/project/29/prefsobjects_macros.h here]) is told to rethink its layout in response to a change in preferences, or Intuition windows list. A shared structure and [[Exec_Mutexes|Mutex]] to protect the data. By the way, winbar.docky source code can be helpful not only for that, but for all other things such as adding context menus, firing requests to AmiDock or other of the many still undocumented features of the API.
=== Seperator.docky ===
 
   
  +
You are notified about the task/bit to signal through DOCKYSET_DockyAttention (you would store it in the library base for an easy access by the main program). When your program signals AmiDock, every docky is sent the DOCKYGET_NeedsAttention message, so it is a good idea to use a flag to know if the notification really comes from your program.
This docky is nothing more than just a seperator line. It automatically adjusts itself to the size and orientation of a dock.
 
   
  +
== How does DOCKYGET_SupportsComposite work? ==
=== SubDocks.docky ===
 
   
  +
When compositing is enabled, a docky receives a DOCKYGET_SupportsComposite query. If it returns TRUE, it will then receive a DOCKYGET_CompositeMode query to which it can reply either DOCKYCOMPMODE_PreblendedRGB (0) or DOCKYCOMPMODE_RawRGB (1). The former has no advantages over the previous method, but was included for backward compatibility. The latter, however, allows you to directly *copy* the source ARGB data to the destination bitmap (or buffer) rather than blend it yourself. This way, it will be AmiDock itself that does the blending (once) without the need to undo the
Use the shortcut Amiga+U to place it in the current dock or throw it in the dock which shall contain it...
 
  +
previous blending to get the raw RGB data.
   
  +
One thing to take into account when using this method, though, is that on a 16-bit screen you will get an actual 16-bit destination bitmap, not 32-bit as it happens when returning FALSE to DOCKYGET_SupportsComposite. In this case, you will need to write the alpha channel separately to the
- drag&drop a icon on it to configure its icon in AmiDock
 
  +
(8-bit) bitmap provided in the DockyRenderDestination's alpha.RP field.
- if you delete the subdock, the docky will remove itself automatically
 
- if you delete the docky, the docky will remove the subdock itself automatically
 
- (in a selected dock) point with the mouse pointer over the docky and press the key "p" to toggle between popupmode (default, closes the dock after a object was clicked) or normal mode (doesn't close the dock)
 
- Use the context menu to toggle the popup mode and ti change the icon.
 
   
=== Test.docky ===
+
= See Also =
The first docky ever written. Just a fun-docky. This docky "listens" to all possible events and shows this by flashing in some color when a action is detected. Move your mouse over the docky and click it. Drag&Drop several files on the docky and watch what happens. This dock needs screen depth >8Bit. AmiDock will deny it on screen depths below 8Bit.
 
   
  +
1. SDK:Documentation/AutoDocs/docky.doc
== AmiDock's hints ==
 
   
  +
2. SYS:Documentation/Commodities/AmiDock_Arexx.doc
- If the Minimizeable-Checkbox is checked, you can minimize a dock by double-clicking it's drag-bar.
 
 
- Bring to front/send to back can be done by double clicking on an empty area in a dock (SHIFT together with a dobule click will send it to back).
 
 
- in a selected dock: shift+click+hold on a icon and move around to interactively change the icon-position
 
 
- to interactively delete a icon or a whole dock: click+hold the object, press the Backspace or Delete key
 
 
= AmiDock's API =
 
 
= Different types of Dockies =
 
== Standalone Dockies ==
 
 
== AppDockIcon Dockies ==
 
 
= How to make a right Docky =
 
 
= How to make a Docky for tray-bar kind Docks =
 
 
If you as developer want to make your dockies to work in tray-bar kind docks, you need to make a docky more flexible, and you should follow some rulz when you do it:
 
 
1.
 
 
2.
 
 
3.
 
 
 
= FAQ =
 
 
= Final Words =
 
 
= Links =
 
 
1. SDK:Documentation/AutoDocs/docky.doc
 
   
  +
3. SDK:Examples/AmiDock/
2. Sys:Documentation/Commodities/AmiDock_Arexx.doc
 

Latest revision as of 11:27, 1 May 2014

Introduction

AmiDock is a tool to maintain a graphical menu bars (Docks) at the Workbench screen that can be used or to execute other programs from a selection of icons (either in the main Dock or in sub-Docks as specified by the AmiDock preferences), or to handle special kind of application called "Dockies", which can provide different functionality: render different kind of data right into the dock, provide user with a menu related to the Docky of choice and so on.

AmiDock implemented as commodity, and together with being responsible for creating and controlling Docks and Dockies it provide different functionality such as ARexx support and a rich API by which your Dockies can control most of AmiDock's features.

What is a Dock and a Docky?

Dock

A Dock is an area or window where the user can put a program icon or an interactive program.

Laucher dock.png

Docky

A Docky is a little program to be placed in a dock. Dockies are able to control most of AmiDock's features and provides a great way to expand AmiDock beyond its default functionality. Dockies may be invisible to the user or show static or dynamic (animated) content. You may change their behavior, size and look according to requirements. Dockies are one of two main types:

Standalone Dockies

A standalone Docky is a special type of program which is made to show an icon in a Dock, delivering some functionality to the user. It is the most common type of Docky. This Docky type uses the standard shared library feature of AmigaOS as a common interface.

Application Dockies

The second type of Docky is an application Docky which may sometimes be known as an 'AppDocky' or 'AppDockIcon Docky'. An AppDocky is a Docky which is introduced to the system at run time by an application using the application.library registration mechanism for applications. The biggest difference between the two types of Dockies types is that AppDockies belong to a running application and usually are used to represent the current state of the owning application.

To sum up in "standalone dockies" the docky itself is the application (the only reason of existence of the application is the docky) while for "AppDockIcon dockies" the docky is just a graphical representation of a bigger application (the docky is just here to add user friendliness or visual feedback of the surrounding application)

How to create and manipulate a simple docky

You write a docky just like you'd write a standard Exec library. In your code you must implement certain specifically-named functions like DockyGet(), DockyProcess(), DockySet() etc. The docky manager (AmiDock) calls these functions when it needs to.

See the datetime.docky source code to get started.

FAQ

Is it possible to create an application docky and then update its content on the fly and how?

Set the icon type to APPICONT_Docky; but you'll need to create a real docky as well then. If it doesn't need to be truly active it is possible just to change the icon's imagery (I think you have to un-register/re-register to get it to change though, so no good for frequent changes)

I have successfully drawn a datatype (a picture) in a Docky and the picture file has more than 256 colors but it is rendered in 256 colors only. Why?

Just add PDTA_DestMode, PMODE_V43 to the NewDTObject call. You might also want to add DTA_GroupID, GID_PICTURE in order to restrict the file type to pictures.

How are context menus created?

Context menus are dynamically built in response to DOCKYGET_ContextMenu attribute:

BOOL DockyGet (struct DockyIFace *Self, uint32 msgType, uint32 *msgData) 
{ 
switch (msgType) 
{ 
/* ... */ 
 
case DOCKYGET_ContextMenu: 
{ 
Object *contextMenu = (Object *)msgData; 
 
Object *item1 = PopupMenuItemObject, 
        PMIA_Title, GetString(&li, LOCALE_ITEM_PREFS), 
        PMIA_ID, PMID_PREFS, 
    PopupMenuItemEnd; 
 
    Object *item2 = PopupMenuItemObject, 
        PMIA_Title, GetString(&li, LOCALE_ITEM_SAVEASDEFAULT), 
        PMIA_ID, PMID_SAVEASDEFAULT, 
    PopupMenuItemEnd; 
 
    Object *item3 = PopupMenuItemObject, 
        PMIA_Title, GetString(&li, LOCALE_ITEM_USEASDEFAULT), 
        PMIA_ID, PMID_USEASDEFAULT, 
    PopupMenuItemEnd; 
 
if (item1 && item2 && item3) 
    { 
        IIntuition->IDoMethod(contextMenu, OM_ADDMEMBER, item1); 
        IIntuition->IDoMethod(contextMenu, OM_ADDMEMBER, item2); 
        IIntuition->IDoMethod(contextMenu, OM_ADDMEMBER, item3); 
    } 
 
} 
break; 
 
/* ... */ 
}

How do you use an alpha layer for a Docky?

On non-composited screens, AmiDock uses a "fake" transparency effect (i.e. the bitmap is filled with the contents of the window behind the dock), meaning that you can only add things over the background but you cannot render half or totally transparent contents without doing the blending at the same time (or you'll lose background information).

So if you want to support this configuration you need to follow this rule or provide an alternate rendering if you want to do fancy stuff when compositing is enabled.

Now, what you are trying to do should work on composited screens, but you have to tell AmiDock that you are using composited mode (see DOCKYGET_SupportsComposite and DOCKYGET_CompositeMode) so that it does not try to de-multiply the docky bitmap. Also I'm not sure you can use legacy pens to fill alpha channel, you're better off with direct ARGB painting (see SetRPAttrs() with RPTAG_APenColor).

Is there a way to trigger a redraw from outside the docky?

Use DOCKYGET_NeedsAttention for this. This is how a docky can be notified from an external task by signaling AmiDock process. Quite straightforward, this is how e.g. winbar.docky (source code is here, prefsobjects_macro.h include file which is required here) is told to rethink its layout in response to a change in preferences, or Intuition windows list. A shared structure and Mutex to protect the data. By the way, winbar.docky source code can be helpful not only for that, but for all other things such as adding context menus, firing requests to AmiDock or other of the many still undocumented features of the API.

You are notified about the task/bit to signal through DOCKYSET_DockyAttention (you would store it in the library base for an easy access by the main program). When your program signals AmiDock, every docky is sent the DOCKYGET_NeedsAttention message, so it is a good idea to use a flag to know if the notification really comes from your program.

How does DOCKYGET_SupportsComposite work?

When compositing is enabled, a docky receives a DOCKYGET_SupportsComposite query. If it returns TRUE, it will then receive a DOCKYGET_CompositeMode query to which it can reply either DOCKYCOMPMODE_PreblendedRGB (0) or DOCKYCOMPMODE_RawRGB (1). The former has no advantages over the previous method, but was included for backward compatibility. The latter, however, allows you to directly *copy* the source ARGB data to the destination bitmap (or buffer) rather than blend it yourself. This way, it will be AmiDock itself that does the blending (once) without the need to undo the previous blending to get the raw RGB data.

One thing to take into account when using this method, though, is that on a 16-bit screen you will get an actual 16-bit destination bitmap, not 32-bit as it happens when returning FALSE to DOCKYGET_SupportsComposite. In this case, you will need to write the alpha channel separately to the (8-bit) bitmap provided in the DockyRenderDestination's alpha.RP field.

See Also

1. SDK:Documentation/AutoDocs/docky.doc

2. SYS:Documentation/Commodities/AmiDock_Arexx.doc

3. SDK:Examples/AmiDock/