Exemplo n.º 1
0
void Entity_setColour()
{
  if(GlobalSelectionSystem().countSelected() != 0)
  {
    const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
    Entity* entity = Node_getEntity(path.top());
    if(entity != 0)
    {
      const char* strColor = entity->getKeyValue("_color");
      if(!string_empty(strColor))
      {
        Vector3 rgb;
        if (string_parse_vector3(strColor, rgb))
        {
          g_entity_globals.color_entity = rgb;
        }
      }

      if(g_pGameDescription->mGameType == "doom3"
        ? color_dialog(GTK_WIDGET(MainFrame_getWindow()), g_entity_globals.color_entity)
        : DoNormalisedColor(g_entity_globals.color_entity))
      {
        char buffer[128];
        sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
                g_entity_globals.color_entity[1],
                g_entity_globals.color_entity[2]);

        Scene_EntitySetKeyValue_Selected("_color", buffer);
      }
    }
  }
}
Exemplo n.º 2
0
bool DoNormalisedColor(Vector3& color)
{
  if(!color_dialog(GTK_WIDGET(MainFrame_getWindow()), color))
    return false;
  /* 
  ** scale colors so that at least one component is at 1.0F 
  */

  float largest = 0.0F;

  if ( color[0] > largest )
    largest = color[0];
  if ( color[1] > largest )
    largest = color[1];
  if ( color[2] > largest )
    largest = color[2];

  if ( largest == 0.0F )
  {
    color[0] = 1.0F;
    color[1] = 1.0F;
    color[2] = 1.0F;
  }
  else
  {
    float scaler = 1.0F / largest;

    color[0] *= scaler;
    color[1] *= scaler;
    color[2] *= scaler;
  }

  return true;
}
Exemplo n.º 3
0
void Entity_setColour(){
	if ( GlobalSelectionSystem().countSelected() != 0 ) {
		const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
		Entity* entity = Node_getEntity( path.top() );

		if( entity == 0 && path.size() == 3 ){
			entity = Node_getEntity( path.parent() );
		}

		if ( entity != 0 ) {
			const char* strColor = entity->getKeyValue( "_color" );
			if ( !string_empty( strColor ) ) {
				Vector3 rgb;
				if ( string_parse_vector3( strColor, rgb ) ) {
					g_entity_globals.color_entity = rgb;
				}
			}
			if ( color_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_entity_globals.color_entity ) ) {
				char buffer[128];
				sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0],
						 g_entity_globals.color_entity[1],
						 g_entity_globals.color_entity[2] );

				StringOutputStream command( 256 );
				command << "entitySetColour " << buffer;
				UndoableCommand undo( command.c_str() );
				Scene_EntitySetKeyValue_Selected( "_color", buffer );
			}
		}
	}
}
Exemplo n.º 4
0
gboolean 
on_foreground_color_picker_button_release_event	(   GtkWidget	   *widget, 
													GdkEventButton *event,
													gpointer       user_data )
{
	if ( event->button == LEFT_BUTTON )
	{
		color_dialog( &foreground_color, _("Select Foreground Color") );
		foreground_show ();
	}
	return TRUE;
}
// When a "Choose color..." button beside a hex color textctrl is clicked, show
// a color dialog, initialize to textctrl's previous value if possible, get the
// color, convert to hex, put it back in the textctrl. Return FALSE if there
// was a problem.
bool utils_controls::textctrl_hex_color_selection( wxTextCtrl* target_color_textctrl )
{
    wxColour col;
    wxColourData color_data;
    
    // Set the default selected color to the hex one already in the textbox, 
    // if possible:
    // 1. Extract the old hex value
    wxString old_hex_color_string = target_color_textctrl->GetValue();    
    // 2. Check to see if valid
    if ( utils_string::is_valid_hex_color_string( old_hex_color_string ) ) 
    {
        wxLogDebug( wxT( "Valid old_hex_color_string=" ) + old_hex_color_string );
        // Convert textboxes previous color from its hex value [utils_string.cpp]
        col = utils_string::hex_string_to_color( old_hex_color_string );
    } 
    else 
    {
        // MSW's Cygwin,BCC (at least) as of Wx 2.4 needed to have an initialization 
        // to something other than black in order to get the matrix part of the dialog 
        // going properly.
		// It was wxColour( "MEDIUM BLUE" ) but compile causes cough on both OSX and 
		// Linux/GTK at least. 
		// So changing "MEDIUM BLUE" to an octal number insteaad        
        col = wxColour( 000066 );
    }
    // Put that value in color_data for the initial color of the color dialog.        
    color_data.SetColour( col );
   
    // Tells MSW to show the full color dialog, not just the smaller one. No
    // effect on other platforms.
    color_data.SetChooseFull( TRUE );

    // Show the color dialog, using the parent of the textctrl as parent of the 
    // new color dialog
    wxColourDialog color_dialog( target_color_textctrl->GetParent(), &color_data );
    // Set the title
    color_dialog.SetTitle( _( "Choose the colour" ) );
    // Only do the action if returned hitting an OK button.
    if ( color_dialog.ShowModal() == wxID_OK ) 
    {
        wxColourData returned_color_data = color_dialog.GetColourData();
        col = returned_color_data.GetColour();
        // Convert to hex [utils_string.cpp]
        wxString output_hex_color_string = utils_string::color_to_hex_string( col );
        // Set the textbox to that hex value
        target_color_textctrl->SetValue( output_hex_color_string );
    }
    return TRUE;
}
//-----------------------------------------------------------------------------
void ChannelSelectionDialog::on_channel_table__cellClicked (int row, int column)
{
    QTableWidgetItem* item = ui_.channel_table_->item (row, column);
    if (column == LABEL_INDEX_)
    {
        self_setting_ = true;
        if (item->checkState() == Qt::Checked)
            item->setCheckState (Qt::Unchecked);
        else
            item->setCheckState (Qt::Checked);
    }
    else if (column == COLOR_INDEX_)
    {
        QColorDialog color_dialog (item->backgroundColor (), this);
        if (color_dialog.exec () == QDialog::Accepted)
            updateColor (row, color_dialog.selectedColor ());
    }
    self_setting_ = false;
}
Exemplo n.º 7
0
static void palette_color_picker ( guint palette )
{
	g_return_if_fail( palette < NUM_PALETTES );
	color_dialog( &pallete_colors[palette], _("Select Color") );
	pallete_show (palette);
}