* view->show: toggle crosshair, size, grid are check menu items * view->show: +Show Light Radiuses toggle * view->show->show stats makes effect immediately * view->show fix: check menu items are sensitive to changing options via shortcuts misc... * option to disable main toolbar * removed bobtoolz caulk selection button; filterbar one does the job better * filterbar: + region set selected button; rightclick = region off * filterbar: + hide selected button; rightclick = show hidden * SelectionSystem option: prefer point entities in 2D views (def = yes) * filterbar: indicate region, hide states by buttons states * fix: region compiles (run build with region enabled = compile regioned part only) * solid selection boxes by default (m_bNoStipple) * always use stipple for stuff behind stuff in 3d (was dependent on m_bNoStipple) * del unused ChooseSmallGridMajorColor ChooseSmallGridMinorColor preferences pipeline * fix: Active View Name and Outline... Clipper... colors saving * fix: ChooseCameraSelectedBrushColor changes the color (requires restart) * fix: ChooseSelectedBrushColor preference saving (requires restart) * fix rubberband selector appearence in 2D with 'show window outline' option enabled * multiple projections layouts: activate a projection on zoom * multiple projections layouts: added wnds updates to correctly indicate active projection (via wnd outline and projection name) * draw projection name is independent from show coordinates option * multiple projections layouts: greyscale axes in inactive views * 'show coordinates' is disabled by default * quick (hacky) method to render things, indicating viewport being active or not (axes, view name, wnd outline)
142 lines
4.3 KiB
C++
142 lines
4.3 KiB
C++
/*
|
|
Copyright (C) 2001-2006, William Joseph.
|
|
All Rights Reserved.
|
|
|
|
This file is part of GtkRadiant.
|
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "plugintoolbar.h"
|
|
|
|
|
|
#include "itoolbar.h"
|
|
#include "modulesystem.h"
|
|
|
|
#include <gtk/gtktoolbar.h>
|
|
|
|
#include "stream/stringstream.h"
|
|
#include "gtkutil/image.h"
|
|
#include "gtkutil/container.h"
|
|
|
|
#include "mainframe.h"
|
|
#include "plugin.h"
|
|
|
|
GtkImage* new_plugin_image( const char* filename ){
|
|
{
|
|
StringOutputStream fullpath( 256 );
|
|
fullpath << AppPath_get() << g_pluginsDir << "bitmaps/" << filename;
|
|
GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() );
|
|
if ( image != 0 ) {
|
|
return image;
|
|
}
|
|
}
|
|
|
|
{
|
|
StringOutputStream fullpath( 256 );
|
|
fullpath << GameToolsPath_get() << g_pluginsDir << "bitmaps/" << filename;
|
|
GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() );
|
|
if ( image != 0 ) {
|
|
return image;
|
|
}
|
|
}
|
|
|
|
{
|
|
StringOutputStream fullpath( 256 );
|
|
fullpath << AppPath_get() << g_modulesDir << "bitmaps/" << filename;
|
|
GtkImage* image = image_new_from_file_with_mask( fullpath.c_str() );
|
|
if ( image != 0 ) {
|
|
return image;
|
|
}
|
|
}
|
|
|
|
return image_new_missing();
|
|
}
|
|
|
|
inline GtkToolbarChildType gtktoolbarchildtype_for_toolbarbuttontype( IToolbarButton::EType type ){
|
|
switch ( type )
|
|
{
|
|
case IToolbarButton::eSpace:
|
|
return GTK_TOOLBAR_CHILD_SPACE;
|
|
case IToolbarButton::eButton:
|
|
return GTK_TOOLBAR_CHILD_BUTTON;
|
|
case IToolbarButton::eToggleButton:
|
|
return GTK_TOOLBAR_CHILD_TOGGLEBUTTON;
|
|
case IToolbarButton::eRadioButton:
|
|
return GTK_TOOLBAR_CHILD_RADIOBUTTON;
|
|
}
|
|
ERROR_MESSAGE( "invalid toolbar button type" );
|
|
return (GtkToolbarChildType)0;
|
|
}
|
|
|
|
void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GtkSignalFunc handler, gpointer data ){
|
|
GtkWidget* widget = gtk_toolbar_append_element( toolbar, gtktoolbarchildtype_for_toolbarbuttontype( type ), 0, text, tooltip, "", GTK_WIDGET( new_plugin_image( icon ) ), handler, data );
|
|
if( type != IToolbarButton::eSpace ){
|
|
GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_FOCUS );
|
|
GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_DEFAULT );
|
|
}
|
|
}
|
|
|
|
void ActivateToolbarButton( GtkWidget *widget, gpointer data ){
|
|
const_cast<const IToolbarButton*>( reinterpret_cast<IToolbarButton*>( data ) )->activate();
|
|
}
|
|
|
|
void PlugInToolbar_AddButton( GtkToolbar* toolbar, const IToolbarButton* button ){
|
|
toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), GTK_SIGNAL_FUNC( ActivateToolbarButton ), reinterpret_cast<gpointer>( const_cast<IToolbarButton*>( button ) ) );
|
|
}
|
|
|
|
GtkToolbar* g_plugin_toolbar = 0;
|
|
|
|
void PluginToolbar_populate(){
|
|
class AddToolbarItemVisitor : public ToolbarModules::Visitor
|
|
{
|
|
GtkToolbar* m_toolbar;
|
|
public:
|
|
AddToolbarItemVisitor( GtkToolbar* toolbar )
|
|
: m_toolbar( toolbar ){
|
|
}
|
|
void visit( const char* name, const _QERPlugToolbarTable& table ) const {
|
|
const std::size_t count = table.m_pfnToolbarButtonCount();
|
|
for ( std::size_t i = 0; i < count; ++i )
|
|
{
|
|
PlugInToolbar_AddButton( m_toolbar, table.m_pfnGetToolbarButton( i ) );
|
|
}
|
|
}
|
|
|
|
} visitor( g_plugin_toolbar );
|
|
|
|
Radiant_getToolbarModules().foreachModule( visitor );
|
|
}
|
|
|
|
void PluginToolbar_clear(){
|
|
container_remove_all( GTK_CONTAINER( g_plugin_toolbar ) );
|
|
}
|
|
|
|
GtkToolbar* create_plugin_toolbar(){
|
|
GtkToolbar *toolbar;
|
|
|
|
toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
|
|
gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL );
|
|
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
|
|
// gtk_toolbar_set_show_arrow( toolbar, TRUE );
|
|
gtk_widget_show( GTK_WIDGET( toolbar ) );
|
|
|
|
g_plugin_toolbar = toolbar;
|
|
|
|
PluginToolbar_populate();
|
|
|
|
return toolbar;
|
|
}
|