Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#4386 closed Patches (Committed)

Live Filter - highlight the matching filter?

Reported by: bripeace Owned by: jmarshall
Priority: 4 - Normal Milestone: 8.10 "Babylon"
Component: Graphical User Interface (GUI) Version: GIT
Severity: Normal Keywords:
Cc: Blocked By:
Blocking: Platform: All
Revision: 1459


This patch adds the ability to in the Library video nav to filter based on a sort of predictive text input. For instance in TV Show list view you can hit 468 (hou) and it will match House for you.

There is more discussion at this forum thread:

Attachments (5)

livefilter.diff (7.4 KB) - added by bripeace 7 years ago.
First Live Filter Patch
livefilter-2.diff (9.4 KB) - added by bripeace 7 years ago.
+highlight and WordToDigits function
livefilter-3.diff (12.9 KB) - added by jmarshall 7 years ago.
livefilter-4.diff (16.5 KB) - added by bripeace 6 years ago.
+Keyboard Live Filter and Skinable Highlight
livefilter-5.diff (21.1 KB) - added by bripeace 6 years ago.
Cleanup, bug fixes

Download all attachments as: .zip

Change History (21)

Changed 7 years ago by bripeace

First Live Filter Patch

comment:1 Changed 7 years ago by jmarshall

Thanks - patch looks great.

Obviously the main room for improvement is making the convert to number routine a little more efficient.

Something along the lines of:

