I want bigger pixbufs rendered onto GtkSourceGutter - c

It seems that the size of the source marks rendered with GtkSourceGutterRenderer are remotely tied up to the size of the text in the GtkSourceView. I want to have bigger pixbufs, without making the text font size bigger and to achieve that I concluded I have to subclass a widget and override its draw signal handler.
However I have no idea which widget to subclass on. Surely one of you knows?

I think it's probably GtkSourceGutterRendererPixbuf itself that you have to subclass. If not that, then probably GtkSourceGutterRenderer with a lot of duplicated code from GtkSourceGutterRendererPixbuf.

Related

GTK4 Image Which Fills Parent

I am trying to create an image which fills its parent widget in both dimensions while keeping the aspect ratio. In gtk4-rs I did
let picture_widget = gtk::Picture::builder()
.hexpand(true)
.vexpand(true)
.halign(gtk::Align::Fill)
.valign(gtk::Align::Fill)
.keep_aspect_ratio(true)
.can_shrink(true)
.build();
But this fills only one dimension of the parent. However, I would like to overflow the parent in that dimension, such that both dimensions are filled.
Generally, I think my goal could be achieved by child.set_size_request(parent_width, parent_height). That needs to be done every time the parent size changes.
Idea 1: Listen to size_allocate signal of parent. Does not work, because the size_allocate signal has been removed: https://docs.gtk.org/gtk4/migrating-3to4.html#adapt-to-gtkwidgets-size-allocation-changes
Idea 2: Subclass Picture and set size in allocate(). But Picture is apparently not subclassable. The compiler tells me that
type ParentType = gtk::Picture; => the trait IsSubclassable<FillingPicture> is not implemented for Picture
Idea 3: Subclass Widget and use Picture inside (from https://github.com/gtk-rs/gtk4-rs/issues/393). I do not know how to then link all the function calls together such that the Picture is actually shown. (It also feels wrong to do this. If this was easily possible, Picture would probably be subclassable?)
Idea 4: Reimplement the whole Picture class from scratch. Seems overkill and too much maintenance overhead just for a simple resize.
Idea 5: Use CSS properties to fill the parent. I tried setting width and height to 100%, but apparently relative sizes are not allowed. Also the cover CSS attribute is not supported.
Idea 6: Drop GTK
Any other ideas or fixes for the ideas above?
Just getting with the same problem yesterday. The one that works for me was the 5th idea...
Idea 5: Use CSS properties to fill the parent. I tried setting width and height to 100%, but apparently relative sizes are not allowed. Also the cover CSS attribute is not supported.
But using background-image instead.
box.nameofclass {
background-image: url("resource:///{your_path_in_gresources}/pic.jpg");
background-position: center;
}
More info:
Backgrounds
I'm just beginning with gtk4-rs, so it may not be the best way to do it. It would be great to set this via properties tbh.

WPF: find how much space a control needs

In my application I have an area in the main window that at any time can contain one of several different controls.
This controls are generated at runtime and their contents can vary depending on underlying data, so I do not know beforehand how much space they'll take up.
What I want to know is: is there a way to determine at runtime how much space a control needs in order not to be "cut off" or need a scroll? ie: how much space does it need to be COMPLETELY visible?
I tried the "DesiredSize" property and it kinda works, but not always: if the control has been used already (it has already a size) it returns it's last used size rather than the correct one, even if I call "InvalidateMeasure()".
Any ideas??
Call Measure on the control. Give it infinite space as the available size for the calculation. Then check the DesiredSize to get the needed width (and/or height).

WPF tabswitch/ render takes too much time

I have a WPF application with many tabs..
in one tab.. i make a verycomplex vector drawing consisting of thousands of drawing visuals.. (this represents a machine and all elements need to be interactable..)
It takes 3/4 seconds for drawing this for the first time..After the first draw it should be done..
The problem is if i switch to another tab and comeback, it takes atlease 2,3 seconds to show the tabpage with drawing again.. Since there is no redraw, why should it take so much time..?
If the component is not going to change, you could call Freeze() on it to mark it as done. Without trying it out I don't know if that would help, but you could give it a shot.
Not all objects are Freezable. Check out the MSDN documentation for more info:
http://msdn.microsoft.com/en-us/library/ms750509.aspx
Another thing you could try would be rendering the vector art to a bitmap, and displaying that. Maybe it makes you feel icky to lose the vector precision, but if you know it's not going to change and it will look the same, what's the harm? (If you support printing or something that will require a hi-res version, you could always switch back for that operation.) For info on how to convert a UIElement to a bitmap, check out:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx
Another possible solution: You don't really explain what kind of interaction you are doing with the elements, but if all you want to do is zoom and pan, a RenderTransform may be good enough (which is more efficient than a LayoutTransform and/or moving all the elements individually). I haven't played around with combining Freeze() and a RenderTransform, but you may be able to get the desired zooming while reducing the amount of layout WPF has to do.

Increasing the size of a WPF application

I've just created my first WPF application (3 calculators inside 3 different tabs).
The entire application has been built using widths/margins/paddings as static values, since I originally didn't know that dynamic values can be used by just putting an asterix after the value.
The client has come back to me though and has asked me to increase the size of the app, that includes form fields, tabs, font-sizes, grids etc...
What would be the easiest (and/or quickest) way to do this? I'd hate to go value by value resizing every single element since there are quite a few.
I can provide code but there is lots of it and I'm not sure of how much help it would be.
Appreciate your help,
Marko
Put it all in one ViewBox, play with viewbox size to change the app size
Write an XSLT transform to take your XAML as input and spit out appropriate modified XAML, which you put back in your app.

Why isn't always possible to set a winforms dimensions?

I'm trying to size a checkboxlist control to 500,250 from its current 502,251 (It's an OCD thing) but every time I try, it just reverts to 502,251.
Is it because the parent container is docked in the window? Are there any workarounds?
(This is through the visual designer)
Most likely the control is being resized due to the control's font size. The ListControl does not like to display an item that will be "split" by the bottom edge, so it will resize the height. Try changing the control's font size and adjust again to verify.
No work around, and you really do not what one, because the control is really doing the right thing.
Yes, it is OCD. I have it also, but this one you have to let go. :O) Consider yourself lucky because you are only one or two pixels off. I was five pixels off once, and I had to put a note on my monitor to ignore it. It so bothered me.

Resources