Results 1 to 7 of 7

Thread: Minor fixes for Highway skin

  1. #1
    Variable Bitrate
    Join Date
    Jun 2008
    Location
    Seattle, WA
    Posts
    366

    Minor fixes for Highway skin

    This is to get the volume control to work with the Highway skin on Linux.

    Code:
    Index: FrontEnd/OpenMobile/PluginHost.cs
    ===================================================================
    --- FrontEnd/OpenMobile/PluginHost.cs	(revision 627)
    +++ FrontEnd/OpenMobile/PluginHost.cs	(working copy)
    @@ -1250,7 +1250,8 @@
                                 return false;
                             if (int.TryParse(arg2, out ret) == false)
                                 return false;
    -                        if ((ret < 0) || (ret >= instanceCount))
    +                        if (ret < 0)
                                 return false;
                             hal.snd("34|" + arg1 + "|" + arg2);
                             raiseSystemEvent(eFunction.systemVolumeChanged, arg1, arg2, String.Empty);
    Index: Plugins/Highway/UI/UI.cs
    ===================================================================
    --- Plugins/Highway/UI/UI.cs	(revision 627)
    +++ Plugins/Highway/UI/UI.cs	(working copy)
    @@ -29,6 +29,11 @@
     {
         public sealed class UI:IHighLevel
         {
    +        IPluginHost theHost;
    +        ScreenManager manager;
    +        System.Timers.Timer tmr;
    +        int[] volCount;
    +        
             public OMPanel loadPanel(string name, int screen)
             {
                 if (name == "")
    @@ -40,9 +45,7 @@
             {
                 get { return "UI"; }
             }
    -        IPluginHost theHost;
    -        ScreenManager manager;
    -        System.Timers.Timer tmr;
    +        
             public eLoadStatus initialize(IPluginHost host)
             {
                 theHost = host;
    @@ -92,9 +95,9 @@
                 voldown.OnClick += new userInteraction(voldown_OnClick);
                 voldown.Transition = eButtonTransition.None;
                 OMButton volup = new OMButton(-11, 525, 112, 84);
    -            volup.Image = theHost.getSkinImage("VolUp");
    -            volup.FocusImage = theHost.getSkinImage("VolUp_HL");
    -            volup.DownImage = theHost.getSkinImage("VolUp_Selected");
    +            volup.Image = theHost.getSkinImage("VolUP");
    +            volup.FocusImage = theHost.getSkinImage("VolUP_HL");
    +            volup.DownImage = theHost.getSkinImage("VolUP_Selected");
                 volup.OnClick += new userInteraction(volup_OnClick);
                 volup.Transition = eButtonTransition.None;
                 OMButton mute = new OMButton(180, 477, 178, 146);
    @@ -206,35 +209,37 @@
             void voldown_OnClick(OMControl sender, int screen)
             {
                 int vol = ((VolumeBar)manager[screen, "volume"][1]).Value;
    -            if (vol == 0)
    -                return;
    +            if (vol > 0)
    +                theHost.execute(eFunction.setSystemVolume, (vol - 1).ToString(), theHost.instanceForScreen(screen).ToString());
                 
    -            theHost.execute(eFunction.setSystemVolume, (vol - 1).ToString(), theHost.instanceForScreen(screen).ToString());
                 if (volCount[screen] == 0)
                 {
                     theHost.execute(eFunction.TransitionToPanel, screen.ToString(), "UI", "volume");
                     theHost.execute(eFunction.ExecuteTransition, screen.ToString(), "SlideRight");
                 }
    +            
                 volCount[screen] = 4;
             }
     
             void bar_OnSliderMoved(OMControl sender, int screen)
             {
    -            theHost.execute(eFunction.setSystemVolume, ((VolumeBar)sender).Value.ToString());
    +            volCount[screen] = 4;
    +            theHost.execute(eFunction.setSystemVolume, ((VolumeBar)sender).Value.ToString(), theHost.instanceForScreen(screen).ToString());
             }
     
             void volup_OnClick(OMControl sender, int screen)
             {
                 int vol=((VolumeBar)manager[screen, "volume"][1]).Value;
    -            if (vol==100)
    -                return;
    +            if (vol < 100)
    +                theHost.execute(eFunction.setSystemVolume, (vol + 1).ToString(), theHost.instanceForScreen(screen).ToString());
                 
    -            theHost.execute(eFunction.setSystemVolume, (vol + 1).ToString(), theHost.instanceForScreen(screen).ToString());
                 if (volCount[screen] == 0)
                 {
                     theHost.execute(eFunction.TransitionToPanel, screen.ToString(), "UI", "volume");
                     theHost.execute(eFunction.ExecuteTransition, screen.ToString(), "SlideRight");
                 }
    +            
                 volCount[screen] = 4;
             }
     
    @@ -316,7 +321,7 @@
                 theHost.execute(eFunction.Stop, theHost.instanceForScreen(screen).ToString());
                 theHost.execute(eFunction.unloadTunedContent, theHost.instanceForScreen(screen).ToString());
             }
    -        int[] volCount;
    +
             void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
             {
                 object o;
    Index: Plugins/Highway/UI/Volume.cs
    ===================================================================
    --- Plugins/Highway/UI/Volume.cs	(revision 627)
    +++ Plugins/Highway/UI/Volume.cs	(working copy)
    @@ -23,7 +23,7 @@
     
     namespace OpenMobile.Controls
     {
    -    internal sealed class VolumeBar:OMProgress,IMouse
    +    internal sealed class VolumeBar:OMProgress,IMouse,IThrow
         {
             imageItem bottom;
             imageItem overlay;
    @@ -87,5 +87,24 @@
             }
     
             #endregion
    +        
    +        #region IThrow Members
    +        //Implemented to prevent gestures
    +        public void MouseThrow(int screen, Point TotalDistance, Point RelativeDistance)
    +        {
    +            //
    +        }
    +
    +        public void MouseThrowStart(int screen, Point StartLocation, PointF scaleFactors, ref bool Cancel)
    +        {
    +            Cancel = true;
    +        }
    +
    +        public void MouseThrowEnd(int screen, Point EndLocation)
    +        {
    +            //
    +        }
    +
    +        #endregion
         }
     }
    Here's a summary of my changes:

    1. When using the Highway skin, PluginHost.instanceCount is always -1, so setting the volume would fail. This is because instanceCount isn't initialized until someone actually queries it. Using the default skin, the NewMedia plugin queries the instanceCount, but the Highway Music page doesn't query it. I tried calling refreshDevices from the PluginHost constructor to properly initialize instanceCount, but that crashed. So instead I just removed the check, since it doesn't seem to be really needed.
    2. File names are case sensitive on Linux.
    3. Hitting volume + or - will always show the volume display, even if you hit + when the volume is maxed. Otherwise, you get no feedback letting you know the current volume.
    4. Adjusting the volume with the progress bar thingy works better now, since before it would disappear after 2 seconds, even if you're actively tapping on it.
    5. Disabled gestures on the volume bar.

    I'll have more changes coming in the near future.

    Just in working out these fixes, I noticed way, way, WAY too many magic numbers sprinkled about. For example, in the patch above you can see

    hal.snd("34|" + arg1 + "|" + arg2);

    This should be changed, so that all of those Hal messages are declared in a single file as const strings, and then when you call hal.snd, it would be with the proper identifier, such as

    hal.snd(HAL_MSG_SET_SYSTEM_VOL ....

    Same thing with the case statement that receives the messages.

    But the biggest offender of magic numbers is the referencing of controls by numeric index. There appear to be tons of those, maybe hundreds (I didn't actually count them). The best solution to this, is when creating each control, give it a name, and then when you need to reference it later, reference it by name instead of numeric index.

    Here's an example:

    void albums_OnClick(OMControl sender, int screen)
    {
    ((OMLabel)manager[screen][10]).Text = "All Albums";
    manager[screen][11].Visible = false;
    manager[screen][12].Visible = true;
    SafeThread.Asynchronous(delegate() { showAlbums(screen); }, theHost);
    }

    To improve this, when declaring the controls, give them names, something like this:

    OMLabel caption = new OMLabel(225, 115, 560, 45, "caption");
    OMList textList = new OMList(225, 162, 563, 316, "textList");
    OMList mainList = new OMList(225, 162, 563, 316, "mainList");

    Then the above function would look like this:

    void albums_OnClick(OMControl sender, int screen)
    {
    ((OMLabel)manager[screen]["caption"]).Text = "All Albums";
    manager[screen]["textList"].Visible = false;
    manager[screen]["mainList"].Visible = true;
    SafeThread.Asynchronous(delegate() { showAlbums(screen); }, theHost);
    }

    BTW, I hope nobody takes offense to my suggestions. I'm just trying to help improve OM.

    Thanks!
    -- Kevin

  2. #2
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by kross View Post
    BTW, I hope nobody takes offense to my suggestions. I'm just trying to help improve OM.
    Input and help is always welcome! Thanks!

    Quote Originally Posted by kross View Post
    1. When using the Highway skin, PluginHost.instanceCount is always -1, so setting the volume would fail. This is because instanceCount isn't initialized until someone actually queries it. Using the default skin, the NewMedia plugin queries the instanceCount, but the Highway Music page doesn't query it. I tried calling refreshDevices from the PluginHost constructor to properly initialize instanceCount, but that crashed. So instead I just removed the check, since it doesn't seem to be really needed.
    The Highway skin is still a work in progress so it's not up to a fully functional level, but this is a good catch. Not always easy to keep remembering to bring all the changes all around the place.
    Thanks. I'll update the current code of the skin.

    Quote Originally Posted by kross View Post
    2. File names are case sensitive on Linux.
    Is this valid for all of OM or just the Highway skin? (Just wondering where I should start updating/searching, I'm not the author of the highway skin but I can at least help out fix the bugs).
    Quote Originally Posted by kross View Post
    3. Hitting volume + or - will always show the volume display, even if you hit + when the volume is
    maxed. Otherwise, you get no feedback letting you know the current volume.
    Agree. It should always give some kind of feedback. Unresponsive buttons or items is a no go!
    Quote Originally Posted by kross View Post
    4. Adjusting the volume with the progress bar thingy works better now, since before it would disappear after 2 seconds, even if you're actively tapping on it.
    Did you increase the time it was shown or did you do some more tweaks do detect clicks (I have not studied your code yet).
    Quote Originally Posted by kross View Post
    5. Disabled gestures on the volume bar.
    Good catch, should have been disabled from start.

    Quote Originally Posted by kross View Post
    I'll have more changes coming in the near future.
    Keep e'm coming allways glad for any help.
    The Highway skin is still a work in progress and it hasn't gone trough a lot of debugging and testing so you'll probably find all kinds of small issues here and there. The main focus of devlopment went back to 0.9 version rather than completing other skins.

    Quote Originally Posted by kross View Post
    Just in working out these fixes, I noticed way, way, WAY too many magic numbers sprinkled about. For example, in the patch above you can see

    hal.snd("34|" + arg1 + "|" + arg2);

    This should be changed, so that all of those Hal messages are declared in a single file as const strings, and then when you call hal.snd, it would be with the proper identifier, such as

    hal.snd(HAL_MSG_SET_SYSTEM_VOL ....

    Same thing with the case statement that receives the messages.
    I agree, I'll bring this back to the dev team to see if a full list of functions is available.

    Quote Originally Posted by kross View Post
    But the biggest offender of magic numbers is the referencing of controls by numeric index. There appear to be tons of those, maybe hundreds (I didn't actually count them). The best solution to this, is when creating each control, give it a name, and then when you need to reference it later, reference it by name instead of numeric index.

    Here's an example:

    void albums_OnClick(OMControl sender, int screen)
    {
    ((OMLabel)manager[screen][10]).Text = "All Albums";
    manager[screen][11].Visible = false;
    manager[screen][12].Visible = true;
    SafeThread.Asynchronous(delegate() { showAlbums(screen); }, theHost);
    }

    To improve this, when declaring the controls, give them names, something like this:

    OMLabel caption = new OMLabel(225, 115, 560, 45, "caption");
    OMList textList = new OMList(225, 162, 563, 316, "textList");
    OMList mainList = new OMList(225, 162, 563, 316, "mainList");

    Then the above function would look like this:

    void albums_OnClick(OMControl sender, int screen)
    {
    ((OMLabel)manager[screen]["caption"]).Text = "All Albums";
    manager[screen]["textList"].Visible = false;
    manager[screen]["mainList"].Visible = true;
    SafeThread.Asynchronous(delegate() { showAlbums(screen); }, theHost);
    }
    This has also been discussed internally in the dev team and you'll see that some plugins uses naming and some uses numbers. This came down to personal opinion of the person programming it. On my side I agree with you, I like names better than numbers so I all plugins/skins created by me uses proper naming.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  3. #3
    Variable Bitrate
    Join Date
    Jun 2008
    Location
    Seattle, WA
    Posts
    366
    Quote Originally Posted by Borte View Post
    Is this valid for all of OM or just the Highway skin? (Just wondering where I should start updating/searching, I'm not the author of the highway skin but I can at least help out fix the bugs).
    I haven't noticed any missing graphics in the other plugins, but I haven't looked at all of them. If you see missing graphics on Linux, but they appear on Windows, it's probably a filename case mismatch.

    Did you increase the time it was shown or did you do some more tweaks do detect clicks (I have not studied your code yet).
    Whenever there's a click on the volume bar, it resets the timer. So the volume bar will disappear 2 seconds after the last time you touched it.

  4. #4
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by kross View Post
    I haven't noticed any missing graphics in the other plugins, but I haven't looked at all of them. If you see missing graphics on Linux, but they appear on Windows, it's probably a filename case mismatch.
    Ok. I haven't tested OM in linux (since others was playing with that) yet so I haven't really had a chance to troubleshoot it. But I'll update any errors that I can find.

    Quote Originally Posted by kross View Post
    Whenever there's a click on the volume bar, it resets the timer. So the volume bar will disappear 2 seconds after the last time you touched it.
    Ok. That's what I expected.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  5. #5
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by kross View Post
    1. When using the Highway skin, PluginHost.instanceCount is always -1, so setting the volume would fail. This is because instanceCount isn't initialized until someone actually queries it. Using the default skin, the NewMedia plugin queries the instanceCount, but the Highway Music page doesn't query it. I tried calling refreshDevices from the PluginHost constructor to properly initialize instanceCount, but that crashed. So instead I just removed the check, since it doesn't seem to be really needed.
    I did not include this change as this was a change to the OM core, the instancecount is not always -1, it's 4 on my system since I have 4 zones (before it was queried).

    Is the error you're seeing happening on linux as I couldn't reproduce it here on my win7 setup.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

  6. #6
    Variable Bitrate
    Join Date
    Jun 2008
    Location
    Seattle, WA
    Posts
    366
    Yes this was on Linux.

  7. #7
    Maximum Bitrate Borte's Avatar
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    529
    Quote Originally Posted by kross View Post
    Yes this was on Linux.
    If I used my eyes and read the first line I wouldn't had to ask...

    I think the error is caused by the audiorouter implementation on Linux but have to verify this.
    Failure is not an option...
    __________________________________________________ ______________________________
    The only full multizone / multiscreen cross platform open source Front End -> OpenMobile

Similar Threads

  1. BMW skin + minor pet peeve fixes
    By marchello2000 in forum StreetDeck Skins
    Replies: 26
    Last Post: 02-05-2011, 10:04 AM
  2. Highway Skin
    By justchat_1 in forum OpenMobile Skins
    Replies: 11
    Last Post: 11-23-2010, 10:27 PM
  3. Skin Tweaks Thread : Minor Modifications
    By Ruffy in forum RR Skins
    Replies: 16
    Last Post: 02-16-2007, 12:17 AM
  4. Highway Noise
    By Socno24 in forum Car Audio
    Replies: 13
    Last Post: 11-10-2004, 09:08 PM
  5. Minor update for Brushed Metal Skin
    By febsperanza in forum MediaCar
    Replies: 18
    Last Post: 03-04-2004, 10:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •