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
Showing with 468 additions and 675 deletions.
  1. +0 −1 TODO.md
  2. +1 −1 src/app/commands/cmd_export_sprite_sheet.cpp
  3. +2 −1 src/app/commands/cmd_import_sprite_sheet.cpp
  4. +7 −9 src/app/commands/cmd_palette_editor.cpp
  5. +19 −20 src/app/commands/filters/color_curve_editor.cpp
  6. +0 −1 src/app/commands/filters/filter_manager_impl.cpp
  7. +66 −66 src/app/dialogs/aniedit.cpp
  8. +0 −1 src/app/ini_file.cpp
  9. +0 −1 src/app/modules/gfx.cpp
  10. +1 −2 src/app/ui/color_bar.cpp
  11. +11 −13 src/app/ui/color_button.cpp
  12. +0 −1 src/app/ui/editor/cursor.cpp
  13. +6 −6 src/app/ui/editor/editor.cpp
  14. +0 −1 src/app/ui/editor/keys.cpp
  15. +15 −15 src/app/ui/file_list.cpp
  16. +4 −5 src/app/ui/mini_editor.cpp
  17. +2 −3 src/app/ui/palette_view.cpp
  18. +2 −2 src/app/ui/popup_window_pin.cpp
  19. +93 −95 src/app/ui/skin/skin_theme.cpp
  20. +2 −3 src/app/ui/skin/skin_theme.h
  21. +2 −2 src/app/ui/status_bar.cpp
  22. +7 −7 src/app/ui/tabs.cpp
  23. +8 −7 src/app/ui/toolbar.cpp
  24. +0 −1 src/ui/CMakeLists.txt
  25. +0 −6 src/ui/base.h
  26. +5 −6 src/ui/box.cpp
  27. +4 −6 src/ui/button.cpp
  28. +6 −6 src/ui/combobox.cpp
  29. +11 −17 src/ui/draw.cpp
  30. +3 −4 src/ui/draw.h
  31. +11 −12 src/ui/entry.cpp
  32. +3 −2 src/ui/graphics.cpp
  33. +0 −1 src/ui/grid.cpp
  34. +29 −29 src/ui/grid_ui_unittest.cpp
  35. +8 −11 src/ui/image_view.cpp
  36. +8 −8 src/ui/listbox.cpp
  37. +15 −15 src/ui/manager.cpp
  38. +7 −7 src/ui/menu.cpp
  39. +0 −1 src/ui/message.cpp
  40. +0 −1 src/ui/message.h
  41. +0 −107 src/ui/rect.cpp
  42. +0 −44 src/ui/rect.h
  43. +10 −10 src/ui/scroll_bar.cpp
  44. +0 −1 src/ui/slider.cpp
  45. +20 −20 src/ui/splitter.cpp
  46. +2 −3 src/ui/system.cpp
  47. +2 −2 src/ui/textbox.cpp
  48. +5 −6 src/ui/theme.cpp
  49. +2 −2 src/ui/tooltips.cpp
  50. +0 −1 src/ui/ui.h
  51. +5 −15 src/ui/view.cpp
  52. +0 −2 src/ui/view.h
  53. +35 −28 src/ui/widget.cpp
  54. +10 −8 src/ui/widget.h
  55. +19 −30 src/ui/window.cpp
View
@@ -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"
Oops, something went wrong.

0 comments on commit dbf4d0d

Please sign in to comment.