Code Monkey home page Code Monkey logo

twui's Introduction

TwUI 0.2.0

TwUI is a hardware accelerated UI framework for Mac, inspired by UIKit. It enables:

  • GPU accelerated rendering backed by CoreAnimation
  • Simple model/view/controller development familiar to iOS developers

It differs from UIKit in a few ways:

  • Simplified table view cells
  • Block-based layout and drawRect
  • A consistent coordinate system (bottom left origin)
  • Sub-pixel text rendering

Setup

To use the current development version, include all the files in your project and import TUIKit.h. Set your target to link to the ApplicationServices and QuartzCore frameworks. Be sure to add NS_BUILD_32_LIKE_64 to your preprocessor flags.

Usage

Your TUIView-based view hierarchy is hosted inside an TUINSView, which is the bridge between AppKit and TwUI. You may set a TUINSView as the content view of your window, if you'd like to build your whole UI with TwUI. Or you may opt to have a few smaller TUINSViews, using TwUI just where it makes sense and continue to use AppKit everywhere else.

Example Project

An included example project shows off the basic construction of a pure TwUI-based app. A TUINSView is added as the content view of the window, and some TUIView-based views are hosted in that. It includes a table view, and a tab bar (which is a good example of how you might build your own custom controls).

Status

TwUI should be considered an alpha project. It is current shipping in Twitter for Mac, in use 24/7 by many, many users and has proven itself very stable. The code still has a few Twitter-for-Mac-isms that should be refactored and cleaned up.

This project follows the SemVer standard. The API may change in backwards-incompatible ways before the 1.0 release.

The goal of TwUI is to build a high-quality UI framework designed specifically for the Mac. Much inspiration comes from UIKit, but diverging to try new things (i.e. block-based layout and drawRect), and to optimize for Mac-specific interactions is encouraged.

Known limitations

There are many places where TwUI could be improved:

  • Accessibility. It would be great to bridge the AppKit accessibility APIs to something simpler, again, inspired by UIKit.

  • Text editing. TUITextEditor is a simple text editor (built on TUITextRenderer). It provides basic editing support and handles a number of standard keybindings. Fleshing this out to be indistinguishable from NSTextView (read: spellchecking, autocorrect) would be useful. If the logic around this were self-contained it would even be great as a standalone project, useful for anyone looking to build a custom text editor for the Mac.

  • Reverse-hosting. Right now TUIViews may be hosted inside of an existing NSView hierarchy. It would be useful if the reverse were possible, adding NSViews inside of TUIViews. Doing so in a robust way so event routing, the responder chain, and CAAnimations all just work is a challenge.

Documentation

You can generate documentation with doxygen. Install it, and then run:

cd docs
doxygen

Documentation is a work in progress, but the API will be familiar if you have used UIKit. (TODO: appledoc looks very cool, moving to that might be nice).

TwUI has a mailing list, subscribe by sending an email to [email protected].

Copyright and License

Copyright 2011 Twitter, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

twui's People

Contributors

aroben avatar boidanny avatar brutella avatar caniszczyk avatar dannygreg avatar jboley avatar joshaber avatar jspahrsummers avatar jwilling avatar kylebrowning avatar lorenbrichter avatar ncuesta avatar patr1ck avatar sandofsky avatar thekarladam avatar zachwaugh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twui's Issues

TUITableView Multiple Selection

I've been using TUITableView, but i could not find an option to allow the selection of multiple cells (using Cmd/Shift+Mouse click).
Not sure if it's possible right now.

TUIControl tracking and events

I've patched up some more of the event handling that UIControl does into TUIControl... as I don't have a git fork for TwUI, I'm going to just post the update here:

