Skip to content

Commit dbf4d0d

Browse files
committed
Replace JRect/jrect struct with gfx::Rect
- Replaced Widget::rc -> Widget::m_bounds private member. - Added Widget::offsetWidgets() method. - Removed View::displaceWidgets().
1 parent d9910f8 commit dbf4d0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+468
-675
lines changed

Diff for: TODO.md

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
then cloned, and finally filled with params.
5757
* About Signals/Slots: Add some field in slots to avoid disconnecting
5858
them from dead signals.
59-
* Replace JRect & jrect with gfx::Rect.
6059
* editors_ -> MultiEditors class widget
6160
* convert all widgets to classes:
6261
* match UI library design with Vaca library.

Diff for: src/app/commands/cmd_export_sprite_sheet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ExportSpriteSheetWindow : public Window {
117117
m_columns.setVisible(state);
118118

119119
gfx::Size reqSize = getPreferredSize();
120-
moveWindow(gfx::Rect(rc->x1, rc->y1, reqSize.w, reqSize.h));
120+
moveWindow(gfx::Rect(getOrigin(), reqSize));
121121

122122
invalidate();
123123
}

Diff for: src/app/commands/cmd_import_sprite_sheet.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class ImportSpriteSheetWindow : public Window,
138138

139139
menu->addChild(item);
140140

141-
menu->showPopup(m_selectFile.rc->x1, m_selectFile.rc->y2);
141+
const gfx::Rect& bounds = m_selectFile.getBounds();
142+
menu->showPopup(bounds.x, bounds.y+bounds.h);
142143
}
143144

144145
void onUseCurrentSprite()

Diff for: src/app/commands/cmd_palette_editor.cpp

+7-9
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ void PaletteEditorCommand::onExecute(Context* context)
217217
// Default bounds
218218
g_window->remapWindow();
219219

220-
int width = MAX(jrect_w(g_window->rc), JI_SCREEN_W/2);
221-
g_window->setBounds(Rect(JI_SCREEN_W - width - jrect_w(ToolBar::instance()->rc),
222-
JI_SCREEN_H - jrect_h(g_window->rc) - jrect_h(StatusBar::instance()->rc),
223-
width, jrect_h(g_window->rc)));
220+
int width = MAX(g_window->getBounds().w, JI_SCREEN_W/2);
221+
g_window->setBounds(Rect(JI_SCREEN_W - width - ToolBar::instance()->getBounds().w,
222+
JI_SCREEN_H - g_window->getBounds().h - StatusBar::instance()->getBounds().h,
223+
width, g_window->getBounds().h));
224224

225225
// Load window configuration
226226
load_window_pos(g_window, "PaletteEditor");
@@ -498,8 +498,7 @@ void PaletteEntryEditor::onMoreOptionsClick(Event& ev)
498498
reqSize.h += 4;
499499

500500
// Remove the space occupied by the "More options" panel
501-
moveWindow(gfx::Rect(rc->x1, rc->y1,
502-
jrect_w(rc), jrect_h(rc) - reqSize.h));
501+
moveWindow(gfx::Rect(getOrigin(), getSize() - gfx::Size(0, reqSize.h)));
503502
}
504503
else {
505504
set_config_bool("PaletteEditor", "ShowMoreOptions", true);
@@ -509,9 +508,8 @@ void PaletteEntryEditor::onMoreOptionsClick(Event& ev)
509508
reqSize = getPreferredSize();
510509

511510
// Add space for the "more_options" panel
512-
if (jrect_h(rc) < reqSize.h) {
513-
gfx::Rect rect(rc->x1, rc->y1,
514-
jrect_w(rc), reqSize.h);
511+
if (getBounds().h < reqSize.h) {
512+
gfx::Rect rect(getOrigin(), gfx::Size(getBounds().w, reqSize.h));
515513

516514
// Show the expanded area inside the screen
517515
if (rect.y2() > JI_SCREEN_H)

Diff for: src/app/commands/filters/color_curve_editor.cpp

+19-20
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "ui/manager.h"
3030
#include "ui/message.h"
3131
#include "ui/preferred_size_event.h"
32-
#include "ui/rect.h"
3332
#include "ui/system.h"
3433
#include "ui/view.h"
3534
#include "ui/widget.h"
@@ -44,27 +43,27 @@
4443
#define SCR2EDIT_X(xpos) \
4544
(m_x1 + \
4645
((m_x2 - m_x1 + 1) \
47-
* ((xpos) - rc->x1 - border_width.l) \
48-
/ (jrect_w(rc) - border_width.l - border_width.r)))
46+
* ((xpos) - getBounds().x - border_width.l) \
47+
/ (getBounds().w - border_width.l - border_width.r)))
4948

5049
#define SCR2EDIT_Y(ypos) \
5150
(m_y1 + \
5251
((m_y2 - m_y1 + 1) \
53-
* ((jrect_h(rc) - border_width.t - border_width.b) \
54-
- ((ypos) - rc->y1 - border_width.t)) \
55-
/ (jrect_h(rc) - border_width.t - border_width.b)))
52+
* ((getBounds().h - border_width.t - border_width.b) \
53+
- ((ypos) - getBounds().y - border_width.t)) \
54+
/ (getBounds().h - border_width.t - border_width.b)))
5655

