R cannot be resolved to a variable why? - eclipse

I have this
public GamePanel(Context context, Game game,int ScreenWidth,int Screenheigt) {
super(context);
getHolder().addCallback(this);
this.game = game;
thread = new MainThread(getHolder(),this);
background = new Background(BitmapFactory.decodeResource(getResources(), R.drawable.game_fon), ScreenWidth, this);
BM = new Barriermanager(BitmapFactory.decodeResource(getResources(), R.drawable.barier), this);
BM.setScreen(ScreenWidth, Screenheigt);
ship = new Ship(BitmapFactory.decodeResource(getResources(), R.drawable.player), 100, 0, ScreenWidth, Screenheigt);
coin = new Bonus(BitmapFactory.decodeResource(getResources(), R.drawable.bonus), -200,-200);
ArrayList<Bitmap> animation = new ArrayList<Bitmap>();
animation.add(BitmapFactory.decodeResource(getResources(), R.drawable.boom1));
animation.add(BitmapFactory.decodeResource(getResources(), R.drawable.boom2));
animation.add(BitmapFactory.decodeResource(getResources(), R.drawable.boom3));
animation.add(BitmapFactory.decodeResource(getResources(), R.drawable.boom4));
ship.setBoomAnimation(animation);
please help! The "R" cannot be resolved to a variable

Related

Why the thrown objects are not thrown forward?

I'm trying to throw objects the same direction the camera is pointing to (forward), but it is behaving really weird. Objects don't always get thrown forward, sometimes it gets thrown up or towards the player itself (backward). And I don't know why:
Here is a snippet of PickingUp class:
public float throwForce = 1000f;
...
private void PickUpObject(GameObject pickUpObj)
{
if (pickUpObj.GetComponent<Rigidbody>())
{
heldObj = pickUpObj;
heldObjRb = pickUpObj.GetComponent<Rigidbody>();
heldObjRb.isKinematic = true;
heldObjRb.transform.parent = holdPos.transform;
heldObj.layer = LayerNumber;
Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), true);
reticle.color = new Color(1, 1, 1, 0.75f);
reticle.enabled = false;
}
}
void DropObject()
{
//re-enable collision with player
Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), false);
heldObj.layer = 0; //object assigned back to default layer
heldObjRb.isKinematic = false;
heldObj.transform.parent = null; //unparent object
heldObj = null; //undefine game object
reticle.color = new Color(1, 1, 1, 0.75f);
reticle.enabled = true;
}
void ThrowObject()
{
//same as drop function, but add force to object before undefining it
Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), false);
heldObj.layer = 0;
heldObjRb.isKinematic = false;
heldObj.transform.parent = null;
Vector3 camerDirection = camera.transform.forward;
heldObjRb.AddForce(camerDirection * throwForce);
// heldObjRb.constraints = RigidbodyConstraints.None;
heldObj = null;
reticle.color = new Color(1, 1, 1, 0.75f);
reticle.enabled = true;
}
All objects have Rigidbody and colliders attached to them. I get the same issue when dropping the objects too.
Try specifying the force mode as impulse on the AddForce method. The default is acceleration which can often require unreasonable large numbers to get the desired effect.
heldObjRb.AddForce(camerDirection * throwForce, ForceMode.Impulse);
A lot of people pointed out that your issue might be collision between the pickupobject and the players collider. You're using a method that tells the physics engine to ignore the collisions that I'm not familiar with, but should be fine to use for your purpose.
I would suggest enabling the collision after a short time delay, so the object has enough time to escape the players collider. You can do so with an invoke.
void ThrowObject()
{
//same as drop function, but add force to object before undefining it
heldObj.layer = 0;
heldObjRb.isKinematic = false;
heldObj.transform.parent = null;
Vector3 camerDirection = camera.transform.forward;
heldObjRb.AddForce(camerDirection * throwForce, ForceMode.Impulse);
// heldObjRb.constraints = RigidbodyConstraints.None;
reticle.color = new Color(1, 1, 1, 0.75f);
reticle.enabled = true;
Invoke("ResetCollision", 0.5f);//can be adjusted
}
public void ResetCollision(){
Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), false);
heldObj = null;
}