- (void)mouseDown:(NSEvent *)event {
    if(!_controlFlags.disabled) {
        [super mouseDown:event];

        BOOL track = [self beginTrackingWithTouch:event withEvent:event];
        if(track && !_controlFlags.tracking) {
            [self _stateWillChange];
            _controlFlags.tracking = 1;
            [self _stateDidChange];
        } else if(!track && _controlFlags.tracking) {
            [self _stateWillChange];
            _controlFlags.tracking = 0;
            [self _stateDidChange];
        }

        if(_controlFlags.tracking) {            
            TUIControlEvents currentEvents = TUIControlEventTouchDown;
            if([event clickCount] < 2)
                currentEvents |= TUIControlEventTouchDownRepeat;

            [self sendActionsForControlEvents:currentEvents];
            [self setNeedsDisplay];
        }
    }
}

- (void)mouseDragged:(NSEvent *)event {
    if(!_controlFlags.disabled) {
        [super mouseDragged:event];

        if(_controlFlags.tracking) {
            BOOL track = [self continueTrackingWithTouch:event withEvent:event];
            if(track && !_controlFlags.tracking) {
                [self _stateWillChange];
                _controlFlags.tracking = 1;
                [self _stateDidChange];
            } else if(!track && _controlFlags.tracking) {
                [self _stateWillChange];
                _controlFlags.tracking = 0;
                [self _stateDidChange];
            }

            if(_controlFlags.tracking) {
                TUIControlEvents currentEvents = (([self eventInside:event])? 
                                                 TUIControlEventTouchDragInside : 
                                                 TUIControlEventTouchDragOutside);

                [self sendActionsForControlEvents:currentEvents];
                [self setNeedsDisplay];
            }
        }
    }
}

- (void)mouseUp:(NSEvent *)event {
    if(!_controlFlags.disabled) {
        [super mouseUp:event];

        if(_controlFlags.tracking) {
            [self endTrackingWithTouch:event withEvent:event];

            TUIControlEvents currentEvents = (([self eventInside:event])? 
                                             TUIControlEventTouchUpInside : 
                                             TUIControlEventTouchUpOutside);

            [self sendActionsForControlEvents:currentEvents];
            [self setNeedsDisplay];

            [self _stateWillChange];
            _controlFlags.tracking = 0;
            [self _stateDidChange];
        }
    }
}

// Support tracking cancelation.
- (void)willMoveToSuperview:(TUIView *)newSuperview {
    if(!_controlFlags.disabled && _controlFlags.tracking) {
        [self _stateWillChange];
        _controlFlags.tracking = 0;
        [self _stateDidChange];

        [self cancelTrackingWithEvent:nil];
        [self setNeedsDisplay];
    }
}

- (void)willMoveToWindow:(TUINSWindow *)newWindow {
    if(!_controlFlags.disabled && _controlFlags.tracking) {
        [self _stateWillChange];
        _controlFlags.tracking = 0;
        [self _stateDidChange];

        [self cancelTrackingWithEvent:nil];
        [self setNeedsDisplay];
    }
}

- (BOOL)beginTrackingWithTouch:(NSEvent *)touch withEvent:(NSEvent *)event {
    // Override.
    return YES;
}

- (BOOL)continueTrackingWithTouch:(NSEvent *)touch withEvent:(NSEvent *)event {
    // Override.
    return YES;
}

- (void)endTrackingWithTouch:(NSEvent *)touch withEvent:(NSEvent *)event {
    // Override.
}

- (void)cancelTrackingWithEvent:(NSEvent *)event {
    // Override.
}

TWUIColor – Components

I think in TWUIColor it'd be useful to have methods such as - redComponent, -blueComponent, -greenComponent, etc. And rename -alpha to -alphaComponent

Overriding drawRect & memory

Is there a reason that overriding drawRect with an empty implementation in an otherwise blank TUIView increases memory usage substantially? This is probably a total newb question and has to do with the way CALayer handles content but I am totally seeing a 40 meg difference in memory when I add a few hundred TUIViews to a scroll view that do and don't override drawRect, even with an empty implementation?

I might remove this question here in a little bit as as I do some further testing. Sorry to waste anybody's time but if somebody has a short answer that would be great.

How to force redraw of single cell in TUITableView

This is not an issue, but a question about how to use the tableview.

