[Gtkradiant] Suggestion: Enhanced Texture Browser (diff included)
Shaderman
Shaderman at gmx.net
Sun May 21 12:37:49 CDT 2006
Hi!
My goal is to achieve a better handling of textures in Radiant. I never
liked the way it works in current versions because it's
too long winded to search and select textures from the textures menu and
the texture viewer. This is my approach to make
mapper's life a bit easier :)
More information and screenshots:
http://splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&p=145042
This is a diff for svn version 70, tested with Enemy Territory and Quake
1 (.wad file support).
The appended toolbar image needs to be copied into the bitmaps folder.
I hope the code is not to crappy and works like expected :)
Shaderman
-------------- next part --------------
Index: radiant/gtkmisc.cpp
===================================================================
--- radiant/gtkmisc.cpp (revision 70)
+++ radiant/gtkmisc.cpp (working copy)
@@ -34,12 +34,14 @@
#include "gtkmisc.h"
+#include <gtk/gtk.h>
#include <gtk/gtkcolorseldialog.h>
#include <gtk/gtkentry.h>
#include "math/vector.h"
#include "os/path.h"
+#include "gtkutil/button.h"
#include "gtkutil/dialog.h"
#include "gtkutil/filechooser.h"
#include "gtkutil/menu.h"
@@ -96,6 +98,54 @@
return toolbar_append_toggle_button(toolbar, description, icon, GlobalToggles_find(commandName));
}
+GtkButton* new_but_with_mnemonic(const char* mnemonic, const Callback& callback)
+{
+ GtkButton* item = GTK_BUTTON (gtk_button_new_with_mnemonic (mnemonic));
+ gtk_widget_show(GTK_WIDGET(item));
+ button_connect_callback (item, callback);
+ return item;
+}
+
+GtkButton* create_button_with_mnemonic(const char* mnemonic, const Command& command)
+{
+ GtkButton* item = new_but_with_mnemonic (mnemonic, command.m_callback);
+ return item;
+}
+
+GtkButton* create_button_with_mnemonic(const char* mnemonic, const char* commandName)
+{
+ GlobalShortcuts_register(commandName);
+ const Command& command = GlobalCommands_find(commandName);
+ global_accel_group_connect(command.m_accelerator, command.m_callback);
+ return create_button_with_mnemonic (mnemonic, command);
+}
+
+GtkToggleButton* new_tog_but_with_mnemonic(const char* mnemonic, const Callback& callback)
+{
+ GtkToggleButton* item = GTK_TOGGLE_BUTTON (gtk_toggle_button_new_with_mnemonic (mnemonic));
+ gtk_widget_show(GTK_WIDGET(item));
+ toggle_button_connect_callback (item, callback);
+ return item;
+}
+
+extern void toggle_button_set_active_callback(GtkToggleButton& button, bool active);
+typedef ReferenceCaller1<GtkToggleButton, bool, toggle_button_set_active_callback> ToggleButtonSetActiveCaller;
+
+GtkToggleButton* create_toggle_button_with_mnemonic(const char* mnemonic, const Toggle& toggle)
+{
+ GtkToggleButton* item = new_tog_but_with_mnemonic (mnemonic, toggle.m_command.m_callback);
+ toggle.m_exportCallback(ToggleButtonSetActiveCaller(*item));
+ return item;
+}
+
+GtkToggleButton* create_toggle_button_with_mnemonic(const char* mnemonic, const char* commandName)
+{
+ GlobalShortcuts_register(commandName);
+ const Toggle& toggle = GlobalToggles_find(commandName);
+ global_accel_group_connect(toggle.m_command.m_accelerator, toggle.m_command.m_callback);
+ return create_toggle_button_with_mnemonic(mnemonic, toggle);
+}
+
// =============================================================================
// File dialog
Index: radiant/gtkmisc.h
===================================================================
--- radiant/gtkmisc.h (revision 70)
+++ radiant/gtkmisc.h (working copy)
@@ -57,11 +57,14 @@
typedef struct _GtkButton GtkButton;
typedef struct _GtkToggleButton GtkToggleButton;
typedef struct _GtkToolbar GtkToolbar;
+typedef struct _GtkToggleButton GtkToggleButton;
// this DOES NOT set up the shortcut using command_connect_accelerator
GtkButton* toolbar_append_button(GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName);
// this DOES NOT set up the shortcut using command_connect_accelerator
GtkToggleButton* toolbar_append_toggle_button(GtkToolbar* toolbar, const char* description, const char* icon, const char* commandName);
+GtkButton* create_button_with_mnemonic(const char* mnemonic, const char* commandName);
+GtkToggleButton* create_toggle_button_with_mnemonic(const char* mnemonic, const char* commandName);
template<typename Element> class BasicVector3;
Index: radiant/mainframe.cpp
===================================================================
--- radiant/mainframe.cpp (revision 70)
+++ radiant/mainframe.cpp (working copy)
@@ -1902,6 +1902,7 @@
LatchedBool g_Layout_enableDetachableMenus(true, "Detachable Menus");
LatchedBool g_Layout_enablePatchToolbar(true, "Patch Toolbar");
LatchedBool g_Layout_enablePluginToolbar(true, "Plugin Toolbar");
+LatchedBool g_Layout_enableEnhancedBrowser(true, "Enhanced Texture Browser");
@@ -2315,7 +2316,8 @@
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_selection_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_bsp_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_grid_menu()));
- gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_textures_menu()));
+ if (!g_Layout_enableEnhancedBrowser.m_value) // old textures menu
+ gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_textures_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_misc_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_entity_menu()));
gtk_container_add(GTK_CONTAINER(menu_bar), GTK_WIDGET(create_brush_menu()));
@@ -2507,6 +2509,10 @@
toolbar_append_toggle_button(toolbar, "Texture Lock", "texture_lock.bmp", "TogTexLock");
+ gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
+
+ toolbar_append_button(toolbar, "Texture Browser", "texture_browser.bmp", "ViewTextures");
+
return toolbar;
}
@@ -3001,7 +3007,13 @@
gtk_paned_add1(GTK_PANED(vsplit2), GTK_WIDGET(camera_window));
// textures
- GtkFrame* texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
+ GtkFrame* texture_window;
+ if (!g_Layout_enableEnhancedBrowser.m_value) // old textures menu
+ {
+ texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
+ } else {
+ texture_window = create_framed_widget(TextureBrowser_constructEnhancedWindow(window));
+ }
gtk_paned_add2(GTK_PANED(vsplit2), GTK_WIDGET(texture_window));
@@ -3101,7 +3113,13 @@
}
{
- GtkFrame* frame = create_framed_widget(TextureBrowser_constructWindow(GroupDialog_getWindow()));
+ GtkFrame* frame;
+ if (!g_Layout_enableEnhancedBrowser.m_value) // old textures menu
+ {
+ frame = create_framed_widget(TextureBrowser_constructWindow(GroupDialog_getWindow()));
+ } else {
+ frame = create_framed_widget(TextureBrowser_constructEnhancedWindow(GroupDialog_getWindow()));
+ }
g_page_textures = GroupDialog_addPage("Textures", GTK_WIDGET(frame), TextureBrowserExportTitleCaller());
}
@@ -3133,8 +3151,14 @@
GtkHPaned* split = create_split_views(camera, yz, xy, xz);
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(split), TRUE, TRUE, 0);
- {
- GtkFrame* frame = create_framed_widget(TextureBrowser_constructWindow(window));
+ {
+ GtkFrame* frame;
+ if (!g_Layout_enableEnhancedBrowser.m_value) // old textures menu
+ {
+ frame = create_framed_widget(TextureBrowser_constructWindow(window));
+ } else {
+ frame = create_framed_widget(TextureBrowser_constructEnhancedWindow(window));
+ }
g_page_textures = GroupDialog_addPage("Textures", GTK_WIDGET(frame), TextureBrowserExportTitleCaller());
}
}
@@ -3479,6 +3503,7 @@
GlobalSelectionSystem().addSelectionChangeCallback(FreeCaller1<const Selectable&, ComponentMode_SelectionChanged>());
GlobalPreferenceSystem().registerPreference("DetachableMenus", BoolImportStringCaller(g_Layout_enableDetachableMenus.m_latched), BoolExportStringCaller(g_Layout_enableDetachableMenus.m_latched));
+ GlobalPreferenceSystem().registerPreference("EnhancedBrowser", BoolImportStringCaller(g_Layout_enableEnhancedBrowser.m_latched), BoolExportStringCaller(g_Layout_enableEnhancedBrowser.m_latched));
GlobalPreferenceSystem().registerPreference("PatchToolBar", BoolImportStringCaller(g_Layout_enablePatchToolbar.m_latched), BoolExportStringCaller(g_Layout_enablePatchToolbar.m_latched));
GlobalPreferenceSystem().registerPreference("PluginToolBar", BoolImportStringCaller(g_Layout_enablePluginToolbar.m_latched), BoolExportStringCaller(g_Layout_enablePluginToolbar.m_latched));
GlobalPreferenceSystem().registerPreference("QE4StyleWindows", IntImportStringCaller(g_Layout_viewStyle.m_latched), IntExportStringCaller(g_Layout_viewStyle.m_latched));
@@ -3521,6 +3546,7 @@
g_Layout_enableDetachableMenus.useLatched();
g_Layout_enablePatchToolbar.useLatched();
g_Layout_enablePluginToolbar.useLatched();
+ g_Layout_enableEnhancedBrowser.useLatched();
Layout_registerPreferencesPage();
Paths_registerPreferencesPage();
Index: radiant/texwindow.cpp
===================================================================
--- radiant/texwindow.cpp (revision 70)
+++ radiant/texwindow.cpp (working copy)
@@ -45,6 +45,7 @@
#include <set>
+#include <gtk/gtk.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkrange.h>
#include <gtk/gtkframe.h>
@@ -281,7 +282,7 @@
GtkMenuItem* g_textures_menu_separator = 0;
namespace
{
- bool g_TexturesMenu_shaderlistOnly = false;
+ bool g_TextureBrowser_shaderlistOnly = false;
}
void TextureGroupsMenu_Construct()
{
@@ -294,7 +295,7 @@
else
{
// scan texture dirs and pak files only if not restricting to shaderlist
- if(g_pGameDescription->mGameType != "doom3" && !g_TexturesMenu_shaderlistOnly)
+ if(g_pGameDescription->mGameType != "doom3" && !g_TextureBrowser_shaderlistOnly)
{
GlobalFileSystem().forEachDirectory("textures/", TextureGroupsAddDirectoryCaller(groups));
}
@@ -412,6 +413,15 @@
STARTUPSHADERS_ALL,
};
+void TextureBrowser_hideUnusedExport(const BoolImportCallback& importer);
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_hideUnusedExport> TextureBrowserHideUnusedExport;
+
+void TextureBrowser_showShadersExport(const BoolImportCallback& importer);
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShadersExport> TextureBrowserShowShadersExport;
+
+void TextureBrowser_showShaderlistOnly(const BoolImportCallback& importer);
+typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
+
class TextureBrowser
{
public:
@@ -426,7 +436,12 @@
GtkWindow* m_parent;
GtkWidget* m_gl_widget;
+ GtkWidget* m_treeView;
+ ToggleItem m_hideunused_item;
+ ToggleItem m_showshaders_item;
+ ToggleItem m_showshaderlistonly_item;
+
guint m_sizeHandler;
guint m_exposeHandler;
@@ -450,6 +465,8 @@
// if true, the texture window will only display in-use shaders
// if false, all the shaders in memory are displayed
bool m_hideUnused;
+ // use old or enhanced texture browser
+ bool m_enableEnhancedBrowser;
void clearFilter()
@@ -473,7 +490,11 @@
m_showShaders(true),
m_showTextureScrollbar(true),
m_startupShaders(STARTUPSHADERS_NONE),
- m_hideUnused(false)
+ m_hideUnused(false),
+ m_enableEnhancedBrowser(true),
+ m_hideunused_item(TextureBrowserHideUnusedExport()),
+ m_showshaders_item(TextureBrowserShowShadersExport()),
+ m_showshaderlistonly_item(TextureBrowserShowShaderlistOnlyExport())
{
}
};
@@ -949,27 +970,10 @@
void TextureBrowser_showShaderlistOnly(const BoolImportCallback& importer)
{
- importer(g_TexturesMenu_shaderlistOnly);
+ importer(g_TextureBrowser_shaderlistOnly);
}
typedef FreeCaller1<const BoolImportCallback&, TextureBrowser_showShaderlistOnly> TextureBrowserShowShaderlistOnlyExport;
-class TexturesMenu
-{
-public:
- ToggleItem m_hideunused_item;
- ToggleItem m_showshaders_item;
- ToggleItem m_showshaderlistonly_item;
-
- TexturesMenu() :
- m_hideunused_item(TextureBrowserHideUnusedExport()),
- m_showshaders_item(TextureBrowserShowShadersExport()),
- m_showshaderlistonly_item(TextureBrowserShowShaderlistOnlyExport())
- {
- }
-};
-
-TexturesMenu g_TexturesMenu;
-
void TextureBrowser_SetHideUnused(TextureBrowser& textureBrowser, bool hideUnused)
{
if(hideUnused)
@@ -981,7 +985,7 @@
textureBrowser.m_hideUnused = false;
}
- g_TexturesMenu.m_hideunused_item.update();
+ textureBrowser.m_hideunused_item.update();
TextureBrowser_heightChanged(textureBrowser);
textureBrowser.m_originInvalid = true;
@@ -1538,6 +1542,228 @@
return hbox;
}
+void TextureTreeModel_Construct (TextureGroups groups, GtkTreeStore *store)
+{
+ GtkTreeIter iter, child;
+
+ TextureGroups::const_iterator i = groups.begin();
+ while (i != groups.end())
+ {
+ const char* dirName = (*i).c_str();
+ const char* firstUnderscore = strchr(dirName, '_');
+ StringRange dirRoot (dirName, (firstUnderscore == 0) ? dirName : firstUnderscore + 1);
+
+ TextureGroups::const_iterator next = i;
+ ++next;
+ if(firstUnderscore != 0
+ && next != groups.end()
+ && string_equal_start((*next).c_str(), dirRoot))
+ {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set (store, &iter, 0, CopiedString(StringRange(dirName, firstUnderscore)).c_str(), -1);
+
+ // keep going...
+ while (i != groups.end() && string_equal_start((*i).c_str(), dirRoot))
+ {
+ gtk_tree_store_append(store, &child, &iter);
+ gtk_tree_store_set (store, &child, 0, (*i).c_str(), -1);
+ ++i;
+ }
+ } else {
+ gtk_tree_store_append(store, &iter, NULL);
+ gtk_tree_store_set (store, &iter, 0, dirName, -1);
+ ++i;
+ }
+ }
+}
+
+TextureGroups TextureGroupsTreeView_Construct()
+{
+ TextureGroups groups;
+
+ if (TextureGroupsMenu_showWads())
+ {
+ GlobalFileSystem().forEachArchive (TextureGroupsAddWadCaller (groups));
+ } else {
+ // scan texture dirs and pak files only if not restricting to shaderlist
+ if (g_pGameDescription->mGameType != "doom3" && !g_TextureBrowser_shaderlistOnly)
+ {
+ GlobalFileSystem().forEachDirectory ("textures/", TextureGroupsAddDirectoryCaller(groups));
+ }
+
+ GlobalShaderSystem().foreachShaderName(TextureGroupsAddShaderCaller(groups));
+ }
+ return groups;
+}
+
+void TextureTreeStore_Construct()
+{
+ TextureGroups groups = TextureGroupsTreeView_Construct();
+ GtkTreeStore* store = gtk_tree_store_new(1, G_TYPE_STRING);
+ TextureTreeModel_Construct (groups, store);
+ GtkTreeModel* model = GTK_TREE_MODEL (store);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (g_TextureBrowser.m_treeView), model);
+
+ g_object_unref (G_OBJECT (store));
+}
+
+void view_onRowActivated (GtkTreeView* treeview, GtkTreePath* path, GtkTreeViewColumn* col, gpointer userdata)
+{
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
+
+ if (gtk_tree_model_get_iter (model, &iter, path))
+ {
+ gchar* dirName;
+ gtk_tree_model_get (model, &iter, 0, &dirName, -1);
+
+ if(!TextureGroupsMenu_showWads())
+ {
+ char buffer[1024];
+ strcpy(buffer, dirName);
+ strcat(buffer, "/");
+ dirName = buffer;
+ }
+
+ ScopeDisableScreenUpdates disableScreenUpdates (dirName, "Loading Textures");
+ TextureBrowser_ShowDirectory (GlobalTextureBrowser (), dirName);
+ TextureBrowser_queueDraw (GlobalTextureBrowser ());
+ }
+}
+
+void Create_Tree_View ()
+{
+ GtkCellRenderer* renderer;
+ g_TextureBrowser.m_treeView = GTK_WIDGET (gtk_tree_view_new ());
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (g_TextureBrowser.m_treeView), FALSE);
+
+ g_signal_connect(g_TextureBrowser.m_treeView, "row-activated", (GCallback) view_onRowActivated, NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (g_TextureBrowser.m_treeView), -1, "", renderer, "text", 0, NULL);
+
+ TextureTreeStore_Construct();
+}
+
+GtkWidget* TextureBrowser_constructEnhancedWindow(GtkWindow* toplevel)
+{
+ GlobalShaderSystem().setActiveShadersChangedNotify(ReferenceCaller<TextureBrowser, TextureBrowser_activeShadersChanged>(g_TextureBrowser));
+
+ GtkWidget* scrolled_window;
+ GtkWidget* m_btn_hide_unused;
+ GtkWidget* m_btn_show_all;
+ GtkWidget* m_btn_show_shaders;
+ GtkWidget* m_btn_refresh_shaders;
+ GtkWidget* m_btn_find_replace;
+ GtkWidget* m_btn_shaders_only;
+
+ GtkWidget* table = gtk_table_new(3, 1, FALSE);
+ GtkWidget* hbox_btn_row1 = gtk_hbox_new (TRUE, 0);
+ GtkWidget* hbox_btn_row2 = gtk_hbox_new (TRUE, 0);
+ GtkWidget* hbox_table = gtk_hbox_new (FALSE, 0);
+ GtkWidget* separator = gtk_hseparator_new ();
+
+ m_btn_hide_unused = GTK_WIDGET (create_toggle_button_with_mnemonic("Hide _Unused", "ShowInUse"));
+ m_btn_show_all = GTK_WIDGET (create_button_with_mnemonic("Show All", "ShowAllTextures"));
+ m_btn_show_shaders = GTK_WIDGET (create_toggle_button_with_mnemonic("Show Shaders", "ToggleShowShaders"));
+ m_btn_refresh_shaders = GTK_WIDGET (create_button_with_mnemonic("Flush & Reload Shaders", "RefreshShaders"));
+ m_btn_find_replace = GTK_WIDGET (create_button_with_mnemonic("Find / Replace", "FindReplaceTextures"));
+ m_btn_shaders_only = GTK_WIDGET (create_toggle_button_with_mnemonic("Shaderlist Only", "ToggleShowShaderlistOnly"));
+
+ gtk_box_pack_start (GTK_BOX (hbox_btn_row1), m_btn_hide_unused, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox_btn_row1), m_btn_show_all, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox_btn_row1), m_btn_find_replace, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox_btn_row2), m_btn_show_shaders, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox_btn_row2), m_btn_shaders_only, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox_btn_row2), m_btn_refresh_shaders, TRUE, TRUE, 0);
+
+ gtk_table_attach (GTK_TABLE (table), hbox_btn_row1, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), hbox_btn_row2, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach_defaults (GTK_TABLE (table), hbox_table, 0, 1, 2, 3);
+
+ gtk_widget_show (separator);
+ gtk_widget_show (hbox_btn_row1);
+ gtk_widget_show (hbox_btn_row2);
+ gtk_widget_show (hbox_table);
+
+ g_TextureBrowser.m_parent = toplevel;
+
+ {
+ GtkWidget* w = gtk_vscrollbar_new (GTK_ADJUSTMENT (gtk_adjustment_new (0,0,0,1,1,1)));
+ gtk_widget_show (w);
+ gtk_box_pack_end (GTK_BOX (hbox_table), w, FALSE, TRUE, 0);
+ g_TextureBrowser.m_texture_scroll = w;
+
+ GtkAdjustment *vadjustment = gtk_range_get_adjustment (GTK_RANGE (g_TextureBrowser.m_texture_scroll));
+ g_signal_connect(G_OBJECT(vadjustment), "value_changed", G_CALLBACK(TextureBrowser_verticalScroll), &g_TextureBrowser);
+
+ widget_set_visible(g_TextureBrowser.m_texture_scroll, g_TextureBrowser.m_showTextureScrollbar);
+ }
+ {
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 0);
+
+ // vertical only scrolling for treeview
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+
+ gtk_box_pack_start (GTK_BOX(hbox_table), scrolled_window, FALSE, FALSE, 0);
+ gtk_widget_show (scrolled_window);
+
+ Create_Tree_View ();
+
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), GTK_WIDGET (g_TextureBrowser.m_treeView));
+ gtk_widget_show (GTK_WIDGET (g_TextureBrowser.m_treeView));
+
+ GtkWidget* texbox = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (texbox);
+
+ {
+ GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
+ gtk_box_pack_start(GTK_BOX(texbox), GTK_WIDGET(entry), FALSE, FALSE, 0);
+
+ g_TextureBrowser.m_filter = entry;
+
+ if(g_TextureBrowser.m_showTextureFilter)
+ {
+ gtk_widget_show(GTK_WIDGET(g_TextureBrowser.m_filter));
+ }
+
+ g_TextureBrowser.m_filterEntry.connect(entry);
+ }
+
+ {
+ g_TextureBrowser.m_gl_widget = glwidget_new(FALSE);
+ gtk_widget_ref(g_TextureBrowser.m_gl_widget);
+
+ gtk_widget_set_events(g_TextureBrowser.m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK);
+ GTK_WIDGET_SET_FLAGS(g_TextureBrowser.m_gl_widget, GTK_CAN_FOCUS);
+
+ gtk_box_pack_start(GTK_BOX(hbox_table), texbox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(texbox), g_TextureBrowser.m_gl_widget, TRUE, TRUE, 0);
+ gtk_widget_show(g_TextureBrowser.m_gl_widget);
+
+ g_TextureBrowser.m_sizeHandler = g_signal_connect(G_OBJECT(g_TextureBrowser.m_gl_widget), "size_allocate", G_CALLBACK(TextureBrowser_size_allocate), &g_TextureBrowser);
+ g_TextureBrowser.m_exposeHandler = g_signal_connect(G_OBJECT(g_TextureBrowser.m_gl_widget), "expose_event", G_CALLBACK(TextureBrowser_expose), &g_TextureBrowser);
+
+ g_signal_connect(G_OBJECT(g_TextureBrowser.m_gl_widget), "button_press_event", G_CALLBACK(TextureBrowser_button_press), &g_TextureBrowser);
+ g_signal_connect(G_OBJECT(g_TextureBrowser.m_gl_widget), "button_release_event", G_CALLBACK(TextureBrowser_button_release), &g_TextureBrowser);
+ g_signal_connect(G_OBJECT(g_TextureBrowser.m_gl_widget), "motion_notify_event", G_CALLBACK(TextureBrowser_motion), &g_TextureBrowser);
+ g_signal_connect(G_OBJECT(g_TextureBrowser.m_gl_widget), "scroll_event", G_CALLBACK(TextureBrowser_scroll), &g_TextureBrowser);
+ }
+ }
+
+ TextureBrowser_updateScroll(g_TextureBrowser);
+
+ gtk_container_set_focus_chain(GTK_CONTAINER(hbox_table), NULL);
+
+ return table;
+}
+
void TextureBrowser_destroyWindow()
{
GlobalShaderSystem().setActiveShadersChangedNotify(Callback());
@@ -1563,16 +1789,24 @@
void TextureBrowser_ToggleShowShaders()
{
g_TextureBrowser.m_showShaders ^= 1;
- g_TexturesMenu.m_showshaders_item.update();
+ g_TextureBrowser.m_showshaders_item.update();
TextureBrowser_queueDraw(g_TextureBrowser);
}
+extern LatchedBool g_Layout_enableEnhancedBrowser;
+
void TextureBrowser_ToggleShowShaderListOnly()
{
- g_TexturesMenu_shaderlistOnly ^= 1;
- g_TexturesMenu.m_showshaderlistonly_item.update();
- TextureGroupsMenu_Destroy();
- TextureGroupsMenu_Construct();
+ g_TextureBrowser_shaderlistOnly ^= 1;
+ g_TextureBrowser.m_showshaderlistonly_item.update();
+
+ if (!g_Layout_enableEnhancedBrowser.m_value) // old texture viewer
+ {
+ TextureGroupsMenu_Destroy();
+ TextureGroupsMenu_Construct();
+ } else {
+ TextureTreeStore_Construct();
+ }
}
void TextureBrowser_showAll()
@@ -1647,6 +1881,11 @@
void TextureBrowser_constructPreferences(PreferencesPage& page)
{
page.appendCheckBox(
+ "", "Enhanced Texture Browser",
+ LatchedBoolImportCaller(g_Layout_enableEnhancedBrowser),
+ BoolExportCaller(g_Layout_enableEnhancedBrowser.m_latched)
+ );
+ page.appendCheckBox(
"", "Texture subsets",
TextureBrowserImportShowFilterCaller(GlobalTextureBrowser()),
BoolExportCaller(GlobalTextureBrowser().m_showTextureFilter)
@@ -1693,11 +1932,11 @@
void TextureBrowser_Construct()
{
- GlobalToggles_insert("ShowInUse", FreeCaller<TextureBrowser_ToggleHideUnused>(), ToggleItem::AddCallbackCaller(g_TexturesMenu.m_hideunused_item), Accelerator('U'));
+ GlobalToggles_insert("ShowInUse", FreeCaller<TextureBrowser_ToggleHideUnused>(), ToggleItem::AddCallbackCaller(g_TextureBrowser.m_hideunused_item), Accelerator('U'));
GlobalCommands_insert("ShowAllTextures", FreeCaller<TextureBrowser_showAll>(), Accelerator('A', (GdkModifierType)GDK_CONTROL_MASK));
GlobalCommands_insert("ViewTextures", FreeCaller<TextureBrowser_toggleShown>(), Accelerator('T'));
- GlobalToggles_insert("ToggleShowShaders", FreeCaller<TextureBrowser_ToggleShowShaders>(), ToggleItem::AddCallbackCaller(g_TexturesMenu.m_showshaders_item));
- GlobalToggles_insert("ToggleShowShaderlistOnly", FreeCaller<TextureBrowser_ToggleShowShaderListOnly>(), ToggleItem::AddCallbackCaller(g_TexturesMenu.m_showshaderlistonly_item));
+ GlobalToggles_insert("ToggleShowShaders", FreeCaller<TextureBrowser_ToggleShowShaders>(), ToggleItem::AddCallbackCaller(g_TextureBrowser.m_showshaders_item));
+ GlobalToggles_insert("ToggleShowShaderlistOnly", FreeCaller<TextureBrowser_ToggleShowShaderListOnly>(), ToggleItem::AddCallbackCaller(g_TextureBrowser.m_showshaderlistonly_item));
GlobalPreferenceSystem().registerPreference("TextureScale",
makeSizeStringImportCallback(TextureBrowserSetScaleCaller(g_TextureBrowser)),
@@ -1712,7 +1951,7 @@
BoolExportStringCaller(GlobalTextureBrowser().m_showTextureScrollbar)
);
GlobalPreferenceSystem().registerPreference("ShowShaders", BoolImportStringCaller(GlobalTextureBrowser().m_showShaders), BoolExportStringCaller(GlobalTextureBrowser().m_showShaders));
- GlobalPreferenceSystem().registerPreference("ShowShaderlistOnly", BoolImportStringCaller(g_TexturesMenu_shaderlistOnly), BoolExportStringCaller(g_TexturesMenu_shaderlistOnly));
+ GlobalPreferenceSystem().registerPreference("ShowShaderlistOnly", BoolImportStringCaller(g_TextureBrowser_shaderlistOnly), BoolExportStringCaller(g_TextureBrowser_shaderlistOnly));
GlobalPreferenceSystem().registerPreference("LoadShaders", IntImportStringCaller(reinterpret_cast<int&>(GlobalTextureBrowser().m_startupShaders)), IntExportStringCaller(reinterpret_cast<int&>(GlobalTextureBrowser().m_startupShaders)));
GlobalPreferenceSystem().registerPreference("WheelMouseInc", SizeImportStringCaller(GlobalTextureBrowser().m_mouseWheelScrollIncrement), SizeExportStringCaller(GlobalTextureBrowser().m_mouseWheelScrollIncrement));
GlobalPreferenceSystem().registerPreference("SI_Colors0", Vector3ImportStringCaller(GlobalTextureBrowser().color_textureback), Vector3ExportStringCaller(GlobalTextureBrowser().color_textureback));
Index: radiant/texwindow.h
===================================================================
--- radiant/texwindow.h (revision 70)
+++ radiant/texwindow.h (working copy)
@@ -49,6 +49,7 @@
typedef struct _GtkWindow GtkWindow;
GtkWidget* TextureBrowser_constructWindow(GtkWindow* toplevel);
void TextureBrowser_destroyWindow();
+GtkWidget* TextureBrowser_constructEnhancedWindow(GtkWindow* toplevel);
void TextureBrowser_ShowDirectory(TextureBrowser& textureBrowser, const char* name);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: texture_browser.bmp
Type: image/bmp
Size: 336 bytes
Desc: not available
Url : http://zerowing.idsoftware.com/pipermail/gtkradiant/attachments/20060521/449accbf/texture_browser.bin
More information about the Gtkradiant
mailing list