WordToNumber(CStdString &word) {

static const char word_to_letter[] = "22233344455566677778889999"; word.ToLower(); for (unsigned int i = 0; i < word.size(); ++i) { NB: This assumes ascii, which probably needs extending at some point.

char letter = word[i]; if (letter >= 'a' && letter <= 'z') assume contiguous letter range

word[i] = word_to_letter[letter];


word[i] = ' '; replace everything else with a space



Also, I think using FindWord() will still work once it's converted to numbers anyway?

Filtering can work by FindWord() returning the index of where it's found. You then format the string up as follows:

Searching for YYYY yields this:


replace with this:


will highlight in red. There'd have to be some more trickery to get the highlight colour skinnable - perhaps we could do a [HIGHLIGHT] block - that's something I can take care of though. We'd also have to make sure we strip any already occuring [COLOR] blocks. It may be better to separate out the rendered label and the underlying text that gives us that label.

Now, how to get it working for the keyboard is an interesting problem. We could have a button that switches an input state boolean in the window class, and then in CApplication::OnKey() we could test said input state and send key messages rather than translated actions might be an idea.

If you wouldn't mind addressing the efficiency stuff (and anything else you wish to do with it) then we can get this in to SVN as-is and can add the keyboard input side of things afterwards.

Cheers, Jonathan

comment:2 Changed 7 years ago by jmarshall

  • Owner set to jmarshall
  • Status changed from new to accepted

Changed 7 years ago by bripeace

+highlight and WordToDigits function

comment:3 Changed 7 years ago by bripeace

I took your code for the wordtodigits, added that plus some things it needed. I also got highlight working. I'm a bit unhappy about it. The problem being adding in the highlighting then having to remove it any time the filter is update to do the searching then adding it back in the right spot. It just seems like it could be done better, but it does work and pretty decently.

I.E if you search h house found! insert highlight [c]h[c]ouse

add o so search for ho remove remove highlight before search house found ho! insert highlight [c]ho[c]use

if you can point me in the direction or you could take care of the [highlight] tag that would at least simplify things a bit since I could make a generic function AddHighlight(str, pos,len) RemoveHighlight which could work on labels and make it skinable as you say.

As for the keyboard stuff - if you look at how it is now it actually works much like you suggest. If you open the filter dialog and type and wait with the dialog still open it will update the list in the background. Matter of fact if you type and hit done too fast it won't update at all. I'm not entirely sure why it works like this.

Anyhow highlight works, I think it's an improvement.

comment:4 Changed 7 years ago by anonymous

Great work. Will take a look and get some initial support in to SVN so that people with remotes can start testing.

I think until we get the keymapping thing completely sorted, what I'll do is have a setting in the UI to enable and disable it. Then instead of relying on the keymapping I'll override it and look for remote button presses directly (and possibly also to keyboard number presses for those without remotes to test as well).

Cheers, Jonathan

Changed 7 years ago by jmarshall

comment:5 Changed 7 years ago by jmarshall

Have added my version of the diff - not many changes just cleanups mostly.

Problems with it are:

  1. Highlighting is not skinnable.
  1. Text we search for is limited to the label, which the skin may or may not use. Skinners can access many fields directly in the CFileItem so do not necessarily use the label we define in the code.
  1. No support for anything other than remotes. Keyboard input would be nice, but I think would require some sort of new action to start the filter. Having some sort of updating field would be nice for keyboard (eg use an edit control).

A possible solution to 2 is:

Grab the CGUIListItemLayout from the item and find out which strings it's using, either modifying them directly with highlight information, or searching + updating the fields which they access.

Will post a win32 binary on SF if I can so that others can test.

Cheers, Jonathan

comment:6 Changed 7 years ago by bripeace

Just a quick update. I have keyboard searching working. Currently you hit tab to toggle then type and it does the filtering. It's setup much like you describe m_filterInput in window catch in OnKey send to filteritems etc. I still have a bit to go before a post a patch things that still need to be done:

Catch FilterInput button action so you don't try to filter it (like tab) Prevent FilterInput key from being a letter or number Ignore all Non- Numeric/Alpha Fix 1-9 (currently they show up as lowercase a-whatever) this has to do with the unicode and all that I'm unfamiliar with Disable actions on buttons that already have actions while FilterInput is on.

I plan to get all that done and get a patch posted tonight, though it probably won't be till late.

Also, I guess we should consider abstracting this filtering a bit so it can be used in more windows. Either way I'll fix it for music as I can see it being very valuable there as well.

comment:7 Changed 7 years ago by jmarshall

Sounds great.

Some notes that may be useful, though I think you're already on to it by the sounds of things:

  1. The variable (m_filterInput) could be read in CApplication::OnKey() and used to alter the useKeyboard variable. This takes care of disabling actions - all you'll get is the raw keyboard events. You'll need to catch the raw keyboard event of the "toggle input state" variable - not sure how you'll do that though as you don't really know the mapping at this point (I guess you could call the buttontranslator to translate the keypress, then check against the action).
  1. No point necessarily ignoring non-alpha/numeric I think. Make sure backspace is picked up though.
  1. A nice idea might be to embed a CGUIEditControl in the mediawindow class, and when in filtering mode just direct all actions to that first. That way you'll get most of this for free, and can just grab the filter directly from the editcontrol. Later on we can grab the editcontrol from the skin if they have it there.

Cheers, Jonathan

comment:8 Changed 6 years ago by bripeace

Okay, here is patch with full functionality of Skinable Highlight and Keyboard Live Filter.

This is done a little different (I don't toggle useKeyboard as once I saw your comment most of this was already done) Also I'm not sure how much I gain going in there. Anyhow most all the problems I listed before are all fixed.

Skinable Highlight works, and I'm not sure if this is what you had in mind. But in the colors/defaults.xml you just add a <color name="highlight">whatever</color> and then it will resolve that in your highlight code. if there is no default highlight it falls back to just using red.

I was thinking, and I haven't really chased this down the most elegant way to do the keyboard stuff is to have a seperate secion on the Keymap all together which when the filter is engaged it switches to that section and onlly uses bindings in there. Really all it would contain is Backspace/Clear but it would probably be a little more elegant.

I imagine there is some significant clean up in this, but it works and you can take a look and I'm sure i'll have a lot more looks at it. This at least 'works' though.

You'll need to bind ToggleFilter to something to get it to work - i use tab. So you hit that button and your in the filter mode. then hit it again to toggle it off.

Changed 6 years ago by bripeace

+Keyboard Live Filter and Skinable Highlight

comment:9 Changed 6 years ago by jmarshall

Thanks - will take a look tonight.

Cheers, Jonathan

Changed 6 years ago by bripeace

Cleanup, bug fixes

comment:10 Changed 6 years ago by bripeace

Okay Yet another patch. I'm happy with this overall.

What I did is what I sort of talked about in my previous comment.

There is a new section in KeyMap and a dummy window associated with it so I can just overlay the Live Filter bindings when live filter is turned on. I have it setup for both Keyboard and Remote to work in this way. So to turn it on you hit your live button filter - in my patch Tab on keyboard and Title/Recorded TV on remote. Once that is hit you filter away. If you toggle on the remote it uses the numeric search everything else doesn't.

This addresses concerns with losing 10 buttons at all times on remote and people accidentally hitting live filter buttons when it's always on and having their movies disappear. Now you have to actually have to hit the toggle button before any of that happens.

Let me know what you think.

comment:11 Changed 6 years ago by anonymous

Sounds like a nice solution. I like the idea of a separate keymap.

I'll take a look at it later on today with any luck.

Cheers, Jonathan

comment:12 Changed 6 years ago by sho

  • Milestone set to 8.10
  • Platform changed from XBox to All

comment:13 Changed 6 years ago by jmarshall

  • Milestone changed from 8.10 to Future

Most stuff here is in SVN now.

The only thing missing atm is the highlighting. There's actions for direct SMS input, and we also allow an edit control to be used for the filter label.

The highlighting is troublesome, and is unlikely to be added until the separation of rendered label from "normal" label occurs.

comment:14 Changed 6 years ago by jmarshall

  • Summary changed from Live Filter to Live Filter - highlight the matching filter?

comment:15 Changed 6 years ago by jmarshall

  • Milestone Future / Pending deleted
  • Resolution set to Commited to SVN
  • Status changed from accepted to closed

IMO the coloured filtering is not really needed.

comment:16 Changed 5 years ago by sho

  • Milestone set to 8.10
Note: See TracTickets for help on using tickets.