Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background transparency #201

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

nathanrobinson
Copy link

This fork allows setting different transparency and blur values for background windows.

@gnachman
Copy link
Owner

Wow, thanks for the big change. It will take me a little bit to get through this, but I am taking a look.

@gnachman
Copy link
Owner

I haven't dug in super deep but I think these comments cover most of the issues:

  • The transparency for background windows doesn't affect the margins (they seem to always use the foreground setting)

  • The prefs dialog is starting to look (more) like the controls on the space shuttle. How about moving the blur and transparency controls into a modal sheet, like the settings in the prefs>advanced panel? Leave behind a button labeled "Transparency and Blur…" that opens the sheet.

  • I saw a few places where "bool" and "true" and "false" were used instead of BOOL and YES/NO; looks like some old wrong code. Instead of being consistent, would you mind fixing those?

  • There's an "Inactivate transparency" label below the "Inactive transparency" checkbox. The label should be removed.

  • Don't use abbreviations except in extreme cases. KEY_BACKGROUND_TRANS and KEY_USE_BACKGROUND_TRANS should spell out TRANSPARENCY, even if it messes up the alignment of the source code.

  • Names in code (for example, useBackgroundTransparency) should match what we see in the UI (where “inactive” is used, not “background”).

  • Minor style issue: new code should use this format for methods:

    - (void)foo {

rather than

- (void)foo
{
  • Always put a space between an if statement and the opening paren of its condition (e.g., in recheckBlur)
  • The use of Hungarian notation is being phased out. Avoid names like "fVal" (e.g., in setBackgroundTransparency:). In the case of setters, the preferred name matches the property name (so, - (void)setBackgroundTransparency:(double)backgroundTransparency { would be correct).
  • Why the + 10 in -[ProfilePreferencesViewController awakeFromNib]? Looks fine without it to me.
  • The /////// Background transparency comments in ProfilesWindowPreferencesViewController.m should be removed or improved (if you keep them, don't use lots of /s, just the two that are required)
  • In general, avoid lines over 100 characters, unless it would compromise readability. For example, in ProfilesWindowPreferencesViewController.m:94

@nathanrobinson
Copy link
Author

Thanks for the feedback.
This is my first foray into objective C, so for the first two bullet items I am completely lost. I will try to track them down, though.
The + 10 is there because, at least on my screen, when a preferences screen scrolls off the bottom of the window, a scroll bar is added to the view which covers up part of the controls.
This would fix itself if I am able to move the transparency and blur controls to a popup.
The rest should be easy to fix.

@gnachman
Copy link
Owner

You're doing well for a first foray! Feel free to ignore the second comment, I'll take care of that. As for the margins not being correct, I think it's because the wrong alpha value is picked in -[PTYSession textViewDrawBackgroundImageInView:viewRect:blendDefaultBackground:].

I think the +10 should stay as the advanced prefs actually look pretty ugly with always-visible scrollbars, but instead of always adding 10, add [NSScroller scrollerWidthForControlSize:NSRegularControlSize scrollerStyle:NSScrollerStyleLegacy]. That'll always be correct even if apple changes how it's rendered (plus it explains what's going on). I always forget to test that configuration so I'm glad you caught it.

…ency

* origin/master:
  Don't try to add a titlebar accessory view controller to a window without a title bar. Issue 3449.
  Make sure to remove tracking rects on the tab bar control before adding new ones. I wasn't able to repro issue 3452 but this should fix it.
  Clean up tab activity indicator code and various odds and ends
@nathanrobinson
Copy link
Author

I think I got them all except the popup for transparency sliders on the preferences dialog.

@@ -801,6 +801,8 @@ - (BOOL)setScreenSize:(NSRect)aRect parent:(id<WindowControllerInterface>)parent
horizontalSpacing:[[_profile objectForKey:KEY_HORIZONTAL_SPACING] floatValue]
verticalSpacing:[[_profile objectForKey:KEY_VERTICAL_SPACING] floatValue]];
[self setTransparency:[[_profile objectForKey:KEY_TRANSPARENCY] floatValue]];
[self setInactiveTransparency:[[_profile objectForKey:KEY_INACTIVE_TRANSPARENCY] floatValue]];
Copy link
Owner

Choose a reason for hiding this comment

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

New code should not look up values in _profile directly because it bypasses the relatively new mechanism for defaults. Older code generally had default values of 0 so it happens to work, and I'm slowly moving everything the new model. Instead, write:
[iTermProfilePreferences objectForKey:KEY_INACTIVE_TRANSPARENCY inProfile:_profile]

@gnachman
Copy link
Owner

I added a bunch of niggling line notes, mostly style stuff. Thanks for taking the time to do this!

@nathanrobinson
Copy link
Author

Well, I think I got it, but you'll want to double check me.

return [iTermProfilePreferences floatForKey:KEY_INACTIVE_BLUR_RADIUS inProfile:_profile];
}

- (float)blurRadius {
Copy link
Owner

Choose a reason for hiding this comment

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

Both float and double are used here; I'm sure that's due to some ancient folly. Let's use double for all new code.

[self setNeedsDisplay:YES];
}

- (void)setIsBackground:(BOOL)isBackground
Copy link
Owner

Choose a reason for hiding this comment

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

For style and consistency, this should be setWindowInactive: and the backing variable should be _windowInactive.

nathanrobinson added 2 commits March 18, 2015 20:14
I tested out appCode’s reformatting and wanted to get your thoughts. It
handles most of your styles, but seems to add extra indents on some
multi-line constructs.
@nathanrobinson
Copy link
Author

I tested out appCode’s reformatting and wanted to get your thoughts. It
handles most of your styles, but seems to add extra indents on some
multi-line constructs.

sources/PTYTab.m Outdated
}

- (double)blurRadius
{
- (double)averageBlurRadiusForInactive:(BOOL)inactive {
double sum = 0;
double count = 0;
NSArray* sessions = [self sessions];
Copy link
Owner

Choose a reason for hiding this comment

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

Space before *, also on next line

@gnachman
Copy link
Owner

Please revert the automatic style changes to PTYTextView and let's revisit that later. I'm working on a significant refactor of that file in a feature branch and this will introduce thousands of merge conflicts.

@nathanrobinson
Copy link
Author

I'm not sure what happened, but now the original blur radius settings aren't working. I'll see if I can track that down.

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

Successfully merging this pull request may close these issues.

2 participants