Changed the image_window so that it doesn't resize itself if you keep

giving it images that are the same size.  This way if you are sending
video data to it will allow the user to change the size of the window
without having it snap right back.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403181
This commit is contained in:
Davis King 2009-09-03 21:29:40 +00:00
parent 49f2050c9a
commit 46401b0641
2 changed files with 25 additions and 7 deletions

View File

@ -5806,7 +5806,9 @@ namespace dlib
image_window::
image_window(
) :
gui_img(*this)
gui_img(*this),
nr(0),
nc(0)
{
// show this window on the screen
show();

View File

@ -3077,8 +3077,15 @@ namespace dlib
)
{
auto_mutex M(m);
// if the new image has a different size when compared to the previous image
// then we should readjust the total rectangle size.
if (new_img.nr() != img.nr() || new_img.nc() != img.nc())
set_total_rect_size(new_img.nc(), new_img.nr());
else
parent.invalidate_rectangle(rect);
assign_image(img,new_img);
set_total_rect_size(img.nc(), img.nr());
}
struct overlay_rect
@ -3162,7 +3169,7 @@ namespace dlib
template < typename image_type >
image_window(
const image_type& img
) : gui_img(*this) { set_image(img); show(); }
) : gui_img(*this), nr(0), nc(0) { set_image(img); show(); }
~image_window(
);
@ -3176,11 +3183,19 @@ namespace dlib
auto_mutex M(wm);
gui_img.set_image(img);
// set the size of this window to match the size of the input image
set_size(img.nc()+padding*2,img.nr()+padding*2);
// Only readjust the size of the window if the new image has a different size
// than the last image given to this object.
if (img.nr() != nr || img.nc() != nc)
{
// set the size of this window to match the size of the input image
set_size(img.nc()+padding*2,img.nr()+padding*2);
// call this to make sure everything else is setup properly
on_window_resized();
// call this to make sure everything else is setup properly
on_window_resized();
nr = img.nr();
nc = img.nc();
}
}
void add_overlay (
@ -3212,6 +3227,7 @@ namespace dlib
image_window& operator= (image_window&);
image_display gui_img;
long nr, nc;
};
// ----------------------------------------------------------------------------------------