I have Problem in making solid ground in cannonjs

I have faced a problem while making solid ground that will make my sphere stop from falling through the plane…
the code below should prevent the sphere from falling through the plane, and also I know that you need to rotate the solid body...
const planeBody = new CANNON.Body({mass: 0})
but surprisingly it doesn’t have any effect at all, what should happen is that it should stop the sphere from falling through the plane…
also, there is another weird problem
the code below should make the plane fall along with the sphere if the sphere also has a mass equal to 1, and indeed that is what happens here
const planeBody = new CANNON.Body({mass: 1})
but when you try to rewrite it in this form, it stops from working
const planeBody = new CANNON.Body()
planeBody.mass = 1;
here is my complete code
import * as THREE from './threeJS/three.module.js';
import { OrbitControls } from './examples/jsm/controls/OrbitControls.js';
import { GUI } from '../dat.gui/files/dat.gui.module.js';
import * as THREEx from './threeX/threeX.keyboardState.js';
// gui
// const gui = new GUI();
// keyboard
const keyboard = new THREEx.default();
// console.log(THREEx.default);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x777777);
// Meshes
const plane = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({ color: 0xdddddd, side: THREE.DoubleSide })
);
plane.rotateX(90 / 57.3);
const sphere = new THREE.Mesh(
new THREE.SphereGeometry(3, 64, 32),
new THREE.MeshStandardMaterial({ color: 'red' })
);
sphere.position.y = 5;
let clientWidth = document.documentElement.clientWidth;
let clientHeight = document.documentElement.clientHeight;
// prettier-ignore
const camera = new THREE.PerspectiveCamera(45, clientWidth / clientHeight, 0.1, 1000);
const canvas = document.querySelector('.webgl');
const controls = new OrbitControls(camera, canvas);
controls.enableDamping = true;
camera.position.set(0, 20, 30);
controls.update();
const renderer = new THREE.WebGLRenderer({
canvas: canvas,
antialias: true,
});
renderer.setSize(clientWidth, clientHeight);
renderer.shadowMap.enabled = true;
// lights
const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.5);
directionalLight.position.set(0, 7, 5);
directionalLight.target = sphere;
directionalLight.target.updateMatrixWorld();
directionalLight.castShadow = true;
// shadows
// ! only three types of light that support shadows
// ! spotlight
// ! directional light
// ! point light
// ! castShadow means will it create a shadow? receiveShadow means will the shadow be on it?
sphere.castShadow = true;
plane.receiveShadow = true;
// Helpers
const AxesHelper = new THREE.AxesHelper(5);
scene.add(AxesHelper, camera, sphere, plane, directionalLight, ambientLight);
// Clock
const clock = new THREE.Clock();
let oldElapsedTime = 0;
// physics
const world = new CANNON.World();
world.gravity.set(0, -9.82, 0);
// Sphere
const sphereShape = new CANNON.Sphere(3);
const sphereBody = new CANNON.Body({
mass: 1,
position: new CANNON.Vec3(0, 5, 0),
shape: sphereShape,
});
world.addBody(sphereBody);
// infinite Plane
const planeShape = new CANNON.Plane();
const planeBody = new CANNON.Body({
mass: 0,
});
planeBody.addShape(planeShape);
planeBody.quaternion.setFromAxisAngle(new CANNON.Vec3(-1, 0, 0), Math.PI * 0.5);
world.addBody(planeBody);
function animate() {
requestAnimationFrame(animate);
let ElapsedTime = clock.getElapsedTime();
let deltaTime = ElapsedTime - oldElapsedTime;
oldElapsedTime = deltaTime;
// to update the world 60 times per second
world.step(1 / 60, deltaTime, 3);
directionalLight.position.z = 3 * Math.sin(ElapsedTime);
directionalLight.position.x = 3 * Math.cos(ElapsedTime);
directionalLight.lookAt(sphere.position);
sphere.position.copy(sphereBody.position);
plane.position.copy(planeBody.position);
// sphere.position.x = keyboard.pressed('right')
// ? sphere.position.x + 0.1
// : keyboard.pressed('left')
// ? sphere.position.x - 0.1
// : sphere.position.x;
// sphere.position.z = keyboard.pressed('up')
// ? sphere.position.z - 0.1
// : keyboard.pressed('down')
// ? sphere.position.z + 0.1
// : sphere.position.z;
controls.update();
renderer.render(scene, camera);
}
animate();
//events
window.addEventListener('resize', () => {
clientWidth = document.documentElement.clientWidth;
clientHeight = document.documentElement.clientHeight;
camera.aspect = clientWidth / clientHeight;
camera.updateProjectionMatrix();
renderer.setSize(clientWidth, clientHeight);
});
window.addEventListener('dblclick', () => {
if (!document.fullscreenElement) {
canvas.requestFullscreen();
} else {
document.exitFullscreen();
}
});

