Skip to contentSkip to conversation

start angle (option of circular_progress) is measured in unusual quantities

PATCH In review Vladimir Testov 4 participants 9 messages Mar 13, 2013 – Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 start angle (option of circular_progress) is measured in unusual quantities

In current state, start angle is measured in "parrots", where 1 "parrot" = 1 / 256 of full circle.

With simple patch we can set start angle in degrees (which makes no difference for the program, but makes configuration to be more user-friendly)

theme.txt:

before:

    start_angle = -64
after:
    start_angle = -90

nothing else is affected

Signature · 4 lines
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
grub-core/gfxmenu/gui_circular_progress.c +1 -1
diff -Naur grub-new2/grub-core/gfxmenu/gui_circular_progress.c grub-new3/grub-core/gfxmenu/gui_circular_progress.c
@@ -233,7 +233,7 @@
     }
   else if (grub_strcmp (name, "start_angle") == 0)
     {
-      self->start_angle = grub_strtol (value, 0, 10);
+      self->start_angle = grub_strtol (value, 0, 10) * 64 / 90;
     }
   else if (grub_strcmp (name, "ticks_disappear") == 0)
     {
#1 lore raw

В Wed, 13 Mar 2013 14:52:13 +0400
Vladimir Testov <[email protected]> пишет:

Quoted 6 lines

In current state, start angle is measured in "parrots", where 1 "parrot" = 1 / 256 of full circle.

With simple patch we can set start angle in degrees (which makes no difference for the program, but makes configuration to be more user-friendly)

This has compatibility issue and probably cannot be done without introducing theme file format version.

What about adding new parameter name instead (although start_angle_angle looks rather silly)?

Quoted 10 lines

theme.txt:

before:

    start_angle = -64
after:
    start_angle = -90

nothing else is affected

#2 lore raw
Quoted 10 lines · Andrey Borzenkov

В Wed, 13 Mar 2013 14:52:13 +0400
Vladimir Testov <[email protected]> пишет:

Quoted 6 lines

In current state, start angle is measured in "parrots", where 1 "parrot" = 1 / 256 of full circle.

With simple patch we can set start angle in degrees (which makes no difference for the program, but makes configuration to be more user-friendly)

Quoted 5 lines

This has compatibility issue and probably cannot be done without introducing theme file format version.

What about adding new parameter name instead (although start_angle_angle looks rather silly)?

start_angle_degrees?

Could have start_angle_radians too (although it would need floating point to be useful).

Could even have start_angle_gradians

Signature · 1 line
Len Sorensen
#3 lore raw
Quoted 14 lines · Lennart Sorensen
Quoted 13 lines · Andrey Borzenkov

В Wed, 13 Mar 2013 14:52:13 +0400
Vladimir Testov <[email protected]> пишет:

Quoted 6 lines

In current state, start angle is measured in "parrots", where 1 "parrot" = 1 / 256 of full circle.

With simple patch we can set start angle in degrees (which makes no difference for the program, but makes configuration to be more user-friendly)

This has compatibility issue and probably cannot be done without introducing theme file format version.

Quoted 7 lines
Quoted 2 lines

What about adding new parameter name instead (although start_angle_angle looks rather silly)?

start_angle_degrees?

Could have start_angle_radians too (although it would need floating point to be useful).

GRUB doesn't use floats at all as it would decrease compatibility and brings nothing useful to us.

Quoted 3 lines

Could even have start_angle_gradians

This would be featuritus

#4 lore raw
In reply to Andrey Borzenkov
Quoted 10 lines · Andrey Borzenkov

В Wed, 13 Mar 2013 14:52:13 +0400
Vladimir Testov <[email protected]> пишет:

Quoted 6 lines

In current state, start angle is measured in "parrots", where 1 "parrot" = 1 / 256 of full circle.

With simple patch we can set start angle in degrees (which makes no difference for the program, but makes configuration to be more user-friendly)

Quoted 6 lines

This has compatibility issue and probably cannot be done without introducing theme file format version.

What about adding new parameter name instead (although start_angle_angle looks rather silly)?

It would be better to have some kind of angle format. I think it would be reasonable to use:
start_angle = 90°;
The only problem is start ° is a non-ASCII character and while GRUB handles those fine, it is easily corrupted on transmission.

Quoted 16 lines
Quoted 10 lines

theme.txt:

before:

    start_angle = -64
after:
    start_angle = -90

nothing else is affected

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
In reply to Vladimir Testov
Quoted 7 lines · Vladimir Testov

In current state, start angle is measured in "parrots", where 1 "parrot" = 1 / 256 of full circle.

With simple patch we can set start angle in degrees (which makes no difference for the program, but makes configuration to be more user-friendly)

Quoted 10 lines

theme.txt:

before:

    start_angle = -64
after:
    start_angle = -90

nothing else is affected

This breaks backward compatibility with already existing themes.

Quoted 6 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw
In reply to Vladimir Testov

Like that? :)

