MacVim: get Vsplit width - scrollbar

I wanted to modify the function created by Andreas Politz (discussion here: https://groups.google.com/d/msg/vim_use/6bO-QKWj9_4/2cdqygSqcMgJ) to work with vsplits too. This function creates a horizontal scrollbar to indicate the current position in the file (I actually don't like MacVim default scrollbars). The size of the scrollbar depends on the width of the whole window and does not adapt to vsplit. As I use NERDTree plugin, every vsplit has a oversized scrollbar.
I've done some searches on StackOverflow and VIM wiki but I only found commands to resize the vsplit and none to get the actual size.
Do you have any clue on how to get the current vsplit width?
PS: My results so far:
:set columns returns actual window size
:set winwidth returns the minimum width of window
:set window gives me a number that doesn't change when I switch between splits (77 each time)

:echo winwidth(0)
returns the width of window 0.
See :help functions for a comprehensive list of functions available in Vim. The documentation is the first place you should visit if you are looking for anything Vim-related.

Related

Adobe Edge: change element's width at document.compositionReady and at window.resize

In my Adobe Edge project, I'm trying to create a website that adapts according to the width of the window. So my plan is:
1. Check the width when the site is loaded and adapt the elements if necessary.
2. Check the width whenever the window is resized and adapt the elements if necessary.
In order to do this I've created this function.
function adapt() {
if ($( window ).width() <= 800) {
sym.$("testo_box").css("width", "99%");
sym.getComposition().getStage().$("corpus_txt").html("Test");
}
}
You can see what the elements are in the attached image.
Elements
The first problem is I couldn't find any way to create this function in such a place and in such a way that it can be global, and call-able from within other scripts.
But my main problem is this: when I place this function inside Stage -> window.resize, and call it with:
adapt();
It works perfectly. But when I place it inside Stage -> document.compositionReady and call it the same way, the following line:
sym.$("testo_box").css("width", "99%");
doesn't produce the expected result. It does nothing.
I'm sure the if condition is checked and verified, because the other line:
sym.getComposition().getStage().$("corpus_txt").html("Test");
produces the expected result.
I have a workaround for this, which makes use of the timeline and labels, but quite frankly is very impractical.
Just to clear things, up, I know it's pointless to create that function to call it right below from the same "place" and only once. The result would be identical if just the "if" part was there. The plan is to make the function global and just call it from those "places".
Thanks to everyone who will be so kind to help out a newbie like me, and hopefully the answers will help other people as well.

Adjust height of QListWidget when window is resized

I have based a settings dialog on the Qt config dialog example found here:
http://doc.qt.io/qt-5/qtwidgets-dialogs-configdialog-example.html
I would like the QListWidget to fill the left of the window (except for the button bar at the bottom) regardless of the vertical size of the window. In Delphi there was a simple property to set. I can't find a similar thing in Qt.
Is this possible? If so, how?
--- edit ---
The example I linked to has the same behaviour. My code is virtually a copy of that example.
Here is a screen shot showing the problem:
This can be fixed by removing mainLayout->addStretch(1); from configdialog.cpp. This line adds empty space that stretches instead of other content when extra space is available.

Qt Layout, resize to minimum after widget size changes

Basically I've got a QGridLayout with a few widgets in it. The important ones are 2 labels, which I use for drawing images to the screen. Well, if the user wants, he can change the resolution of the incoming images, thus, forcing the Labels to resize.
Let's assume the initial size of the label is 320x240. The user changes the VideoMode to 640x480, the label and the entire GUI resizes perfectly. But when the user switches back to 320x240, the label shrinks, but the Layout/Window does NOT.
I've played around with sizePolicies and sizeHints, and resize(0,0), but nothing did the trick. Could somebody help me with this?
Here some screenshots to clarify the problem:
You need to set the size constraint of the layout holding all your widgets to "SetFixedSize". Although the name doesn't sound like it will work, it ensures that your layout will only use the space it needs. You will not have the problem like you do in your second screenshot.
Example:
mainLayout.setSizeConstraint(QLayout::SetFixedSize);
QLayout::setSizeConstraint(QLayout::SetFixedSize) solves this problem well when you prefer keeping your widget's size fixed at all times--that is, if you'd like it to always be fixed to its "packed" size (which may still vary as the child widgets change size). That is what the "fixed" means there: "fixed" to the correct size, even as the latter varies. (In Qt terms, what I'm calling the "packed" size is simply the widget's sizeHint.)
But a constraint may be too strong a solution in some instances. In particular, if you apply it to a top-level window, then the user will not be free to resize the window. If you don't like that, you can instead perform the "set size to sizeHint" operation instantaneously each time it's needed, rather than imposing it as an unrelenting constraint. The way to do that is to call QWidget::adjustSize().
http://doc.qt.io/qt-5/qwidget.html#adjustSize
Note that if the container whose children are changing size is not the top-level window, then adjustSize() may have to be called recursively on the container and its parents. (In my case I had to do that, anyway. I also tried the size-constraint scheme, and found that applying the constraint at only the topmost level was successful in compacting all levels. I haven't enough knowledge of Qt to comment usefully on these observations, so I merely share them.)
You need to store the original size of your widget parent window before applying any changes to the layout and restore it when the user switches back to the original.
Notice that you need to work with the widget parent window size and not the widget parent size.
in your widget before applying the layout changes:
minimumWindowSize = this->window().size();
when you finished reorganizing the widget to the compact size
this->window().resize(minimumWindowSize);
So that is exactly what i'm doing in mu project.
Resolution os doesn't matter. I have only to have a widget for rendering video, or image in your case.
void MainWindow::resizeEvent(QResizeEvent* event)
{
QMainWindow::resizeEvent(event);
if ((player != 0) && ((player->isPlaying()) || player->isLoaded() || player>isLoaded())){
renderer->resize(ui->mainVideoWidget->width(),ui->mainVideoWidget->height());
resizeFilter();
}
}

Enable QLabel to shrink even if it truncates text

How can I get a QLabel to be resized even if it means truncating its containing text? I have a QLabel stretching the whole horizontal space of a Widget. When setting its text I make sure it is correctly truncated, ie getting its FontMetrics and Width and using metrics.elidedText().
But when the user resizes the widget the Label doesn't allow it to shrink any further since it would truncate its text.
Any ideas how to solve this? The simplest solution I think would be to somehow tell the QLabel to always shrink and then catch the resize event and correctly format the text - I just have no idea how to do the first part (different size policies don't help)
Although you mention that setting size policies didn't help, setting the QLabel's horizontal size policy to QSizePolicy::Ignored should tell the containing layout manager to ignore any minimum size hint from the label. An alternative would be to set the QLabel's minimum horizontal size to a non-zero value, like 1. If neither of these work then there is something else interfering.

Problems when printing a SWF in browser

I'm trying to print a SWF and have come across some problems.
When using the Print function in the browser, the SWF will be distorted, and not scaled correctly. So I've tried to implement a Print function using Actionscript instead.
The different approaches I've taken are:
Printing using the right click context menu of the Flash Player and choose Print. This works almost as expected, but It flattens transparent PNGs and isn't scaled correctly.
Creating a FlexPrintJob and adding the component to the job. Will not scale the component to fit the page, even though I've set FlexPrintJobScaleType.SHOW_ALL on the print job.
Creating a PrintView containing an Image. Then taking a screenshot of the component and set this as the Image in the PrintView. When this is done, I create a new FlexPrintJob and send it. This seems to work most of the times, but the scaling will distort and make small elements (like text) look really bad.
The code for printing looks like this:
var pj:FlexPrintJob = new FlexPrintJob();
if (pj.start())
{
pj.addObject(componentToBePrinted, FlexPrintJobScaleType.SHOW_ALL);
pj.send();
}
What I would like to do is to get the right click context menu to work, and by that I mean setting the scaling of the SWF. Is this possible? Are there any other alternatives when printing a SWF? What am I doing wrong?
When testing, I'm printing to a PDF, but I don't think that will change the results.
You need to scale your Print Job for what you want in FlexPrintJobScaleType:
MATCH_WIDTH
(Default) Scales the object to fill
the available page width. If the
resulting object height exceeds the
page height, the output spans multiple
pages.
MATCH_HEIGHT
Scales the object to fill the
available page height. If the
resulting object width exceeds the
page width, the output spans multiple
pages.
SHOW_ALL
Scales the object to fit on a single
page, filling one dimension; that is,
it selects the smaller of the
MATCH_WIDTH or MATCH_HEIGHT scale
types.
FILL_PAGE
Scales the object to fill at least one
page completely; that is, it selects
the larger of the MATCH_WIDTH or
MATCH_HEIGHT scale types.
NONE
Does not scale the output. The printed
page has the same dimensions as the
object on the screen. If the object
height, width, or both dimensions
exceed the page width or height, the
output spans multiple pages.
See http://livedocs.adobe.com/flex/3/html/help.html?content=printing_3.html
for more information on this.

Resources