X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fscr_mod.c;h=48e51a0fdcaf2e793783cdee6cc431edc9824ca7;hb=3c3612761bcf77a5c4ec6810aa47e0e3f0131bf1;hp=3ad4e7b64a55c777b90aa028b9cd7cc103cfc937;hpb=bba16e9faf7ff0e4089ba75c06baef713da04a4a;p=retroray
diff --git a/src/scr_mod.c b/src/scr_mod.c
index 3ad4e7b..48e51a0 100644
--- a/src/scr_mod.c
+++ b/src/scr_mod.c
@@ -15,7 +15,6 @@ 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, see .
*/
-#include
#include "gaw/gaw.h"
#include "app.h"
#include "rtk.h"
@@ -25,50 +24,10 @@ along with this program. If not, see .
#include "meshgen.h"
#include "font.h"
#include "rend.h"
-
-enum {
- TBN_NEW, TBN_OPEN, TBN_SAVE, TBN_SEP1,
- TBN_SEL, TBN_MOVE, TBN_ROT, TBN_SCALE, TBN_SEP2,
- TBN_ADD, TBN_RM, TBN_SEP3,
- TBN_UNION, TBN_ISECT, TBN_DIFF, TBN_SEP4,
- TBN_MTL, TBN_REND, TBN_REND_AREA, TBN_VIEWREND, TBN_SEP5, TBN_CFG,
-
- NUM_TOOL_BUTTONS
-};
-static const char *tbn_icon_name[] = {
- "new", "open", "save", 0,
- "sel", "move", "rot", "scale", 0,
- "add", "remove", 0,
- "union", "isect", "diff", 0,
- "mtl", "rend", "rend-area", "viewrend", 0, "cfg"
-};
-static int tbn_icon_pos[][2] = {
- {0,0}, {16,0}, {32,0}, {-1,-1},
- {48,0}, {64,0}, {80,0}, {96,0}, {-1,-1},
- {112,0}, {112,16}, {-1,-1},
- {0,16}, {16,16}, {32,16}, {-1,-1},
- {48,16}, {64,16}, {64, 32}, {80,16}, {-1,-1}, {96,16}
-};
-static int tbn_istool[] = {
- 0, 0, 0, 0,
- 1, 1, 1, 1, 0,
- 0, 0, 0,
- 1, 1, 1, 0,
- 0, 0, 1, 0, 0, 0
-};
-static rtk_icon *tbn_icons[NUM_TOOL_BUTTONS];
-static rtk_widget *tbn_buttons[NUM_TOOL_BUTTONS];
-
-#define TOOLBAR_HEIGHT 26
-
-enum {
- TOOL_SEL, TOOL_MOVE, TOOL_ROT, TOOL_SCALE,
- TOOL_UNION, TOOL_ISECT, TOOL_DIFF, TOOL_REND_AREA,
- NUM_TOOLS
-};
-static rtk_widget *tools[NUM_TOOLS];
+#include "modui.h"
static int vpdirty;
+static rtk_rect totalrend;
static int mdl_init(void);
@@ -84,14 +43,11 @@ static void mdl_motion(int x, int y);
static void draw_object(struct object *obj);
static void setup_material(struct material *mtl);
static void draw_grid(void);
-static void tbn_callback(rtk_widget *w, void *cls);
static void act_settool(int tidx);
static void act_addobj(void);
static void act_rmobj(void);
-static void fix_rect(rtk_rect *rect);
-static void draw_rband(void);
static void moveobj(struct object *obj, int px0, int py0, int px1, int py1);
static void inval_vport(void);
@@ -105,8 +61,6 @@ struct app_screen scr_model = {
mdl_keyb, mdl_mouse, mdl_motion
};
-static rtk_widget *toolbar;
-static rtk_iconsheet *icons;
static struct cmesh *mesh_sph;
@@ -128,47 +82,10 @@ static rtk_rect rendrect;
static int mdl_init(void)
{
- int i, toolidx;
- rtk_widget *w;
-
- if(!(icons = rtk_load_iconsheet("data/icons.png"))) {
- errormsg("failed to load iconsheet\n");
+ if(modui_init() == -1) {
+ errormsg("failed to initialize modeller UI\n");
return -1;
}
- for(i=0; i= 0) {
- act_settool(prev_tool);
+ if(rband.width && rband.height) {
+ rendering = 1;
+ rend_size(win_width, win_height);
+ rtk_fix_rect(&rband);
+ rendrect = rband;
+ rend_begin(rband.x, rband.y, rband.width, rband.height);
+ app_redisplay(rband.x, rband.y, rband.width, rband.height);
+
+ if(totalrend.width) {
+ rtk_rect_union(&totalrend, &rband);
+ } else {
+ totalrend = rband;
+ }
}
- rendering = 1;
- rend_size(win_width, win_height);
- fix_rect(&rband);
- rendrect = rband;
- rend_begin(rband.x, rband.y, rband.width, rband.height);
}
- app_redisplay(rband.x, rband.y, rband.width, rband.height);
} else if(bn == 0 && x == rband.x && y == rband.y) {
primray(&pickray, x, y);
@@ -458,6 +380,7 @@ static void mdl_motion(int x, int y)
rband.width = x - rband.x;
rband.height = y - rband.y;
rband_valid = 1;
+ app_rband(rband.x, rband.y, rband.width, rband.height);
}
break;
@@ -485,11 +408,16 @@ static void add_sphere(void)
scn_add_object(scn, obj);
}
-static void tbn_callback(rtk_widget *w, void *cls)
+void tbn_callback(rtk_widget *w, void *cls)
{
int id = (intptr_t)cls;
switch(id) {
+ case TBN_NEW:
+ scn_clear(scn);
+ inval_vport();
+ break;
+
case TBN_SEL:
case TBN_MOVE:
case TBN_ROT:
@@ -501,6 +429,16 @@ static void tbn_callback(rtk_widget *w, void *cls)
case TBN_DIFF:
act_settool(id - TBN_UNION + TOOL_UNION);
break;
+
+ case TBN_MTL:
+ if(rtk_visible(mtlwin)) {
+ rtk_hide(mtlwin);
+ inval_vport();
+ } else {
+ rtk_show(mtlwin);
+ }
+ break;
+
case TBN_REND_AREA:
act_settool(TOOL_REND_AREA);
break;
@@ -523,6 +461,14 @@ static void act_settool(int tidx)
int i;
rtk_rect r;
+ if(tidx == cur_tool) return;
+
+ if(cur_tool == TOOL_REND_AREA) {
+ totalrend.width = 0;
+ app_redisplay(totalrend.x, totalrend.y, totalrend.width, totalrend.height);
+ inval_vport();
+ }
+
prev_tool = cur_tool;
cur_tool = tidx;
for(i=0; ix = x;
- rect->y = y;
- rect->width = w;
- rect->height = h;
-}
-
-static void draw_rband(void)
-{
- int i;
- rtk_rect rect;
- uint32_t *fbptr, *bptr;
-
- rect = rband;
- fix_rect(&rect);
-
- fbptr = framebuf + rect.y * win_width + rect.x;
- bptr = fbptr + win_width * (rect.height - 1);
-
- for(i=0; i