use
start_angle = "XXX degree" or start_angle = "XXX degrees" for setting angle in degrees

use
start_angle = "XXX rad" or start_angle = "XXX rads" for setting angle int rads

or use
start_angle = XXX
for setting angle in "parrots", like it was before

Signature · 4 lines
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
grub-core/gfxmenu/gui_circular_progress.c +27 -1
diff -Naur grub-2.00/grub-core/gfxmenu/gui_circular_progress.c grub-new/grub-core/gfxmenu/gui_circular_progress.c
@@ -223,6 +223,32 @@
   self->end = end;
 }
 
+static int
+parse_angle (const char *value)
+{
+  int pos = 0;
+  int len = grub_strlen (value);
+  int angle = grub_strtol (value, 0, 10);
+  /* Find space symbol */
+  while (pos < len && value[pos] != ' ')
+    pos++;
+  /* Skip spaces */
+  while (pos < len && value[pos] == ' ')
+    pos++;
+  if (pos < len)
+    {
+      char *unit = grub_new_substring (value, pos, len);
+      if ((grub_strcmp (unit, "degree") == 0)
+          || (grub_strcmp (unit, "degrees") == 0))
+        angle = angle * 64 / 90;
+      else if ((grub_strcmp (unit, "rad") == 0)
+               || grub_strcmp (unit, "rads") == 0)
+        angle = angle * 64 / 100;
+      grub_free (unit);
+    }
+  return angle;
+}
+
 static grub_err_t
 circprog_set_property (void *vself, const char *name, const char *value)
 {
@@ -233,7 +259,7 @@
     }
   else if (grub_strcmp (name, "start_angle") == 0)
     {
-      self->start_angle = grub_strtol (value, 0, 10);
+      self->start_angle = parse_angle(value);
     }
   else if (grub_strcmp (name, "ticks_disappear") == 0)
     {
#7 lore raw

В Thu, 11 Apr 2013 19:48:35 +0400
Vladimir Testov <[email protected]> пишет:

Quoted 5 lines

Like that? :)

use
start_angle = "XXX degree"
or start_angle = "XXX degrees"

I think "XXX deg" is enough. It avoids confusion with single/plural forms and we just need something to distinguish from plain number.

Please add also documentation for it.

Quoted 11 lines

for setting angle in degrees

use
start_angle = "XXX rad"
or start_angle = "XXX rads"
for setting angle int rads

or use
start_angle = XXX
for setting angle in "parrots", like it was before

#8 lore raw
In reply to Vladimir Testov

Oh, I think that version of patch is safer.

--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru

grub-core/gfxmenu/gui_circular_progress.c +29 -1
diff -Naur grub-2.00/grub-core/gfxmenu/gui_circular_progress.c grub-new/grub-core/gfxmenu/gui_circular_progress.c
@@ -223,6 +223,34 @@
   self->end = end;
 }
 
+static int
+parse_angle (const char *value)
+{
+  int pos = 0;
+  int len = grub_strlen (value);
+  int angle = grub_strtol (value, 0, 10);
+  /* Find space symbol */
+  while (pos < len && value[pos] != ' ')
+    pos++;
+  /* Skip spaces */
+  while (pos < len && value[pos] == ' ')
+    pos++;
+  if (pos < len)
+    {
+      char *unit = grub_new_substring (value, pos, len);
+      if (!unit)
+        return angle;
+      if ((grub_strcmp (unit, "degree") == 0)
+          || (grub_strcmp (unit, "degrees") == 0))
+        angle = angle * 64 / 90;
+      else if ((grub_strcmp (unit, "rad") == 0)
+               || grub_strcmp (unit, "rads") == 0)
+        angle = angle * 64 / 100;
+      grub_free (unit);
+    }
+  return angle;
+}
+
 static grub_err_t
 circprog_set_property (void *vself, const char *name, const char *value)
 {
@@ -233,7 +261,7 @@
     }
   else if (grub_strcmp (name, "start_angle") == 0)
     {
-      self->start_angle = grub_strtol (value, 0, 10);
+      self->start_angle = parse_angle(value);
     }
   else if (grub_strcmp (name, "ticks_disappear") == 0)
     {