diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Toolbar.cc | 125 |
1 files changed, 76 insertions, 49 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 7e0cf2b..fa4a29a 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Toolbar.cc,v 1.106 2003/08/11 20:19:16 fluxgen Exp $ | 25 | // $Id: Toolbar.cc,v 1.107 2003/08/13 09:50:45 fluxgen Exp $ |
26 | 26 | ||
27 | #include "Toolbar.hh" | 27 | #include "Toolbar.hh" |
28 | 28 | ||
@@ -266,22 +266,30 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, FbTk::Menu &menu, size_t wi | |||
266 | m_item_list.push_back(new IconbarTool(frame.window, m_iconbar_theme, screen())); | 266 | m_item_list.push_back(new IconbarTool(frame.window, m_iconbar_theme, screen())); |
267 | m_item_list.push_back(new ClockTool(frame.window, m_clock_theme, screen())); | 267 | m_item_list.push_back(new ClockTool(frame.window, m_clock_theme, screen())); |
268 | 268 | ||
269 | m_theme.font().setAntialias(screen().antialias()); | 269 | m_clock_theme.setAntialias(screen().antialias()); |
270 | 270 | m_iconbar_theme.setAntialias(screen().antialias()); | |
271 | m_workspace_theme.setAntialias(screen().antialias()); | ||
272 | // signal a change | ||
273 | m_clock_theme.reconfigSig().notify(); | ||
274 | m_workspace_theme.reconfigSig().notify(); | ||
275 | m_iconbar_theme.reconfigSig().notify(); | ||
276 | |||
271 | // setup hide timer | 277 | // setup hide timer |
272 | m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); | 278 | m_hide_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); |
273 | FbTk::RefCount<FbTk::Command> toggle_hidden(new FbTk::SimpleCommand<Toolbar>(*this, &Toolbar::toggleHidden)); | 279 | FbTk::RefCount<FbTk::Command> toggle_hidden(new FbTk::SimpleCommand<Toolbar>(*this, &Toolbar::toggleHidden)); |
274 | m_hide_timer.setCommand(toggle_hidden); | 280 | m_hide_timer.setCommand(toggle_hidden); |
275 | m_hide_timer.fireOnce(true); | 281 | m_hide_timer.fireOnce(true); |
276 | 282 | ||
277 | // get everything together | ||
278 | reconfigure(); | ||
279 | 283 | ||
280 | // show all windows | 284 | // show all windows |
281 | frame.window.showSubwindows(); | 285 | frame.window.showSubwindows(); |
282 | frame.window.show(); | 286 | frame.window.show(); |
283 | 287 | ||
284 | scrn.resourceManager().unlock(); | 288 | scrn.resourceManager().unlock(); |
289 | |||
290 | // get everything together | ||
291 | reconfigure(); | ||
292 | |||
285 | } | 293 | } |
286 | 294 | ||
287 | Toolbar::~Toolbar() { | 295 | Toolbar::~Toolbar() { |
@@ -359,7 +367,9 @@ void Toolbar::lower() { | |||
359 | 367 | ||
360 | void Toolbar::reconfigure() { | 368 | void Toolbar::reconfigure() { |
361 | 369 | ||
362 | theme().font().setAntialias(screen().antialias()); | 370 | m_clock_theme.setAntialias(screen().antialias()); |
371 | m_iconbar_theme.setAntialias(screen().antialias()); | ||
372 | m_workspace_theme.setAntialias(screen().antialias()); | ||
363 | 373 | ||
364 | if (doAutoHide()) | 374 | if (doAutoHide()) |
365 | m_hide_timer.start(); | 375 | m_hide_timer.start(); |
@@ -376,10 +386,10 @@ void Toolbar::reconfigure() { | |||
376 | // recallibrate size | 386 | // recallibrate size |
377 | setPlacement(placement()); | 387 | setPlacement(placement()); |
378 | 388 | ||
379 | if (isHidden()) | 389 | if (isHidden()) { |
380 | frame.window.moveResize(frame.x_hidden, frame.y_hidden, | 390 | frame.window.moveResize(frame.x_hidden, frame.y_hidden, |
381 | frame.width, frame.height); | 391 | frame.width, frame.height); |
382 | else { | 392 | } else { |
383 | frame.window.moveResize(frame.x, frame.y, | 393 | frame.window.moveResize(frame.x, frame.y, |
384 | frame.width, frame.height); | 394 | frame.width, frame.height); |
385 | } | 395 | } |
@@ -394,40 +404,7 @@ void Toolbar::reconfigure() { | |||
394 | m_shape->update(); | 404 | m_shape->update(); |
395 | 405 | ||
396 | 406 | ||
397 | // calculate size for fixed items | 407 | rearrangeItems(); |
398 | ItemList::iterator item_it = m_item_list.begin(); | ||
399 | ItemList::iterator item_it_end = m_item_list.end(); | ||
400 | int fixed_width = 0; // combined size of all fixed items | ||
401 | int fixed_items = 0; // number of fixed items | ||
402 | for (; item_it != item_it_end; ++item_it) { | ||
403 | if ((*item_it)->type() == ToolbarItem::FIXED) { | ||
404 | fixed_width += (*item_it)->width(); | ||
405 | fixed_items++; | ||
406 | } | ||
407 | } | ||
408 | // calculate what's going to be left over to the relative sized items | ||
409 | int relative_width = 0; | ||
410 | if (fixed_items == 0) // no fixed items, then the rest is the entire width | ||
411 | relative_width = width(); | ||
412 | else { | ||
413 | const int relative_items = m_item_list.size() - fixed_items; | ||
414 | if (relative_items == 0) | ||
415 | relative_width = 0; | ||
416 | else // size left after fixed items / number of relative items | ||
417 | relative_width = (width() - fixed_width)/relative_items; | ||
418 | } | ||
419 | |||
420 | // now move and resize the items | ||
421 | int next_x = 0; | ||
422 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { | ||
423 | if ((*item_it)->type() == ToolbarItem::RELATIVE) { | ||
424 | (*item_it)->moveResize(next_x, 0, relative_width, height()); | ||
425 | } else { // fixed size | ||
426 | (*item_it)->moveResize(next_x, 0, | ||
427 | (*item_it)->width(), height()); | ||
428 | } | ||
429 | next_x += (*item_it)->width(); | ||
430 | } | ||
431 | 408 | ||
432 | m_toolbarmenu.reconfigure(); | 409 | m_toolbarmenu.reconfigure(); |
433 | // we're done with all resizing and stuff now we can request a new | 410 | // we're done with all resizing and stuff now we can request a new |
@@ -541,7 +518,22 @@ void Toolbar::setPlacement(Toolbar::Placement where) { | |||
541 | 518 | ||
542 | 519 | ||
543 | frame.width = head_w * (*m_rc_width_percent) / 100; | 520 | frame.width = head_w * (*m_rc_width_percent) / 100; |
544 | frame.height = m_theme.font().height(); | 521 | //!! TODO: change this |
522 | // max height of each toolbar items font... | ||
523 | unsigned int max_height = 0; | ||
524 | if (max_height < m_clock_theme.font().height()) | ||
525 | max_height = m_clock_theme.font().height(); | ||
526 | |||
527 | if (max_height < m_workspace_theme.font().height()) | ||
528 | max_height = m_workspace_theme.font().height(); | ||
529 | |||
530 | if (max_height < m_iconbar_theme.focusedText().font().height()) | ||
531 | max_height = m_iconbar_theme.focusedText().font().height(); | ||
532 | |||
533 | if (max_height < m_iconbar_theme.unfocusedText().font().height()) | ||
534 | max_height = m_iconbar_theme.unfocusedText().font().height(); | ||
535 | |||
536 | frame.height = max_height; | ||
545 | 537 | ||
546 | frame.height += 2; | 538 | frame.height += 2; |
547 | frame.height += (frame.bevel_w * 2); | 539 | frame.height += (frame.bevel_w * 2); |
@@ -553,13 +545,9 @@ void Toolbar::setPlacement(Toolbar::Placement where) { | |||
553 | if (isVertical()) { | 545 | if (isVertical()) { |
554 | frame.width = frame.height; | 546 | frame.width = frame.height; |
555 | frame.height = head_h * (*m_rc_width_percent) / 100; | 547 | frame.height = head_h * (*m_rc_width_percent) / 100; |
556 | if (!m_theme.font().isRotated()) | ||
557 | m_theme.font().rotate(90); // rotate to vertical text | ||
558 | 548 | ||
559 | } else { // horizontal toolbar | 549 | } // else horizontal toolbar |
560 | if (m_theme.font().isRotated()) | 550 | |
561 | m_theme.font().rotate(0); // rotate to horizontal text | ||
562 | } | ||
563 | 551 | ||
564 | // So we get at least one pixel visible in hidden mode | 552 | // So we get at least one pixel visible in hidden mode |
565 | if (bevel_width <= border_width) | 553 | if (bevel_width <= border_width) |
@@ -794,3 +782,42 @@ void Toolbar::saveOnHead(int head) { | |||
794 | m_rc_on_head = head; | 782 | m_rc_on_head = head; |
795 | reconfigure(); | 783 | reconfigure(); |
796 | } | 784 | } |
785 | |||
786 | void Toolbar::rearrangeItems() { | ||
787 | |||
788 | // calculate size for fixed items | ||
789 | ItemList::iterator item_it = m_item_list.begin(); | ||
790 | ItemList::iterator item_it_end = m_item_list.end(); | ||
791 | int fixed_width = 0; // combined size of all fixed items | ||
792 | int fixed_items = 0; // number of fixed items | ||
793 | for (; item_it != item_it_end; ++item_it) { | ||
794 | if ((*item_it)->type() == ToolbarItem::FIXED) { | ||
795 | fixed_width += (*item_it)->width() + (*item_it)->borderWidth()*2; | ||
796 | fixed_items++; | ||
797 | } | ||
798 | } | ||
799 | // calculate what's going to be left over to the relative sized items | ||
800 | int relative_width = 0; | ||
801 | if (fixed_items == 0) // no fixed items, then the rest is the entire width | ||
802 | relative_width = width(); | ||
803 | else { | ||
804 | const int relative_items = m_item_list.size() - fixed_items; | ||
805 | if (relative_items == 0) | ||
806 | relative_width = 0; | ||
807 | else // size left after fixed items / number of relative items | ||
808 | relative_width = (width() - fixed_width)/relative_items; | ||
809 | } | ||
810 | |||
811 | // now move and resize the items | ||
812 | int next_x = m_item_list.front()->borderWidth(); | ||
813 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { | ||
814 | if ((*item_it)->type() == ToolbarItem::RELATIVE) { | ||
815 | (*item_it)->moveResize(next_x, 0, relative_width, height()); | ||
816 | } else { // fixed size | ||
817 | (*item_it)->moveResize(next_x, 0, | ||
818 | (*item_it)->width(), height()); | ||
819 | } | ||
820 | next_x += (*item_it)->width() + (*item_it)->borderWidth()*2; | ||
821 | } | ||
822 | |||
823 | } | ||