NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 32 33 34 35 36 … 93 Next »
Too many buttons in plugin

 
  • 0 Vote(s) - 0 Average
Too many buttons in plugin
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#1
2008-05-06, 04:49 AM
Is there a way to limit the number of buttons displayed in a plugin's menu? If not, is there a way to refresh the call to getButtonList()? I've got too many menu buttons and they get rendered off the screen. I think I have a method of resolving this but I wanted to make sure I wasn't overcomplicating it.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 108,479
Threads: 784
Joined: Nov 2003
#2
2008-05-06, 05:09 AM
Unfortunately no, there is nothing built in to handle this.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#3
2008-05-06, 05:11 AM
No problem, as I said, I think I found a workaround. Thanks for the reply.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#4
2008-05-06, 05:15 AM
One more quick question, is there a way to get the selected button? I though I saw a method for this but I can't find it now.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 108,479
Threads: 784
Joined: Nov 2003
#5
2008-05-06, 05:22 AM
Again, unfortunately no. The BaseButtonListUiTask plugins arent aware of which is highlighted until the use clicks it, at which time handleCommand() method is executed.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#6
2008-05-06, 05:28 AM
No problem, I'll figure something out.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#7
2008-05-06, 09:05 AM
I figured it out. To wrap up this thread and in case anyone else wants to do this, there may be an easier way but this worked for me:

Add the following global variables to your plugin:
Code:
List<UiButton> DisplayedButtons = new List<UiButton>(); List<System.Drawing.RectangleF> ButtonPositions = new List<System.Drawing.RectangleF>(); private int maxButtons = 10; // The number of buttons you want to display; private int lastActiveButton = 0;

Then for your getRenderList():
Code:
public override ArrayList GetRenderList() { ArrayList rList = base.GetRenderList(); ArrayList newRenderList = new ArrayList(); ArrayList bList = buttonList; bool activeButtonFound = false; for (int x = 0; x < buttonList.Count; x++) { UiButton button = (UiButton)buttonList[x]; if (button.isActive() || button.buttonState == UiButton.State.Activating) { if (!DisplayedButtons.Contains(button)) { DisplayedButtons = new List<UiButton>(); if (x == 0 || lastActiveButton == 0 || lastActiveButton < x) { if (x > maxButtons - 1) { for (int y = x - (maxButtons - 1); y < (x + 1); y++) DisplayedButtons.Add((UiButton)buttonList[y]); } else for (int y = 0; y < maxButtons; y++) DisplayedButtons.Add((UiButton)buttonList[y]); } else { if (x == buttonList.Count - 1) { for (int y = buttonList.Count - (maxButtons + 1); y < buttonList.Count; y++) DisplayedButtons.Add((UiButton)buttonList[y]); } else for (int y = x; y < x + maxButtons; y++) DisplayedButtons.Add((UiButton)buttonList[y]); } } activeButtonFound = true; lastActiveButton = x; break; } } if (!activeButtonFound && DisplayedButtons.Count == 0) for (int x = 0; x < maxButtons; x++) DisplayedButtons.Add((UiButton)buttonList[x]); foreach (GBPVRUiElement elem in rList) { if (!elem.name.StartsWith("button-")) { newRenderList.Add(elem); } else { ButtonPositions.Add(elem.rect); for (int x = 0; x < DisplayedButtons.Count; x++) { if (elem.name.StartsWith(string.Format("button-{0}", DisplayedButtons[x].name))) { elem.SetRect(ButtonPositions[x]); newRenderList.Add(elem); break; } } } } return newRenderList; }
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#8
2008-05-07, 07:04 PM
Just a warning. The above code only works for keyboard and remote commands. Mouse clicking a button could result in an undisplayed button being activated.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  PIP plugin for Kodi sgilani 2 5,481 2022-10-17, 12:44 AM
Last Post: sgilani
  New Systems Plugin kirschey 10 5,720 2020-11-14, 08:01 PM
Last Post: sub
  VIdeo playback from plugin mvallevand 5 5,067 2015-08-06, 10:43 PM
Last Post: sub
  Attention Sub: Open TV / Custom Data Grabber plugin Benoire 2 3,900 2014-11-14, 02:05 AM
Last Post: Benoire
  API docs to help with plugin development? McBainUK 3 3,762 2013-06-08, 06:14 PM
Last Post: sub
  Refreshing TV Guide Data (after System plugin EPG update) imilne 13 8,196 2013-03-24, 08:03 PM
Last Post: imilne
  sabnzbd plugin to show processed files Wakalaka 1 2,835 2013-03-12, 06:48 AM
Last Post: psycik
  Plugin problems with started from the command line mvallevand 11 6,859 2012-08-12, 07:56 PM
Last Post: sub
  Get NextPVR data directory from outside a plugin McBainUK 3 3,150 2012-02-11, 05:42 PM
Last Post: mvallevand
  Weather Plugin imilne 0 2,102 2012-01-15, 08:33 PM
Last Post: imilne

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode