nomad-software / tkd

GUI toolkit for the D programming language based on Tcl/Tk
MIT License
117 stars 16 forks source link

Added font options for widgets that support it. #52

Closed AndrewGrim closed 5 years ago

AndrewGrim commented 5 years ago

I implemented the changes you asked for, kept it limited in scope to just the font. Unless you have any other corrections this should be good.

nomad-software commented 5 years ago

Thanks, I like it. I've had an idea for a few tweaks to simplify the API even further.

AndrewGrim commented 5 years ago

I have seen the changes and I do like them but I have an idea that at least to me is even better. When I was working on the example customization tab I wanted to add the option of changing the font by using the font dialog. The way it was setup I would have had to split the string returned by the font dialog into several different variables. I thought that was needlessly complex so I made a new function that would take the entire string as one argument. This makes changing the font using the dialog very simple but I think that its also pretty easy to write and understand by the user.

public auto setFontFromDialog(this T)(string font)
{
    this._tk.eval("%s configure -font {%s}", this.id, font);

    return cast(T) this;
}

On the simple end the font string argument looks like this Consolas 10. Once you turn on all the bells and whistles: {Yu Gothic UI} 10 bold italic underline overstrike.

Personally I would keep only one function: setFont() but I would replace its contents with the function shown above.

Alternatively we could have both but keeping in mind what you said about simplicity I don't think thats the way to go.

Let me know what you think about this change.