Is it possible to force the redraw/refresh of a single row of a table view? (or a tuiview inside the cell)

I haven't been able to achieve it. I tried setting setNeedsDisplay/Layout to the cell. I also tried setNeedsDisp/Layout to the tableview, but it seems that calls are ignored.

I only got it to display again the new value when i call reloadData or when i resize the table View (it seems it forces a layout/redraw of the table).

TUITableView cell dragging issue

During dragging a cell from one section to another, the section header, of the section I drag the cell to, occludes the top cell.

Section header occlusion

Several how to questions

Hello,

These are not really an issue but more How to questions:

  • I Would like to have the black tooltips we have with side bar buttons in the offical Twitter for Mac App. I've checked in TWui but didn't found anything for this. Is this something supported and if not how to get a similar result.
  • What is the best way to replace a view by another one with a fade effect?
  • What do you think about creating an How to section in the wiki?

Thanks for your help,

Regards,

Wrong arc in CGContextAddRoundRect

In TUI/UIKit/TUICGAdditions.m:

void CGContextAddRoundRect(CGContextRef context, CGRect rect, CGFloat radius)
...

CGContextAddArc(context, rect.origin.x + radius, rect.origin.y + rect.size.height - radius, radius, M_PI / 4, M_PI / 2, 1);

The line above should be changed into the following:

CGContextAddArc(context, rect.origin.x + radius, rect.origin.y + rect.size.height - radius, radius, M_PI , M_PI / 2, 1);

Apple Mach-O Linker (Ld) Warning when using Xcode 4.2 OS X 10.7.2

Ld /Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Products/Debug/Example.app/Contents/MacOS/Example normal x86_64
cd /Volumes/Data/stoneros/Desktop/twitter-twui-a302717/ExampleProject
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -L/Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Products/Debug -F/Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Products/Debug -filelist /Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Intermediates/Example.build/Debug/Example.build/Objects-normal/x86_64/Example.LinkFileList -mmacosx-version-min=10.6 -framework QuartzCore -framework ApplicationServices -framework Cocoa -o /Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Products/Debug/Example.app/Contents/MacOS/Example

ld: warning: instance method 'setDrawRect:' in category from /Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Intermediates/Example.build/Debug/Example.build/Objects-normal/x86_64/TUIView.o overrides method from class in /Volumes/Data/stoneros/Library/Developer/Xcode/DerivedData/Example-hafykyiiqnbqvifyltzchgxygaol/Build/Intermediates/Example.build/Debug/Example.build/Objects-normal/x86_64/TUIView.o

Should right mouse click on table view select the cell?

The right mouse click events are mostly used to show context menus based on underlying cell. Therefore I think the cell should also be selected when right clicking on the cell.

In the current implementation the cell is only selected when left clicking on the cell.

reloadData in TUITableView

after call reloadData in TUITableView, the view gona be blank and some time all cell a missing until you click them while scrolling...is there any way to fix this problem?

TUITextView and TUITextRenderer

I've been trying to get TUITextView to scroll properly like NSTextView, and I decided to start by switching TUITextRender to subclass TUIView... anyone want to point me on what I should do next? The entire architecture of TwUI is completely different than both UIKit and AppKit.

TUIScrollView animation

I am trying to create a resize toggle animation on this simple custom TUIScrollView class that I have built. It is called TUILayout and supports horizontal layout as well as vertical, animated insertions and removals and has a more declarative way of supplying data to it's cells that I prefer over delegation. It recycles views similar to TUITableView. Anyway if you want to follow along, it's just one class and is here.

https://github.com/mrjjwright/TUILayout.

In the example code, the user clicks the blue button in the lower left and all the rows shrink smoothly to a size where the user can reorder and delete some rows (right click on a row in the example to see this in action), etc... and then the user toggle the rows back out to their original size by clicking the blue button again.

