mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-07 02:39:56 +00:00
GLK: Remaining window rearrange code
This commit is contained in:
parent
89102c42ca
commit
b9bafba382
38
engines/gargoyle/picture.cpp
Normal file
38
engines/gargoyle/picture.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software{} you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation{} either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY{} without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program{} if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gargoyle/picture.h"
|
||||
|
||||
namespace Gargoyle {
|
||||
|
||||
void Picture::increment() {
|
||||
++_refCount;
|
||||
}
|
||||
|
||||
void Picture::decrement() {
|
||||
if (_refCount > 0 && --_refCount == 0) {
|
||||
free();
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Gargoyle
|
53
engines/gargoyle/picture.h
Normal file
53
engines/gargoyle/picture.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GARGOYLE_PICTURE_H
|
||||
#define GARGOYLE_PICTURE_H
|
||||
|
||||
#include "graphics/surface.h"
|
||||
|
||||
namespace Gargoyle {
|
||||
|
||||
struct Picture : Graphics::Surface {
|
||||
int _refCount;
|
||||
uint32 _id;
|
||||
bool _scaled;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Picture() : Graphics::Surface(), _refCount(0), _id(0), _scaled(0) {}
|
||||
|
||||
/**
|
||||
* Increment reference counter
|
||||
*/
|
||||
void increment();
|
||||
|
||||
/**
|
||||
* Decrement reference counter
|
||||
*/
|
||||
void decrement();
|
||||
};
|
||||
|
||||
} // End of namespace Gargoyle
|
||||
|
||||
#endif
|
@ -541,7 +541,7 @@ void TextBufferWindow::touchScroll() {
|
||||
_windows->clearSelection();
|
||||
|
||||
// TODO
|
||||
//winrepaint(win->bbox.left, win->bbox.top, win->bbox.right, win->bbox.bottom);
|
||||
//winrepaint(bbox.left, bbox.top, bbox.right, bbox.bottom);
|
||||
for (int i = 0; i < scrollmax; i++)
|
||||
lines[i].dirty = true;
|
||||
}
|
||||
@ -632,10 +632,10 @@ void TextBufferWindow::putCharUni(glui32 ch) {
|
||||
|
||||
gli_tts_speak(&ch, 1);
|
||||
|
||||
pw = (win->bbox.x1 - win->bbox.x0 - Windows::_tMarginx * 2 - gli_scroll_width) * GLI_SUBPIX;
|
||||
pw = (bbox.right - bbox.left - Windows::_tMarginx * 2 - gli_scroll_width) * GLI_SUBPIX;
|
||||
pw = pw - 2 * SLOP - radjw - ladjw;
|
||||
|
||||
color = gli_override_bg_set ? gli_window_color : win->bgcolor;
|
||||
color = gli_override_bg_set ? gli_window_color : bgcolor;
|
||||
|
||||
// oops ... overflow
|
||||
if (numchars + 1 >= TBLINELEN)
|
||||
@ -669,7 +669,7 @@ void TextBufferWindow::putCharUni(glui32 ch) {
|
||||
}
|
||||
}
|
||||
|
||||
if (gli_conf_dashes && win->attr.style != style_Preformatted)
|
||||
if (gli_conf_dashes && attr.style != style_Preformatted)
|
||||
{
|
||||
if (ch == '-')
|
||||
{
|
||||
@ -693,9 +693,9 @@ void TextBufferWindow::putCharUni(glui32 ch) {
|
||||
dashed = 0;
|
||||
}
|
||||
|
||||
if (gli_conf_spaces && win->attr.style != style_Preformatted
|
||||
&& styles[win->attr.style].bg == color
|
||||
&& !styles[win->attr.style].reverse)
|
||||
if (gli_conf_spaces && attr.style != style_Preformatted
|
||||
&& styles[attr.style].bg == color
|
||||
&& !styles[attr.style].reverse)
|
||||
{
|
||||
// turn (period space space) into (period space)
|
||||
if (gli_conf_spaces == 1)
|
||||
@ -731,7 +731,7 @@ void TextBufferWindow::putCharUni(glui32 ch) {
|
||||
}
|
||||
|
||||
chars[numchars] = ch;
|
||||
attrs[numchars] = win->attr;
|
||||
attrs[numchars] = attr;
|
||||
numchars++;
|
||||
|
||||
// kill spaces at the end for line width calculation
|
||||
@ -800,8 +800,58 @@ void TextBufferWindow::TextBufferRow::resize(size_t newSize) {
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
GraphicsWindow::GraphicsWindow(Windows *windows, uint32 rock) : Window(windows, rock) {
|
||||
GraphicsWindow::GraphicsWindow(Windows *windows, uint32 rock) : Window(windows, rock),
|
||||
w(0), h(0), dirty(false), _surface(nullptr) {
|
||||
_type = wintype_Graphics;
|
||||
Common::copy(&bgcolor[0], &bgcolor[3], bgnd);
|
||||
}
|
||||
|
||||
void GraphicsWindow::rearrange(const Common::Rect &box) {
|
||||
int newwid, newhgt;
|
||||
int bothwid, bothhgt;
|
||||
int oldw, oldh;
|
||||
Graphics::ManagedSurface *newSurface;
|
||||
|
||||
bbox = box;
|
||||
|
||||
newwid = box.width();
|
||||
newhgt = box.height();
|
||||
oldw = w;
|
||||
oldh = h;
|
||||
|
||||
if (newwid <= 0 || newhgt <= 0) {
|
||||
w = 0;
|
||||
h = 0;
|
||||
delete _surface;
|
||||
_surface = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
bothwid = w;
|
||||
if (newwid < bothwid)
|
||||
bothwid = newwid;
|
||||
bothhgt = h;
|
||||
if (newhgt < bothhgt)
|
||||
bothhgt = newhgt;
|
||||
|
||||
newSurface = new Graphics::ManagedSurface(newwid, newhgt,
|
||||
Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0));
|
||||
|
||||
// If the new surface is equal or bigger than the old one, copy it over
|
||||
if (_surface && bothwid && bothhgt)
|
||||
newSurface->blitFrom(*_surface);
|
||||
|
||||
delete _surface;
|
||||
_surface = newSurface;
|
||||
w = newwid;
|
||||
h = newhgt;
|
||||
|
||||
touch();
|
||||
}
|
||||
|
||||
void GraphicsWindow::touch() {
|
||||
dirty = true;
|
||||
// winrepaint(bbox.left, bbox.top, bbox.right, bbox.bottom);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -817,6 +867,90 @@ PairWindow::PairWindow(Windows *windows, glui32 method, Window *_key, glui32 _si
|
||||
_type = wintype_Pair;
|
||||
}
|
||||
|
||||
void PairWindow::rearrange(const Common::Rect &box) {
|
||||
Common::Rect box1, box2;
|
||||
int min, diff, split, splitwid, max;
|
||||
Window *keyWin;
|
||||
Window *ch1, *ch2;
|
||||
|
||||
bbox = box;
|
||||
|
||||
if (vertical) {
|
||||
min = bbox.left;
|
||||
max = bbox.right;
|
||||
} else {
|
||||
min = bbox.top;
|
||||
max = bbox.bottom;
|
||||
}
|
||||
diff = max - min;
|
||||
|
||||
// We now figure split.
|
||||
if (vertical)
|
||||
splitwid = Windows::_wPaddingx; // want border?
|
||||
else
|
||||
splitwid = Windows::_wPaddingy; // want border?
|
||||
|
||||
switch (division) {
|
||||
case winmethod_Proportional:
|
||||
split = (diff * size) / 100;
|
||||
break;
|
||||
|
||||
case winmethod_Fixed:
|
||||
keyWin = key;
|
||||
split = !keyWin ? 0 : keyWin->getSplit(size, vertical);
|
||||
break;
|
||||
|
||||
default:
|
||||
split = diff / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!backward)
|
||||
split = max - split - splitwid;
|
||||
else
|
||||
split = min + split;
|
||||
|
||||
if (min >= max) {
|
||||
split = min;
|
||||
} else {
|
||||
if (split < min)
|
||||
split = min;
|
||||
else if (split > max - splitwid)
|
||||
split = max - splitwid;
|
||||
}
|
||||
|
||||
if (vertical) {
|
||||
box1.left = bbox.left;
|
||||
box1.right = split;
|
||||
box2.left = split + splitwid;
|
||||
box2.right = bbox.right;
|
||||
box1.top = bbox.top;
|
||||
box1.bottom = bbox.bottom;
|
||||
box2.top = bbox.top;
|
||||
box2.bottom = bbox.bottom;
|
||||
} else {
|
||||
box1.top = bbox.top;
|
||||
box1.bottom = split;
|
||||
box2.top = split + splitwid;
|
||||
box2.bottom = bbox.bottom;
|
||||
box1.left = bbox.left;
|
||||
box1.right = bbox.right;
|
||||
box2.left = bbox.left;
|
||||
box2.right = bbox.right;
|
||||
}
|
||||
|
||||
if (!backward) {
|
||||
ch1 = child1;
|
||||
ch2 = child2;
|
||||
} else {
|
||||
ch1 = child2;
|
||||
ch2 = child1;
|
||||
}
|
||||
|
||||
ch1->rearrange(box1);
|
||||
ch2->rearrange(box2);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void Attributes::clear() {
|
||||
|
@ -210,6 +210,11 @@ public:
|
||||
* Rearranges the window
|
||||
*/
|
||||
virtual void rearrange(const Common::Rect &box) { bbox = box; }
|
||||
|
||||
/**
|
||||
* Get window split size within parent pair window
|
||||
*/
|
||||
virtual glui32 getSplit(glui32 size, bool vertical) const { return 0; }
|
||||
};
|
||||
typedef Window *winid_t;
|
||||
|
||||
@ -277,7 +282,15 @@ public:
|
||||
/**
|
||||
* Rearranges the window
|
||||
*/
|
||||
virtual void rearrange(const Common::Rect &box);
|
||||
virtual void rearrange(const Common::Rect &box) override;
|
||||
|
||||
/**
|
||||
* Get window split size within parent pair window
|
||||
*/
|
||||
virtual glui32 getSplit(glui32 size, bool vertical) const override {
|
||||
return vertical ? size * Windows::_cellW + Windows::_tMarginx * 2 :
|
||||
size * Windows::_cellH + Windows::_tMarginy * 2;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -373,7 +386,14 @@ public:
|
||||
/**
|
||||
* Rearranges the window
|
||||
*/
|
||||
virtual void rearrange(const Common::Rect &box);
|
||||
virtual void rearrange(const Common::Rect &box) override;
|
||||
|
||||
/**
|
||||
* Get window split size within parent pair window
|
||||
*/
|
||||
virtual glui32 getSplit(glui32 size, bool vertical) const override {
|
||||
return (vertical) ? size * Windows::_cellW : size * Windows::_cellH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the window
|
||||
@ -385,11 +405,30 @@ public:
|
||||
* Graphics window
|
||||
*/
|
||||
class GraphicsWindow : public Window {
|
||||
private:
|
||||
void touch();
|
||||
public:
|
||||
unsigned char bgnd[3];
|
||||
bool dirty;
|
||||
int w, h;
|
||||
Graphics::ManagedSurface *_surface;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
GraphicsWindow(Windows *windows, uint32 rock);
|
||||
|
||||
/**
|
||||
* Rearranges the window
|
||||
*/
|
||||
virtual void rearrange(const Common::Rect &box) override;
|
||||
|
||||
/**
|
||||
* Get window split size within parent pair window
|
||||
*/
|
||||
virtual glui32 getSplit(glui32 size, bool vertical) const override {
|
||||
return size;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -412,6 +451,11 @@ public:
|
||||
* Constructor
|
||||
*/
|
||||
PairWindow(Windows *windows, glui32 method, Window *_key, glui32 _size);
|
||||
|
||||
/**
|
||||
* Rearranges the window
|
||||
*/
|
||||
virtual void rearrange(const Common::Rect &box) override;
|
||||
};
|
||||
|
||||
} // End of namespace Gargoyle
|
||||
|
Loading…
x
Reference in New Issue
Block a user