Generally when you want something to flash on and off in a smooth fashion you have a duration that you want an icon to fade in and out at. You then tend to have a timer that increments up to the fade value and when it hits the fade value begins to decrement again down to zero. See the code below for an example of this in action
static const f32 totalFadeTime = 4.0
if (m_fadeUp)
{
timer += delta;
if (m_timer > m_revealTime)
{
timer = m_revealTime;
m_fadeUp = false;
}
}
else
{
timer -= delta;
if (timer < 0.0f)
{
timer = 0.0f;
m_fadeUp = true;
}
}
const f32 alpha = timer / totalFadeTime;
icon->SetAlpha(alpha);
The approach above uses linear interpolation so the fade looks quite even and bland. To get a nicer smooth fade you can use sin or cos alongside the linear value to give you a smoother looking effect. This is because of the curve of cos is not linear cos curve. Add the following lines to achieve this effect:
const f32 alpha = timer / totalFadeTime;
const f32 newAlpha = (cosf(TwoPi * alpha) - 1.0f) * -0.5f;
icon->SetAlpha(alpha);
Unfortunately I don’t have an example of this on hand to show but I does the trick nicely.
testing FB and twitter posts
It’s been quiet around here lately. I’m going to try to make an effort to blog here a bit more, it will mostly be about my SingStar coding experiences!
So you’ve somehow managed to get lumped with the abomination that is Lotus Notes. It is a hideous user experience but I have a few tips that may make life easier and make it work somewhat.
Tips:
- Ctrl+M creates a new memo (i.e. mail).
- Finding people in your address book is slow, instead type their first name and the first initial of their second and press comma ‘,’. This will either autofill the username or bring up a dialog of users to select the correct user.
- To attach a document, click into the body of the email and go to File->Attach (obviously). There is no attach button that I can aware of.
- F5 does NOT refresh your mail. In fact it logs you out of Lotus Notes and you must go in again. I can’t find an easy way to change keyboard shortcuts so you’re stuck with these sucky ones.
- You do not get any alarms for meetings by default. Whenever I get a meeting I accept the meeting first. Then I go into my calendar on the left hand side and find the meeting. Double click into the meeting and click on the ‘Edit Document’ button on the top left. Next click the ‘Notify Me’ checkbox and a dialog will appear. I generally send an email as well as receiving the alarm, so click on the ‘Send mail notification with subject’ checkbox and enter your own name. REMEMBER to click ‘Save and Close’ when done otherwise your changes will be lost. To permanently enable a message box to be displayed for meeting then click on the tools icon on the left hand side of the client and then on Email preferences. In the dialog that appears click on calendar and Todo tab and then on the Alarms tab. Click on whichever type of meeting, reminder etc. that you want a reminder for an hit Ok. You should now receive a message box reminding you of meetings in advance, hurrah!
- This is a bit of a personal preference but I know a lot of people use it, spell checking on sending of mails. In the left hand column click on the Tool’s icon and then on Email Preferences. Click on the ‘Automatically check mail messages for misspellings before sending’. The option is about half way down the dialog.
Functionality
- Go to View->Document Preview and click Show Preview. This turns on the mail preview, I think this is a must for any mail application, to be able to view a mail without having to double click into it every time.
- As a consequence of having a preview, I have seem many people with three or four thousand mails unread as clicking on a mail and viewing it in the preview doesn’t mark an email as read by default. This irritates me but thankfully there is a way of getting around this. Go to File->User Preferences and in the ‘Additional Options’ pane click on the first option, ‘Mark documents read when opened in preview pane’.
- Any url in Lotus Notes will open up in the in-client browser by default. This is terrible and may sites don’t work at all in it. You can change the default browser that is used by: Go to File->Preferences->Location Preferences. Click on the internet browser tab and click on the drop down shaped button to the right of the ‘Notes’ browser name. You should now be able to select the browser you want, I set mine to Firefox by default. If your browser isn’t present you can add it by clicking the weird looking torch button and navigating to its location.
Thats all I can think of for the moment. This application drives me insane but hopefully these tips may help someone.
I encountered a rather unintuitive compiler warning yesterday that I’d thought I’d share. See the simple templated class below:
template
class ATemplateClass
{
public:
ATemplateClass()
{
}
virtual ~ATemplateClass()
{
}
void Add()
{
++size;
}
void Reset()
{
size = 0;
}
private:
int size;
};
(for some reason my code output tags are doing strange things to liek putting in a and messing up the template tag, grrr!
Obviously this isn’t what my class is doing but is illustrative of the problem. When attempting to use this class on the stack like so:
MeanAverage myTemplate = MeanAverage();
I got the compiler warning:
warning: ‘myTemplate ‘ is used uninitialized in this function
After some head scratching (it is clearly being initialised!) one of my colleagues suggested the reason why I was getting the warning. The ‘size’ member of ATemplateClass wasn’t being initialised in the constructor which seems to have the knock on effect of causing the entire template to appear to not be initialised to the compiler! It may be a particularly strict but it fixes the warning nonetheless, hurrah!
Hi there,
I recently upgraded to Snow Leopard and was shocked to see that Apple have not kept up support for DVI to S-Video output. The output on screen appears in greyscale and poor quality. Even with restarting I had the same problem. The latest patch for Snow Leopard doesn’t seem to have anything to fix this problem so I was left with no alternative but to revert back to Leopard or lose my TV in my room, no thanks. Also upon upgrading I lost some widgets I used such as MenuMeters and my replacement for the time stopped working also.
Luckily I had a backup with Time Machine from a few days ago which could be restored!
Beware of Snow Leopard!
EDIT: I’ve just upgraded again and these issues appear to be fixed, damn right!
I got this the other day when I was attempting to search for some text. Nothing had visibly changed that I could see and for some reason the search was always returning ‘No files were found to look in’ regardless of the search options I entered (i.e. types to search, looking in entire solution, project etc).
I cannot explain this but focus on Visual Studio and press Ctrl + Scroll Lock fixes it. Yes it is mad and doesn’t make sense.
Credit goes to: here
Quick post that might help someone.
I had an XML file that I had changed in Dashcode and for some reason the older XML content was being read into my app. I ‘re-touched’ it in XCode and even though the right XML showed up within the project the wrong XML was being loaded up in the simulator.
A little perplexed by this I checked what file was being loaded by stepping through code and saw that the XML was being loaded up from a path that looked something like “/Users//Library/Application Support/iPhone Simulator/User/Applications/xxx”. This location obviously contained the old version of the XML file and not the new one I had in XCode. To solve this problem I cleaned the project and performed a full re-build and low-and-behold the correct XML was loaded. I suspect cleaning the project deletes the app and all associated data from the simulator cache.
I found myself in the position that I had a string that came in from XML and wanted to create an appropriate class from this string. After some searching I found the neat little function NSClassFromString. So given a string I could allocate a class by doing
id newClass = [[NSClassFromString(string) alloc] init];
I also needed to go back the other way, get the name of the class as a string. Again there is a similar function definition
NSString* name = NSStringFromClass([self class]);
This above shows how to get the class from self using [self class].
I’ve needed to figure out if a certain function exists for a class before instantiating a new class. However the init function takes two parameters and all code samples I’ve seen use selectors with just a single parameter. Below is the code that checks if a selector with two parameters is present.
if([NSClassFromString(classType) instancesRespondToSelector: @selector(initWithTwoParameters: withSecondParameter:)])
{
}