While doing this resize in setObjectHeight:animated I first resize my model objects that represent the rows, recalculate and set the contentSize on the TUIScrollView, cycle in all the new views (say 10 more views will fit in the shrunk view so dequeueReusableView and addSubview gets called 10 times) and finally I animate the frames of all the views to their size and location in layoutSubviews.

The result is that the scrollview correctly shrinks to a size where the scrollbar no longer displays, the views that are on screen animate smoothly down to their reduced size, but the newly added subviews that can now fit in the visibleRect animate in much later as one block of subviews.

So all the newly added subviews lag behind the views that were on the screen and I can't figure out why the animation isn't all happening together. I have tried lots of different combos of things with no luck including CATransactions. I am wondering if it has to with how a CAScrollLayer works or if somebody can help me think through this. I won't leave this up for long if nobody is interesed as I know there is no core issue here with TUI.

The more general issue is how to smoothly handle resizing animations on scrollviews that recycles their views and I have looked at several other grids out there in iOS world and have got some inspiration but am looking for more.

Thanks!

John

How to make horizontal TUITableView?

When i add
self.tableView.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
the tableview just scroll left and right when i scroll up and down,how to fix this?
Please help?

TUIAttributtedString: CTParagraphStyle not kept

I am using a TUIAttributted string, and i found a problem. When i set the lineheight, the Alignment/linebreak properties i previously defined are ignored, and the text is drawn using the default properties.

I located the problem in these functions:

  • (void)setLineHeight:(CGFloat)f inRange:(NSRange)range
  • (void)setAlignment:(TUITextAlignment)alignment lineBreakMode:(TUILineBreakMode)lineBreakMode

In those methods, a new CTParagraphStyle object is created, but each method only sets the values for the values received, ignoring the values previously set.

The solution would be to recreate the CTParagrahStyleRef object with all the expected properties.
I could fix it, but my doubt is how to implement it .
The easiest way seemed to keep ivars for those values and recreate the CTParagraphStyle object, but currently, those methods belong to the NSMutableAttributedString (TUIAdditions) category, and categories cannot have ivars.

I can see other options:

  • Moving those methods to the TUIAttributtedString class, and adding ivars for those values.
  • Reading current CTParagrahStyleRef and changing only the modified values, but i think this solution is worse.
  • add a new method setAlignment:lineBreakMode:lineHeight , but this is not maintainable if more paragraph styles are added in the future.

any suggestion?

TUITableView cell queue fix

EDIT: The code I posted previously really did not fix anything. It was a placebo :[
The question that remains is that the -reloadData call ends up jumbling up all the cells and in my use-case, the table view becomes really unusable. What am I missing here/what is going wrong? What needs to be fixed?

Various rendering issues while using fast user switching on OSX 10.7 Lion

I am seeing several issues related to fast user switching and twui.

I have a mac book pro running lion. I am logged in as 'User A', I create 'User B' and ensure that 'fast user switching' is enabled. I am using the Example.app included in the source code in all scenarios.

App becomes unresponsive after switching to User B and then back to User A:
1.) As User A, launch Example.app, notice that everything is working fine (scrolling, clicks, etc)
2.) Fast user switch to User B
3.) Fast user switch back to User A
Expected:
Example.app continues to operate normally
Actual:
The app appears to no longer respond to clicks or scrolls. I believe that events are still being handled, its just that nothing is being rendered.

App goes "blank" after being restarted while "switched out":
1.) Login as User A
1.) Move Example.app to ~/Applications
2.) execute this command from the command line

sleep 10 ; ~/Applications/Example.app

3.) quickly switch to User B (before the 10 seconds elapses)
4.) as User B, wait for more than 10 seconds to allow the app to launch while switched out
5.) switch back to User B
Expected:
Example.app is running normall
Actual:
Example.app is running, but the screen is blank. Nothing is rendered, although events seem to be processed

How to create a link in TUIAttributedString?

I was wondering how to detect click on a hyperlinkTUIAttributedString created as below. The event mouseDown is not registering on the associated TUITextRenderer. Is there a better way to create links in TUITextRenderers?

Thanks!