How to pan/scale the contents inside a GUI area?

I want to have a zoom effect inside an area in a EditorWindow, something like a zoomable scrollview.
The following snippet deals only with the panning effect but it exemplifies the issue I'm having when the contents inside the zoomable area and the clipping rect can't be handled independently of each other through hSliderValue1 (clipping) and hSliderValue2 (panning).
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class ZoomTestWindow : EditorWindow
{
private static float kEditorWindowTabHeight = 20;
private static Matrix4x4 _prevGuiMatrix;
public static float hSliderValue1 = 0;
public static float hSliderValue2 = 0;
Rect[] wr = new Rect[]{
new Rect(0, 0, 100, 100),
new Rect(50, 50, 100, 100),
new Rect(100, 100, 100, 100)
};
[MenuItem("Window/Zoom Test #%w")]
private static void Init()
{
ZoomTestWindow window = EditorWindow.GetWindow<ZoomTestWindow>("Zoom Test", true, new System.Type[] {
typeof(UnityEditor.SceneView),
typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow")});
window.Show();
EditorWindow.FocusWindowIfItsOpen<ZoomTestWindow>();
}
public static Rect BeginZoomArea()
{
GUI.EndGroup(); //End the group that Unity began so we're not bound by the EditorWindow
GUI.BeginGroup(new Rect(hSliderValue1, 0, 200, 200));
_prevGuiMatrix = GUI.matrix;
GUI.matrix = Matrix4x4.TRS(new Vector2(hSliderValue2, 0), Quaternion.identity, Vector3.one);;
return new Rect();
}
public static void EndZoomArea()
{
GUI.matrix = _prevGuiMatrix;
GUI.EndGroup();
GUI.BeginGroup(new Rect(0.0f, kEditorWindowTabHeight, Screen.width, Screen.height - (kEditorWindowTabHeight + 3)));
}
public void OnGUI()
{
BeginZoomArea();
BeginWindows();
wr[0] = GUI.Window(0, wr[0], DrawWindow, "hello");
wr[1] = GUI.Window(1, wr[1], DrawWindow, "world");
wr[2] = GUI.Window(2, wr[2], DrawWindow, "!");
EndWindows();
EndZoomArea();
hSliderValue1 = GUI.HorizontalSlider(new Rect(200, 5, 100, 30), hSliderValue1, 0, 100);
hSliderValue2 = GUI.HorizontalSlider(new Rect(200, 25, 100, 30), hSliderValue2, 0, 100);
}
void DrawWindow(int id)
{
GUI.Button(new Rect(0, 30, 100, 50), "Wee!");
GUI.DragWindow();
}
}
Is there a way to do this, maybe by using a scroll view?
Embed the group controlled by hSliderValue1 inside a new group.
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class ZoomMoveTestWindow: EditorWindow
{
private static float kEditorWindowTabHeight = 20;
private static Matrix4x4 _prevGuiMatrix;
public static float hSliderValue1 = 0;
public static float hSliderValue2 = 0;
Rect[] wr = new Rect[]{
new Rect(0, 0, 100, 100),
new Rect(50, 50, 100, 100),
new Rect(100, 100, 100, 100)
};
[MenuItem("Window/Zoom Test #%w")]
private static void Init()
{
ZoomMoveTestWindow window = EditorWindow.GetWindow<ZoomMoveTestWindow>("Zoom Test", true, new System.Type[] {
typeof(UnityEditor.SceneView),
typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow")});
window.Show();
EditorWindow.FocusWindowIfItsOpen<ZoomMoveTestWindow>();
}
public static Rect BeginZoomArea(Rect rect)
{
GUI.BeginGroup(rect);
GUI.BeginGroup(new Rect(hSliderValue1, 0, 200, 200));
_prevGuiMatrix = GUI.matrix;
GUI.matrix = Matrix4x4.TRS(new Vector2(hSliderValue2, 0), Quaternion.identity, Vector3.one);
return new Rect();
}
public static void EndZoomArea()
{
GUI.EndGroup();
GUI.matrix = _prevGuiMatrix;
GUI.EndGroup();
GUI.BeginGroup(new Rect(0.0f, kEditorWindowTabHeight, Screen.width, Screen.height - (kEditorWindowTabHeight + 3)));
}
public void OnGUI()
{
GUI.EndGroup(); //End the group that Unity began so we're not bound by the EditorWindow
BeginZoomArea(new Rect(10,10, 200, 200));
BeginWindows();
wr[0] = GUI.Window(0, wr[0], DrawWindow, "hello");
wr[1] = GUI.Window(1, wr[1], DrawWindow, "world");
wr[2] = GUI.Window(2, wr[2], DrawWindow, "!");
EndWindows();
EndZoomArea();
hSliderValue1 = GUI.HorizontalSlider(new Rect(250, 5, 100, 30), hSliderValue1, 0, 100);
hSliderValue2 = GUI.HorizontalSlider(new Rect(250, 35, 100, 30), hSliderValue2, 0, 100);
}
void DrawWindow(int id)
{
GUI.Button(new Rect(0, 30, 100, 50), "Wee!");
GUI.DragWindow();
}
}
It works but I don't know why. Because the interaction of GUI.matrix and BeginGroup(rect) is unknown.
PS: This post may help you.

How do I switch the components from a character motor to a character controller?

I am trying to code some underwater functionality for my Unity game, but I am having trouble switching the CharacterMotor components to the CharacterController ones. This is my code:
#pragma strict
var waterLevel : float;
var myParticles : ParticleSystem;
private var isUnderwater : boolean;
private var normalColor : Color;
private var underwaterColor : Color;
private var charcontroller:CharacterController;
function Start ()
{
normalColor = new Color (0.5f, 0.5f, 0.5f, 0.5f);
underwaterColor = new Color (0.22f, 0.65f, 0.77f, 0.5f);
charcontroller = GetComponent(CharacterController);
myParticles.Stop();
GameObject.Find("Blob Light Projector").GetComponent(Projector).enabled = false;
}
function Update ()
{
if ((transform.position.y < waterLevel) != isUnderwater)
{
isUnderwater = transform.position.y < waterLevel;
if (isUnderwater) SetUnderwater ();
if (!isUnderwater) SetNormal ();
}
if(isUnderwater && Input.GetKey(KeyCode.E))
{
constantForce.relativeForce = Vector3(0,-200, 0);
}
else
{
constantForce.relativeForce = Vector3(0, 0, 0);
}
if(isUnderwater && Input.GetKey(KeyCode.Q))
{
constantForce.relativeForce = Vector3(0, 200, 0);
}
}
function SetNormal ()
{
RenderSettings.fogColor = normalColor;
RenderSettings.fogDensity = 0.05f;
GameObject.Find("Blob Light Projector").GetComponent(Projector).enabled = false;
}
**function SetUnderwater ()
{
RenderSettings.fogColor = underwaterColor;
RenderSettings.fogDensity = 0.08f;
charcontroller.Move.gravity = 2;
charcontroller.Move.maxFallSpeed = 5;
charcontroller.Move.maxForwardSpeed = 4;
charcontroller.Move.maxSidewaysSpeed = 4;
myParticles.Play();
GameObject.Find("Blob Light Projector").GetComponent(Projector).enabled = true;
}**
The bolded code is where the error is coming from. Here is a snapshot of the errors I'm getting:
Any help would be really appreciated! Thanks!
You're trying to set properties on CharacterController.Move, which is a function. It doesn't reflect the "movement" property of CharacterMotor.
Check out the script reference and manual to see how to use CharacterController. Specifically, you'll be calling Move with a simple Vector3, and relying on the physics system to take care of the rest.

How to resize layout containers when the parent window resizes?

I am developing a music player application in Vala 0.14. The main toolbar of this application contains nested Box Layouts and all of them have the hexpand property set to true.
While packing the widgets/layouts I made sure that the expand and fill arguments were true, however the toolbar fails to resize when the size of parent window changes.
Here are the screenshots.
[NORMAL]
[RESIZE -- SIZE INCREASED]
[RESIZE -- SIZE DECREASED]
Is it enough to set the hexpand property to true or do I need to make some adjustments to the box layouts when the parent window's size_allocate signal is emitted ?
CODE:
using Gtk;
namespace Conjure.Widget
{
public class MainToolBar : Object
{
/* Declare reference variables */
private Toolbar tlbMain;
private ToolItem tiMain;
public Scale sclProgress;
private Label lblSongName;
private Label lblArtistName;
private Label lblAlbumName;
private Box hboxMain;
private Box vboxControls;
private Box hboxControls;
private Box hboxButtons;
private Box hboxMetaData;
private Box vboxMetaData;
private Box vboxPreferences;
private Box hboxPreferences;
private Image imgArt;
private Image icnPrevious;
public Image icnPlay;
public Image icnPause;
private Image icnNext;
private Image icnRepeat;
private Image icnVolume;
private Image icnPhone;
private Image icnSuperMenu;
private Image icnEqualizer;
public Button btnPrevious;
public Button btnTogglePlay;
public Button btnNext;
public Button btnVolume;
public Button btnSuperMenu;
public Button btnEqualizer;
private ToggleButton btnPhone;
private ToggleButton btnRepeat;
private Separator sep1;
private Separator sep2;
construct
{
/* Create the parent box */
hboxMain = new Box(Orientation.HORIZONTAL, 0);
hboxMain.hexpand = true;
hboxMain.homogeneous = true; //
/* Create boxes to hold meta data */
hboxMetaData = new Box(Orientation.HORIZONTAL, 5);
vboxMetaData = new Box(Orientation.VERTICAL, 0);
vboxMetaData.homogeneous = true;
hboxMetaData.hexpand = true;
vboxMetaData.hexpand = true;
/* Create boxes for control elements */
vboxControls = new Box(Orientation.VERTICAL, 0);
hboxControls = new Box(Orientation.HORIZONTAL, 0);
hboxButtons = new Box(Orientation.HORIZONTAL, 0);
vboxControls.homogeneous = true;
vboxControls.hexpand = true;
hboxButtons.homogeneous = false;
hboxButtons.hexpand = true;
hboxButtons.halign = Align.CENTER;
hboxControls.hexpand = true;
/* Create boxes for preference control */
vboxPreferences = new Box(Orientation.VERTICAL, 0);
hboxPreferences = new Box(Orientation.HORIZONTAL, 0);
vboxPreferences.hexpand = true;
hboxPreferences.hexpand = true;
/* Create and load image mockup */
imgArt = new Image();
//imgArt.set_from_file("/home/utsav/jmrfs.png");
imgArt.halign = Align.START;
/* Make labels for meta data */
lblSongName = new Label(null);
lblArtistName = new Label(null);
lblAlbumName = new Label(null);
lblSongName.set_markup_with_mnemonic("<b>Down</b>");
lblArtistName.set_markup_with_mnemonic("Jay Sean ft. Lil' Wayne");
lblAlbumName.set_markup_with_mnemonic("All or Nothing");
lblSongName.halign = Align.START;
lblArtistName.halign = Align.START;
lblAlbumName.halign = Align.START;
lblSongName.hexpand = true;
lblAlbumName.hexpand = true;
lblArtistName.hexpand = true;
/* Create audio progress bar */
sclProgress = new Scale(Gtk.Orientation.HORIZONTAL, new Adjustment(0.0, 0.0, 10.0, 0.1, 1.0, 1.0));
sclProgress.draw_value = false;
sclProgress.width_request = 300;
// Stylize control
/*StyleContext style_context = sclProgress.get_style_context();
CssProvider css_provider = new CssProvider();
try
{
css_provider.load_from_path(Conjure.Utility.path_to_assets () + "/css/style.css");
}
catch(Error e)
{
stderr.puts("Unable to load specified style sheet.");
}
style_context.add_provider(css_provider, STYLE_PROVIDER_PRIORITY_THEME);*/
/* Create toolbar buttons */
btnPrevious = new Button();
btnTogglePlay = new Button();
btnNext = new Button();
btnVolume = new Button();
btnSuperMenu = new Button();
btnEqualizer = new Button();
btnRepeat = new ToggleButton();
btnPhone = new ToggleButton();
btnPrevious.hexpand = false;
icnPrevious = new Image();
icnPause = new Image();
icnPlay = new Image();
icnNext = new Image();
icnPhone = new Image();
icnRepeat = new Image();
icnVolume = new Image();
icnSuperMenu = new Image();
icnEqualizer = new Image();
/*icnPrevious.set_from_file(Conjure.Utility.path_to_assets () + "/icons/media-skip-backward.png");
icnPlay.set_from_file(Conjure.Utility.path_to_assets () + "/icons/media-playback-start.png");
icnPause.set_from_file(Conjure.Utility.path_to_assets () + "/icons/media-playback-pause.png");
icnNext.set_from_file(Conjure.Utility.path_to_assets () + "/icons/media-skip-forward.png");
icnPhone.set_from_file(Conjure.Utility.path_to_assets () + "/icons/phone.png");
icnRepeat.set_from_file(Conjure.Utility.path_to_assets () + "/icons/media-playlist-repeat.png");
icnVolume.set_from_file(Conjure.Utility.path_to_assets () + "/icons/audio-volume-high.png");
icnSuperMenu.set_from_file(Conjure.Utility.path_to_assets () + "/icons/document-properties.png");
icnEqualizer.set_from_file(Conjure.Utility.path_to_assets () + "/icons/media-graphic-equalizer.png");
btnPrevious.image = icnPrevious;
btnNext.image = icnNext;
btnTogglePlay.image = icnPlay;
btnPhone.image = icnPhone;
btnRepeat.image = icnRepeat;
btnVolume.image = icnVolume;
btnSuperMenu.image = icnSuperMenu;
btnEqualizer.image = icnEqualizer;*/
sep1 = new Separator(Orientation.VERTICAL);
sep2 = new Separator(Orientation.VERTICAL);
/* Start packing widgets */
// Pack Meta Data Box
vboxMetaData.pack_start(lblSongName, true, true, 0);
vboxMetaData.pack_start(lblAlbumName, true, true, 0);
vboxMetaData.pack_start(lblArtistName, true, true, 0);
hboxMetaData.pack_start(imgArt, false, true, 0);
hboxMetaData.pack_start(vboxMetaData, true, true, 0);
// Pack controls box
vboxControls.pack_start(sclProgress, true, true, 0);
hboxButtons.pack_start(btnPrevious, false, false, 0);
hboxButtons.pack_start(btnTogglePlay, false, false, 0);
hboxButtons.pack_start(btnNext, false, false, 0);
hboxButtons.pack_start(sep1, false, false, 0);
hboxButtons.pack_start(btnRepeat, false, false, 0);
hboxButtons.pack_start(btnVolume, false, false, 0);
hboxButtons.pack_start(sep2, false, false, 0);
hboxButtons.pack_start(btnPhone, false, false, 0);
vboxControls.pack_start(hboxButtons, true, true, 0);
// Pack preference box
hboxPreferences.pack_end(btnSuperMenu, false, false, 0);
hboxPreferences.pack_end(btnEqualizer, false, false, 0);
vboxPreferences.pack_end(hboxPreferences, false, false, 0);
vboxPreferences.halign = Align.END;
// Pack main box
hboxMain.pack_start(hboxMetaData, true, true, 0);
hboxMain.pack_start(vboxControls, true, true, 0);
hboxMain.pack_start(vboxPreferences, true, true, 0);
/* Create ToolItem */
tiMain = new ToolItem();
tiMain.add(hboxMain);
tiMain.hexpand = true;
/* Create Toolbar */
tlbMain = new Toolbar();
tlbMain.add(tiMain);
tlbMain.hexpand = true;
tlbMain.vexpand = false;
}
public void resize_main_layout()
{
}
public Gtk.Widget toolbar
{
get
{
return tlbMain;
}
}
}
}
[Main Module]
using Gtk;
using Conjure.Widget;
namespace Conjure.App
{
public class MainWindow : Window
{
private Box vboxMain;
private Box hboxPlaylists;
private MainToolBar maintoolbar;
/*private Conjure.Library.MusicPlayer player;
private SyncThread t;
public Cancellable c;
private unowned Thread<void*> t_a;
// dummy variable
bool track_selected;*/
construct
{
this.title = "Conjure";
this.set_default_size(905, 600);
this.window_position = WindowPosition.CENTER;
//t = null;
//c = null;
//track_selected = true;
vboxMain = new Box(Orientation.VERTICAL, 0);
hboxPlaylists = new Box(Orientation.HORIZONTAL, 0);
maintoolbar = new MainToolBar();
//player = Conjure.Library.MusicPlayer.get();
vboxMain.homogeneous = false;
vboxMain.pack_start(maintoolbar.toolbar, false, true, 0);
//maintoolbar.btnTogglePlay.clicked.connect(toggle_play_clicked);
maintoolbar.sclProgress.set_state (Gtk.StateType.INSENSITIVE);
/*player.state_changed.connect(() =>
{
if(player.get_state() == Conjure.Library.States.READY)
{
track_selected = true;
update_metaphors ();
}
});*/
/*maintoolbar.sclProgress.change_value.connect((s, d) =>
{
stderr.printf("Moved\n");
player.toggle_play ();
player.seek_player((int64) d);
player.toggle_play ();
});
this.size_allocate.connect((allocation) =>
{
stderr.printf("Resized\n");
maintoolbar.resize_main_layout ();
vboxMain.resize_children ();
});*/
vboxMain.hexpand = true;
add(vboxMain);
}
/*void toggle_play_clicked(Gtk.Widget w)
{
w.set_sensitive (false);
if (new_track_selected () && player.get_state() != Conjure.Library.States.PLAYING)
{
stderr.puts("A\n");
kill_thread ();
player.set_track("/home/utsav/abc.mp3");
player.toggle_play ();
make_and_run_thread ();
}
else if (player.get_state() == Conjure.Library.States.PLAYING)
{
stderr.puts("B\n");
kill_thread ();
player.toggle_play ();
}
else if (!(new_track_selected ()) && player.get_state() == Conjure.Library.States.PAUSED)
{
stderr.puts("C\n");
player.toggle_play();
make_and_run_thread ();
}
update_metaphors ();
w.set_sensitive (true);
}*/
/*bool new_track_selected()
{
// method stub
bool p;
p = track_selected;
track_selected = false;
return p;
}*/
/*void kill_thread ()
{
try
{
if(c!=null)
{
c.cancel ();
t_a.join();
}
}
catch(ThreadError err)
{
stderr.printf ("Error: %s", err.message);
}
}
void make_and_run_thread()
{
try
{
c = new Cancellable();
t = new SyncThread(maintoolbar.sclProgress, player.audio_player (), c);
t_a = Thread.create<void*> (t.thread_func, true);
}
catch(ThreadError err)
{
stderr.printf ("Error: %s", err.message);
}
}*/
/*void update_metaphors()
{
if(player.get_state()== Conjure.Library.States.PLAYING)
{
maintoolbar.btnTogglePlay.image = maintoolbar.icnPause;
}
else
{
maintoolbar.btnTogglePlay.image = maintoolbar.icnPlay;
}
}*/
}
}
Without seeing the code it's hard to tell for sure, but my guess is that it does expand. Assuming you have a horizontal box with three children (one for each section) you probably want to set only the middle child to expand. Right now, that third child is also expanding and allocating whitespace.
My advice is to try to create your UI in Glade first. Even if you don't want to use Glade for the final product, it makes it easy to see what different configurations do and will make diagnosing issues like this much easier.