Page 1 of 1

Circle Button ?

Posted: Wed Aug 20, 2008 09:32
by traibuidoi
Everything in CEGUI base on rectangle

But I want to create a circle button in my game . How could i do that ?

Maybe should i change button skin to a circle ?

But it isn't real circle because user can click the outside of circle but inside the button's rectangle and my button will response :(

To create un-rectangle shape like circle,heart ,ect .. what should i do ?

Another question : i want to make a scrollpane without srollbar . I found scrollcontainer class but when i looked in Falagard_System_base_widgets :http://www.cegui.org.uk/wiki/index.php/Falagard_System_base_widgets_reference . It isn't here !!!! :(
What should i do ?

Posted: Wed Aug 20, 2008 11:09
by scriptkid
Hi,

it is not possible to create non-rectangular windows, sorry...

About your scrollable pane withouth scrollbars (if you're still interested ;))

You can query the scrollbars and hide them, for example:

Code: Select all

scrollablePane->getVertScrollbar()->setVisible(false);
scrollablePane->getHorzScrollbar()->setVisible(false);


HTH.

Posted: Thu Aug 21, 2008 02:58
by traibuidoi
scriptkid wrote:Hi,

it is not possible to create non-rectangular windows, sorry...

About your scrollable pane withouth scrollbars (if you're still interested ;))

You can query the scrollbars and hide them, for example:

Code: Select all

scrollablePane->getVertScrollbar()->setVisible(false);
scrollablePane->getHorzScrollbar()->setVisible(false);


HTH.


thank you for your reply . I hope you'll add this features in recent days . Game with rectangled-GUI seem boring , do you think so ? :?

And the scrollpane problem : since i don't use the scrollbar , how can i move the viewport by code ? I've looked the API Scrollpane references , but there's nothing function like setViewport . it has only getViewableArea

Should i inherited your class and make my setViewableArea function ?

Posted: Mon Aug 25, 2008 13:46
by daves
There are no circular buttons so to speak. But I do think that it may be possible to emulate a circular button. This does involve creating a button wrapper class that is able to detect a button press and then to return "true" (handled), or "false" not handled depending on whether the user clicks in the circular region or the boundary region (outside of the circle). Along with this making only the circular region visible is quite simple. The idea would be for this wrapper button to let mouse events pass to the parent widget heirarchy if it detects that the mouse event is outside the circle.

Havent tried this, and I think that the only thing that may stand in the way of this working is the "mouse handling logic" as a function of window heirarchy. I know there have been several posts on the fact that CE is looking to do a rewrite on this logic.

The following cegui mouse event handler shows you the basic mechanism for determing where within the rectangular window the mouse event occurs. Once you know this, a little bit of geometry can be applied to determine if this is within the "circle of interest":

Code: Select all

bool ColorChooser::handleCustomColorImageSelection(const CEGUI::EventArgs& e)
   {
      const CEGUI::MouseEventArgs& mouseEventArgs = static_cast<const CEGUI::MouseEventArgs&>(e);
      if(!mSelectingColor)
      {
         return true;
      }
      CEGUI::Window *window = mouseEventArgs.window;
      CEGUI::Point mousePos = mouseEventArgs.position;

      CEGUI::Point mouseWndPos = CEGUI::CoordConverter::screenToWindow(*window, mousePos);

      float xScale = sEnhancedImageSize.d_width/window->getWidth().asAbsolute(window->getParentPixelWidth());
      float yScale = sEnhancedImageSize.d_height/window->getHeight().asAbsolute(window->getParentPixelHeight());
      CEGUI::Vector2 scale(xScale, yScale);
      mouseWndPos *= scale;
   
      setEditableColor(getEnhancedImageColorAtPixel(mouseWndPos));

      return true;

   }


I use this handler in a "color picker" window that allows me to pick a specific pixel within a displayed image.