Allow user to resize window such that Gtk3 TextView component can't show all text - resize

I'm working on a GTK program in Rust (someone can probably answer this if they don't know Rust, as I can figure out how to translate between different bindings and the native C API) via the gtk-rs bindings for which I want to have a non-editable TextView who's contents are constantly updated in my code. I want the user to be able to resize the TextView to any size, after which my code will re-calculate its contents accordingly. Unfortunately, GTK prevents any resize from taking place that would hide any contents that are current in the TextView. I can't use a ScrolledWindow because I don't want visible scrollbars, and disabling the scrollbars on a ScrolledWindow prevents the resizing behavior that I want. I also tried calling set_size_request to set the size to both 1, 1, and 0, 0 after every text change, but this does not change the behavior at all either — the user still can't properly resize the TextView (by resizing the window).
How can I enable the resizing behavior that I want?

Probably this is not possible. What would be the point of resizing the text view smaller, if the user can never see the text that is outside of the viewport because you don't want scrollbars? That seems like it would confound the user's expectation of how such a component would usually work.
Maybe an approach could be that you pick a certain number of lines to show, make that the size of the viewport, and delete the old contents of the text view that scroll outside of the viewport?

Related

Understanding collapsible box layout and sizing

I am working on a Qt-UI with PyQt and found this nice snipped to create a custom collapsible box widget here: How to create collapsible box in PyQt
I have just replaced the internal QScrollArea by a QFrame.
It works perfectly, as long as the content of the layout that is added stays the same.
However, I allow the user to add or remove widgets from that layout dynamically during use. Here I need some help. I am adding a Grid Layout with, say, 3 widgets inside there (initial creation of the box with .setContentLayout) and once the user adds a 4th widget:
the layout is compressed and keeps its original size
all widgets inside are compressed to fit in the newly created one
overall size of the collapsible box is kept constant.
I have played with various options like updateGeometry() on the content_area and all surounding widgets. It seems I don't fully understand what this code does, I am not really familiar with these animations yet. My best guess is, that the animation somehow blocks the update of the height of the collapsible box, causing the layout to be compressed.
I would be really happy for a pointer where to look / what to adjust to get the size of the collapsible box reacting to the size of the containing layout.
Thanks!

Displaying overlayed QGraphicsItems

I have developed an application in PyQt5 that displays an image and allows the user to pan the image using the mouse and zoom using the mouse wheel. I now need to add the functionality to show popup text associated to specific parts of the displayed image. While painting the text directly on to the QGraphicsScene is a possibility, the range of zooms that are commonly used means that the text will be much too small when zoomed out, or much too large when zoomed in.
I would like to achieve a way of placing the QGraphicsTextItem widgets at a static location that is not affected by the pan and zoom. This way, they can be statically located around the perimiter of the QGrapicsView, and I can draw a line from the text box to the position in the scene. My problem is that I cannot find a way to place the text items so they are independant of the QGraphicsScene. I am thinking that I should have the text items external to the scene, and place the QGraphicsView and any text boxes in a parent QObject. I cannot figure out if this is the best method, and have had limited success with trying to connect a line from QGraphicsElipsesItem that marks the position on the image, to a QLabel in the parent QObject.
I hope I have made this clear enough. Please comment if it needs more clarification.

Add a scrollbar to yfiles.canvas.Control

I have a yfiles.canvas.Control, with some nodes inside. However, the number of nodes is getting bigger, and I need to add a scrollbar in order to vertically navigate through them, despite the reduced size in height.
How can I do this? I see that a ScrollBar class exists, but I don't know how to integrate it.
yFiles for HTML comes with scrollbars built in. You can customize their visibility, but by default they will be shown as soon as the content rectangle is larger than the visible area. Maybe calling updateContentRect is all that is missing in your code?

live tiles in Windows Phone and Grids

I'm trying to create a live tile for my application, using a user control.
The user control contains a grid, an image and a rectangle filled with color.
Now here comes the funny part.
I want the rectangle to act as a background for the tile's title, and the image to fill the rest of the tile. And i said to myself, well, lets put some rows in that grid and set the like you usually set them in a WPF/SL application.
I then write the entire thing in a WBM and save it to isostore.
The problem is, the parser seems to ignore the presence of grid's rows. regardless of what I try, the rectangle is not shown, and the image covers the full tile, when it should only cover the first row. It is as if the grid didn't even existed.
Another funny aspect is that it doesn't matter if I use rows or columns, the result is the same.
Any ideas?
Are you using the following method?
Dynamic LiveTile - adding background image?
I recently implemented a Live Tile using a Grid with Rows and Columns for layout of some TextBlocks. I encountered similar challenges, so I placed the control that I was using for my Live Tile on a blank page in my app to better see what was happening. Does the control render correctly when displayed on a page (versus being rendered to a WriteableBitmap)?
Another idea. Instead of trying to position the Rectangle relative to the tile's Title, why not leave the Title property blank and put the same text in a TextBlock within the user control?
If you are careful about the font and positioning of the TextBlock, the text on the resulting background image can appear indistinguishable from text displayed from the Title property. I decided to follow this strategy myself. I found the font information in the following answer:
Font size and family for a tile's title
Otherwise, could you post an example of the XAML you are using?

VB.NET: Scrollbar "button"?

I plan on using a scrollbar for, well, scrolling an image. The image is 200x500, however, the only visible area is 200x250.
So I set the max value to 250, and the min value to 0. The idea is that if I drag the scrollbar's button to the bottom, 250 pixels will have moved for the image, right?
But wait, the scrollbar's button is.... very small. And the scrollbar is actually pretty long. Is there a way to make the scrollbar's button longer?
How did you create this scrollbar? Is it a separate control all together, or it is a component of another control? I do know that scrollbars added separately act kinda funny at times.
What I would suggest is using the scollbars built into another container control, which should achieve the exact same effect.
Create a new panel control on your form, and name it. (I suggest something like panelPicture)
Position the panel where you want your picture to be.
Set the panel's size to 200x250.
Set the panel's "Autoscroll" property to True.
Put a PictureBox inside this panel, and name it. (I suggest something like picMyPicture.)
Set the PictureBox's position to 0, 0.
Set the PictureBox's size to 200x500 (or whatever is necessary).
Set the PictureBox's Image property as desired.
Now, the scrollbar should automatically appear on the picture, and it should look normal.
As a side note (which may or may not be relevant), users typically don't like having to scroll to see the rest of an image, so if you don't need the user to scroll down on the image for some definitive purpose (or because you don't know what the size of the image that will be handled is), I'd try and change the size of things on your form so scrolling will not be necessary.
I hope this helps!