2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
23 static const char *tbn_icon_name[] = {
24 "new", "open", "save", 0,
25 "sel", "move", "rot", "scale", 0,
27 "union", "isect", "diff", 0,
28 "mtl", "rend", "rend-area", "viewrend", 0, "cfg"
30 static int tbn_icon_pos[][2] = {
31 {0,0}, {16,0}, {32,0}, {-1,-1},
32 {48,0}, {64,0}, {80,0}, {96,0}, {-1,-1},
33 {112,0}, {112,16}, {-1,-1},
34 {0,16}, {16,16}, {32,16}, {-1,-1},
35 {48,16}, {64,16}, {64, 32}, {80,16}, {-1,-1}, {96,16}
37 static int tbn_istool[] = {
44 static rtk_icon *tbn_icons[NUM_TOOL_BUTTONS];
45 static rtk_widget *tbn_buttons[NUM_TOOL_BUTTONS];
46 static rtk_iconsheet *icons;
48 rtk_widget *toolbar, *mtlwin;
49 rtk_widget *tools[NUM_TOOLS];
51 static int create_toolbar(void);
52 static int create_mtlwin(void);
56 if(!(icons = rtk_load_iconsheet("data/icons.png"))) {
57 errormsg("failed to load iconsheet\n");
61 if(create_toolbar() == -1) {
64 if(create_mtlwin() == -1) {
70 static int create_toolbar(void)
75 for(i=0; i<NUM_TOOL_BUTTONS; i++) {
76 if(tbn_icon_name[i]) {
77 tbn_icons[i] = rtk_define_icon(icons, tbn_icon_name[i],
78 tbn_icon_pos[i][0], tbn_icon_pos[i][1], 16, 16);
84 if(!(toolbar = rtk_create_window(0, "toolbar", 0, 0, win_width, TOOLBAR_HEIGHT, 0))) {
87 rtk_win_layout(toolbar, RTK_HBOX);
90 for(i=0; i<NUM_TOOL_BUTTONS; i++) {
92 rtk_create_separator(toolbar);
94 if(!(w = rtk_create_iconbutton(toolbar, tbn_icons[i], 0))) {
98 rtk_set_callback(w, tbn_callback, (void*)(intptr_t)i);
100 rtk_bn_mode(w, RTK_TOGGLEBN);
101 tools[toolidx++] = w;
108 assert(toolidx == NUM_TOOLS);
113 static int create_mtlwin(void)
115 if(!(mtlwin = rtk_create_window(0, "Materials", win_width / 2, 64, 256, 380,
116 RTK_WIN_FRAME | RTK_WIN_MOVABLE | RTK_WIN_RESIZABLE))) {
123 void modui_cleanup(void)
125 rtk_free_widget(toolbar);
126 rtk_free_widget(mtlwin);
127 rtk_free_iconsheet(icons);