gedbg: Allow grow and shrink to fit.

This commit is contained in:
Unknown W. Brackets 2016-01-10 09:25:54 -08:00
parent c6ffed6484
commit 6ebbf2cb72
2 changed files with 20 additions and 4 deletions

View File

@ -322,7 +322,7 @@ void SimpleGLWindow::GetContentSize(float &x, float &y, float &fw, float &fh) {
x = 0.0f;
y = 0.0f;
if (flags_ & (RESIZE_SHRINK_FIT | RESIZE_CENTER) && !zoom_) {
if ((flags_ & RESIZE_SHRINK_FIT) != 0 && !zoom_) {
float wscale = fw / w_, hscale = fh / h_;
// Too wide, and width is the biggest problem, so scale based on that.
@ -334,6 +334,17 @@ void SimpleGLWindow::GetContentSize(float &x, float &y, float &fw, float &fh) {
fh = (float)h_;
}
}
if ((flags_ & RESIZE_GROW_FIT) != 0) {
float wscale = fw / w_, hscale = fh / h_;
if (wscale > hscale && wscale < 1.0f) {
fw = (float)w_;
fh /= wscale;
} else if (hscale > wscale && hscale < 1.0f) {
fw /= hscale;
fh = (float)h_;
}
}
if (flags_ & RESIZE_CENTER) {
x = ((float)w_ - fw) / 2;
y = ((float)h_ - fh) / 2;

View File

@ -46,11 +46,16 @@ struct SimpleGLWindow {
enum Flags {
RESIZE_NONE = 0x00,
RESIZE_CENTER = 0x02,
RESIZE_SHRINK_FIT = 0x01,
RESIZE_CENTER = 0x01,
RESIZE_SHRINK_FIT = 0x02,
RESIZE_SHRINK_CENTER = 0x03,
RESIZE_GROW_FIT = 0x04,
RESIZE_GROW_CENTER = 0x05,
RESIZE_BEST_FIT = 0x06,
RESIZE_BEST_CENTER = 0x07,
ALPHA_IGNORE = 0x00,
ALPHA_BLEND = 0x04,
ALPHA_BLEND = 0x08,
};
SimpleGLWindow(HWND wnd);