more G-Labs products

Author Topic: Themes  (Read 1386 times)

March 10, 2015, 03:51:37 AM
Read 1386 times

tara

  • *
  • Information
  • Newbie
  • Posts: 8
It would be great to be able to choose alternative widget sets and css files, so that widgets don't have to replace the existing ones to get used.

It may be that Gene will be interested in doing this himself. Still, I'd like to offer to do it.

---TLDR Boundary---

I'd be interested in making a fork and working on it. G can take or leave what he likes, or tell me to do it a different way. I poked around this evening, and I see that defaulting to homegenie/generic/<type> is hardcoded in pages/control/_control.js, and I don't see a useful way to use the other ways widgets are matched to modules there.

I've also noticed that what ui-theme choices there are are provided in js/api/homegenie.inc.js. The lettered choices and the changes they make are fixed there.

Obviously I've only had a cursory look, and Gene will know instantly if this makes sense. My instinct is that the cleanest most useful way of changing this without major changes to the code would be to add the theme's widgets in the same way they are imported / exported now, but en masse. In the first level directory of the theme directory, place css and images subdirectories. Load theme css after existing css.

In the code, have the themes selectable, perhaps in the same place where the lettered themes are now. Then change the _control.js code so that themer.theme/generic/<type> is looked for before homegenie/generic/type.

In that way (I'm guessing, haven't got this far into it) the theme can use css to try to bully existing widgets to dimensions that won't destroy the theme's layout. Some things will get ugly, but that's between the themer and the user of the device / widget in question, hehe.

I realize saying all this is very forward of me, since I just got here and I'm just guessing. I hope I'm not offending. But I also hope to provoke Gene and others to tell me I'm wrong and why, and in that way point me in a better direction faster than I could get there myself.

Waddya think?

March 10, 2015, 10:59:12 AM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Hi tara,

as you suggest, we can put a widget brand selector in the maintenance menu, next to the UI theme selector (the one with the letters a,b,c....).
In order for this to work, the custom theme widgets have to be placed in the "generic" category.
So for example you'll have:

tara/generic/dimmer
tara/generic/switch

and the theme name, shown in the theme select list, will be "tara". If a widget is not found in the selected theme, a fallback to the homegenie/generic widgets theme will be took in place.

This can be implemented without involving c# coding, but just html.

The following is the API function that can be used to determine the list of themes to show:

Code: [Select]
HG.Configure.Widgets.List(function(items) {
    // here we can loop through each item
    // and if it contains at least one 'generic' widget
    // we can add the brand to the themes list
});

Cheers,
g.

March 10, 2015, 01:28:38 PM
Reply #2

tara

  • *
  • Information
  • Newbie
  • Posts: 8
Hah. Notice that my post was written at 3:51 (my time). This morning I was horrified thinking how intrusive that post might seem from someone who got here yesterday. But instead your answer is awesome and practical.

So yeah, that seems like it should be fairly straightforward in html/js. I'll give it a go after work and let you know the results.


March 27, 2015, 10:57:04 PM
Reply #3

tara

  • *
  • Information
  • Newbie
  • Posts: 8
Just an update. Work has had me deployed almost non-stop, and I haven't slept more than a few nights in my own city/apartment since my last post.  Even so, I have grabbed a few free moments to start working out exactly what is needed to make this work, and have come to the conclusion that it's worth doing right, meaning doing a little more than what I said.

Unfortunately, on Sunday I'm going on vacation to the U.S.A. for all of holy week, and the following week I am already scheduled to spend 3 days in the south for work. So there is no chance I will get to work on this until after that, i.e. the weekend of the 11th.

So then.