NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 15 16 17 18 19 … 93 Next »
Bending ButtonStrip to my will - Setting button attributes at runtime

 
  • 0 Vote(s) - 0 Average
Bending ButtonStrip to my will - Setting button attributes at runtime
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#1
2010-11-13, 12:37 PM
So, when npvr (or whatever name it finished with) was first released, I put aside any plugin development until it and the API had matured a little.

Tonight, feeling motivated, I decided to give moving the pvrx2 plugin code across - and almost immediately hit a wall.

So, let's start with wall one. I would very much like to stick with the horizontal buttonstip style, since that is what is use through the rest of npvr, and, it provides additional horizontal space for the main pane.

However, I have a number of different buttons that may or may not need to be made available depending on what options the user has selected.

The button attributes (location, size) are all hardcoded in the skin file - and I've been able to find no means to use, for example, "@button1size". Which leaves me having to design for the widest button, which just looks silly.

Beyond rolling my own control from scratch, are there any recommendations in using the buttonstrip to do what I need it to do? That is, resize itself and its contents, based on the button text provided, using the skin-supplied font?
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#2
2010-12-07, 11:45 AM
Augh - so I'm trying to recreate it myself, with little to no success. Closer to no, really.

Seems every uiElement must have a named <element> node in the skin xml - which is exactly what I'm trying to avoid. Am I missing something - again?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,661
Threads: 767
Joined: Nov 2003
#3
2010-12-07, 05:10 PM
Ommina Wrote:Seems every uiElement must have a named <element> node in the skin xml - which is exactly what I'm trying to avoid. Am I missing something - again?
A UiElement doesnt need to have a <Element> node in the skin.xml. It contains a bitmap, which you could have got from anywhere. Most people get that bitmap using the SkinHelper, which is designed to get it from skin.xml file, but you dont have to get it from there. ie, you can create your own bitmap and draw the text wherever you want.

That said, do you really need this? If, for example, you wanted to always show at least two buttons, but sometimes four, then just define the maximum four buttons in the skin element, and the unused ones wont be shown.

I have modified the skinhelper to allow you pass in the location and size of the sub elements as parameters though:
Code:
    <Element name="SomeElement" location="0,20" size="100,70" alpha="180" visibleRows="7">
        <Text text="@someText" location="@someTextX,@someTextY" size="90,10" font="TitleText" align="center"/>
        <Text text="@someText2" location="@someText2X,@someText2Y" size="@someText2W,@someText2H" font="TitleText" align="center"/>
    </Element>
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#4
2010-12-08, 09:13 AM
Sigh. I did try using a Bitmap when creating the uiElement, but it didn't work, so I went back to the SkinHelper version. I realize, now, that it didn't work because I created the Bitmap in a using block so it would be disposed - and it was. Why that was lost on me last night when it's so obvious 18 hours later...

My objection to the plan of defining the maximum number of buttons required and leaving the extra unused is strictly an aesthetic one. I would have to create all buttons the width of the largest text, which works great for the button list, but looks silly for the button strip. Further, the parent RoundedRectangle would then need to be large enough to fit all those buttons, leaving an extra blob at the end if not all buttons are used. It lacks sexiness!

But! With the addition of the parameter-able location and size values, I'm not confined to the skin-defined widths, so both my concerns fade gently away. (And I get to relax until the next release. . .)
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#5
2011-04-09, 07:48 AM (This post was last modified: 2011-04-09, 10:56 AM by Ommina.)
Rise my thread, RISE, RISE!

sub Wrote:I have modified the skinhelper to allow you pass in the location and size of the sub elements as parameters though:

OK, I have to check -- did this change make it in? Because even if I do something fairly minor - for example, change a size="18,75.28" to a size="@foo,75.28", then .add("@foo", 18.0), the results just don't fly.

The menustrip is displayed as expected on startup, but as soon as I hit a key, the text takes a jump to the left. If I use it on a RoundedRect, it seems to have a width of zero.

It seems pretty straightforward. Am I doing something wrong? If I dump out all the args + values of the UiButtonStrip, the "@foo" is there, with a value of 18.0.

I'm at a loss! (Or maybe just spoiled by JavaWiz having shielded me from all this the first time through.)

Edit:

It seems if I add the "@foo" via the .args property (after object creation) instead of having it included in the hasttable provided to the constructor, I don't even get the one startup render correct.

Edit2!:

I don't know if this is related, or just another sign that I'm doing something wrong. Is UiButtonStrip always supposed to return true for needsRendering ? As soon as I enter the plugin, CPU usage spikes. I'm implementing IScreenPlugin, so maybe I'm missing something there yet.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,661
Threads: 767
Joined: Nov 2003
#6
2011-04-09, 05:10 PM
Can you see if this helps?
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#7
2011-04-10, 09:36 AM
sub Wrote:Can you see if this helps?

It does, thank you! It's nice to know that I wasn't going loopy.

One gotcha that came with it - it gets very angry if I add an integer to the hashtable instead of a float; it gives an invalid cast exception.

Not a big deal, but, if this thread has any readers looking to try out feeding @stuff to those attributes, give it floats, not ints.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,661
Threads: 767
Joined: Nov 2003
#8
2011-04-10, 04:43 PM
I've modified it for the next release to cope with float, double and int.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  API / web call for setting recordings Pbathuk 2 3,276 2018-01-13, 05:17 AM
Last Post: Pbathuk
  Update NewSyleListPlugin Button list dynamically? psycik 2 1,727 2011-12-22, 12:25 AM
Last Post: mvallevand
  Access 'Stay on top' setting from a plugin? McBainUK 5 2,355 2011-11-07, 04:43 PM
Last Post: sub
  Bending ListView to my will (a variation on a theme) Ommina 19 5,282 2011-05-20, 05:53 AM
Last Post: sub
  Installer setting folder permissions..bad idea? Fatman_do 3 1,862 2009-11-30, 04:07 PM
Last Post: zehd
  reading the skin.xml file attributes idkpmiller 2 1,493 2009-02-03, 09:23 AM
Last Post: idkpmiller
  GBPVRX2.Popups.PopupBase don't close on button press psycik 2 1,440 2008-11-03, 07:35 AM
Last Post: psycik
  Setting recording externally NumberFive 1 1,184 2008-01-21, 03:45 PM
Last Post: sub
  newb: How to add setting/control panel to plugin capone 3 1,617 2007-06-06, 04:30 AM
Last Post: sub
  Setting compression parameters on HW encoders tmrt 5 2,002 2007-05-21, 04:13 PM
Last Post: sub

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

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

Linear Mode
Threaded Mode