buchizo / ClaudiaIDE

This extension can change easily the background image of editor window in Visual Studio.
https://marketplace.visualstudio.com/items?itemName=kbuchi.ClaudiaIDE
641 stars 112 forks source link

[Feature] Image should be able to be positioned relative to the current scroll position. #210

Open SquirrelKiev opened 3 weeks ago

SquirrelKiev commented 3 weeks ago

Not entirely sure how to phrase this, but, it'd be nice if the image could be positioned relative to the current scroll position (as well as absolutely, as it is currently). Scroll all the way to the bottom of the code window and you see the image type thing.

SquirrelKiev commented 3 weeks ago

https://github.com/user-attachments/assets/78ca4a97-445c-4d9f-937f-53e973f94bc3

Still not confident in my phrasing haha, hope this explains better.

buchizo commented 3 weeks ago

Your wants feature means like as parallax, rights? If right, it's so cool. But unfotunataly ClaudiaIDE is limited by Visual Studio editor.

Visual Studio's editor is include a lot of layers. e.g. text, cursor, highlight, line number, e.t.c. e.t.c.. ClaudiaIDE insert image layer to Visual Studio. This means ClaudiaIDE can control only mine layer. I guess this feature should control all area for editor (maybe virtual), however I'm not know how to it.

SquirrelKiev commented 3 weeks ago

Prefacing with I'm not too familiar with how Visual Studio rendering works, but if it's possible to get the current position of where the code window is currently scrolled to, it should be trivial to figure out the math for where to place the image from there I'd assume?

SquirrelKiev commented 3 weeks ago

https://github.com/user-attachments/assets/c9ae2ad4-c627-47f4-a56b-dfaefe8c6132

Tried the approach I mentioned above, seems to work, although not well without lots of tweaks. From what I can gather it seems like it'd be quite a bit of work to get this working with all the existing settings options.

For reference, here's a snippet of the implementation above. Had to change the ViewportUnits which alone i can imagine would break a fair few settings if integrated properly,

                _view.LayoutChanged += (s, e) =>
                {
                    if (!_hasImage)
                    {
                        InvokeChangeImage(null, null);
                    }
                    else
                    {
                        RefreshBackground();
                    }

                    if (_visualBrushStatic != null)
                    {
                        // a lot of this should be changed at creation time of _visualBrushStatic, not every layout change like im doing here.
                        _visualBrushStatic.ViewportUnits = BrushMappingMode.Absolute;

                        var vp = _visualBrushStatic.Viewport;
                        // 0 here should be replaced with _settings.ViewBoxPointX and _settings.ViewBoxPointY respectively
                        // but that causes weird positioning due to other defined behaviour
                        vp.X = 0 - _view.ViewportLeft;
                        vp.Y = 0 - _view.ViewportTop;
                        // this is wrong really, as this will only be the width and height of the viewable area.
                        vp.Width = _view.ViewportWidth;
                        vp.Height = _view.ViewportHeight;

                        _visualBrushStatic.Viewport = vp;
                    }
                };
buchizo commented 3 weeks ago

WIP

https://github.com/user-attachments/assets/290b2369-2f45-425f-9134-4c37f98eaedd