Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add 'Toggle Tree Side' menu item #46

Merged
merged 11 commits into from
Mar 10, 2014
Merged

Add 'Toggle Tree Side' menu item #46

merged 11 commits into from
Mar 10, 2014

Conversation

heyvito
Copy link
Contributor

@heyvito heyvito commented Feb 27, 2014

This adds a new menu item called 'Toggle Tree Side', that toggles the tree view side between right and left

@kevinsawicki
Copy link
Contributor

It would be nice to have this as a checkbox in the settings view which means it would need a true/false value and clear name that articulated the default value

So how about naming it showOnLeftSide and make it true by default?

@benogle
Copy link
Contributor

benogle commented Mar 4, 2014

A nit, but I'd rather it were called showOnRightSide and have it be false as a default. That implies that the left is the default, and you know if you check that box, it will be on the right.

@kevinsawicki
Copy link
Contributor

@benogle good point, let's go with showOnRightSide 👍

@heyvito
Copy link
Contributor Author

heyvito commented Mar 5, 2014

No problems, will fix it asap!

@heyvito
Copy link
Contributor Author

heyvito commented Mar 6, 2014

@kevinsawicki There's a point unclear to me.
When changing a plugin config through cmd+,, is any event triggered to the plugin?

Edit: I kept the menu items unchanged since there is no way to add checkmarks to them, and also because I noticed you are using Toggle Tree View, so Toggle Tree Side seemed reasonable. (Or even Toggle Tree View Side, perhaps)

Also added default configuration value
@kevinsawicki
Copy link
Contributor

@VictorGama yes, you can use atom.config.observe "tree-view.configSetting" to listen to a config setting changing.

https://atom.io/docs/api/v0.67.0/api/classes/Config.html

@heyvito
Copy link
Contributor Author

heyvito commented Mar 6, 2014

@kevinsawicki Perfect!
And about the menu item? Can I leave it as Toggle Tree Side?

@kevinsawicki
Copy link
Contributor

Yeah, that works


toggleSide: ->
newValue = !atom.config.get('tree-view.showOnRightSide')
atom.config.set('tree-view.showOnRightSide', newValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an atom.config.toggle method that comes in handy here.

atom.config.toggle('tree-view.showOnRightSide')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 09e1526

@@ -150,7 +156,9 @@ class TreeView extends ScrollView
$(document.body).off('mouseup', @resizeStopped)

resizeTreeView: ({pageX}) =>
@width(pageX)
w = pageX
w = $('body').width() - w if atom.config.get('tree.toggleSide')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be tree-view.showOnRightSide instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ops! Sorry.

Edit: Whoa. I forgot several rules. Thanks for the heads up!

@heyvito heyvito mentioned this pull request Mar 7, 2014
onSideToggled: (newValue) ->
@detach()
@attach()
$(this).attr('data-toggle-showOnRightSide', newValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use @attr here instead of $(this).attr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 9e11874

@@ -16,7 +16,7 @@ FileView = require './file-view'
module.exports =
class TreeView extends ScrollView
@content: ->
@div class: 'tree-view-resizer tool-panel panel-left', =>
@div class: 'tree-view-resizer tool-panel', 'data-showOnRightSide': atom.config.get('tree-view.showOnRightSide'), =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Really minor feedback but I think this data attribute would read better if it was dasherized instead of camel cased since it is referenced in the .less file and class names are dasherized there.

So data-show-on-right-side instead of data-showOnRightSide

@heyvito
Copy link
Contributor Author

heyvito commented Mar 7, 2014

@kevinsawicki Dasherized :)

@@ -16,7 +16,7 @@ FileView = require './file-view'
module.exports =
class TreeView extends ScrollView
@content: ->
@div class: 'tree-view-resizer tool-panel panel-left', =>
Copy link
Contributor

Choose a reason for hiding this comment

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

A .panel-right style needs to be added to the default light/dark ui themes and then I think this is ready to be merged.

Since this is the first thing going on the right side there are no existing styles and not having .panel-left on it removes the border which is visually important

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May I add these classes on @attach?
Insert a ternary operator in the middle of this structure will be pretty bad.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, for sure, @attach is the right place to handle them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed on 358cb13

@kevinsawicki
Copy link
Contributor

I think this is almost ready, just need to get some panel-right styling in the default themes to make sure it looks consistent when on either side.

I've opened up issues on the appropriate repos.

@heyvito
Copy link
Contributor Author

heyvito commented Mar 7, 2014

Looks like some code leaked into the wrong branch. My fault.
Well, it's clean and working. :shipit:

kevinsawicki added a commit that referenced this pull request Mar 10, 2014
Add 'Toggle Tree Side' menu item
@kevinsawicki kevinsawicki merged commit 73e4acb into atom:master Mar 10, 2014
@kevinsawicki
Copy link
Contributor

Thanks for all your hard work on this, I've merged it into master. 👍

@TeckniX
Copy link

TeckniX commented Jan 16, 2015

I'm currently on Version 0.174.0 yet I do not see this preference within the settings? I saw it within the 'Open my Config' file, but this thread made it seemed like it was added to the actual cmd+, settings along with the 'Show Tabs', 'Show Line Numbers'.

I'm all for hacking config files, but for something as simple as a true/false, when the above 'Show...' have a similar true/false flag alread in the settings, then that's where I expected it.

edit: Found the menu under Package -> Tree View -> Toggle Tree Side

@ghost
Copy link

ghost commented Nov 28, 2015

Thank you so much for this! #CodeOnTheLeft4Life

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.

4 participants