dijit.dialog - Dynamically Sized dijit.Dialog Not Centered - dojo

I'm having issues with correct sizing and positioning of digit.dialog.
I'm using the built in logic of dijit.dialog to determine the dialog width and positioning as it's content can be any size. In addition, the dialog content needs to be set via the href tag. If I start the browser window at 300px width, the right side of the dialog is all the way to the right. As soon as I manually resize the browser to the full width, and then shrink it, it adjusts the position. Sometimes it gets it correctly, but it's not consistent.
How do you get digit.dialog correctly so it displays it's content correctly for the first load time?
Please look at plunkr: http://plnkr.co/edit/FLO1VFWX2LbZeZAZuhYm?p=preview
new dijit.Dialog({
id: "modal",
href: "modal.html
});

Your content needs to have a fixed size. Otherwise The position is calculated with an inner size which is not relevant anymore after the sizing.
Basically, when re-sizing, the position is calculated using the previous width.
By calling multiple times the resize method, the dialog will adjust its position (a sort of binary search of the best position/size)
dialog.show().then(function() {
dialog.resize();
dialog.resize();
dialog.resize();
dialog.resize();
dialog.resize();
});
http://plnkr.co/edit/bhhAZlYOE6kIduxOX8cn?p=preview
But this is extremely ugly. You should consider giving a width of the content

Related

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

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?

Codenameone Slider cannot set height

I am finding it difficult to set the right look and feel of a CN1 Slider control. Essentially i want it to look like the one in the CN1 Default Demo of the Theme window, and have it with the Thumb image to allow the user to set the scroll.
But when i code it up as per online examples, it comes out skinny on the simulator (as below)
...but doesn't display the line at all on the actual iphone device.
When i start messing with the methods, such as 'getSliderEmptyUnselectedStyle()' then this makes the background show and can see the progress but its tall and i cannot seem to shrink it.
Container container = new Container(new FlowLayout());
container.getAllStyles().setBgTransparency(255);
container.getAllStyles().setBgColor(0xffffff);
Slider slider = new Slider();
// slider.getAllStyles().setFgColor(0);
// slider.getAllStyles().setMarginLeft(0);
// slider.getSliderEmptyUnselectedStyle().setBgTransparency(255);
// slider.getSliderFullUnselectedStyle().setBgTransparency(255);
// slider.getSliderEmptySelectedStyle().setBgTransparency(255);
// slider.getSliderFullSelectedStyle().setBgTransparency(255);
// slider.getSliderEmptyUnselectedStyle().setBgColor(0xffffff);
// slider.getSliderFullUnselectedStyle().setBgColor(0x42B72A);
// slider.getSliderEmptySelectedStyle().setBgColor(0xffffff);
// slider.getSliderFullSelectedStyle().setBgColor(0x42B72A);
Style sliderStyle = UIManager.getInstance().getComponentStyle("Label");
sliderStyle.setFgColor(0);
slider.setThumbImage(
FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, sliderStyle, 4).toImage());
slider.setMinValue(0);
slider.setIncrements(25);
slider.setProgress(entity.getCompletion_pct());
slider.setEditable(true);
container.add(slider);
return container;
How can i get it pretty much to the CN1 example?
Thanks
The slider in the example used a 9-piece border or a 3-piece border both of which have a fixed minimum height/width. This minimal height is applied to the way the slider is rendered.
Your code can be made thicker with padding but it will create a problem when you add a thumb. Once you add the thumb it will increase the overall size and make the entire height of the thumb have that background. So you need to style this via the designer and for this specific case you would want to use an image border that is carefully measured to align with the thumb image.
Also notice you used getAllStyles() which is wrong. Slider is a special case and uses the Slider and SliderFull UIID so effectively the component has two UIID's and two separate sets of Style objects.

How to shrink wrap image in wxScrolledWindow

I have a frame that has some stuff at the top, and a wxScrolledWindow below. The scrolled window contains an image selected by the user. I want the frame to shrink-wrap it so that background never shows in the scrolled window. I am using a BoxSizer in the frame. Everything works perfectly until the user drags a border to increase the viewing area. He takes it too far, and background shows. I have tried at least a dozen methods, but I cannot get the window's border to snap back when the user drags the border beyond where the scrollbars disappear. When the image is loaded, the scrolled window calls SetMaxClientSize() with the right numbers, but it has no effect. A couple of pictures will help. I have just dragged the right border to the right, increasing the viewing area. Here is what it looks like:
I want the border to snap back so it looks like this:
Windows 7 x64, wxWidgets 2.9.4
Re-implement the size event handler. If the new size is larger than you want, modify it to the largest you accept. Then call the base implementation.
void MyFrame::OnSize(wxSizeEvent& event)
{
wxSize new_size = event.GetSize()
wxSize max_size = ... calculate max size ....
if ( new_size.GetHeight() > max_size.GetHeight() {
new_size.SetHeight( max_size.GetHeight() );
if ( new_size.GetWidth() > max_size.GetWidth() {
new_size.SetWidth( max_size.GetWidth() );
event.SetSize( new_size );
wxFrame::OnSize( event );
Also, be aware of this note in the documentation:
Important : Sizers ( see Sizers Overview ) rely on size events to
function correctly. Therefore, in a sizer-based layout, do not forget
to call Skip on all size events you catch (and don't catch size events
at all when you don't need to).
Ravenspoint's answer doesn't seem to work (using wxWidgets 3.0.3 or 2.8.12). The frame is resized larger than desired even when the event size is reduced and propagated as you suggested. Here's an example:

jQuery Isotope: resize elements via user control?

I'm using jQuery Isotope and I'm wondering if there's a built-in (or at least "easy") way to have it dynamically resize elements via a user control, like a slider.
There's a fluid/responsive demo in the documentation, but it resizes elements based on the size of the browser window. I'm looking for something where the window/container would stay the same size, and the user could control the size of the elements by dragging a slider (like the thumbnail size slider in iPhoto).
Is this even possible? I haven't been able to find any examples of Isotope used in this way.
You should try this link: http://isotope.metafizzy.co/demos/relayout.html This sample shows you how an item resizes onclick, but you can transfer this code to make it work with a slider. But as far as I know this plugin uses predefined width and heights via css-classes for its animations, so you might add a lot of css-classes different sizes and it won't work stageless but I am insecure about this. You'll probably need to set the size of an element dynamically. For example you can use the following code to increase the size of an item 5px in width and height:
/* resizing and relayouting the list */
$container.on('click', '.item', function(){
$this = $(this);
$this.width( $this.width() + 5);
$this.height( $this.height() + 5);
//reorganizes the elements in the list
$container.isotope('reLayout');
});
$container is your wrapping element and ".item" is the class of an item. You should probably use a named function for this event handler to bind and call it with your scroller. Hope that helps.

Controls change place and form size changes

I have designed a form in VB.NET. At design time I have placed two buttons on it.
When I run it, the form size looks smaller and the buttons I have placed at the bottom are not visible. Also the alignment of the text and picture box is also different from what I set at design time.
Computer at which I am running the form is using a different resolution.
change the properties (F4) of the buttons: in ANCHOR put Bottom, Right
your buttons will be tied to the bottom and the right of the screen, instead of to the top, left, which is the default.
Grab the screen size at runtime with
Dim screen as System.Windows.Forms.Screen = System.Windows.Forms.Screen.PrimaryScreen
and using a scale factor depending on the current size (in design), scale the window to match. Check the coordinates of the buttons by hand to make sure they are not outside of the visible portion of the window.
You may not have to leave this feature in if you can debug it to the point that you know the exact resolution that you need.