5756
#define EDIT2SCR_X(xpos) \
58-
(rc->x1 + border_width.l \
59-
+ ((jrect_w(rc) - border_width.l - border_width.r) \
57+
(getBounds().x + border_width.l \
58+
+ ((getBounds().w - border_width.l - border_width.r) \
6059
* ((xpos) - m_x1) \
6160
/ (m_x2 - m_x1 + 1)))
6261

63-
#define EDIT2SCR_Y(ypos) \
64-
(rc->y1 \
65-
+ (jrect_h(rc) - border_width.t - border_width.b) \
66-
- ((jrect_h(rc) - border_width.t - border_width.b) \
67-
* ((ypos) - m_y1) \
62+
#define EDIT2SCR_Y(ypos) \
63+
(getBounds().y \
64+
+ (getBounds().h - border_width.t - border_width.b) \
65+
- ((getBounds().h - border_width.t - border_width.b) \
66+
* ((ypos) - m_y1) \
6867
/ (m_y2 - m_y1 + 1)))
6968

7069
namespace app {
@@ -146,7 +145,7 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
146145
BITMAP *bmp;
147146
int x, y, u;
148147

149-
bmp = create_bitmap(jrect_w(rc), jrect_h(rc));
148+
bmp = create_bitmap(getBounds().w, getBounds().h);
150149
clear_to_color(bmp, makecol (0, 0, 0));
151150

152151
// Draw border
@@ -165,31 +164,31 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
165164

166165
// Draw curve
167166
for (x=border_width.l;
168-
x<jrect_w(rc)-border_width.r; x++) {
169-
u = SCR2EDIT_X(rc->x1+x);
167+
x<getBounds().w-border_width.r; x++) {
168+
u = SCR2EDIT_X(getBounds().x+x);
170169
u = MID(m_x1, u, m_x2);
171170

172171
y = values[u - m_x1];
173172
y = MID(m_y1, y, m_y2);
174173

175-
putpixel(bmp, x, EDIT2SCR_Y(y)-rc->y1,
174+
putpixel(bmp, x, EDIT2SCR_Y(y)-getBounds().y,
176175
makecol(255, 255, 255));
177176
}
178177

179178
// Draw nodes
180179
for (ColorCurve::iterator it = m_curve->begin(), end = m_curve->end(); it != end; ++it) {
181180
const gfx::Point& point = *it;
182181

183-
x = EDIT2SCR_X(point.x) - rc->x1;
184-
y = EDIT2SCR_Y(point.y) - rc->y1;
182+
x = EDIT2SCR_X(point.x) - getBounds().x;
183+
y = EDIT2SCR_Y(point.y) - getBounds().y;
185184

186185
rect(bmp, x-2, y-2, x+2, y+2,
187186
m_editPoint == &point ? makecol(255, 255, 0):
188187
makecol(0, 0, 255));
189188
}
190189

191190
// Blit to screen
192-
blit(bmp, ji_screen, 0, 0, rc->x1, rc->y1, bmp->w, bmp->h);
191+
blit(bmp, ji_screen, 0, 0, getBounds().x, getBounds().y, bmp->w, bmp->h);
193192
destroy_bitmap(bmp);
194193
return true;
195194
}

Diff for: src/app/commands/filters/filter_manager_impl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "raster/sprite.h"
3838
#include "raster/stock.h"
3939
#include "ui/manager.h"
40-
#include "ui/rect.h"
4140
#include "ui/view.h"
4241
#include "ui/widget.h"
4342

0 commit comments

Comments
 (0)