Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 18-01-2015, 10: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, 13:11   #2
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
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, 15: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, 16:12   #4
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
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, 16: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, 17:38   #6
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
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, 17: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

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 03:23
Open CPN - AIS Tab - No Rollover Options Colin Stone OpenCPN 1 14-10-2010 09:29
Challenge: Capsize to 180 Most Likely to Continue to full 360 Rollover? Lodesman Challenges 20 03-02-2010 15:31
Furuno GPS - 'GPS Week Number Rollover' bitman Navigation 0 25-11-2009 04:53
A near 360 degree rollover knockdown watersofdiego General Sailing Forum 4 07-12-2008 13:29



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

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


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.