Skip to content
Permalink
Browse files
Replace JRect/jrect struct with gfx::Rect
- Replaced Widget::rc -> Widget::m_bounds private member.
- Added Widget::offsetWidgets() method.
- Removed View::displaceWidgets().
  • Loading branch information
dacap committed Oct 26, 2013
1 parent d9910f8 commit dbf4d0d490d62b7a1d83d5db09baa281fc564250
Show file tree
Hide file tree
Showing 55 changed files with 468 additions and 675 deletions.
@@ -56,7 +56,6 @@
then cloned, and finally filled with params.
* About Signals/Slots: Add some field in slots to avoid disconnecting
them from dead signals.
* Replace JRect & jrect with gfx::Rect.
* editors_ -> MultiEditors class widget
* convert all widgets to classes:
* match UI library design with Vaca library.
@@ -117,7 +117,7 @@ class ExportSpriteSheetWindow : public Window {
m_columns.setVisible(state);

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

invalidate();
}
@@ -138,7 +138,8 @@ class ImportSpriteSheetWindow : public Window,

menu->addChild(item);

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

void onUseCurrentSprite()
@@ -217,10 +217,10 @@ void PaletteEditorCommand::onExecute(Context* context)
// Default bounds
g_window->remapWindow();

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

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

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

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

// Show the expanded area inside the screen
if (rect.y2() > JI_SCREEN_H)
@@ -29,7 +29,6 @@
#include "ui/manager.h"
#include "ui/message.h"
#include "ui/preferred_size_event.h"
#include "ui/rect.h"
#include "ui/system.h"
#include "ui/view.h"
#include "ui/widget.h"
@@ -44,27 +43,27 @@
#define SCR2EDIT_X(xpos) \
(m_x1 + \
((m_x2 - m_x1 + 1) \
* ((xpos) - rc->x1 - border_width.l) \
/ (jrect_w(rc) - border_width.l - border_width.r)))
* ((xpos) - getBounds().x - border_width.l) \
/ (getBounds().w - border_width.l - border_width.r)))

#define SCR2EDIT_Y(ypos) \
(m_y1 + \
((m_y2 - m_y1 + 1) \
* ((jrect_h(rc) - border_width.t - border_width.b) \
- ((ypos) - rc->y1 - border_width.t)) \
/ (jrect_h(rc) - border_width.t - border_width.b)))
* ((getBounds().h - border_width.t - border_width.b) \
- ((ypos) - getBounds().y - border_width.t)) \
/ (getBounds().h - border_width.t - border_width.b)))

#define EDIT2SCR_X(xpos) \
(rc->x1 + border_width.l \
+ ((jrect_w(rc) - border_width.l - border_width.r) \
(getBounds().x + border_width.l \
+ ((getBounds().w - border_width.l - border_width.r) \
* ((xpos) - m_x1) \
/ (m_x2 - m_x1 + 1)))

#define EDIT2SCR_Y(ypos) \
(rc->y1 \
+ (jrect_h(rc) - border_width.t - border_width.b) \
- ((jrect_h(rc) - border_width.t - border_width.b) \
* ((ypos) - m_y1) \
#define EDIT2SCR_Y(ypos) \
(getBounds().y \
+ (getBounds().h - border_width.t - border_width.b) \
- ((getBounds().h - border_width.t - border_width.b) \
* ((ypos) - m_y1) \
/ (m_y2 - m_y1 + 1)))

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

bmp = create_bitmap(jrect_w(rc), jrect_h(rc));
bmp = create_bitmap(getBounds().w, getBounds().h);
clear_to_color(bmp, makecol (0, 0, 0));

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

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

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

putpixel(bmp, x, EDIT2SCR_Y(y)-rc->y1,
putpixel(bmp, x, EDIT2SCR_Y(y)-getBounds().y,
makecol(255, 255, 255));
}

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

x = EDIT2SCR_X(point.x) - rc->x1;
y = EDIT2SCR_Y(point.y) - rc->y1;
x = EDIT2SCR_X(point.x) - getBounds().x;
y = EDIT2SCR_Y(point.y) - getBounds().y;

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

// Blit to screen
blit(bmp, ji_screen, 0, 0, rc->x1, rc->y1, bmp->w, bmp->h);
blit(bmp, ji_screen, 0, 0, getBounds().x, getBounds().y, bmp->w, bmp->h);
destroy_bitmap(bmp);
return true;
}
@@ -37,7 +37,6 @@
#include "raster/sprite.h"
#include "raster/stock.h"
#include "ui/manager.h"
#include "ui/rect.h"
#include "ui/view.h"
#include "ui/widget.h"

0 comments on commit dbf4d0d

Please sign in to comment.