John

  +(id)hyperlinkFromString:(NSString*)inString withURL:(NSURL*)aURL
  {
      TUIAttributedString* attrString = [TUIAttributedString stringWithString:inString];
      NSRange range = NSMakeRange(0, [attrString length]);

      [attrString beginEditing];
      [attrString addAttribute:NSLinkAttributeName value:[aURL absoluteString] range:range];

      // make the text appear in blue
      NSColor *blueColor = [TUIColor colorWithHexString:@"#3B5998"].nsColor;
      [attrString addAttribute:NSForegroundColorAttributeName value:blueColor range:range];

      [attrString endEditing];

      return attrString;
  }

TUITextRenderer Break modes with multiple lines

When lineBreakMode is set for the renderer, it seems to behave differently when the frame allows drawing multiple lines of the text.
For a frame that can contain multiple lines, if the text renderer properties are set like this:

[textRedender setAlignment:TUITextAlignmentLeft lineBreakMode:TUILineBreakModeWordWrap];

Multiple lines are drawn, the last line is wrapped to the last word, and the ellipsis is not drawn as expected.

But it i change the properties to this:

[textRedender setAlignment:TUITextAlignmentLeft lineBreakMode:TUILineBreakModeWordWrap | TUILineBreakModeTailTruncation];

then the ellipsis is shown at the end, but only the first line is drawn. The rest of the lines are not drawn by the renderer.

EDIT: Added screenshot

screenshot

The upper part has been drawn without TUILineBreakModeTailTruncation. It shows both lines. The lower part was drawn with that option added, and in this case, the second line is not drawn. The frame size is the same in both cases.

TUITextView not respond to Input methods.

I'm building a app totally based on TwUI, But I found that TUITextView doesn't respond to Input methods (such like Chinese Pinyin).When I type in it, the Input method's word select window doesn't show. there has a same problem in the Twitter for Mac's search field (new tweet window works fine.)

I'v tried using a TUIViewNSViewContainer to add a NSTextView in a TUIView. but app receive a EXC BAD ACCESS when I add the nsview container view, here is the code :

TUIView * root = [[TUIView alloc] init];
    root.backgroundColor = [TUIColor colorWithWhite:0.9 alpha:1.0];
    tuiContainer.rootView = root;
    NSTextView * textView = [[NSTextView alloc] initWithFrame:root.bounds];
    TUIViewNSViewContainer * nsViewCon = [[TUIViewNSViewContainer alloc] initWithNSView:textView];
    [root addSubview:nsViewCon];

Does there have any solution to handle input method using Twui? Thanks~

No horizontal bounce scroll or option to disable bounce scroll

