Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fonts api with Themes integrated #8492

Merged
merged 8 commits into from
Jul 22, 2014
Merged

Fonts api with Themes integrated #8492

merged 8 commits into from
Jul 22, 2014

Conversation

MiguelCastillo
Copy link
Contributor

Fixes:
#8425
#8381

References:
#8305

@MiguelCastillo
Copy link
Contributor Author

cc @dangoor @TomMalbran

Object.keys(newSettings).forEach(function (setting) {
prefs.set(setting, newSettings[setting]);
if (prefs.hasOwnProperty(setting)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't work. Preferences aren't properties of the PrefixedPreferencesSystem which is what prefs is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was I thinking!? Sorry man, I will patch that up and submit a PR. Thanks for merging this. Its a real nightmare to keep themes changes and fonts synced!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, i thought this was merged and that's why it was closed. Misread

$style.html(cssRule + "{ " + styleStr + " }");

// Let's make sure we remove the already existing item from the DOM.
_removeDynamicProperty(propertyID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It seems to me that these nodes will always exist (after they're initially created), so we might as well just add them once and change the contents, rather than adding/removing them.

That's a nit, though, because I don't think there would be any functional difference and any performance difference is irrelevant in this context... I wouldn't block landing for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah man, we can definitely reuse the same nodes. I tried to keep as much of what was there as possible. I changed quite a bit of code as it is.

@dangoor
Copy link
Contributor

dangoor commented Jul 22, 2014

@MiguelCastillo You started saying something last night about how the line height setting may need to go, but I don't think you finished that thought because of the scrollbar discussion. What was your concern about line height?

@MiguelCastillo
Copy link
Contributor Author

I was just about to bring that up again... :) So I think having line height is really useful, and that's why I have added that in. But it seems a bit fragile because I am changing spans to be inline-blocks so that spans get a height that takes into account padding and what not. We will just need to be much more careful with CodeMirror plugins we introduce because if they use spans to decorate the DOM then that's an immediate candidate for introducing issues.

@dangoor
Copy link
Contributor

dangoor commented Jul 22, 2014

I agree that line height is useful. It's a matter of personal taste and can make a big difference in readability.

@dangoor
Copy link
Contributor

dangoor commented Jul 22, 2014

It's really nice that I can finally use Comic Sans MS as my coding font.

@MiguelCastillo
Copy link
Contributor Author

Yup, exactly why I don't want to remove it. I have it set to 1.4, so I personally think it is needed. Cool, let's leave it and we can deal with any hurdles when they come up :)

@MiguelCastillo
Copy link
Contributor Author

Oh that's right. Font family is one of the reasons I added the restore settings button. So, I may want to play with a font, and maybe I want to just go back because what I added really sucks... "Restore me baby" is what the button should say :)

This would be alleviated by applying settings right away without having to dismiss the dialog, and still be able to cancel out of the whole thing.

@@ -347,6 +551,10 @@ define(function (require, exports, module) {
CommandManager.register(Strings.CMD_THEMES, Commands.CMD_THEMES_OPEN_SETTINGS, _handleThemeSettings);

PreferencesManager.convertPreferences(module, {"fontSizeAdjustment": "user"}, true, _convertToNewViewState);

prefs.definePreference("fontSize", "string", DEFAULT_FONT_SIZE + "px");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule, you should listen for preference changes. It's not as obvious in this case, because we have actual UI for these preferences. But, I just deleted some of the settings from my preferences file and the changes don't take effect until I reload because there's no listener here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah man, I had that before... I removed it because for some odd reason the listener was never getting called. I guess I should have asked :/

https://github.com/MiguelCastillo/brackets/commit/395dd1e471087646960d6e2da4d8c466362aa579

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally just do something like this:

prefs.definePreference("fontSize", "string", DEFAULT_FONT_SIZE + "px").on("change", function () {
// do stuff
});

@dangoor
Copy link
Contributor

dangoor commented Jul 22, 2014

This change gave me the idea that the PreferencesSystem should just delete the pref value if it's told to set the value to the default.

I realized that there's not a lot of value in changing restore to do actually delete the pref values by setting to undefined, because the next time the user changes anything in the themes dialog, all of the prefs will be set again.

@dangoor
Copy link
Contributor

dangoor commented Jul 22, 2014

Merging

dangoor added a commit that referenced this pull request Jul 22, 2014
Fonts api with Themes integrated
@dangoor dangoor merged commit 93bea99 into adobe:master Jul 22, 2014
@MiguelCastillo
Copy link
Contributor Author

Thank you Kevin! Should we log an issue for prefs changes?

@dangoor
Copy link
Contributor

dangoor commented Jul 22, 2014

@MiguelCastillo I just filed #8499 for the font and theme prefs listeners.

@TomMalbran
Copy link
Contributor

@MiguelCastillo Good job. But the highlight matches are using a bottom border, so now each time one is selected, the line height is 2px taller.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants