Cruisers Forum
 

Go Back   Cruisers & Sailing Forums > Seamanship, Navigation & Boat Handling > OpenCPN
Cruiser Wiki Click Here to Login
Register Vendors FAQ Community Calendar Today's Posts Log in

Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 18-01-2015, 09:12   #1
Marine Service Provider

Join Date: Dec 2014
Posts: 46
Plugin Icons - How to Toggle/Rollover?

Hello,

I'm new to OpenCPN plugins world. Trying to figure out how to toggle a toolbar's icon when it's pressed, as well as switch the image on mouse-over event. Am I on the right track with using these two functions?

SetToolbarItemState()
SetToolbarToolBitmaps()

Tried calling them but there don't seem to be any changes.

Thank you.
Skipper Web is offline   Reply With Quote
Old 18-01-2015, 12:11   #2
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: Plugin Icons - How to Toggle/Rollover?

Skipper Web...
SetToolbarItemState() sets the pressed/depressed state of your toolbar icon. That is the only thing you can control in regards of mouse events on the toolbar and typically is called from
Code:
void myplugin_pi::OnToolbarToolCallback ( int id )
{
    m_iconpressed = !m_iconpressed;
    SetToolbarItemState( id, m_iconpressed );
}
To receive this callback, you must return WANTS_TOOLBAR_CALLBACK from myplugin_pi::Init()

The ability to define the hover state icon was disabled in the core when the UI styles were introduced and currently the toolbar generates the icon representaion from the first bitmap parameter of InsertPlugInTool() - the API is unchanged for backward compatibility.

You don't need SetToolbarToolBitmaps at all unless you want to change your icons based on the state of the plugin at runtime.

If you need more help, push your code to github or similar place.

Pavel
nohal is offline   Reply With Quote
Old 18-01-2015, 14:34   #3
Marine Service Provider

Join Date: Dec 2014
Posts: 46
Re: Plugin Icons - How to Toggle/Rollover?

Thank you! That worked. Well, almost. In the clicked state the icon shifts to the left upper corner. Is it correct to assume that the icon is supposed to be 32x32 pixels, with alpha background?
Skipper Web is offline   Reply With Quote
Old 18-01-2015, 15:12   #4
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: Plugin Icons - How to Toggle/Rollover?

Yes, 32x32 with alpha. The "shift" is a result of the toggled icon creation in the core code. If it annoys you enough (it so far does not to me), you may send a patch for the process starting at https://github.com/OpenCPN/OpenCPN/b...tyles.cpp#L352

Pavel
nohal is offline   Reply With Quote
Old 18-01-2015, 15:50   #5
Marine Service Provider

Join Date: Dec 2014
Posts: 46
Re: Plugin Icons - How to Toggle/Rollover?

Thank you. That code is above my level for now. I'll settle on a non-alpha version to avoid shifts.

Since I have your attention, a somewhat unrelated question. Is it possible to change cursor from within plugin? Love what Create Route tool does with a pencil. Tried calling and got nowhere with this as a test:

::wxSetCursor(*wxCROSS_CURSOR)
Skipper Web is offline   Reply With Quote
Old 18-01-2015, 16:38   #6
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,211
Re: Plugin Icons - How to Toggle/Rollover?

I don't see your code, but suppose you should change the cursor on the canvas window.
Something like
Code:
int myplugin_pi::Init()
{
...
m_parent_window = GetOCPNCanvasWindow();
...
}

void myplugin_pi::Whatever()
{
...
m_parent_window->SetCursor(wxCURSOR_CROSS);
...
m_parent_window->SetCursor(wxCURSOR_DEFAULT);
...
}
nohal is offline   Reply With Quote
Old 18-01-2015, 16:41   #7
Marine Service Provider

Join Date: Dec 2014
Posts: 46
Re: Plugin Icons - How to Toggle/Rollover?

Makes sense. I didn't realize the need to use canvas. Thank you!

I will share the code as soon as it's presentable. Not much to look at just yet.
Skipper Web is offline   Reply With Quote
Reply

Tags
plug


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenCPN Plugin Icons phiggins OpenCPN 30 11-10-2012 02:23
Open CPN - AIS Tab - No Rollover Options Colin Stone OpenCPN 1 14-10-2010 08:29
Challenge: Capsize to 180° Most Likely to Continue to full 360° Rollover? Lodesman Challenges 20 03-02-2010 14:31
Furuno GPS - 'GPS Week Number Rollover' bitman Navigation 0 25-11-2009 03:53
A near 360 degree rollover knockdown watersofdiego General Sailing Forum 4 07-12-2008 12:29

Advertise Here


All times are GMT -7. The time now is 16:11.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.