I discovered a few little problems with TUIScrollView during my brief testing. First of all, when you are scrolling horizontally, it continues to use bounce scroll in the vertical direction while you scroll (so if your scrolling direction isn't perfectly horizontal, it will bounce upwards a bit and disrupt inertial scrolling). This also means that there is no bounce scroll in the horizontal direction. As mentioned in the title, I think it would be useful to have an option to disable bounce scroll as well.

TUIView Animation Problem

I'm writing a navigation controller based on twui,

and I'm trying to make a animation like iOS when the navigation controller push new view.

In the pushViewController: method, follow things will be done:
1.insert new view to index 0;
2.set new view's start frame;
3.animate old view and new view to destination frame.

here is a sample project:
https://github.com/Naituw/TUIViewAnimationDemo

when I click push button, old view's animation works fine,
but , the new view doesn't make any animation, it just jump to the destination frame.

Did I missed anything?

Pulling in not working for scrollViewDidEndDragging

In TUIScrollView ~line 950,


if(_pull.xPulling) {
    _pull.xPulling = NO;
...
 }
        
if(_pull.yPulling) {
    _pull.yPulling = NO;
...
}
        
if(self.isPulling && _scrollViewFlags.didChangeContentInset){
...
}

self.isPulling is always false. Create a temporary variable to remember the state of isPulling can solve this problem.

Steven

TUITableView resizing issue

There seems to be a problem when resizing a window with a containing TUITableView.

I couldn't find the corresponding code, which produces the error - maybe someone else finds it ;)

TUITableView from Example project

TUIButton does not render properly?

I'm trying to use TUIButton without external graphics, so I'm using setDrawRect: and calling the TUIButton's drawRect from within that, but I notice that the label is horribly placed, and the states aren't defined well. Is there a way to set custom Core Graphics "drawRects" for TUIButtons on different states? And how should I go about fixing the position of the label? I've looked through TUIButton's implementation, but I don't see how it draws incorrectly.

EXC_BAD_ACCESS in demo App using keyboard

I am getting a crash in the demo app when the keyboard is used to navigate the tableview.

These are the steps to reproduce it:

  1. In the test app, Scroll down to the last row of the table (using mouse or keyboard)
  2. Click on any row to select it.
  3. Keep pressing up & down keys to change the selected row. Eventually, an EXC_BAD_ACCESS in cellForRowAtIndexPath of TUITableview.m. The section number in the indexPath parameter seem to have an abnormally high value. section=10376293541730151571 , but the row number seems OK.

EDIT: After some more tests, it seems that in step 1 it's not needed to go to the end of the table.
just clicking a row in a section different to the first one, can cause the crash.

EDIT2: It seems that the problem happens only with current version in github. If i rollback to the previous version (without this commit ) it works fine.
It seems the problem is in the function - (void)selectRowAtIndexPath:(TUIFastIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(TUITableViewScrollPosition)scrollPosition , and with the "oldIndexPath".
If i revert that function to the code before the commit, they keyboard works fine and it does not crash.

Inconsistent UITableViewCell state

I have been in the process of adding multiple selection support to the TUITableView and friends classes, and it seems that the cells do not maintain a consisten state, as far as selection is concerned. Setting the boolean ivar selected in UITableViewCell does not stay consistent throughout the drawing process, ie. in drawRect:. I had to test in drawRect: whether or not the indexPath was in the UITableView's list of selected index paths, an ugly hack.

The code is forked on my account; there may be a more elegant way for you to see it but I'm not familiar enough with git or GitHub to know how to do it.

Dragging a selected cell

Hey, thanks for developing twui. I recently found a issue about the selected cell problem.

How to reproduce:
Select a cell and drag it into another row. After release the mouse, the cell with the old indexpath is selected.

I have to add the following code inside TUITableView+Cell.m to reset the _selectedCellIndexPath.


    if ([[self indexPathForCell:cell] isEqual:_selectedIndexPath]) {
      [_selectedIndexPath release];
      _selectedIndexPath = [targetIndexPath retain];
    }

Did I do something wrong? Maybe I don't have to do this hack?

Needed: TUINavigationController

I need a UINavigationController like component for my app and was wondering if anybody has already built one they would like to share. If not I plan to take some inspiration from Chameleon and build one myself.

Thanks!

TUITextRenderer color problem

Drawing a TUIAttributedString with a TUITextRenderer and setting the line break mode to TUILineBreakModeTailTruncation, I get the '...' string at the end. But changing the font color to white, doesn't include the '...' string.

Take a look: Rendered string

Automatic OS detection and screen scale factors.

Wouldn't it be far better to do something like:

TUIKit.h:

// Test for Lion support.
extern BOOL isAtleastLion(void);

// Set and get global screen scale factor.
extern float screenScale(void);
extern void setScreenScale(float);

TUIKit.m:

static BOOL initialized = NO;
static float screen_scale = 0.0;
static BOOL is_lion = NO;

BOOL isAtleastLion() {
if(!initialized) {
SInt32 major = 0;
SInt32 minor = 0;
Gestalt(gestaltSystemVersionMajor, &major);
Gestalt(gestaltSystemVersionMinor, &minor);
if((major == 10 && minor >= 7) || major >= 11) {
is_lion = YES;
} else is_lion = NO;

    initialized = YES;
} return is_lion;

}

float screenScale() {
if(screen_scale <= CGFLOAT_MIN)
screen_scale = [[NSScreen mainScreen] userSpaceScaleFactor];

return screen_scale;

}

void setScreenScale(float scale) {
if((scale > CGFLOAT_MIN)) {
screen_scale = scale;
}
}

To abstract the screen scaling and OS detection away from the end developer?
What I did was move all TUIGraphics* functions into a new .h/.m TUIGraphics.m, and add those functions into TUIKit.h/.m. Then I proceeded to remove #import "TUIKit.h"'s and replaced them with #import "TUIGraphics.h" to make more sense.

MouseExited called when mouse enter subview

Every time I move cursor into a TUITableViewCell's subview, TUIView will call cell's mouseExited. but cursor is still in cell. Is there any way to know when cursor exited the cell to another cell. Thanks!

TUITextView needs single-line capability

I see preliminary support in place for a single-line text view, but it still needs to be implemented to scroll to the right when additional text is entered, as well as to the left when selecting, arrowing, or deleting.

TUINSView Drawing Problems

hi,guys ,I'm trying to make a TUINSView's rootview transparent , but when I do that it look like I have drawing problem when set TUINSView->rootView's background as a [TUIColor clearColor].
It's look like This
Did I doing Something wrong with this?

Default backgroundColor for TUIImageView

I drew an icon on CGBitmapContextCreate with CoreGraphics and assigned it to a TUIImageView. That icon was designed to be clipped as RoundRect, but what I got was a round-rect-ed icon with black corners.

After a few tries, it would not work until the backgroundColor of TUIImageView was set to clear color.

It seems that the default backgroundColor was nil for both TUIImageView and TUIView(, correct me if I am wrong). Is this an issue?

TUITableView as rootView

If you set a TUITableView as rootView, events are not caught properly, no scroll, no clicks...

Set a TUIView as rootView and TUITableView as a subview of the TUIView fix this issue.

Removing, re-adding TUI hierarchy causes it to display nothing

Removing a view hierarchy containing TUI content from a window and then subsequently re-adding the same view hierarchy (e.g., to toggle between two different top-level views or something) causes the TUI content to display nothing. It's actually there and still seems to get key events just fine, though.

Specifically, I've got:

  • NSWindow
    • NSView
      • NSView (this one is switched out)
        • TUINSView
          • TUIView...

Switching out the view noted above with another view, and then switching back by re-adding it causes the problem.

I've been poking around a bit, but I have no idea why this would happen.

Paged TUIScrollView

I want to implement a paged TUIScrollView photo viewer for flipping through photos iOS Photo app style. I have some example code from different iOS libs but was wanting input or making sure nobody else has done the same here.

Thanks!

TUIButton in tableview header. Popup Menu not showing

I am using a a TUITableView, with one header and several cells.
The header view has a TuiButton with a menu. First time the table view is loaded, the button displays the menu.

But i found a problem whenever i reload the data. If i reload the data, the button won't display the menu any more.
Debugging, i can see that the mousedown is catched, and that the call to the popUpMenuPositioningItem function is done.
But no menu is shown.
If just after that i resize the window, even a little bit, and then i click again in the button, the menu shows just fine.

I've done another test displaying a popup menu when mousedown is detected in the header view of the table, and the same happens. I need to resize the window after "reloadData" in order to be able to show the popup menu.

text-renderer select issue

(My english is poor , but I'm trying hard to explain this. : ) )
I have a textRenderer in a TUITableViewCell , but it is abnormal when I use mouse drag to select text in it.

The background didn't change when I dragging.

I found TUITableViewCell has override selfs' mouseDragged: method for cell reordering function.

so I add [super mouseDragged:event]; in this method.
method seems like below now.

-(void)mouseDragged:(NSEvent *)event {
  // notify our table view of the event
    [super mouseDragged:event];
  [self.tableView __mouseDraggedCell:self offset:_mouseOffset event:event];
}

Is that correct ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.