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

Sync code hint font size with code view font size #13091

Merged
merged 6 commits into from
Mar 9, 2017

Conversation

swmitra
Copy link
Collaborator

@swmitra swmitra commented Feb 10, 2017

This PR enhances Brackets user experience by syncing the code hint font-size with code view font size. This was a problem in high dpi monitors ( WQHD and above ), where code hints were not readable with the current font-size. With this PR , when user changes code view font size, code hint font size also gets changed accordingly.

Without this PR, code hints are rendered as -

hdpihint

With the changes in PR -

hdpihintfix

@ficristo
Copy link
Collaborator

In case of JS hints the icon doesn't look good.

Copy link
Collaborator

@ficristo ficristo left a comment

Choose a reason for hiding this comment

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

I would like to see at least the documentation fixed.

@@ -122,10 +128,10 @@ define(function (require, exports, module) {
* @param {string} value Is the value of the style
* @param {boolean} important Is a flag to make the style property !important
Copy link
Collaborator

Choose a reason for hiding this comment

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

cssRule and cssText aren't documented.

cssRule = cssRule || ".CodeMirror";
var $style = $("<style type='text/css'></style>").attr("id", propertyID);
var styleStr = StringUtils.format("{0}: {1}{2}", name, value, important ? " !important" : "");
var styleStr = cssText || StringUtils.format("{0}: {1} {2}", name, value, important ? " !important" : "");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you can remove the space between this two parameters {1} {2}.


/**
* @private
* Adds a new embeded style top sync code-hint font size with codeview font size
Copy link
Collaborator

Choose a reason for hiding this comment

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

fontSize is not documented

var styleStr = "";
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "font-size", fontSize, " !important");
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "line-height", (parseInt(fontSize, 10) + 2) + fontSize.replace(parseInt(fontSize, 10), ""), " !important");
_addDynamicProperty(DYNAMIC_CODEHINT_FONT_STYLE_ID, "font-size", fontSize, true, ".codehint-menu .dropdown-menu li a", styleStr);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to pass the values font-size, fontSize and true but they aren't actually used.
Perhaps it's personal style but it doesn't seems good.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think function _addDynamicProperty(propertyID, options) would make more sense (where options would be an object of { name, value, important, cssRule, cssText } etc.)

@swmitra
Copy link
Collaborator Author

swmitra commented Feb 13, 2017

Thanks a lot @ficristo for the quick review 👍 I will update the PR soon.

@MiguelCastillo
Copy link
Contributor

Question around the approach. Adding the a method specific for code hints seems reasonable, but I am not sure how that will scale if we had to add more methods for different parts of the UI. Is there a way we can leverage CSS for the fonts size/type?

@swmitra
Copy link
Collaborator Author

swmitra commented Mar 7, 2017

@MiguelCastillo Good point to consider 👍.
I had tried the most generic approach by increasing the base font size for body. In that way we can increase and sync the font size in other panes like project panel and Dialogs as well. But it's not convincing use case for every one. In fact most of the people I spoke with wanted to increase just the code view font size and nothing else. I will hold this PR for now and lets ask other developers about the actual feature scope itself. Please let me know your opinion about the feature scope.

@zaggino
Copy link
Contributor

zaggino commented Mar 7, 2017

I'd say that while @MiguelCastillo 's point is valid, we should not get into the habit of stacking feature on top of feature in PRs which makes them not only very large but also increases the time which they take to merge, sometimes are these even never merged as authors get discouraged. So if @swmitra 's PR works and solves the problem it was meant to solve (without introducing new ones), we should merge it and open further suggestions as separate issues.

@swmitra
Copy link
Collaborator Author

swmitra commented Mar 7, 2017

@ficristo We no longer use that icon in JS code hints. I am a bit confused as I don't see those icons in JS code hints, Can you please confirm once more?

@ficristo
Copy link
Collaborator

ficristo commented Mar 7, 2017

@swmitra you are right. After I had disabled my extensions I don't see it anymore.

@swmitra
Copy link
Collaborator Author

swmitra commented Mar 7, 2017

Thanks a lot @ficristo for quick confirmation 👍 . Can you please have a look at the changes again as I have tried to address the comments? @petetnt I have wrapped the parameters in a configuration object as per your suggestion, can you please have a look?

@swmitra
Copy link
Collaborator Author

swmitra commented Mar 7, 2017

@MiguelCastillo Can you please check the implementation now? I just tried to make it extensible by using a less template.

@MiguelCastillo
Copy link
Contributor

yup i am checking now. BTW - thank you for clarifying the use case. It definitely helped me understand the scope of what we are accomplishing. I am happy with what we got here :)

}

.codehint-menu .dropdown-menu {
max-height: @maxvisibleitems * @lineheight !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

how does line height affect this when the fontsize is define in px vs em?

@MiguelCastillo
Copy link
Contributor

I like what you have done here! very interesting! I just had a question regarding the max-height value and how it is affected when font size is specified with different units.

@swmitra
Copy link
Collaborator Author

swmitra commented Mar 8, 2017

@MiguelCastillo I had made core template calculations unit agnostic. Also I had to introduce an additional step to convert only em to px. Rest all units like pt, rem and px works well with this implementation.
Thanks a lot for bringing the point up as it finally resulted in a better implementation 👍.

Please check the code and try out the implementation and let me know if see any issues.

@MiguelCastillo
Copy link
Contributor

@swmitra yeah - this is good to merge for me. I am not sure if there are any TODOs pending, are there?

@swmitra
Copy link
Collaborator Author

swmitra commented Mar 9, 2017

@ficristo Can you please have a look now?

@ficristo
Copy link
Collaborator

ficristo commented Mar 9, 2017

@MiguelCastillo review is more than enough for me.

@MiguelCastillo MiguelCastillo merged commit ad93627 into master Mar 9, 2017
@saurabh95 saurabh95 added this to the Release 1.9 milestone Mar 10, 2017
@ficristo ficristo deleted the swmitra/DyanamicHintFontSize branch March 16, 2017 19:11
@chylex
Copy link

chylex commented Sep 25, 2017

Is there any way to revert this? It feels like I can see way fewer hints than I used to, and any code hints that include documentation look misaligned, so I'd rather go back to the default font size & code hint area height.

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.

7 participants