Help with OnMessage(GUIMessage message) when using ViewMode.Filmstrip (1 Viewer)

ltfearme

Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    Hi, I need some help in the TVSeries Plugin. I have added a Filmstrip view for TVseries Posters but I'm not receiving any messages in OnMessage(GUIMessage message) when using ViewMode.Filmstrip.

    Code:
    ViewMode.BigIcons and ViewMode.List work as expected but not ViewMode.Filmstrip, why is that? Here is a code snipet for the override of the OnMessage method:
    
    public override bool OnMessage(GUIMessage message)
            {            
                switch (message.Message)
                {
                    case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED:
                        {
                            int iControl = message.SenderControlId;
                            if (iControl == (int)m_Facade.GetID)
                            {
                                switch (this.listLevel)
                                {
                                    case Listlevel.Group:
                                        Group_OnItemSelected(m_Facade.SelectedListItem);
                                        break;
                                    case Listlevel.Series:
                                        Series_OnItemSelected(m_Facade.SelectedListItem);
                                        break;
    
                                    case Listlevel.Season:
                                        Season_OnItemSelected(m_Facade.SelectedListItem);
                                        break;
    
                                    case Listlevel.Episode:
                                        Episode_OnItemSelected(m_Facade.SelectedListItem);
                                        break;
                                }
                            }
                        }
                        return true;
    
                    case GUIMessage.MessageType.GUI_MSG_PLAYBACK_ENDED:
                    case GUIMessage.MessageType.GUI_MSG_PLAYBACK_STOPPED:
                        {
                            //-- Need to reload the GUI to display changes 
                            //-- if episode is classified as watched
                            LoadFacade();
                        }
                        return true;
    
                    default:
                        return base.OnMessage(message);
                }
            }
    The GUI_MSG_ITEM_FOCUS_CHANGED message is used to update properties in the skin using the _OnItemSelected(m_Facade.SelectedListItem) functions above.

    Any help will be appreciated.

    Cheers,
    Damien
     

    fforde

    Community Plugin Dev
    June 7, 2007
    2,667
    1,702
    42
    Texas
    Home Country
    United States of America United States of America
    The GUI_MSG_ITEM_FOCUS_CHANGED OnMessage event for the filmstrip view of the facade is either broken or intentionally not implemented. I am not sure which. I had the same problem with Moving Pictures though. The solution for me was to attach a listener to the OnItemSelected event of each GUIListItem added to the facade. Basically you'd just get rid of the GUI_MSG_ITEM_FOCUS_CHANGED part of your OnMessage method and throw it into a method that gets called by the event I mentioned.

    You can see the implementation in Moving Pictures here:
    moving-pictures - Google Code

    Should be the first two methods based on that link.
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    • Thread starter
    • Moderator
    • #3
    Thanks fforde, looks like I will have to do that then.

    Ive been working around it in the meantime using OnAction override method (ACTION_MOVE_RIGHT, ACTION_MOVE_LEFT, ACTION_MOUSE_MOVE). For the most part it works, but if scroll offset is used in the filmstrip then I have to use a dodgy hack because it seems that the selected item is still the same before and after the action. e.g:

    Code:
    case Action.ActionType.ACTION_MOVE_RIGHT:
                        if (this.m_Facade.View == GUIFacadeControl.ViewMode.LargeIcons)
                        {
                           // CODESTRIPPED FOR ILLUSTRATION
                        }
                        else if (this.m_Facade.View == GUIFacadeControl.ViewMode.Filmstrip)
                        {
                            object oPrevSelectedSeries = m_Facade.SelectedListItem.TVTag;                        
                            base.OnAction(action);                        
                            // If Scroll offset is applied, SelectedListItem doesnt update yet!
                            // also sometimes if navigate too fast this wont work
                            if (m_Facade.SelectedListItem.TVTag.Equals(oPrevSelectedSeries))
                            {
                                if (this.listLevel == Listlevel.Series)
                                {
                                    GUIListItem realSelected = new GUIListItem();
                                    List<DBSeries> seriesList = m_CurrLView.getSeriesItems(m_CurrViewStep, m_stepSelection);
                                    // Dodgy hack to push the next selected item which is the real selected one
                                    realSelected.TVTag = seriesList[m_Facade.SelectedListItemIndex + 1];                                
                                    Series_OnItemSelected(realSelected);
                                }
                            }
                            else
                            {
                                if (this.listLevel == Listlevel.Series)
                                    Series_OnItemSelected(m_Facade.SelectedListItem);
                            }
                        }
    
                        break;

    Thanks for your help ;)
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    • Thread starter
    • Moderator
    • #4
    Had quick look at the onItemSelected handller and it works well. I noticed that when scrolloffset is reached that it gets triggered twice. That would explain why onAction Before and After are the same and I needed to do hack.

    I think I noticed a few issues with using this handler and Inkers threading loading of the facade items. Some items were not listening to the event, I will further into this.

    Cheers,
    Damien
     

    fforde

    Community Plugin Dev
    June 7, 2007
    2,667
    1,702
    42
    Texas
    Home Country
    United States of America United States of America
    Hrmm. The offset bug I wasn't aware of, that is good to know. As for the dynamic facade loading I dunno. So long as you assign a delegate to the event for every GUIListItem when it get's created, I would think you'd be okay. Good luck with all that. If you find any other unusual quirks, I'd wouldn't mind hearing about them though. :p
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    • Thread starter
    • Moderator
    • #7
    If you find any other unusual quirks, I'd wouldn't mind hearing about them though. :p

    Well there is another quirk, I can't set 'this.m_Facade.SelectedListItemIndex' with the last selected series. I have no idea why, it just ignores what I set.

    All other views that I use work e.g. BigIcons and List. Filmstrip simply ignores. I had a look at your code and don't see anything special for you to get it to work.

    mattsk88, thanks will try get you a a new test build soon.

    Cheers
    Damien
     

    fforde

    Community Plugin Dev
    June 7, 2007
    2,667
    1,702
    42
    Texas
    Home Country
    United States of America United States of America
    If you find any other unusual quirks, I'd wouldn't mind hearing about them though. :p

    Well there is another quirk, I can't set 'this.m_Facade.SelectedListItemIndex' with the last selected series. I have no idea why, it just ignores what I set.

    All other views that I use work e.g. BigIcons and List. Filmstrip simply ignores. I had a look at your code and don't see anything special for you to get it to work.

    Yeah, for some reason the SelectedListItemIndex property of the GUIFilmstripView class is read only, which means that you can't programmatically set the index. :( No idea why, all the other facade view classes support this. I am not sure that there is a work around though.
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    • Thread starter
    • Moderator
    • #9
    Oh that's strange, usually visual studio complains that you try to set a readonly property.

    In moving pictures, I have seen your last selected movie return to selected when entering the selected movie information screen and back again. How do you do that without SelectedListItemIndex?

    Thanks,
    Damien
     

    fforde

    Community Plugin Dev
    June 7, 2007
    2,667
    1,702
    42
    Texas
    Home Country
    United States of America United States of America
    The GUIFacadeControl SelectedListItemIndex property is read/write. But the facade, as you probably know is just a wrapper class for several other classes (roughly one for each view type). So it basically wraps around a GUIListControl, a GUIThumbnailControl, and a GUIFilmstripControl. So when you add an item to the facade, internally it is adding that item to all the internal classes (again, one for each view). See here is the SelectedListItemIndex property for GUIFacadeControl, it is just delegating to the subclasses:

    Code:
        public int SelectedListItemIndex
        {
          get
          {
            if (_currentViewMode == ViewMode.Filmstrip && _viewFilmStrip != null)
              return _viewFilmStrip.SelectedListItemIndex;
            else if (_currentViewMode == ViewMode.List && _viewList != null)
              return _viewList.SelectedListItemIndex;
            else if ((_currentViewMode == ViewMode.SmallIcons || _currentViewMode == ViewMode.LargeIcons) && _viewThumbnail != null)
              return _viewThumbnail.SelectedListItemIndex;
            else if (_currentViewMode == ViewMode.AlbumView && _viewAlbum != null)
              return _viewAlbum.SelectedListItemIndex;
            else if (_currentViewMode == ViewMode.Playlist && _viewPlayList != null)
              return _viewPlayList.SelectedListItemIndex;
            return -1;
          }
          set
          {
            if (_currentViewMode == ViewMode.List && _viewList != null)
              _viewList.SelectedListItemIndex = value;
            else if (_currentViewMode == ViewMode.AlbumView && _viewAlbum != null)
              _viewAlbum.SelectedListItemIndex = value;
            else if ((_currentViewMode == ViewMode.SmallIcons || _currentViewMode == ViewMode.LargeIcons) && _viewThumbnail != null)
              _viewThumbnail.SelectedListItemIndex = value;
            else if (_currentViewMode == ViewMode.Playlist && _viewPlayList != null)
              _viewPlayList.SelectedListItemIndex = value;
          }
        }

    The problem at first appears to be that, in the set section, it is just not assigning the SelectedListItemIndex property of the GUIFilmstripControl. But if you look at the implementation of that property, in the GUIFilmstripControl:

    Code:
        public int SelectedListItemIndex
        {
          get
          {
            int iItem = _offset + _cursorX;
            if (iItem >= 0 && iItem < _listItems.Count)
            {
              return iItem;
            }
            return -1;
          }
        }

    See, in this property, no set accessor. I am not sure why it wasn't implemented. I am sure it could be done, but I have not taken the time to do it. Because set is not implemented here though, that means that when you set the SelectedListItemIndex property in the GUIFacadeControl, it works for everything except filmstrip view. Which is clear as mud, but that is the way it is.

    So yes, in Moving Pictures the selected index is retained in most views, but it is unfortunately not retained in filmstrip view. And as far as I know, to get it to work, a change needs to be made to the GUIFilmstripControl class.

    Maybe there is some other way to set the selected item that I am not aware of though.
     

    Users who are viewing this thread

    Top Bottom