-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make the minimap view shown match minimap #8
Comments
I see it is especially bad on big screens with vertical panel split, because the minimap canvas gets really narrow compared to the total width. The main problem is that the minimap has dynamic width, where as the tabs width are static for consistency and to make room for the title. Plus scaling of the minimap canvas does not look very nice - it gets fuzzy. But I still do not know why it gets even smaller then the original minimap canvas. I'm experimenting with scaling according to full window width to accommodate this, but still don't overflow on smaller windows/screens. |
Hi there, let me thank you for this nice plugin, I had the idea to use the minimap as a file preview in the back of my mind for some time now so I'm really happy to see it being implemented. As for the issue at hand, I think the point here is that you should not reuse the canvas from the minimap view, but create your own view instead: minimap = minimapModule.minimapForEditor(@item)
minimapElement = document.createElement('atom-text-editor-minimap')
minimapElement.setModel(minimap) As you correctly identified, the minimap canvas size is dynamic, but it's because it needs to update itself when the size change (ie. when opening However, as is, I'm not sure how well a minimap element behaves outside of a text element (you may have tried it, so I'm interested in your feedback on that). I quickly checked the sources and I think that, as long as you don't call the Let me know if yout need some changes in the minimap, but anyway, your package gives me some ideas to evolve the minimap to make it less tied to its text editor (so that package like yours can make use of the preview feature more easily). |
Thank you @abe33 and I can say the same thing to you about atom-minimap - very nice plugin. I experimented with a couple of solution before I settled with the current implementation:
As I figured most users would probably already have minimap installed, I just chose the "steal the canvas" solution 3. I would on the other hand happily go back to solution 2 since I believe it's more correct. Especially if the expose package could depend on atom-minimap as an npm dependency instead of using Currently I use When I get the time I will continue with solution 2 outside a text editor. But I probably need some additional notes from you. |
I started working on a stand-alone version of the minimap (see here), if you want to give it a try. In the end, the goal is to have stand-alone minimap's size being completely controlled by their view, so that you can put a view anywhere, give it any size and still have the associated model behaves properly when it comes to scrolling and redraw. I also tried to figure how to use the current version in stand-alone mode based on the hypothesis I made in my previous post. There's a lot of things that break (like most styles and the rendering of the minimap when scrolling in the text editor), but I still get a result that should be enough for I made a quick gist that you can put in your init script to test that, it'll work with both the old and new API so you can take inspiration from that if you want to support both versions. It appends a minimap view in the top right corner of the screen with a fixed size defined through CSS, just click on it to destroy the view: atom.packages.serviceHub.consume 'minimap', '1.0.0', (minimapAPI) ->
atom.commands.add 'atom-workspace',
'minimap:test-stand-alone': =>
# With the new API we can just get a new stand-alone minimap
if minimapAPI.standAloneMinimapForEditor?
minimap = minimapAPI.standAloneMinimapForEditor(atom.workspace.getActiveTextEditor())
minimapElement = atom.views.getView(minimap)
minimapElement.attach(document.body)
# With the old API we have to reuse the existing minimap model
else
minimap = minimapAPI.getActiveMinimap()
minimapElement = document.createElement('atom-text-editor-minimap')
minimapElement.setModel(minimap)
document.body.appendChild(minimapElement)
minimapElement.attached = true
minimapElement.style.cssText = '''
width: 300px;
height: 300px;
position: fixed;
top: 0;
right: 100px;
z-index: 10;
'''
minimapElement.addEventListener 'click', f = ->
minimapElement.removeEventListener 'click', f
minimapElement.destroy()
There's an Atom service you can consume (see my snippet above). Also, when the packages set feature will be available, you could probably make use of it to bundle |
@abe33; I played around with the standalone minimap consumable that you recently released, which is definitely a better solution for me. I still have questions/tasks that needs to be looked at:
|
|
Thank you @abe33. I have just published a package update using the minimap standalone consumable and it is definately a better appoach. I will add the things I have observed using the standalone minimap to the minimap repo, where it belongs, when I get the time. Especially the scaling was a bit cumbersome. It does however not improve much on the original issue by @eboracus. I have scaled it up a bit, but if I set it to fill the div it looks terrible. |
Sure, I'll be waiting your feedback. Thinking again about this issue, maybe I can make the rendering settings (line height, char width and height) overridable at the minimap level so that one can tweak them at will when using a stand-alone minimap. I think that in your case, the proper way to use this would be to test whether there's a preferred width defined so that you can adjust the render size to match your container. I may face some difficulties to work on that until Atom 1.0.20 gets released as there were some API changes in it that broke the minimap (I was using some private API that were removed), and as I'm always using an Atom version built against master I'm also forced to use a patched version of the minimap that is not released yet (I'm waiting the official release to push the patch). I'm also wondering if the scroll indicator should be displayed in that mode, I was somehow displeased seeing it all alone on the right of the preview: |
58d5f4e removes the minimap control. A helper method for scaling would be much appreciated, but I do not see how custom line height, char width and char height would help in my case. |
Scaling a canvas is almost never the best approach as it gives a blurry result.
If you you want to have a preview that is consistent with what the user see in its minimap you shouldn't touch anything (no scaling, no rendering tweaks). But it will result in the preview not fitting the tab width (in my case a line will never takes more that 80px, which leave a lot of empty space in the preview tab). If you don't care being consistent with the minimap render, and rather trying to fill as much of the available space then tweaking the minimap render can be useful. Let's say that the preview tab has a width of 160px, if I have a preferred line length of 80 chars then you can compute that to fill the available space you can use a char width of 2px, but it will give a weird render if the other setting aren't changed accordingly, in that case, to be more consistent you should end up with a minimap with a 2px interline, 2px char width and 4px char height. Now it's just a suggestion as I don't really know what should be the best here, I just think that scaling a canvas should be the last resort. |
4a9691c does not completely solve the issue, but I believe it makes it a lot better - sharper, better sized and less of a hack. If you are still not convinced, I will reopen this issue again. |
Appreciate all the effort that has gone into this. I agree, even if its not optimum, it certainly looks a lot better filling more of the tab now. Nice job! 👍 🍻 |
The minimap view I'm getting on expose seems to be a lot narrower than the view shown by the minimap itself for each file (which is much more representative of how the file content looks). Is something squashing the width of the minimap when shown on the tabs? It'd be really nice if the view could fill the tab as it does in the file.
Minimap view on tabs:
Minimap view in file:
The text was updated successfully, but these errors were encountered: