Message Boards Message Boards

0
|
1397 Views
|
7 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How to control slider value font size?

Posted 1 year ago

POSTED BY: Werner Geiger
7 Replies
Posted 1 month ago

I am still busy styling value fields within Manipulate controls.

In addition to my previous post, I have a picture that shows what I can and cannot control:

  1. Within the first Manipulate parameter (the expression to be executed), normal styling is of course used.
  2. The Manipulate option LabelStyle controls the styling of static labels.
  3. The Manipulate option LabelStyle does not control the FontSize of value fields. But it does control FontColor and FontSlant.
  4. I have no idea how to control the font size of value fields.
  5. The Manipulate option BaseStyle does not appear to control anything.

Does anyone know how to change the font size (and field size) of the value fields?

Attachment

Attachments:
POSTED BY: Werner Geiger
Posted 1 month ago

See if this does what you want:

Manipulate[
  Style[x,Darker[Green],Bold,14],
  Row[{
    Control@{{x,0.5,"x-Wert"},0,1,AppearanceElements->None},
    Control@{{x,0.5,""},InputField,FieldSize->4}
  }],
  LabelStyle->{12,Blue,Italic}
]
POSTED BY: Hans Milton
Posted 1 month ago

Thanks Hans.

Of course this works, because I can display each value (even dynamically) in a different control field.

But that's not what I want. There are similar font size problems with Slider2D and others. Unfortunately, we don't have complete control over the styling of all elements of Controls. At least we would need something similar to LabelStyle called ValueStyle or something.

POSTED BY: Werner Geiger
Posted 1 month ago

For Slider2D, what is wrong with the result of the code below?

Manipulate[
  ParametricPlot[{Sin[t+d[[1]]],Sin[t+d[[2]]]},{t,0,2Pi}],
  {d,{0,0},{Pi,Pi},Appearance->"Labeled"},
  LabelStyle->{14,Blue,Italic}
]
POSTED BY: Hans Milton
Posted 27 days ago

You're right. Strangely, LabelStyle is honored in terms of FontSize, -Slant, and -Color in Slider2D. The same applies to Slider:

Manipulate[Style[x, Darker[Green], Bold, 14],
 {{x, 0.5, "x-Wert"}, 0, 1, ControlType -> Slider, 
  Appearance -> "Labeled"},
 LabelStyle -> {FontSize -> 12, FontColor -> Blue, FontSlant -> Italic}
 ]

To conclude: I think it's simply a bug in the Manipulator control where they forgot to take FontSize into account.

POSTED BY: Werner Geiger

Hi Werner,

My original post was too long and unhelpful, so I've edited it. I don't know where to find the Manipulator code except for the five different constructor-functions found in MiscExpressions.tr, which I can locate with the code below, which should be system-independent. Perhaps you don't recognize the code as Wolfram Language because of the *Box commands or because of the non-WL lines @@resource <resource_name> and @|. Between each @@resource...@| pair is a WL expression. The first is a list of key -> value pairs used by the Front End. In this list we find the keys for "Manipulate03" through "Manipulate07" paired with functions for constructing manipulators.

If you specify the BaseStyle or LabelStyle options in Manipulator, Mathematica will use the "Manipulator07" API found in the following MiscExpressions.tr file that comes with Wolfram app:

FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
    "TextResources", "MiscExpressions.tr"}] (* location varies with installation *)
FileExistsQ[%] (* verify the file exists *)

The code for "Manipulator07" is in box form, so that it may be interpreted by the Front End. The API has 26 #n arguments. The boxes, the arguments, and other FE context commands make it a little hard to read, but most of the boxes correspond to the "Box"-less command. For instance, InputFieldBox for InputField.

According to the code for "Manipulator07", the LabelStyle option value is passed to the input field to the right of the slider as the option

BaseStyle -> {"Manipulator", <..LabelStyle options..> }

Similarly, the BaseStyle option value in a Manipulator is passed to the input field below the sliders as

BaseStyle -> {"Manipulator", <..BaseStyle options..>, 
              FontSize :> CurrentValue[{"ControlsFontSize", #5}]}

Here #5 is the "smaller size" argument, which is not explained. The default seems to be Small.

Arguments #20 to #23 of "Manipulator07" are labeled as the default options for the Slider, Animator, and each InputField. I've never seen these to be anything but an empty list with one exception: ImageSize -> 50 (or other number) is passed as a slider option, but symbolic settings such as ImageSize -> Large are not passed. So arguments #20 to #23seem unusable in the standard usage ofManipulateandManipulator, unless there is an undocumented way to get to them. My original answer gave a way to pass values for these arguments. If arguments#20to #23 are unreachable, as they appear to be, then the only effect one may have on the two input fields is through the BaseStyle of each InputField, which may be set through the LabelStyle and BaseStyle options of the Manipulator. Other options, such as FieldSize cannot be changed.

If you wish to explore this line of inquiry, I have been using the following to see the 26 arguments passed to the "Manipulator07" API. The arguments are minimally documented in MiscExpressions.tr.

MakeBoxes[
 Manipulator[Dynamic[x], {0, 1},
  Appearance -> {"Open", "Labeled"}, 
  BaseStyle -> {FontColor -> Red, FontSize -> 24}, 
  LabelStyle -> {FontColor -> Orange, FontSize -> 40}],
 StandardForm]
POSTED BY: Michael Rogers
Posted 25 days ago

Thanks, Michael, that's a good example of building custom controls. Of course, I can always build my own custom controls if I want, and I do sometimes. But my goal is not to improve the Wolfram system, but to solve my own problems using the Wolfram API.

I tried to find the original manipulator source code in my Wolfram|One installation to fix the bug. But I couldn't find anything like that in Wolfram coding. Maybe you have an idea where it is?

POSTED BY: Werner Geiger
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract