binds...
	* F12: maximize main wnd view under cursor
	* ctrl + t: patch thicken
menus...
	* simplified curve menu
misc...
	* square option in exact patch creators (= redisperse rows + cols)
	* axis option in patch deform dialog
	* spinner instead of entry in: patch deform, thicken; brush prism, cone, sphere, rock dialogs
	* maximized brush cone prefab sides limit
This commit is contained in:
Garux 2017-08-02 09:06:50 +03:00
parent e7c45da823
commit cac514541c
9 changed files with 311 additions and 144 deletions

View File

@ -61,7 +61,7 @@ PanedState g_hpaned = { 0.5f, -1, };
PanedState g_vpaned1 = { 0.5f, -1, };
PanedState g_vpaned2 = { 0.5f, -1, };
GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright ){
GtkWidget* create_split_views( GtkWidget* topleft, GtkWidget* botleft, GtkWidget* topright, GtkWidget* botright, GtkWidget*& vsplit1, GtkWidget*& vsplit2 ){
GtkHPaned* hsplit = GTK_HPANED( gtk_hpaned_new() );
gtk_widget_show( GTK_WIDGET( hsplit ) );
@ -70,6 +70,7 @@ GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidge
{
GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() );
vsplit1 = GTK_WIDGET( vsplit );
gtk_paned_add1( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
gtk_widget_show( GTK_WIDGET( vsplit ) );
@ -77,18 +78,19 @@ GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidge
g_signal_connect( G_OBJECT( vsplit ), "notify::position", G_CALLBACK( paned_position ), &g_vpaned1 );
gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topleft ) ) );
gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topright ) ) );
gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botleft ) ) );
}
{
GtkVPaned* vsplit = GTK_VPANED( gtk_vpaned_new() );
vsplit2 = GTK_WIDGET( vsplit );
gtk_paned_add2( GTK_PANED( hsplit ), GTK_WIDGET( vsplit ) );
gtk_widget_show( GTK_WIDGET( vsplit ) );
g_signal_connect( G_OBJECT( vsplit ), "size_allocate", G_CALLBACK( vpaned_allocate ), &g_vpaned2 );
g_signal_connect( G_OBJECT( vsplit ), "notify::position", G_CALLBACK( paned_position ), &g_vpaned2 );
gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botleft ) ) );
gtk_paned_add1( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( topright ) ) );
gtk_paned_add2( GTK_PANED( vsplit ), GTK_WIDGET( create_framed_widget( botright ) ) );
}
return hsplit;
return GTK_WIDGET( hsplit );
}

View File

@ -24,6 +24,6 @@
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkHPaned GtkHPaned;
GtkHPaned* create_split_views( GtkWidget* topleft, GtkWidget* topright, GtkWidget* botleft, GtkWidget* botright );
GtkWidget* create_split_views( GtkWidget* topleft, GtkWidget* botleft, GtkWidget* topright, GtkWidget* botright, GtkWidget*& vsplit1, GtkWidget*& vsplit2 );
#endif

View File

@ -155,7 +155,7 @@ void Brush_ConstructPrism( Brush& brush, const AABB& bounds, std::size_t sides,
}
const std::size_t c_brushCone_minSides = 3;
const std::size_t c_brushCone_maxSides = 32;
const std::size_t c_brushCone_maxSides = c_brush_maxFaces - 1;
const char* const c_brushCone_name = "brushCone";
void Brush_ConstructCone( Brush& brush, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection ){

View File

@ -590,7 +590,7 @@ void Entity_constructMenu( GtkMenu* menu ){
create_menu_item_with_mnemonic( menu, "_KillConnect", "KillConnectSelection" );
}
create_menu_item_with_mnemonic( menu, "_Select Color...", "EntityColor" );
create_menu_item_with_mnemonic( menu, "_Normalize Color...", "NormalizeColor" );
create_menu_item_with_mnemonic( menu, "_Normalize Color", "NormalizeColor" );
}

View File

@ -61,6 +61,7 @@
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkspinbutton.h>
#include "os/path.h"
#include "math/aabb.h"
@ -384,7 +385,8 @@ void DoProjectSettings(){
void DoSides( int type, int axis ){
ModalDialog dialog;
GtkEntry* sides_entry;
//GtkEntry* sides_entry;
GtkWidget* sides_spin;
GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Arbitrary sides", G_CALLBACK( dialog_delete_callback ), &dialog );
@ -399,12 +401,40 @@ void DoSides( int type, int axis ){
gtk_widget_show( GTK_WIDGET( label ) );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
}
// {
// GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
// gtk_widget_show( GTK_WIDGET( entry ) );
// gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 );
// sides_entry = entry;
// gtk_widget_grab_focus( GTK_WIDGET( entry ) );
// }
{
GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
gtk_widget_show( GTK_WIDGET( entry ) );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 );
sides_entry = entry;
gtk_widget_grab_focus( GTK_WIDGET( entry ) );
GtkAdjustment* adj;
EBrushPrefab BrushPrefabType = (EBrushPrefab)type;
switch ( BrushPrefabType )
{
case eBrushPrism :
case eBrushCone :
adj = GTK_ADJUSTMENT( gtk_adjustment_new( 8, 3, 1022, 1, 10, 0 ) );
break;
case eBrushSphere :
adj = GTK_ADJUSTMENT( gtk_adjustment_new( 8, 3, 31, 1, 10, 0 ) );
break;
case eBrushRock :
adj = GTK_ADJUSTMENT( gtk_adjustment_new( 32, 10, 1000, 1, 10, 0 ) );
break;
default:
adj = GTK_ADJUSTMENT( gtk_adjustment_new( 8, 3, 31, 1, 10, 0 ) );
break;
}
GtkWidget* spin = gtk_spin_button_new( adj, 1, 0 );
gtk_widget_show( spin );
gtk_box_pack_start( GTK_BOX( hbox ), spin, FALSE, FALSE, 0 );
gtk_widget_set_size_request( spin, 64, -1 );
gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE );
sides_spin = spin;
}
{
GtkVBox* vbox = create_dialog_vbox( 4 );
@ -424,9 +454,12 @@ void DoSides( int type, int axis ){
}
if ( modal_dialog_show( window, dialog ) == eIDOK ) {
const char *str = gtk_entry_get_text( sides_entry );
// const char *str = gtk_entry_get_text( sides_entry );
Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, atoi( str ), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
// Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, atoi( str ), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
gtk_spin_button_update ( GTK_SPIN_BUTTON( sides_spin ) );
int sides = static_cast<int>( gtk_spin_button_get_value( GTK_SPIN_BUTTON( sides_spin ) ) );
Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, sides, TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
}
gtk_widget_destroy( GTK_WIDGET( window ) );

View File

@ -2158,8 +2158,9 @@ GtkMenuItem* create_misc_menu(){
create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" );
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
// create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<WXY_Print>());
create_menu_item_with_mnemonic( menu, "_Background select", FreeCaller<WXY_BackgroundSelect>() );
create_menu_item_with_mnemonic( menu, "_Background image...", FreeCaller<WXY_BackgroundSelect>() );
create_menu_item_with_mnemonic( menu, "Fullscreen", "Fullscreen" );
create_menu_item_with_mnemonic( menu, "Maximize view", "MaximizeView" );
return misc_menu_item;
}
@ -3013,9 +3014,12 @@ void MainFrame::Create(){
g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
}
m_vSplit = 0;
m_hSplit = 0;
m_vSplit2 = 0;
GroupDialog_show();
}
else // 4 way
@ -3041,8 +3045,8 @@ void MainFrame::Create(){
GtkWidget* xz = m_pXZWnd->GetWidget();
GtkHPaned* split = create_split_views( camera, yz, xy, xz );
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 );
m_hSplit = create_split_views( camera, yz, xy, xz, m_vSplit, m_vSplit2 );
gtk_box_pack_start( GTK_BOX( vbox ), m_hSplit, TRUE, TRUE, 0 );
{
GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
@ -3293,6 +3297,73 @@ void MainFrame_toggleFullscreen(){
}
}
class MaximizeView
{
public:
MaximizeView(): m_maximized( false ){
}
void toggle(){
return m_maximized ? restore() : maximize();
}
private:
bool m_maximized;
int m_vSplitPos;
int m_vSplit2Pos;
int m_hSplitPos;
void restore(){
m_maximized = false;
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), m_vSplitPos );
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), m_vSplit2Pos );
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), m_hSplitPos );
}
void maximize(){
m_maximized = true;
m_vSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit ) );
m_vSplit2Pos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit2 ) );
m_hSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_hSplit ) );
int vSplitX, vSplitY, vSplit2X, vSplit2Y, hSplitX, hSplitY;
gdk_window_get_origin( g_pParentWnd->m_vSplit->window, &vSplitX, &vSplitY );
gdk_window_get_origin( g_pParentWnd->m_vSplit2->window, &vSplit2X, &vSplit2Y );
gdk_window_get_origin( g_pParentWnd->m_hSplit->window, &hSplitX, &hSplitY );
vSplitY += m_vSplitPos;
vSplit2Y += m_vSplit2Pos;
hSplitX += m_hSplitPos;
int cur_x, cur_y;
Sys_GetCursorPos( MainFrame_getWindow(), &cur_x, &cur_y );
if( cur_x > hSplitX ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 9999 );
}
if( cur_y > vSplitY ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 9999 );
}
if( cur_y > vSplit2Y ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 9999 );
}
}
};
MaximizeView g_maximizeview;
void Maximize_View(){
if( g_pParentWnd != 0 && g_pParentWnd->m_vSplit != 0 && g_pParentWnd->m_vSplit2 != 0 && g_pParentWnd->m_hSplit != 0 )
g_maximizeview.toggle();
}
#include "preferencesystem.h"
#include "stringio.h"
@ -3392,6 +3463,7 @@ void MainFrame_Construct(){
GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) );
GlobalCommands_insert( "Fullscreen", FreeCaller<MainFrame_toggleFullscreen>(), Accelerator( GDK_F11 ) );
GlobalCommands_insert( "MaximizeView", FreeCaller<Maximize_View>(), Accelerator( GDK_F12 ) );
GlobalCommands_insert( "CSGSubtract", FreeCaller<CSG_Subtract>(), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) );

View File

@ -73,10 +73,13 @@ void Create();
void SaveWindowInfo();
void Shutdown();
public:
GtkWidget* m_vSplit;
GtkWidget* m_hSplit;
GtkWidget* m_vSplit2;
private:
XYWnd* m_pXYWnd;
XYWnd* m_pYZWnd;
XYWnd* m_pXZWnd;

View File

@ -811,20 +811,20 @@ void Patch::InsertPoints( EMatrixMajor mt, bool bFirst ){
return;
}
if ( bFirst ) {
pos = height - 1;
pos = 2;
}
else
{
pos = 2;
pos = height - 1;
}
if ( pos >= height ) {
if ( bFirst ) {
pos = height - 1;
pos = 2;
}
else
{
pos = 2;
pos = height - 1;
}
}
else if ( pos == 0 ) {
@ -955,19 +955,19 @@ void Patch::RemovePoints( EMatrixMajor mt, bool bFirst ){
return;
}
if ( bFirst ) {
pos = height - 3;
pos = 2;
}
else
{
pos = 2;
pos = height - 3;
}
if ( pos >= height ) {
if ( bFirst ) {
pos = height - 3;
pos = 2;
}
else
{
pos = 2;
pos = height - 3;
}
}
else if ( pos == 0 ) {

View File

@ -46,7 +46,7 @@
PatchCreator* g_patchCreator = 0;
void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const char* shader, EPatchPrefab eType, int axis, std::size_t width = 3, std::size_t height = 3 ){
void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const char* shader, EPatchPrefab eType, int axis, std::size_t width = 3, std::size_t height = 3, bool redisperse = false ){
Select_Delete();
GlobalSelectionSystem().setSelectedAll( false );
@ -57,6 +57,10 @@ void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const cha
patch->SetShader( shader );
patch->ConstructPrefab( aabb, eType, axis, width, height );
if( redisperse ){
patch->Redisperse( COL );
patch->Redisperse( ROW );
}
patch->controlPointsChanged();
{
@ -172,26 +176,25 @@ void Scene_PatchDoCap_Selected( scene::Graph& graph, const char* shader ){
}
}
void Patch_deform( Patch& patch, scene::Instance& instance, const int deform ){
void Patch_deform( Patch& patch, scene::Instance& instance, const int deform, const int axis ){
patch.undoSave();
for (PatchControlIter i = patch.begin(); i != patch.end(); ++i)
{
for ( PatchControlIter i = patch.begin(); i != patch.end(); ++i ){
PatchControl& control = *i;
int randomNumber = int( deform * (float(std::rand()) / float(RAND_MAX)));
control.m_vertex[2] += randomNumber;
int randomNumber = int( deform * ( float( std::rand() ) / float( RAND_MAX ) ) );
control.m_vertex[ axis ] += randomNumber;
}
patch.controlPointsChanged();
}
void Scene_PatchDeform( scene::Graph& graph, const int deform )
void Scene_PatchDeform( scene::Graph& graph, const int deform, const int axis )
{
InstanceVector instances;
Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
{
Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform );
Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform, axis );
}
}
@ -579,30 +582,30 @@ void Patch_Plane(){
DoNewPatchDlg( ePlane, 3, 3, 3, 3, 0, 0 );
}
void Patch_InsertInsertColumn(){
UndoableCommand undo( "patchInsertColumns" );
Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, false );
}
void Patch_InsertAddColumn(){
UndoableCommand undo( "patchAddColumns" );
void Patch_InsertFirstColumn(){
UndoableCommand undo( "patchInsertFirstColumns" );
Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, true );
}
void Patch_InsertInsertRow(){
UndoableCommand undo( "patchInsertRows" );
void Patch_InsertLastColumn(){
UndoableCommand undo( "patchInsertLastColumns" );
Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, false );
Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, false );
}
void Patch_InsertAddRow(){
UndoableCommand undo( "patchAddRows" );
void Patch_InsertFirstRow(){
UndoableCommand undo( "patchInsertFirstRows" );
Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, true );
}
void Patch_InsertLastRow(){
UndoableCommand undo( "patchInsertLastRows" );
Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, false );
}
void Patch_DeleteFirstColumn(){
UndoableCommand undo( "patchDeleteFirstColumns" );
@ -816,23 +819,23 @@ void Patch_registerCommands(){
GlobalCommands_insert( "InvertCurveTextureY", FreeCaller<Patch_FlipTextureY>(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
GlobalCommands_insert( "NaturalizePatch", FreeCaller<Patch_NaturalTexture>(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "PatchCylinder", FreeCaller<Patch_Cylinder>() );
GlobalCommands_insert( "PatchDenseCylinder", FreeCaller<Patch_DenseCylinder>() );
GlobalCommands_insert( "PatchVeryDenseCylinder", FreeCaller<Patch_VeryDenseCylinder>() );
// GlobalCommands_insert( "PatchDenseCylinder", FreeCaller<Patch_DenseCylinder>() );
// GlobalCommands_insert( "PatchVeryDenseCylinder", FreeCaller<Patch_VeryDenseCylinder>() );
GlobalCommands_insert( "PatchSquareCylinder", FreeCaller<Patch_SquareCylinder>() );
GlobalCommands_insert( "PatchXactCylinder", FreeCaller<Patch_XactCylinder>() );
GlobalCommands_insert( "PatchXactSphere", FreeCaller<Patch_XactSphere>() );
GlobalCommands_insert( "PatchXactCone", FreeCaller<Patch_XactCone>() );
GlobalCommands_insert( "PatchEndCap", FreeCaller<Patch_Endcap>() );
GlobalCommands_insert( "PatchBevel", FreeCaller<Patch_Bevel>() );
GlobalCommands_insert( "PatchSquareBevel", FreeCaller<Patch_SquareBevel>() );
GlobalCommands_insert( "PatchSquareEndcap", FreeCaller<Patch_SquareEndcap>() );
// GlobalCommands_insert( "PatchSquareBevel", FreeCaller<Patch_SquareBevel>() );
// GlobalCommands_insert( "PatchSquareEndcap", FreeCaller<Patch_SquareEndcap>() );
GlobalCommands_insert( "PatchCone", FreeCaller<Patch_Cone>() );
GlobalCommands_insert( "PatchSphere", FreeCaller<Patch_Sphere>() );
GlobalCommands_insert( "SimplePatchMesh", FreeCaller<Patch_Plane>(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller<Patch_InsertAddColumn>() );
GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "PatchInsertAddRow", FreeCaller<Patch_InsertAddRow>() );
GlobalCommands_insert( "PatchInsertFirstColumn", FreeCaller<Patch_InsertFirstColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "PatchInsertLastColumn", FreeCaller<Patch_InsertLastColumn>() );
GlobalCommands_insert( "PatchInsertFirstRow", FreeCaller<Patch_InsertFirstRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "PatchInsertLastRow", FreeCaller<Patch_InsertLastRow>() );
GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller<Patch_DeleteFirstColumn>() );
GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>() );
@ -845,10 +848,10 @@ void Patch_registerCommands(){
GlobalCommands_insert( "MatrixTranspose", FreeCaller<Patch_Transpose>(), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
GlobalCommands_insert( "CapCurrentCurve", FreeCaller<Patch_Cap>(), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) );
GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator( 'N', (GdkModifierType)GDK_SHIFT_MASK ) );
GlobalCommands_insert( "MakeOverlayPatch", FreeCaller<Patch_OverlayOn>(), Accelerator( 'Y' ) );
GlobalCommands_insert( "ClearPatchOverlays", FreeCaller<Patch_OverlayOff>(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
// GlobalCommands_insert( "MakeOverlayPatch", FreeCaller<Patch_OverlayOn>(), Accelerator( 'Y' ) );
// GlobalCommands_insert( "ClearPatchOverlays", FreeCaller<Patch_OverlayOff>(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
GlobalCommands_insert( "PatchDeform", FreeCaller<Patch_Deform>() );
GlobalCommands_insert( "PatchThicken", FreeCaller<Patch_Thicken>() );
GlobalCommands_insert( "PatchThicken", FreeCaller<Patch_Thicken>(), Accelerator( 'T', (GdkModifierType)GDK_CONTROL_MASK ) );
}
void Patch_constructToolbar( GtkToolbar* toolbar ){
@ -856,58 +859,49 @@ void Patch_constructToolbar( GtkToolbar* toolbar ){
}
void Patch_constructMenu( GtkMenu* menu ){
create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" );
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Dense Cylinder", "PatchDenseCylinder" );
create_menu_item_with_mnemonic( menu_in_menu, "Very Dense Cylinder", "PatchVeryDenseCylinder" );
create_menu_item_with_mnemonic( menu_in_menu, "Square Cylinder", "PatchSquareCylinder" );
create_menu_item_with_mnemonic( menu_in_menu, "Exact Cylinder...", "PatchXactCylinder" );
}
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
{
// GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
create_menu_item_with_mnemonic( menu, "Cylinder (9x3)", "PatchCylinder" );
create_menu_item_with_mnemonic( menu, "Square Cylinder (9x3)", "PatchSquareCylinder" );
create_menu_item_with_mnemonic( menu, "Exact Cylinder...", "PatchXactCylinder" );
create_menu_item_with_mnemonic( menu, "Cone (9x3)", "PatchCone" );
create_menu_item_with_mnemonic( menu, "Exact Cone...", "PatchXactCone" );
create_menu_item_with_mnemonic( menu, "Sphere (9x5)", "PatchSphere" );
create_menu_item_with_mnemonic( menu, "Exact Sphere...", "PatchXactSphere" );
// {
// GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( menu_in_menu );
// }
create_menu_item_with_mnemonic( menu, "Square Endcap", "PatchSquareBevel" );
create_menu_item_with_mnemonic( menu, "Square Bevel", "PatchSquareEndcap" );
}
// create_menu_item_with_mnemonic( menu_in_menu, "Dense Cylinder", "PatchDenseCylinder" );
// create_menu_item_with_mnemonic( menu_in_menu, "Very Dense Cylinder", "PatchVeryDenseCylinder" );
// create_menu_item_with_mnemonic( menu_in_menu, "Square Cylinder", "PatchSquareCylinder" );
// }
// {
// //not implemented
// create_menu_item_with_mnemonic( menu, "Square Endcap", "PatchSquareBevel" );
// create_menu_item_with_mnemonic( menu, "Square Bevel", "PatchSquareEndcap" );
// }
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Cone", "PatchCone" );
create_menu_item_with_mnemonic( menu, "Exact Cone...", "PatchXactCone" );
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Sphere", "PatchSphere" );
create_menu_item_with_mnemonic( menu, "Exact Sphere...", "PatchXactSphere" );
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
menu_separator( menu );
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert/Delete" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Columns", "PatchInsertAddColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) First Columns", "PatchInsertFirstColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Last Columns", "PatchInsertLastColumn" );
menu_separator( menu_in_menu );
create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" );
create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" );
}
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "First (2) Columns", "PatchDeleteFirstColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Last (2) Columns", "PatchDeleteLastColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) First Rows", "PatchInsertFirstRow" );
create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Last Rows", "PatchInsertLastRow" );
menu_separator( menu_in_menu );
create_menu_item_with_mnemonic( menu_in_menu, "First (2) Rows", "PatchDeleteFirstRow" );
create_menu_item_with_mnemonic( menu_in_menu, "Last (2) Rows", "PatchDeleteLastRow" );
create_menu_item_with_mnemonic( menu_in_menu, "Del First (2) Columns", "PatchDeleteFirstColumn" );
create_menu_item_with_mnemonic( menu_in_menu, "Del Last (2) Columns", "PatchDeleteLastColumn" );
menu_separator( menu_in_menu );
create_menu_item_with_mnemonic( menu_in_menu, "Del First (2) Rows", "PatchDeleteFirstRow" );
create_menu_item_with_mnemonic( menu_in_menu, "Del Last (2) Rows", "PatchDeleteLastRow" );
}
menu_separator( menu );
{
@ -917,24 +911,16 @@ void Patch_constructMenu( GtkMenu* menu ){
}
create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" );
create_menu_item_with_mnemonic( menu_in_menu, "Transpose", "MatrixTranspose" );
// GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( menu_3 );
// }
menu_separator( menu_in_menu );
create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Rows", "RedisperseRows" );
create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Columns", "RedisperseCols" );
// GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( menu_4 );
// }
menu_separator( menu_in_menu );
create_menu_item_with_mnemonic( menu_in_menu, "Smooth Rows", "SmoothRows" );
create_menu_item_with_mnemonic( menu_in_menu, "Smooth Columns", "SmoothCols" );
}
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
menu_separator( menu );
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Texture" );
if ( g_Layout_enableDetachableMenus.m_value ) {
@ -946,15 +932,15 @@ void Patch_constructMenu( GtkMenu* menu ){
create_menu_item_with_mnemonic( menu_in_menu, "Invert Y", "InvertCurveTextureY" );
}
menu_separator( menu );
{
GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Set", "MakeOverlayPatch" );
create_menu_item_with_mnemonic( menu_in_menu, "Clear", "ClearPatchOverlays" );
}
// menu_separator( menu );
// { //unfinished
// GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( menu_in_menu );
// }
// create_menu_item_with_mnemonic( menu_in_menu, "Set", "MakeOverlayPatch" );
// create_menu_item_with_mnemonic( menu_in_menu, "Clear", "ClearPatchOverlays" );
// }
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Deform...", "PatchDeform" );
create_menu_item_with_mnemonic( menu, "Thicken...", "PatchThicken" );
@ -966,6 +952,7 @@ void Patch_constructMenu( GtkMenu* menu ){
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkradiobutton.h>
#include <gtk/gtkcombobox.h>
#include <gtk/gtkspinbutton.h>
#include <gtk/gtklabel.h>
#include "gtkutil/dialog.h"
#include "gtkutil/widget.h"
@ -974,6 +961,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
ModalDialog dialog;
GtkComboBox* width;
GtkComboBox* height;
GtkWidget* redisperseCheckBox;
GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog );
@ -984,7 +972,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
GtkHBox* hbox = create_dialog_hbox( 4, 4 );
gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
{
GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
GtkTable* table = create_dialog_table( 3, 2, 4, 4 );
gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
{
GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) );
@ -1055,6 +1043,18 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
height = combo;
}
if( prefab != ePlane ){
GtkWidget* _redisperseCheckBox = gtk_check_button_new_with_label( "Square" );
gtk_widget_set_tooltip_text( _redisperseCheckBox, "Redisperse columns & rows" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( _redisperseCheckBox ), FALSE );
gtk_widget_show( _redisperseCheckBox );
gtk_table_attach( table, _redisperseCheckBox, 0, 2, 2, 3,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
redisperseCheckBox = _redisperseCheckBox;
}
}
{
@ -1082,8 +1082,11 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
if ( modal_dialog_show( window, dialog ) == eIDOK ) {
int w = gtk_combo_box_get_active( width ) * 2 + mincols;
int h = gtk_combo_box_get_active( height ) * 2 + minrows;
Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h );
bool redisperse = false;
if( prefab != ePlane ){
redisperse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( redisperseCheckBox ) ) ? true : false;
}
Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h, redisperse );
}
gtk_widget_destroy( GTK_WIDGET( window ) );
@ -1094,6 +1097,9 @@ void DoPatchDeformDlg(){
ModalDialog dialog;
GtkWidget* deformW;
GtkWidget* rndY;
GtkWidget* rndX;
GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog );
GtkAccelGroup* accel = gtk_accel_group_new();
@ -1113,15 +1119,49 @@ void DoPatchDeformDlg(){
(GtkAttachOptions) ( 0 ), 0, 0 );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
// {
// GtkWidget* entry = gtk_entry_new();
// gtk_entry_set_text( GTK_ENTRY( entry ), "64" );
// gtk_widget_show( entry );
// gtk_table_attach( table, entry, 1, 2, 0, 1,
// (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
// (GtkAttachOptions) ( 0 ), 0, 0 );
//
// deformW = entry;
// }
{
GtkWidget* entry = gtk_entry_new();
gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
gtk_widget_show( entry );
gtk_table_attach( table, entry, 1, 2, 0, 1,
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 64, -9999, 9999, 1, 10, 0 ) );
//GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( adj, 1, 0 ) );
GtkWidget* spin = gtk_spin_button_new( adj, 1, 0 );
gtk_widget_show( spin );
gtk_table_attach( table, spin, 1, 2, 0, 1,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
gtk_widget_set_size_request( spin, 64, -1 );
gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE );
deformW = entry;
deformW = spin;
}
{
// Create the radio button group for choosing the axis
GtkWidget* _rndZ = gtk_radio_button_new_with_label_from_widget( NULL, "Z" );
GtkWidget* _rndY = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_rndZ), "Y" );
GtkWidget* _rndX = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_rndZ), "X" );
gtk_widget_show( _rndZ );
gtk_widget_show( _rndY );
gtk_widget_show( _rndX );
GtkHBox* _hbox = create_dialog_hbox( 4, 4 );
gtk_table_attach( table, GTK_WIDGET( _hbox ), 0, 2, 1, 2,
(GtkAttachOptions) ( GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
gtk_box_pack_start( GTK_BOX( _hbox ), GTK_WIDGET( _rndX ), TRUE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX( _hbox ), GTK_WIDGET( _rndY ), TRUE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX( _hbox ), GTK_WIDGET( _rndZ ), TRUE, TRUE, 0 );
rndX = _rndX;
rndY = _rndY;
}
}
{
@ -1143,10 +1183,18 @@ void DoPatchDeformDlg(){
}
if ( modal_dialog_show( window, dialog ) == eIDOK ) {
int deform = static_cast<int>( atoi( gtk_entry_get_text( GTK_ENTRY( deformW ) ) ) );
Scene_PatchDeform( GlobalSceneGraph(), deform );
//int deform = static_cast<int>( atoi( gtk_entry_get_text( GTK_ENTRY( deformW ) ) ) );
gtk_spin_button_update ( GTK_SPIN_BUTTON( deformW ) );
int deform = static_cast<int>( gtk_spin_button_get_value( GTK_SPIN_BUTTON( deformW ) ) );
int axis = 2; //Z
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( rndX ) ) ){
axis = 0;
}
else if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( rndY ) ) ){
axis = 1;
}
Scene_PatchDeform( GlobalSceneGraph(), deform, axis );
}
gtk_widget_destroy( GTK_WIDGET( window ) );
}
@ -1325,7 +1373,6 @@ void DoPatchThickenDlg(){
GtkWidget* radX;
GtkWidget* radY;
GtkWidget* radZ;
GtkWidget* radNormals;
GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch thicken", G_CALLBACK( dialog_delete_callback ), &dialog );
@ -1346,23 +1393,35 @@ void DoPatchThickenDlg(){
(GtkAttachOptions) ( 0 ), 0, 0 );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
// {
// GtkWidget* entry = gtk_entry_new();
// gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
// gtk_widget_set_size_request( entry, 40, -1 );
// gtk_widget_show( entry );
// gtk_table_attach( table, entry, 1, 2, 0, 1,
// (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
// (GtkAttachOptions) ( 0 ), 0, 0 );
//
// thicknessW = entry;
// }
{
GtkWidget* entry = gtk_entry_new();
gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
gtk_widget_set_size_request( entry, 40, -1 );
gtk_widget_show( entry );
gtk_table_attach( table, entry, 1, 2, 0, 1,
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 16, -9999, 9999, 1, 10, 0 ) );
GtkWidget* spin = gtk_spin_button_new( adj, 1, 0 );
gtk_widget_show( spin );
gtk_table_attach( table, spin, 1, 2, 0, 1,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
gtk_widget_set_size_request( spin, 48, -1 );
gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE );
thicknessW = entry;
thicknessW = spin;
}
{
// Create the "create seams" label
GtkWidget* _seamsCheckBox = gtk_check_button_new_with_label( "Side walls" );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( _seamsCheckBox ), TRUE );
gtk_widget_show( _seamsCheckBox );
gtk_table_attach( table, _seamsCheckBox, 3, 4, 0, 1,
gtk_table_attach( table, _seamsCheckBox, 2, 4, 0, 1,
(GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
(GtkAttachOptions) ( 0 ), 0, 0 );
seamsW = _seamsCheckBox;
@ -1396,7 +1455,6 @@ void DoPatchThickenDlg(){
radX = _radX;
radY = _radY;
radZ = _radZ;
radNormals = _radNormals;
}
}
{
@ -1418,9 +1476,11 @@ void DoPatchThickenDlg(){
}
if ( modal_dialog_show( window, dialog ) == eIDOK ) {
int axis;
int axis = 3; // Extrude along normals
bool seams;
float thickness = static_cast<float>( atoi( gtk_entry_get_text( GTK_ENTRY( thicknessW ) ) ) );
//float thickness = static_cast<float>( atoi( gtk_entry_get_text( GTK_ENTRY( thicknessW ) ) ) );
gtk_spin_button_update ( GTK_SPIN_BUTTON( thicknessW ) );
float thickness = static_cast<float>( gtk_spin_button_get_value( GTK_SPIN_BUTTON( thicknessW ) ) );
seams = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( seamsW )) ? true : false;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radX))) {
@ -1432,10 +1492,7 @@ void DoPatchThickenDlg(){
else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radZ))) {
axis = 2;
}
else {
// Extrude along normals
axis = 3;
}
Scene_PatchThicken( GlobalSceneGraph(), thickness, seams, axis );
}